Skip to content

Commit 2dfeb7b

Browse files
committed
Merge branch 'master' of github.com:rails/rails
2 parents b613c3c + e6331b1 commit 2dfeb7b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

railties/lib/rails/generators/actions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def freeze!(args={})
275275
#
276276
def route(routing_code)
277277
log :route, routing_code
278-
sentinel = /\.routes\.draw do(\s*\|map\|)?\s*$/
278+
sentinel = /\.routes\.draw do(?:\s*\|map\|)?\s*$/
279279

280280
in_root do
281281
inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }

railties/test/generators/scaffold_generator_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,19 @@ def test_scaffold_with_namespace_on_revoke
216216
# Stylesheets (should not be removed)
217217
assert_file "public/stylesheets/scaffold.css"
218218
end
219+
220+
def test_scaffold_generator_on_revoke_does_not_mutilate_legacy_map_parameter
221+
run_generator
222+
223+
# Add a |map| parameter to the routes block manually
224+
route_path = File.expand_path("config/routes.rb", destination_root)
225+
content = File.read(route_path).gsub(/\.routes\.draw do/) do |match|
226+
"#{match} |map|"
227+
end
228+
File.open(route_path, "wb") { |file| file.write(content) }
229+
230+
run_generator ["product_line"], :behavior => :revoke
231+
232+
assert_file "config/routes.rb", /\.routes\.draw do\s*\|map\|\s*$/
233+
end
219234
end

0 commit comments

Comments
 (0)