diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2015-01-29 11:22:26 +0000 |
---|---|---|
committer | Andrew White <pixeltrix@users.noreply.github.com> | 2015-01-29 11:22:26 +0000 |
commit | 069b72aaf04d2caef76f8e71f320716129f2d949 (patch) | |
tree | ab8d7309d4110ea01291d46860e44f62130b122d /actionpack/test | |
parent | de3d61518366e2b8b77646ceb01b396d517aa68d (diff) | |
parent | db870f222e7ba4402590ee2f4143bcd40c3dbc56 (diff) | |
download | rails-069b72aaf04d2caef76f8e71f320716129f2d949.tar.gz rails-069b72aaf04d2caef76f8e71f320716129f2d949.tar.bz2 rails-069b72aaf04d2caef76f8e71f320716129f2d949.zip |
Merge pull request #18627 from tekin/dont-blat-default-format
Preserve default format when generating URLs
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/base_test.rb | 21 |
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 |