Skip to content

Commit

Permalink
Improved test [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Nov 7, 2024
1 parent 3f17301 commit 1cf8ba0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/safe_by_default_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_add_foreign_key_column
end

def test_add_foreign_key_invalid
skip unless postgresql? && ActiveRecord::VERSION::STRING.to_f >= 7.1
skip unless postgresql?

user = User.create!(order_id: 1)

Expand All @@ -146,7 +146,13 @@ def test_add_foreign_key_invalid

user.update!(order_id: nil)

migrate AddForeignKey
if ActiveRecord::VERSION::STRING.to_f >= 7.1
migrate AddForeignKey
else
assert_raises(ActiveRecord::StatementInvalid) do
migrate AddForeignKey
end
end

# fail if trying to add the same foreign key in a future migration
assert_raises(ActiveRecord::StatementInvalid) do
Expand Down

0 comments on commit 1cf8ba0

Please sign in to comment.