Skip to content

Commit

Permalink
Regexp.escape(load_path) in add_routing_namespaces initializer [#4442
Browse files Browse the repository at this point in the history
…state:resolved]

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information
phs authored and NZKoz committed Apr 19, 2010
1 parent 69bd542 commit d03196c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion railties/lib/rails/engine.rb
Expand Up @@ -166,7 +166,7 @@ def load_tasks
paths.app.controllers.to_a.each do |load_path|
load_path = File.expand_path(load_path)
Dir["#{load_path}/*/**/*_controller.rb"].collect do |path|
namespace = File.dirname(path).sub(/#{load_path}\/?/, '')
namespace = File.dirname(path).sub(/#{Regexp.escape(load_path)}\/?/, '')
app.routes.controller_namespaces << namespace unless namespace.empty?
end
end
Expand Down

2 comments on commit d03196c

@radar
Copy link
Contributor

@radar radar commented on d03196c Apr 19, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this have been tested to ensure a regression wouldn't happen?

@phs
Copy link
Contributor Author

@phs phs commented on d03196c Apr 19, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find any tests involving the string "controller_namespaces". If you point me at an appropriate suite, (which hopefully knows how to run enough of the rails boot sequence to hit this initializer) I'll make a test. Alternately we could pull the initializer's contents out to somewhere more testable, but I don't trust myself yet to do that refactoring properly.

Please sign in to comment.