diff options
Diffstat (limited to 'actionview/test/activerecord')
-rw-r--r-- | actionview/test/activerecord/polymorphic_routes_test.rb | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/actionview/test/activerecord/polymorphic_routes_test.rb b/actionview/test/activerecord/polymorphic_routes_test.rb index afb714484b..1ead18518a 100644 --- a/actionview/test/activerecord/polymorphic_routes_test.rb +++ b/actionview/test/activerecord/polymorphic_routes_test.rb @@ -112,6 +112,31 @@ class PolymorphicRoutesTest < ActionController::TestCase 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 @@ -295,17 +320,17 @@ class PolymorphicRoutesTest < ActionController::TestCase end end - def test_nesting_with_array_containing_nil + def test_nesting_with_array with_test_routes do @project.save - assert_equal "http://example.com/projects/#{@project.id}/bid", polymorphic_url([@project, nil, :bid]) + assert_equal "http://example.com/projects/#{@project.id}/bid", polymorphic_url([@project, :bid]) end end def test_with_array_containing_single_object with_test_routes do @project.save - assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url([nil, @project]) + assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url([@project]) end end @@ -438,7 +463,7 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_with_array_containing_single_irregular_plural_object with_test_routes do @tax.save - assert_equal "http://example.com/taxes/#{@tax.id}", polymorphic_url([nil, @tax]) + assert_equal "http://example.com/taxes/#{@tax.id}", polymorphic_url([@tax]) end end |