From b44bfa4c244e25642bd838972ee41669d2b37222 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 1 May 2014 16:03:26 -0700 Subject: [PATCH] always pass options to the _url method --- .../routing/polymorphic_routes.rb | 4 +--- actionview/test/template/test_test.rb | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index dd2cbdcddc..55f40fe204 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -135,9 +135,7 @@ def polymorphic_url(record_or_hash_or_array, options = {}) named_route = build_named_route_call(record_or_hash_or_array, record, inflection, options) url_options = options.except(:action, :routing_type) - unless url_options.empty? - args << url_options - end + args << url_options args.collect! { |a| convert_to_model(a) } diff --git a/actionview/test/template/test_test.rb b/actionview/test/template/test_test.rb index 108a674d95..5721ee6c6f 100644 --- a/actionview/test/template/test_test.rb +++ b/actionview/test/template/test_test.rb @@ -37,10 +37,20 @@ def test_homepage_url def test_link_to_person with_test_route_set do - person = mock(:name => "David") - person.class.extend ActiveModel::Naming - expects(:mocha_mock_path).with(person).returns("/people/1") + person = Struct.new(:name) { + extend ActiveModel::Naming + def self.name; 'Mocha::Mock'; end + }.new "David" + + the_model = nil + extend Module.new { + define_method(:mocha_mock_path) { |model, *args| + the_model = model + "/people/1" + } + } assert_equal 'David', link_to_person(person) + assert_equal person, the_model end end -- GitLab