diff options
author | José Valim <jose.valim@gmail.com> | 2010-08-02 16:17:34 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-08-02 16:17:34 +0200 |
commit | 2dfeb7bc30b3506e87c70853ebfee0bd305f4550 (patch) | |
tree | bd9882bb713cfa3da36f5d7fab66b1ab83d4a6a3 | |
parent | b613c3cc7b08b00595e33d1b5302cd5d42687d4e (diff) | |
parent | e6331b1e97d608c46aaadd1814a1e370bdcdd40a (diff) | |
download | rails-2dfeb7bc30b3506e87c70853ebfee0bd305f4550.tar.gz rails-2dfeb7bc30b3506e87c70853ebfee0bd305f4550.tar.bz2 rails-2dfeb7bc30b3506e87c70853ebfee0bd305f4550.zip |
Merge branch 'master' of github.com:rails/rails
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/scaffold_generator_test.rb | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 2280cc1507..668ef48892 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -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 } diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index ea469cb3c8..f12445ae35 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -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 |