aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template
diff options
context:
space:
mode:
authorMaksym Pugach <pugach.m@gmail.com>2017-01-02 18:26:05 +0200
committerMaksym Pugach <pugach.m@gmail.com>2017-01-04 06:33:29 +0200
commit13352f6972b4dbc9af33b0634a26184f1c4eb2c1 (patch)
tree9ceec3b4527fad1d571bde65a0a97bc7168f5d71 /actionview/test/template
parent33e60514aed85b3076f2636d5f1ccfb513aace1c (diff)
downloadrails-13352f6972b4dbc9af33b0634a26184f1c4eb2c1.tar.gz
rails-13352f6972b4dbc9af33b0634a26184f1c4eb2c1.tar.bz2
rails-13352f6972b4dbc9af33b0634a26184f1c4eb2c1.zip
Add `check_parameters` option to `current_page?`
Example: For "http://www.example.com/shop/checkout?order=desc&page=1" current_page?('http://www.example.com/shop/checkout') => true current_page?( 'http://www.example.com/shop/checkout', check_parameters: true ) => false
Diffstat (limited to 'actionview/test/template')
-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 1e64385b52..ed7d033622 100644
--- a/actionview/test/template/url_helper_test.rb
+++ b/actionview/test/template/url_helper_test.rb
@@ -496,6 +496,15 @@ class UrlHelperTest < ActiveSupport::TestCase
assert current_page?("http://www.example.com/")
end
+ def test_current_page_considering_params
+ @request = request_for_url("/?order=desc&page=1")
+
+ assert !current_page?(url_hash, check_parameters: true)
+ assert !current_page?(url_hash.merge(check_parameters: true))
+ assert !current_page?(ActionController::Parameters.new(url_hash.merge(check_parameters: true)).permit!)
+ assert !current_page?("http://www.example.com/", check_parameters: true)
+ end
+
def test_current_page_with_params_that_match
@request = request_for_url("/?order=desc&page=1")