Skip to content

Commit

Permalink
Edge case spec
Browse files Browse the repository at this point in the history
  • Loading branch information
AlasdairWallaceMackie committed Dec 10, 2024
1 parent 1887980 commit 1b54e81
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions spec/rubocop/cop/sequel/irreversible_migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,28 @@
expect(offenses).to be_empty
end
end

describe 'and an invalid change method contains another invalid change method as an argument' do
let(:source) do
<<~SOURCE
change do
alter_table(:stores) do
drop_column(:products, JSON, null: false, default: Sequel.pg_json({}))
end
end
SOURCE
end

it 'only registers 1 offense' do
offenses = inspect_source_within_migration(source)
expect(offenses.size).to eq(1)
end

it 'only registers an offense for the parent method' do
offenses = inspect_source_within_migration(source)
expect(offenses.first.message).to include('drop_column')
end
end
end

context 'when inside an up block' do
Expand Down

0 comments on commit 1b54e81

Please sign in to comment.