Skip to content

Commit

Permalink
Add test for rails 7.1 or lower
Browse files Browse the repository at this point in the history
To maintain test coverage
  • Loading branch information
avinhurry committed Aug 15, 2024
1 parent 32dc3b9 commit d19d9aa
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion spec/dfe/analytics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
end
end

describe 'when no database connection is available' do
describe 'when no database connection is available on rails 7.2 or higher' do
before do
allow(Rails).to receive(:version).and_return('7.2')
allow(ActiveRecord::Base).to receive(:with_connection).and_raise(ActiveRecord::ConnectionNotEstablished)
Expand All @@ -34,6 +34,18 @@
end
end

describe 'when no database connection is available on rails 7.1 or lower' do
before do
allow(Rails).to receive(:version).and_return('7.1')
allow(ActiveRecord::Base).to receive(:connection).and_raise(ActiveRecord::ConnectionNotEstablished)
end

it 'recovers and logs' do
expect(Rails.logger).to receive(:info).with(/No database connection/)
expect { DfE::Analytics.initialize! }.not_to raise_error
end
end

describe 'when migrations are pending' do
it 'recovers and logs' do
allow(DfE::Analytics::Fields).to receive(:check!).and_raise(ActiveRecord::PendingMigrationError)
Expand Down

0 comments on commit d19d9aa

Please # to comment.