Skip to content
This repository

Route formatter: remove unnecessary gsub call #33

Merged
merged 1 commit into from almost 2 years ago

2 participants

Bogdan Gusiev Aaron Patterson
Bogdan Gusiev
bogdan commented May 24, 2012

Remove unnecessary gsub call.

Originally this gsub call appeared as "for performance" hack. But unfortunattely having it right there doesn't fix some problems described here: 8317cde

Now, we can remove it.

Also removed test that asserts some internal behavior of the formatter that doesn't have a use case in actionpack: it tests behavior of formatter when it doens't have all required parameters, but this case is filtered at verify_required_parts!.

Aaron Patterson tenderlove merged commit c1ac1e6 into from May 24, 2012
Aaron Patterson tenderlove closed this May 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

May 24, 2012
Bogdan Gusiev Route formatter: remove unnecessary gsub call 29b62a2
This page is out of date. Refresh to see the latest.
5  lib/journey/route.rb
@@ -71,10 +71,7 @@ def format path_options
71 71
         path_options.delete key if defaults[key].to_s == path_options[key].to_s
72 72
       end
73 73
 
74  
-      formatter      = Visitors::Formatter.new(path_options)
75  
-
76  
-      formatted_path = formatter.accept(path.spec)
77  
-      formatted_path.gsub(/\/\x00/, '')
  74
+      Visitors::Formatter.new(path_options).accept(path.spec)
78 75
     end
79 76
 
80 77
     def optional_parts
8  test/test_route.rb
@@ -38,14 +38,6 @@ def test_default_ip
38 38
       assert_equal(//, route.ip)
39 39
     end
40 40
 
41  
-    def test_format_empty
42  
-      path  = Path::Pattern.new '/messages/:id(.:format)'
43  
-      route = Route.new("name", nil, path, {},
44  
-                        { :controller => 'foo', :action => 'bar' })
45  
-
46  
-      assert_equal '/messages', route.format({})
47  
-    end
48  
-
49 41
     def test_format_with_star
50 42
       path  = Path::Pattern.new '/:controller/*extra'
51 43
       route = Route.new("name", nil, path, {},
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.