diff options
author | José Valim <jose.valim@gmail.com> | 2012-04-25 06:15:12 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-04-25 06:15:12 -0700 |
commit | 33d80919ff9549c64ef7fc657d70012fd6e22fb0 (patch) | |
tree | 0ba58ea1dfbac20006647b81246e8c84c8614d62 | |
parent | cd65682835c3fe1cbad8d02f3282c64a24d29b71 (diff) | |
parent | 6ac9e493fb14cf7f9ca426f1ddd077ece6dc581f (diff) | |
download | rails-33d80919ff9549c64ef7fc657d70012fd6e22fb0.tar.gz rails-33d80919ff9549c64ef7fc657d70012fd6e22fb0.tar.bz2 rails-33d80919ff9549c64ef7fc657d70012fd6e22fb0.zip |
Merge pull request #5902 from avakhov/generator-no-indent-blank-lines
Don't indent blank lines in named base generators
-rw-r--r-- | railties/lib/rails/generators/named_base.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/namespaced_generators_test.rb | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index c457b5fbbc..e85d1b8fa2 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -40,7 +40,7 @@ module Rails def indent(content, multiplier = 2) spaces = " " * multiplier - content = content.each_line.map {|line| "#{spaces}#{line}" }.join + content = content.each_line.map {|line| line.blank? ? line : "#{spaces}#{line}" }.join end def wrap_with_namespace(content) diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb index 76c34d4c50..abafcefde5 100644 --- a/railties/test/generators/namespaced_generators_test.rb +++ b/railties/test/generators/namespaced_generators_test.rb @@ -61,6 +61,14 @@ class NamespacedControllerGeneratorTest < NamespacedGeneratorTestCase run_generator ["account"] assert_file "app/views/test_app/account" end + + def test_namespaced_controller_dont_indent_blank_lines + run_generator + assert_file "app/controllers/test_app/account_controller.rb" + File.readlines(File.expand_path("app/controllers/test_app/account_controller.rb", destination_root)).each do |line| + assert_no_match line.chomp, /^\s+$/, "Don't indent blank lines" + end + end end class NamespacedModelGeneratorTest < NamespacedGeneratorTestCase |