未验证 提交 0eb2d607 编写于 作者: B bogdanvlviv

Invoke rails command inside the railties' test app with TestHelpers::Generation#rails

See #30520
上级 ff67743f
......@@ -300,7 +300,7 @@ def change
end
MIGRATION
Dir.chdir(app_path) { `rake db:migrate` }
rails("db:migrate")
require "#{rails_root}/config/environment"
get "/title"
......@@ -314,7 +314,7 @@ def change
end
MIGRATION
Dir.chdir(app_path) { `rake db:migrate` }
rails("db:migrate")
get "/body"
assert_equal "BODY", last_response.body
......
......@@ -101,6 +101,7 @@ def test_should_not_eager_load_model_for_rake
add_to_config <<-RUBY
rake_tasks do
task do_nothing: :environment do
puts 'There is nothing'
end
end
RUBY
......@@ -113,10 +114,8 @@ def test_should_not_eager_load_model_for_rake
raise 'should not be pre-required for rake even eager_load=true'
RUBY
Dir.chdir(app_path) do
assert system("bin/rails do_nothing RAILS_ENV=production"),
"should not be pre-required for rake even eager_load=true"
end
output = rails("do_nothing", "RAILS_ENV=production")
assert_match "There is nothing", output
end
def test_code_statistics_sanity
......@@ -294,9 +293,8 @@ def test_loading_only_yml_fixtures
def test_scaffold_tests_pass_by_default
rails "generate", "scaffold", "user", "username:string", "password:string"
output = Dir.chdir(app_path) do
`RAILS_ENV=test bin/rails db:migrate test`
end
with_rails_env("test") { rails("db:migrate") }
output = rails("test")
assert_match(/7 runs, 9 assertions, 0 failures, 0 errors/, output)
assert_no_match(/Errors running/, output)
......@@ -313,9 +311,8 @@ class ApplicationController < ActionController::API
RUBY
rails "generate", "scaffold", "user", "username:string", "password:string"
output = Dir.chdir(app_path) do
`RAILS_ENV=test bin/rails db:migrate test`
end
with_rails_env("test") { rails("db:migrate") }
output = rails("test")
assert_match(/5 runs, 7 assertions, 0 failures, 0 errors/, output)
assert_no_match(/Errors running/, output)
......@@ -325,9 +322,8 @@ def test_scaffold_with_references_columns_tests_pass_by_default
rails "generate", "model", "Product"
rails "generate", "model", "Cart"
rails "generate", "scaffold", "LineItems", "product:references", "cart:belongs_to"
output = Dir.chdir(app_path) do
`RAILS_ENV=test bin/rails db:migrate test`
end
with_rails_env("test") { rails("db:migrate") }
output = rails("test")
assert_match(/7 runs, 9 assertions, 0 failures, 0 errors/, output)
assert_no_match(/Errors running/, output)
......
......@@ -42,7 +42,7 @@ def teardown
pid = Process.spawn("#{app_path}/bin/rails server -P tmp/dummy.pid", in: slave, out: slave, err: slave)
assert_output("Listening", master)
Dir.chdir(app_path) { system("bin/rails restart") }
rails("restart")
assert_output("Restarting", master)
assert_output("Inherited", master)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册