Compare commits

..

No commits in common. "namespace-options" and "master" have entirely different histories.

2 changed files with 8 additions and 22 deletions

View File

@ -139,9 +139,9 @@ module Rails
end
end
def namespace(name, options = {})
def namespace(name)
debug "mapping namespace #{name}"
namespace = FakeNamespace.new(name, options)
namespace = FakeNamespace.new(name)
namespace = stack(namespace) do
yield(self)
@ -200,22 +200,16 @@ module Rails
end
class FakeNamespace < RouteObject
attr_accessor :routes, :name, :options
attr_accessor :routes, :name
def initialize(name, options = {})
def initialize(name)
@routes = []
@name, @options = name, options
@name = name
@indent = RouteRedrawer.indent
end
def to_route_code
if !@options.empty?
options = ', ' + opts_to_string(@options)
else
options = ''
end
lines = ["namespace :#{@name}#{options} do", @routes.map {|r| r.to_route_code}, "end"]
lines = ["namespace :#{@name} do", @routes.map {|r| r.to_route_code}, "end"]
indent_lines(lines)
end
@ -363,4 +357,4 @@ module Rails
end
end
end
end
end

View File

@ -74,14 +74,6 @@ end
assert_equal "namespace :static do\nmatch '/about' => 'static#about'\nend\n", ns.to_route_code
end
def test_generates_code_for_namespace_with_options
ns = Rails::Upgrading::FakeNamespace.new("static", { :path_prefix => 'prefix' })
# Add a route to the namespace
ns << Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about'})
assert_equal "namespace :static, :path_prefix => 'prefix' do\nmatch '/about' => 'static#about'\nend\n", ns.to_route_code
end
def test_generates_code_for_resources
route = Rails::Upgrading::FakeResourceRoute.new("hats")
assert_equal "resources :hats", route.to_route_code
@ -181,4 +173,4 @@ end
upgrader.routes_code = routes_code
assert_equal new_routes_code.strip, upgrader.generate_new_routes.strip
end
end
end