diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-08 15:06:53 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-08 15:07:15 -0800 |
commit | 2875b4a66e38e4333da887a4afbed33358999298 (patch) | |
tree | 30cebea95c700033b10e469ba898e8721b3cf9f8 /railties/test/generators | |
parent | e4e750ba1a82c88aed492329c3e024efa07c43d0 (diff) | |
download | rails-2875b4a66e38e4333da887a4afbed33358999298.tar.gz rails-2875b4a66e38e4333da887a4afbed33358999298.tar.bz2 rails-2875b4a66e38e4333da887a4afbed33358999298.zip |
add a more restricted codepath for templates fixes #13390
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 195f13bdc3..be109cc598 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -163,12 +163,21 @@ class AppGeneratorTest < Rails::Generators::TestCase end end + def test_arbitrary_code + output = Tempfile.open('my_template') do |template| + template.puts 'puts "You are using Rails version #{Rails::VERSION::STRING}."' + template.close + run_generator([destination_root, "-m", template.path]) + end + assert_match 'You are using', output + end + def test_add_gemfile_entry Tempfile.open('my_template') do |template| template.puts 'gemfile_entry "tenderlove"' template.flush template.close - run_generator([destination_root, "-m", template.path]) + run_generator([destination_root, "-n", template.path]) assert_file "Gemfile", /tenderlove/ end end @@ -176,9 +185,21 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_add_skip_entry Tempfile.open 'my_template' do |template| template.puts 'add_gem_entry_filter { |gem| gem.name != "jbuilder" }' - template.flush + template.close - run_generator([destination_root, "-m", template.path]) + run_generator([destination_root, "-n", template.path]) + assert_file "Gemfile" do |contents| + assert_no_match 'jbuilder', contents + end + end + end + + def test_remove_gem + Tempfile.open 'my_template' do |template| + template.puts 'remove_gem "jbuilder"' + template.close + + run_generator([destination_root, "-n", template.path]) assert_file "Gemfile" do |contents| assert_no_match 'jbuilder', contents end @@ -190,7 +211,7 @@ class AppGeneratorTest < Rails::Generators::TestCase template.puts 'add_gem_entry_filter { |gem| gem.name != "turbolinks" }' template.flush - run_generator([destination_root, "-m", template.path]) + run_generator([destination_root, "-n", template.path]) assert_file "Gemfile" do |contents| assert_no_match 'turbolinks', contents end |