Skip to content

Commit 3618f32

Browse files
authored
Merge pull request #965 from aidanharan/coerce-foreign-key-test
[Rails 7] Coerce foreign key test for SQL Server error message
2 parents 4c1fc00 + 10cc67f commit 3618f32

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,19 @@ def test_add_on_delete_restrict_foreign_key_coerced
952952
@connection.add_foreign_key :astronauts, :rockets, column: "rocket_id", on_update: :restrict
953953
end
954954
end
955+
956+
# Error message depends on the database adapter.
957+
coerce_tests! :test_add_foreign_key_with_if_not_exists_not_set
958+
def test_add_foreign_key_with_if_not_exists_not_set_coerced
959+
@connection.add_foreign_key :astronauts, :rockets
960+
assert_equal 1, @connection.foreign_keys("astronauts").size
961+
962+
error = assert_raises do
963+
@connection.add_foreign_key :astronauts, :rockets
964+
end
965+
966+
assert_match(/TinyTds::Error: There is already an object named '.*' in the database/, error.message)
967+
end
955968
end
956969
end
957970
end

0 commit comments

Comments
 (0)