Merge branch 'master' of github.com:rails/rails

This commit is contained in:
José Valim
2010-08-02 16:17:34 +02:00
2 changed files with 16 additions and 1 deletions

View File

@@ -275,7 +275,7 @@ module Rails
#
def route(routing_code)
log :route, routing_code
sentinel = /\.routes\.draw do(\s*\|map\|)?\s*$/
sentinel = /\.routes\.draw do(?:\s*\|map\|)?\s*$/
in_root do
inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }

View File

@@ -216,4 +216,19 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
# Stylesheets (should not be removed)
assert_file "public/stylesheets/scaffold.css"
end
def test_scaffold_generator_on_revoke_does_not_mutilate_legacy_map_parameter
run_generator
# Add a |map| parameter to the routes block manually
route_path = File.expand_path("config/routes.rb", destination_root)
content = File.read(route_path).gsub(/\.routes\.draw do/) do |match|
"#{match} |map|"
end
File.open(route_path, "wb") { |file| file.write(content) }
run_generator ["product_line"], :behavior => :revoke
assert_file "config/routes.rb", /\.routes\.draw do\s*\|map\|\s*$/
end
end