diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-09-18 18:39:44 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-09-18 18:39:44 -0300 |
commit | c2dfc316912e780dfd6113e6ab9668128264f111 (patch) | |
tree | 93e6c936d6d7110750a968aafa0e1f8cacb3107b | |
parent | 112077c255879351edf4530791cc4bcc7bd4005b (diff) | |
parent | 7137c6b7750ca5d1ddcc794de5e9b219af65de1c (diff) | |
download | rails-c2dfc316912e780dfd6113e6ab9668128264f111.tar.gz rails-c2dfc316912e780dfd6113e6ab9668128264f111.tar.bz2 rails-c2dfc316912e780dfd6113e6ab9668128264f111.zip |
Merge pull request #16936 from untidy-hair/plugin_test_db_migrate_path
Specify dummy app's db migrate path in plugin's test_helper.rb
Conflicts:
railties/CHANGELOG.md
-rw-r--r-- | railties/CHANGELOG.md | 6 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb | 3 | ||||
-rw-r--r-- | railties/test/generators/plugin_generator_test.rb | 15 |
3 files changed, 21 insertions, 3 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index db9dc09e35..0543b57ad4 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,9 @@ +* Specify dummy app's db migrate path in plugin's test_helper.rb. + + Fixes #16877. + + *Yukio Mizuta* + * Inject `Rack::Lock` if `config.eager_load` is false. Fixes #15089. diff --git a/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb index 40c83d063a..c6e2247e16 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +++ b/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb @@ -2,6 +2,9 @@ ENV["RAILS_ENV"] = "test" require File.expand_path("../../<%= options[:dummy_path] -%>/config/environment.rb", __FILE__) +<% unless options[:skip_active_record] -%> +ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../<%= options[:dummy_path] -%>/db/migrate", __FILE__)] +<% end -%> require "rails/test_help" Rails.backtrace_cleaner.remove_silencers! diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index 645efa5daf..ed4e100a9b 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -54,7 +54,10 @@ class PluginGeneratorTest < Rails::Generators::TestCase run_generator assert_file "README.rdoc", /Bukkits/ assert_no_file "config/routes.rb" - assert_file "test/test_helper.rb", /require.+test\/dummy\/config\/environment/ + assert_file "test/test_helper.rb" do |content| + assert_match(/require.+test\/dummy\/config\/environment/, content) + assert_match(/ActiveRecord::Migrator\.migrations_paths.+test\/dummy\/db\/migrate/, content) + end assert_file "test/bukkits_test.rb", /assert_kind_of Module, Bukkits/ end @@ -270,7 +273,10 @@ class PluginGeneratorTest < Rails::Generators::TestCase assert_file "spec/dummy" assert_file "spec/dummy/config/application.rb" assert_no_file "test/dummy" - assert_file "test/test_helper.rb", /require.+spec\/dummy\/config\/environment/ + assert_file "test/test_helper.rb" do |content| + assert_match(/require.+spec\/dummy\/config\/environment/, content) + assert_match(/ActiveRecord::Migrator\.migrations_paths.+spec\/dummy\/db\/migrate/, content) + end end def test_creating_dummy_application_with_different_name @@ -278,7 +284,10 @@ class PluginGeneratorTest < Rails::Generators::TestCase assert_file "spec/fake" assert_file "spec/fake/config/application.rb" assert_no_file "test/dummy" - assert_file "test/test_helper.rb", /require.+spec\/fake\/config\/environment/ + assert_file "test/test_helper.rb" do |content| + assert_match(/require.+spec\/fake\/config\/environment/, content) + assert_match(/ActiveRecord::Migrator\.migrations_paths.+spec\/fake\/db\/migrate/, content) + end end def test_creating_dummy_without_tests_but_with_dummy_path |