Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 7.1 Support w/ testing #670

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ gemfile:
- gemfiles/rails_5_1.gemfile
- gemfiles/rails_5_2.gemfile
- gemfiles/rails_6_0.gemfile
- gemfiles/rails_6_1.gemfile
- gemfiles/rails_7_0.gemfile
- gemfiles/rails_master.gemfile
bundler_args: --without local
before_install:
Expand Down Expand Up @@ -44,20 +46,40 @@ matrix:
gemfile: gemfiles/rails_5_2.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_6_1.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_7_0.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_master.gemfile
- rvm: 2.2.9
- rvm: 2.2.9
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.2.9
gemfile: gemfiles/rails_6_1.gemfile
- rvm: 2.2.9
gemfile: gemfiles/rails_7_0.gemfile
- rvm: 2.3.6
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.3.6
gemfile: gemfiles/rails_6_1.gemfile
- rvm: 2.3.6
gemfile: gemfiles/rails_7_0.gemfile
- rvm: 2.4.3
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.4.3
gemfile: gemfiles/rails_6_1.gemfile
- rvm: 2.4.3
gemfile: gemfiles/rails_7_0.gemfile
- rvm: jruby-9.1.15.0
gemfile: gemfiles/rails_5_1.gemfile
- rvm: jruby-9.1.15.0
gemfile: gemfiles/rails_5_2.gemfile
- rvm: jruby-9.1.15.0
gemfile: gemfiles/rails_6_0.gemfile
- rvm: jruby-9.1.15.0
gemfile: gemfiles/rails_6_1.gemfile
- rvm: jruby-9.1.15.0
gemfile: gemfiles/rails_7_0.gemfile
- rvm: jruby-9.1.15.0
gemfile: gemfiles/rails_master.gemfile
fast_finish: true
Expand Down
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.3.0
* June 12, 2024

## Added
- Support for Ruby 3.2

# 2.2.1
* June 19, 2019

Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace :db do
apartment_db_file = 'spec/config/database.yml'
rails_db_file = 'spec/dummy/config/database.yml'

FileUtils.copy(apartment_db_file + '.sample', apartment_db_file, :verbose => true) unless File.exists?(apartment_db_file)
FileUtils.copy(rails_db_file + '.sample', rails_db_file, :verbose => true) unless File.exists?(rails_db_file)
FileUtils.copy(apartment_db_file + '.sample', apartment_db_file, :verbose => true) unless File.exist?(apartment_db_file)
FileUtils.copy(rails_db_file + '.sample', rails_db_file, :verbose => true) unless File.exist?(rails_db_file)
end
end

Expand Down
2 changes: 1 addition & 1 deletion apartment.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.licenses = ["MIT"]

# must be >= 3.1.2 due to bug in prepared_statements
s.add_dependency 'activerecord', '>= 3.1.2', '< 6.1'
s.add_dependency 'activerecord', '>= 3.1.2', '< 8'
s.add_dependency 'rack', '>= 1.3.6'
s.add_dependency 'public_suffix', '>= 2'
s.add_dependency 'parallel', '>= 0.7.1'
Expand Down
22 changes: 22 additions & 0 deletions gemfiles/rails_6_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "rails", "~> 6.1"

group :local do
gem "pry"
gem "guard-rspec", "~> 4.2"
end

platforms :ruby do
gem "sqlite3", "~> 1.4"
end

platforms :jruby do
gem "activerecord-jdbc-adapter", "~> 61.1"
gem "activerecord-jdbcpostgresql-adapter", "~> 61.1"
gem "activerecord-jdbcmysql-adapter", "~> 61.1"
end

gemspec path: "../"
22 changes: 22 additions & 0 deletions gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "rails", "~> 7.0"

group :local do
gem "pry"
gem "guard-rspec", "~> 4.2"
end

platforms :ruby do
gem "sqlite3", "~> 1.4"
end

platforms :jruby do
gem "activerecord-jdbc-adapter", "~> 61.1"
gem "activerecord-jdbcpostgresql-adapter", "~> 61.1"
gem "activerecord-jdbcmysql-adapter", "~> 61.1"
end

gemspec path: "../"
10 changes: 9 additions & 1 deletion lib/apartment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ class << self
attr_accessor(*ACCESSOR_METHODS)
attr_writer(*WRITER_METHODS)

def_delegators :connection_class, :connection, :connection_config, :establish_connection
def_delegators :connection_class, :connection, :establish_connection

def connection_config
if ::ActiveRecord::Base.respond_to?(:connection_db_config)
::ActiveRecord::Base.connection_db_config.configuration_hash
else
::ActiveRecord::Base.connection_config
end
end

# configure apartment with available options
def configure
Expand Down
2 changes: 1 addition & 1 deletion lib/apartment/adapters/abstract_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def multi_tenantify_with_tenant_db_name(config, tenant)
# Load a file or raise error if it doesn't exists
#
def load_or_raise(file)
if File.exists?(file)
if File.exist?(file)
load(file)
else
raise FileNotFound, "#{file} doesn't exist yet"
Expand Down
6 changes: 3 additions & 3 deletions lib/apartment/adapters/sqlite3_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(config)

def drop(tenant)
raise TenantNotFound,
"The tenant #{environmentify(tenant)} cannot be found." unless File.exists?(database_file(tenant))
"The tenant #{environmentify(tenant)} cannot be found." unless File.exist?(database_file(tenant))

File.delete(database_file(tenant))
end
Expand All @@ -30,14 +30,14 @@ def current

def connect_to_new(tenant)
raise TenantNotFound,
"The tenant #{environmentify(tenant)} cannot be found." unless File.exists?(database_file(tenant))
"The tenant #{environmentify(tenant)} cannot be found." unless File.exist?(database_file(tenant))

super database_file(tenant)
end

def create_tenant(tenant)
raise TenantExists,
"The tenant #{environmentify(tenant)} already exists." if File.exists?(database_file(tenant))
"The tenant #{environmentify(tenant)} already exists." if File.exist?(database_file(tenant))

begin
f = File.new(database_file(tenant), File::CREAT)
Expand Down
2 changes: 1 addition & 1 deletion lib/apartment/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Apartment
VERSION = "2.2.1"
VERSION = "2.3.0"
end
6 changes: 3 additions & 3 deletions spec/adapters/sqlite3_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def tenant_names
it "should create a new database" do
subject.create db_name

expect(File.exists?("#{default_dir}/#{Rails.env}_#{db_name}.sqlite3")).to eq true
expect(File.exist?("#{default_dir}/#{Rails.env}_#{db_name}.sqlite3")).to eq true
end
end

Expand All @@ -55,7 +55,7 @@ def tenant_names
it "should create a new database" do
subject.create db_name

expect(File.exists?("#{default_dir}/#{db_name}.sqlite3")).to eq true
expect(File.exist?("#{default_dir}/#{db_name}.sqlite3")).to eq true
end
end

Expand All @@ -73,7 +73,7 @@ def tenant_names
it "should create a new database" do
subject.create db_name

expect(File.exists?("#{default_dir}/#{db_name}_#{Rails.env}.sqlite3")).to eq true
expect(File.exist?("#{default_dir}/#{db_name}_#{Rails.env}.sqlite3")).to eq true
end
end

Expand Down