1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Change the assertions depending in the database adapter

This will avoid the confusing flunk logic
This commit is contained in:
Rafael Mendonça França 2014-03-10 10:23:17 -03:00
parent 18b9595814
commit d547b23754

View file

@ -62,22 +62,17 @@ class FinderTest < ActiveRecord::TestCase
end
def test_exists_fails_when_parameter_has_invalid_type
begin
assert_equal false, Topic.exists?(("9"*53).to_i) # number that's bigger than int
flunk if current_adapter?(:PostgreSQLAdapter) # PostgreSQL does raise here
rescue ActiveRecord::StatementInvalid
# PostgreSQL complains that it can't coerce a numeric that's bigger than int into int
rescue Exception
flunk
end
if current_adapter?(:PostgreSQLAdapter)
assert_raises ActiveRecord::StatementInvalid do
Topic.exists?(("9"*53).to_i) # number that's bigger than int
end
begin
assert_raises ActiveRecord::StatementInvalid do
Topic.exists?("foo")
end
else
assert_equal false, Topic.exists?(("9"*53).to_i) # number that's bigger than int
assert_equal false, Topic.exists?("foo")
flunk if current_adapter?(:PostgreSQLAdapter) # PostgreSQL does raise here
rescue ActiveRecord::StatementInvalid
# PostgreSQL complains about string comparison with integer field
rescue Exception
flunk
end
end