Skip to content

Commit

Permalink
Remove specs for old rails versions
Browse files Browse the repository at this point in the history
  • Loading branch information
codez committed Dec 3, 2024
1 parent d3b8c6b commit a54dd46
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 58 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@ jobs:
- 3.1
- 3.2
- 3.3
- jruby
rails_version:
- 6_1
- 7_0
- 7_1
- 7_2
# - master # versions failing
exclude:
- ruby_version: jruby
rails_version: 7_1
- ruby_version: jruby
rails_version: 7_2
- master
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails_version }}.gemfile
CI: true
Expand Down
3 changes: 2 additions & 1 deletion spec/adapters/sqlite3_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def tenant_names
it_behaves_like 'a connection based apartment adapter'

after(:all) do
File.delete(Apartment::Test.config['connections']['sqlite']['database'])
db_file = Apartment::Test.config['connections']['sqlite']['database']
File.delete(db_file) if File.exist?(db_file)

Check warning on line 28 in spec/adapters/sqlite3_adapter_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] spec/adapters/sqlite3_adapter_spec.rb#L28

Lint/NonAtomicFileOperation: Use atomic file operation method FileUtils.rm_f.
Raw output
spec/adapters/sqlite3_adapter_spec.rb:28:9: W: Lint/NonAtomicFileOperation: Use atomic file operation method FileUtils.rm_f.
        File.delete(db_file) if File.exist?(db_file)
        ^^^^^^^^^^^^^^^^^^^^

Check warning on line 28 in spec/adapters/sqlite3_adapter_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] spec/adapters/sqlite3_adapter_spec.rb#L28

[Correctable] Lint/NonAtomicFileOperation: Remove unnecessary existence check File.exist?.
Raw output
spec/adapters/sqlite3_adapter_spec.rb:28:30: W: [Correctable] Lint/NonAtomicFileOperation: Remove unnecessary existence check File.exist?.
        File.delete(db_file) if File.exist?(db_file)
                             ^^^^^^^^^^^^^^^^^^^^^^^
end
end

Expand Down
71 changes: 21 additions & 50 deletions spec/integration/apartment_rake_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,60 +47,31 @@
Company.delete_all
end

context 'with ActiveRecord below 5.2.0' do
before do
allow(ActiveRecord::Migrator).to receive(:migrations_paths) { %w[spec/dummy/db/migrate] }
allow(Apartment::Migrator).to receive(:activerecord_below_5_2?) { true }
end

describe '#migrate' do
it 'should migrate all databases' do
expect(ActiveRecord::Migrator).to receive(:migrate).exactly(company_count).times

@rake['apartment:migrate'].invoke
end
end

describe '#rollback' do
it 'should rollback all dbs' do
expect(ActiveRecord::Migrator).to receive(:rollback).exactly(company_count).times

@rake['apartment:rollback'].invoke
end
let(:migration_context_double) { double(:migration_context) }

Check failure on line 50 in spec/integration/apartment_rake_integration_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] spec/integration/apartment_rake_integration_spec.rb#L50

[Correctable] RSpec/ScatteredLet: Group all let/let! blocks in the example group together.
Raw output
spec/integration/apartment_rake_integration_spec.rb:50:5: C: [Correctable] RSpec/ScatteredLet: Group all let/let! blocks in the example group together.
    let(:migration_context_double) { double(:migration_context) }
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

describe '#migrate' do
it 'should migrate all databases' do
if ActiveRecord.version >= Gem::Version.new('7.2.0')
allow(ActiveRecord::Base.connection_pool)
else
allow(ActiveRecord::Base.connection)
end.to receive(:migration_context) { migration_context_double }
expect(migration_context_double).to receive(:migrate).exactly(company_count).times

@rake['apartment:migrate'].invoke
end
end

context 'with ActiveRecord above or equal to 5.2.0' do
let(:migration_context_double) { double(:migration_context) }

before do
allow(Apartment::Migrator).to receive(:activerecord_below_5_2?) { false }
end

describe '#migrate' do
it 'should migrate all databases' do
if ActiveRecord.version >= Gem::Version.new('7.2.0')
allow(ActiveRecord::Base.connection_pool)
else
allow(ActiveRecord::Base.connection)
end.to receive(:migration_context) { migration_context_double }
expect(migration_context_double).to receive(:migrate).exactly(company_count).times

@rake['apartment:migrate'].invoke
end
end
describe '#rollback' do
it 'should rollback all dbs' do
if ActiveRecord.version >= Gem::Version.new('7.2.0')
allow(ActiveRecord::Base.connection_pool)
else
allow(ActiveRecord::Base.connection)
end.to receive(:migration_context) { migration_context_double }
expect(migration_context_double).to receive(:rollback).exactly(company_count).times

describe '#rollback' do
it 'should rollback all dbs' do
if ActiveRecord.version >= Gem::Version.new('7.2.0')
allow(ActiveRecord::Base.connection_pool)
else
allow(ActiveRecord::Base.connection)
end.to receive(:migration_context) { migration_context_double }
expect(migration_context_double).to receive(:rollback).exactly(company_count).times

@rake['apartment:rollback'].invoke
end
@rake['apartment:rollback'].invoke
end
end

Expand Down

0 comments on commit a54dd46

Please sign in to comment.