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

Support for Activerecord 6.1 #677

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
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', '<= 6.1.7.6'
s.add_dependency 'rack', '>= 1.3.6'
s.add_dependency 'public_suffix', '>= 2'
s.add_dependency 'parallel', '>= 0.7.1'
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
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