Project

General

Profile

« Previous | Next » 

Revision 706de3cf

Added by Tom Caspy over 8 years ago

fixes #11862 - validating that casted hash is valid

Catch parse errors correctly under Ruby 1.9.3, and ensure the uncasted
value is displayed back in the UI if it fails to parse.

View differences:

test/lib/parameters/caster_test.rb
Foreman::Parameters::Caster.new(item, :attribute_name => :foo, :to => :zibi).cast!
end
end
test "caster raises error on invalid hash" do
item = OpenStruct.new(:foo => "{:foo => :bar}")
assert_raises(JSON::ParserError) do
Foreman::Parameters::Caster.new(item, :attribute_name => :foo, :to => :hash).cast!
end
end
end
end

Also available in: Unified diff