From 8302bd45f7ca338b304a0d5c943fa39e2fdb1ad1 Mon Sep 17 00:00:00 2001 From: Pascal Zumkehr Date: Tue, 3 Dec 2024 16:05:07 +0100 Subject: [PATCH] Remove specs for old rails versions --- .../apartment_rake_integration_spec.rb | 71 ++++++------------- 1 file changed, 21 insertions(+), 50 deletions(-) diff --git a/spec/integration/apartment_rake_integration_spec.rb b/spec/integration/apartment_rake_integration_spec.rb index e9acfb10..d2aec82c 100644 --- a/spec/integration/apartment_rake_integration_spec.rb +++ b/spec/integration/apartment_rake_integration_spec.rb @@ -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) } + + 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