Rails 5.1 point type should not raise exception if empty string is provided as value

This commit is contained in:
bUg 2016-05-15 15:00:10 +03:00 committed by Alexander Grebennik
parent 0827f9932f
commit e3cd321d4b
2 changed files with 9 additions and 0 deletions

@ -14,6 +14,8 @@ def type
def cast(value)
case value
when ::String
return if value.blank?
if value[0] == '(' && value[-1] == ')'
value = value[1...-1]
end

@ -104,6 +104,13 @@ def test_string_assignment
assert_equal ActiveRecord::Point.new(1, 2), p.x
end
def test_empty_string_assignment
assert_nothing_raised { PostgresqlPoint.new(x: "") }
p = PostgresqlPoint.new(x: "")
assert_equal nil, p.x
end
def test_array_of_points_round_trip
expected_value = [
ActiveRecord::Point.new(1, 2),