aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/url_helper_test.rb
diff options
context:
space:
mode:
authorJoel Ambass <ambass.joel@gmail.com>2018-06-28 01:17:10 +0200
committerJoel Colin Ambass <ambass.joel@gmail.com>2018-10-01 19:31:08 +0200
commitb48c2ade09e9c43d6f7acee02d074a9d54323a70 (patch)
tree31d0656ed48a43ba554ddf11c9fad02e07c136f8 /actionview/test/template/url_helper_test.rb
parentdf9c972afe88e3c9c65bfcd96eddca927a42b5e3 (diff)
downloadrails-b48c2ade09e9c43d6f7acee02d074a9d54323a70.tar.gz
rails-b48c2ade09e9c43d6f7acee02d074a9d54323a70.tar.bz2
rails-b48c2ade09e9c43d6f7acee02d074a9d54323a70.zip
respect path_only option when an array is passed into url_for
The url_for method is now extracting the path_only option in order to determine if polymorphic_path or polymorphic_url should be called. If the path_only option is not set it will be set to true unless the host option is set. This behaviour is the same as when a Hash or Params object is passed. To support this unifying the code responsible for setting this default value has been extracted into a private method
Diffstat (limited to 'actionview/test/template/url_helper_test.rb')
-rw-r--r--actionview/test/template/url_helper_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb
index 6db9eb3be1..1ab28e4749 100644
--- a/actionview/test/template/url_helper_test.rb
+++ b/actionview/test/template/url_helper_test.rb
@@ -75,6 +75,15 @@ class UrlHelperTest < ActiveSupport::TestCase
assert_equal "javascript:history.back()", url_for(:back)
end
+ def test_url_for_with_array_defaults_to_only_path_true
+ assert_equal "/other", url_for([:other, { controller: "foo" }])
+ end
+
+ def test_url_for_with_array_and_only_path_set_to_false
+ default_url_options[:host] = "http://example.com"
+ assert_equal "http://example.com/other", url_for([:other, { controller: "foo", only_path: false }])
+ end
+
def test_to_form_params_with_hash
assert_equal(
[{ name: "name", value: "David" }, { name: "nationality", value: "Danish" }],