aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2015-12-15 13:56:47 -0500
committereileencodes <eileencodes@gmail.com>2015-12-15 15:19:26 -0500
commitbecf1bcb1d6e72e782995507ebc89d75db357184 (patch)
tree412ef453bab51877b3b5f0847f8904af3be614e1 /railties
parent98a039dcd987fd3a8c2c0cbd527c71ac3ffaaf06 (diff)
downloadrails-becf1bcb1d6e72e782995507ebc89d75db357184.tar.gz
rails-becf1bcb1d6e72e782995507ebc89d75db357184.tar.bz2
rails-becf1bcb1d6e72e782995507ebc89d75db357184.zip
Run railties generated app tests in test env
Running railties generated app tests in development env can cause unintended consequences. The environments are different and tests aren't meant to be run in development mode. The changes to the generator exposed this issue where the random test order in the generated apps could cause problems when those tests are run in development mode. Particularly we saw failures in `railties/test/application/rake_test.rb` generated apps that used the scaffold to create applications and then run the migration and immediately run the tests. The error we saw was `ActiveRecord::RecordNotFound: Couldn't find User with 'id'=980190962` and seemed to only occur if the destroy test ran first. I'm not entirely sure _why_ this causes that error to be thrown but I believe it is related to the environments being different.
Diffstat (limited to 'railties')
-rw-r--r--railties/test/application/rake_test.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index 0da0928b48..1d3550add9 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -186,7 +186,7 @@ module ApplicationTests
def test_scaffold_tests_pass_by_default
output = Dir.chdir(app_path) do
`bin/rails generate scaffold user username:string password:string;
- bin/rake db:migrate test`
+ RAILS_ENV=test bin/rake db:migrate test`
end
assert_match(/7 runs, 12 assertions, 0 failures, 0 errors/, output)
@@ -205,7 +205,7 @@ module ApplicationTests
output = Dir.chdir(app_path) do
`bin/rails generate scaffold user username:string password:string;
- bin/rake db:migrate test`
+ RAILS_ENV=test bin/rake db:migrate test`
end
assert_match(/5 runs, 7 assertions, 0 failures, 0 errors/, output)
@@ -218,7 +218,7 @@ module ApplicationTests
output = Dir.chdir(app_path) do
`bin/rails generate scaffold LineItems product:references cart:belongs_to;
- bin/rake db:migrate test`
+ RAILS_ENV=test bin/rake db:migrate test`
end
assert_match(/7 runs, 12 assertions, 0 failures, 0 errors/, output)