aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorTekin Suleyman <tekin@tekin.co.uk>2015-01-21 15:40:02 +0000
committerTekin Suleyman <tekin@tekin.co.uk>2015-01-28 21:15:52 +0000
commitdb870f222e7ba4402590ee2f4143bcd40c3dbc56 (patch)
tree89888642a22a12b8ea4aa9b60b1f36de7d1c9a21 /actionpack/test/controller
parent82173989de711ecda71b7e887291a524c23c14ce (diff)
downloadrails-db870f222e7ba4402590ee2f4143bcd40c3dbc56.tar.gz
rails-db870f222e7ba4402590ee2f4143bcd40c3dbc56.tar.bz2
rails-db870f222e7ba4402590ee2f4143bcd40c3dbc56.zip
Preserve default url options when generating URLs
Fixes an issue that would cause default_url_options to be lost when generating URLs with fewer positional arguments than parameters in the route definition.
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/base_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index 001493afc0..999dd6e351 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -27,6 +27,16 @@ class DefaultUrlOptionsController < ActionController::Base
end
end
+class OptionalDefaultUrlOptionsController < ActionController::Base
+ def show
+ render nothing: true
+ end
+
+ def default_url_options
+ { format: 'atom', id: 'default-id' }
+ end
+end
+
class UrlOptionsController < ActionController::Base
def from_view
render :inline => "<%= #{params[:route]} %>"
@@ -234,7 +244,18 @@ class DefaultUrlOptionsTest < ActionController::TestCase
assert_equal '/en/descriptions/1.xml', @controller.send(:description_path, 1, :format => "xml")
end
end
+end
+class OptionalDefaultUrlOptionsControllerTest < ActionController::TestCase
+ def test_default_url_options_override_missing_positional_arguments
+ with_routing do |set|
+ set.draw do
+ get "/things/:id(.:format)" => 'things#show', :as => :thing
+ end
+ assert_equal '/things/1.atom', thing_path('1')
+ assert_equal '/things/default-id.atom', thing_path
+ end
+ end
end
class EmptyUrlOptionsTest < ActionController::TestCase