aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/actions_test.rb
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2015-03-18 10:27:55 -0400
committerArthur Neves <arthurnn@gmail.com>2015-03-18 10:33:59 -0400
commit2f23f97b2e58ddb13af30d12c149e55d610a8a26 (patch)
treea3a7d1b05f778a6d6e5d594ca48839108999186f /railties/test/generators/actions_test.rb
parent4df806f95f8c64c8a1406aebf5f82807ff76c611 (diff)
downloadrails-2f23f97b2e58ddb13af30d12c149e55d610a8a26.tar.gz
rails-2f23f97b2e58ddb13af30d12c149e55d610a8a26.tar.bz2
rails-2f23f97b2e58ddb13af30d12c149e55d610a8a26.zip
Add a new-line to the end of route method generated code.
Fix regression on route method that was added by bac812a7ef2660a2fe2ab00822e5e66228379822. The regression was that when calling the `route` method, we were not appending a \n anymore. [fixes #19316]
Diffstat (limited to 'railties/test/generators/actions_test.rb')
-rw-r--r--railties/test/generators/actions_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index c6de2c1fb9..c0b88089b3 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -219,6 +219,30 @@ class ActionsTest < Rails::Generators::TestCase
assert_file 'config/routes.rb', /#{Regexp.escape(route_command)}/
end
+ def test_route_should_add_data_with_an_new_line
+ run_generator
+ action :route, "root 'welcome#index'"
+ route_path = File.expand_path("config/routes.rb", destination_root)
+ content = File.read(route_path)
+
+ # Remove all of the comments and blank lines from the routes file
+ content.gsub!(/^ \#.*\n/, '')
+ content.gsub!(/^\n/, '')
+
+ File.open(route_path, "wb") { |file| file.write(content) }
+ assert_file "config/routes.rb", /\.routes\.draw do\n root 'welcome#index'\nend\n\z/
+
+ action :route, "resources :product_lines"
+
+ routes = <<-F
+Rails.application.routes.draw do
+ resources :product_lines
+ root 'welcome#index'
+end
+F
+ assert_file "config/routes.rb", routes
+ end
+
def test_readme
run_generator
Rails::Generators::AppGenerator.expects(:source_root).times(2).returns(destination_root)