Skip to content
Browse files

passing a nil should always raise an ArgumentError

  • Loading branch information...
1 parent 61d5731 commit dece005f0a8aa1f4210e381efb429eca5d793d91 @tenderlove tenderlove committed May 2, 2014
View
1 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -104,7 +104,6 @@ def polymorphic_url(record_or_hash_or_array, options = {})
recipient = self
if record_or_hash_or_array.kind_of?(Array)
- record_or_hash_or_array = record_or_hash_or_array.compact
if record_or_hash_or_array.first.is_a?(ActionDispatch::Routing::RoutesProxy)
recipient = record_or_hash_or_array.shift
end
View
25 actionview/test/activerecord/polymorphic_routes_test.rb
@@ -112,6 +112,31 @@ def test_with_nil
end
end
+ def test_with_empty_list
+ with_test_routes do
+ assert_raise ArgumentError, "Nil location provided. Can't build URI." do
+ polymorphic_url([])
+ end
+ end
+ end
+
+ def test_with_nil_id
+ with_test_routes do
+ assert_raise ArgumentError, "Nil location provided. Can't build URI." do
+ polymorphic_url({ :id => nil })
+ end
+ end
+ end
+
+ def test_with_nil_in_list
+ with_test_routes do
+ assert_raise ArgumentError, "Nil location provided. Can't build URI." do
+ @series.save
+ polymorphic_url([nil, @series])
+ end
+ end
+ end
+
def test_with_record
with_test_routes do
@project.save

0 comments on commit dece005

Please sign in to comment.
Something went wrong with that request. Please try again.