Skip to content
This repository has been archived by the owner on Sep 13, 2017. It is now read-only.

Commit

Permalink
Merge pull request #33 from bogdan/refactor_formatter
Browse files Browse the repository at this point in the history
Route formatter: remove unnecessary gsub call
  • Loading branch information
tenderlove committed May 24, 2012
2 parents 47aaabf + 29b62a2 commit c1ac1e6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
5 changes: 1 addition & 4 deletions lib/journey/route.rb
Expand Up @@ -71,10 +71,7 @@ def format path_options
path_options.delete key if defaults[key].to_s == path_options[key].to_s
end

formatter = Visitors::Formatter.new(path_options)

formatted_path = formatter.accept(path.spec)
formatted_path.gsub(/\/\x00/, '')
Visitors::Formatter.new(path_options).accept(path.spec)
end

def optional_parts
Expand Down
8 changes: 0 additions & 8 deletions test/test_route.rb
Expand Up @@ -38,14 +38,6 @@ def test_default_ip
assert_equal(//, route.ip)
end

def test_format_empty
path = Path::Pattern.new '/messages/:id(.:format)'
route = Route.new("name", nil, path, {},
{ :controller => 'foo', :action => 'bar' })

assert_equal '/messages', route.format({})
end

def test_format_with_star
path = Path::Pattern.new '/:controller/*extra'
route = Route.new("name", nil, path, {},
Expand Down

0 comments on commit c1ac1e6

Please sign in to comment.