diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-02-07 10:34:38 -0800 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2012-02-07 10:34:38 -0800 |
commit | 12c3b3d65738eccb7b7a043b2a8a1ba65a46d34e (patch) | |
tree | 9866451e41e9562a51bdc91f732794d7db979d6c /actionpack | |
parent | 275c3a1cb3d0f38d1a28b1a8d6145a4d7e379acc (diff) | |
parent | 30e5503d004971a8c7ddb039f9023dca3a6bdcd7 (diff) | |
download | rails-12c3b3d65738eccb7b7a043b2a8a1ba65a46d34e.tar.gz rails-12c3b3d65738eccb7b7a043b2a8a1ba65a46d34e.tar.bz2 rails-12c3b3d65738eccb7b7a043b2a8a1ba65a46d34e.zip |
Merge pull request #4928 from rmm5t/fix_force_ssl_redirect_with_params_master
Fix force_ssl redirect with 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 b45f211e83..69e37d8713 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) flash.keep redirect_to redirect_options end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index c96999d23f..8e3975e369 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -567,6 +567,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 70e03d24ea..791edb9069 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -158,6 +158,22 @@ class UrlOptionsTest < ActionController::TestCase rescue_action_in_public! 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 3ea3c06ac4..b681a19fe0 100644 --- a/actionpack/test/controller/force_ssl_test.rb +++ b/actionpack/test/controller/force_ssl_test.rb @@ -50,6 +50,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 |