Skip to content

Commit

Permalink
Generating routes with optional format segment does not inherit param…
Browse files Browse the repository at this point in the history
…s format [#2043 state:resolved]
  • Loading branch information
josh committed Mar 4, 2009
1 parent 6087fe8 commit 638b3b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion actionpack/lib/action_controller/routing/segments.rb
Expand Up @@ -324,7 +324,11 @@ def regexp_chunk
def to_s
'(.:format)?'
end


def extract_value
"#{local_name} = options[:#{key}] && options[:#{key}].to_s.downcase"
end

#the value should not include the period (.)
def match_extraction(next_capture)
%[
Expand Down
16 changes: 16 additions & 0 deletions actionpack/test/controller/routing_test.rb
Expand Up @@ -2237,6 +2237,22 @@ def test_query_params_will_be_shown_when_recalled
)
end

def test_format_is_not_inherit
set.draw do |map|
map.connect '/posts.:format', :controller => 'posts'
end

assert_equal '/posts', set.generate(
{:controller => 'posts'},
{:controller => 'posts', :action => 'index', :format => 'xml'}
)

assert_equal '/posts.xml', set.generate(
{:controller => 'posts', :format => 'xml'},
{:controller => 'posts', :action => 'index', :format => 'xml'}
)
end

def test_expiry_determination_should_consider_values_with_to_param
set.draw { |map| map.connect 'projects/:project_id/:controller/:action' }
assert_equal '/projects/1/post/show', set.generate(
Expand Down

0 comments on commit 638b3b1

Please sign in to comment.