diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-02-07 09:05:07 -0800 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2012-02-07 09:05:07 -0800 |
commit | f3595b5924c5d6245fb97c1ce13b3400ca11b1c8 (patch) | |
tree | b2cc9b2cd63664214bc2c5b7c40dcc265661fd6c /actionpack | |
parent | 8c7378aae81cc1ceabb41c197bccd68f535b9833 (diff) | |
parent | 0e482b3681c688c9e4d0d379166a3d76cf0a52ae (diff) | |
download | rails-f3595b5924c5d6245fb97c1ce13b3400ca11b1c8.tar.gz rails-f3595b5924c5d6245fb97c1ce13b3400ca11b1c8.tar.bz2 rails-f3595b5924c5d6245fb97c1ce13b3400ca11b1c8.zip |
Merge pull request #4916 from rmm5t/fix_force_ssl_redirect_with_params
Fixed force_ssl redirects to include original query params
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal/force_ssl.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 1 | ||||
-rw-r--r-- | actionpack/test/controller/base_test.rb | 16 | ||||
-rw-r--r-- | actionpack/test/controller/force_ssl_test.rb | 6 |
4 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/force_ssl.rb b/actionpack/lib/action_controller/metal/force_ssl.rb index 0fd42f9d8a..7a0ede02a2 100644 --- a/actionpack/lib/action_controller/metal/force_ssl.rb +++ b/actionpack/lib/action_controller/metal/force_ssl.rb @@ -29,6 +29,7 @@ module ActionController if !request.ssl? && !Rails.env.development? redirect_options = {:protocol => 'https://', :status => :moved_permanently} redirect_options.merge!(:host => host) if host + redirect_options.merge!(:params => request.query_parameters) redirect_to redirect_options end end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 06919518e8..552d472afa 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -575,6 +575,7 @@ module ActionDispatch path_addition, params = generate(path_options, path_segments || {}) path << path_addition + params.merge!(options[:params] || {}) ActionDispatch::Http::URL.url_for(options.merge!({ :path => path, diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 6e13aab518..777ca11d85 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -257,6 +257,22 @@ class UrlOptionsTest < ActionController::TestCase assert_equal '/special', rs.url_for(url_params) end + def test_url_for_query_params_included + rs = ActionDispatch::Routing::RouteSet.new + rs.draw do + match 'home' => 'pages#home' + end + + options = { + :action => "home", + :controller => "pages", + :only_path => true, + :params => { "token" => "secret" } + } + + assert_equal '/home?token=secret', rs.url_for(options) + end + def test_url_options_override with_routing do |set| set.draw do diff --git a/actionpack/test/controller/force_ssl_test.rb b/actionpack/test/controller/force_ssl_test.rb index 43b20fdead..3cbc111ebb 100644 --- a/actionpack/test/controller/force_ssl_test.rb +++ b/actionpack/test/controller/force_ssl_test.rb @@ -35,6 +35,12 @@ class ForceSSLControllerLevelTest < ActionController::TestCase assert_equal "https://test.host/force_ssl_controller_level/banana", redirect_to_url end + def test_banana_redirects_to_https_with_extra_params + get :banana, :token => "secret" + assert_response 301 + assert_equal "https://test.host/force_ssl_controller_level/banana?token=secret", redirect_to_url + end + def test_cheeseburger_redirects_to_https get :cheeseburger assert_response 301 |