Skip to content
Merged
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
27 changes: 21 additions & 6 deletions spec/config/strong_migrations_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,31 @@
expect(message).to end_with("disable preboot for this deploy.\n")
end

it 'carries the note exactly once on each destructive-operation message' do
counts = preboot_keys.index_with do |key|
StrongMigrations.error_messages.fetch(key).scan('disable preboot for this deploy').size
it 'carries the note exactly once, after the gem text, on each destructive-operation message' do
preboot_keys.each do |key|
message = StrongMigrations.error_messages.fetch(key)

expect(message.scan('disable preboot for this deploy').size).to eq(1)
expect(message).not_to start_with('Heroku preboot')
expect(message).to end_with("disable preboot for this deploy.\n")
end
end

it 'does not add the preboot note to messages for other checks' do
untouched_keys = StrongMigrations.error_messages.keys.map(&:to_sym) - preboot_keys

expect(counts.values).to all(eq(1))
expect(untouched_keys).not_to be_empty
untouched_keys.each do |key|
expect(StrongMigrations.error_messages.fetch(key)).not_to include('Heroku preboot')
end
end

it 'leaves messages for other checks unchanged' do
expect(StrongMigrations.error_messages[:add_index]).not_to include('Heroku preboot')
it 'fails loudly when a future gem version drops a listed key' do
messages_without_rename = StrongMigrations.error_messages.except(:rename_column)
allow(StrongMigrations).to receive(:error_messages).and_return(messages_without_rename)

expect { load Rails.root.join('config/initializers/strong_migrations.rb').to_s }
.to raise_error(KeyError, /rename_column/)
end
end
end
Loading