diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2017-11-12 19:18:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-12 19:18:49 -0500 |
commit | a45f234b028fd4dda5338e5073a3bf2b8bf2c6fd (patch) | |
tree | 84e2fd89dbc7248b1853c11dc16100305fa9089b /railties | |
parent | d2a04ccc40c456bc62de66f3f76a818874163245 (diff) | |
parent | 87598c8c80f4cbeef114267d75c46f1c87ca057a (diff) | |
download | rails-a45f234b028fd4dda5338e5073a3bf2b8bf2c6fd.tar.gz rails-a45f234b028fd4dda5338e5073a3bf2b8bf2c6fd.tar.bz2 rails-a45f234b028fd4dda5338e5073a3bf2b8bf2c6fd.zip |
Merge pull request #30773 from y-yagi/fix_30765
Make automatically synchronize test schema work inside engine
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/tasks/engine.rake | 3 | ||||
-rw-r--r-- | railties/test/engine/test_test.rb | 31 |
2 files changed, 34 insertions, 0 deletions
diff --git a/railties/lib/rails/tasks/engine.rake b/railties/lib/rails/tasks/engine.rake index c24d1ad532..9db9d78ec4 100644 --- a/railties/lib/rails/tasks/engine.rake +++ b/railties/lib/rails/tasks/engine.rake @@ -70,6 +70,9 @@ namespace :db do desc "Retrieves the current schema version number" app_task "version" + + # desc 'Load the test schema' + app_task "test:prepare" end def find_engine_path(path) diff --git a/railties/test/engine/test_test.rb b/railties/test/engine/test_test.rb new file mode 100644 index 0000000000..18af85a0aa --- /dev/null +++ b/railties/test/engine/test_test.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require "abstract_unit" + +class Rails::Engine::TestTest < ActiveSupport::TestCase + setup do + @destination_root = Dir.mktmpdir("bukkits") + Dir.chdir(@destination_root) { `bundle exec rails plugin new bukkits --mountable` } + end + + teardown do + FileUtils.rm_rf(@destination_root) + end + + test "automatically synchronize test schema" do + Dir.chdir(plugin_path) do + # In order to confirm that migration files are loaded, generate multiple migration files. + `bin/rails generate model user name:string; + bin/rails generate model todo name:string; + RAILS_ENV=development bin/rails db:migrate` + + output = `bin/rails test test/models/bukkits/user_test.rb` + assert_includes(output, "0 runs, 0 assertions, 0 failures, 0 errors, 0 skips") + end + end + + private + def plugin_path + "#{@destination_root}/bukkits" + end +end |