aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/rake_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/application/rake_test.rb')
-rw-r--r--railties/test/application/rake_test.rb55
1 files changed, 46 insertions, 9 deletions
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index ff12b3e9fc..545020357a 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -107,9 +107,9 @@ module ApplicationTests
def test_loading_specific_fixtures
Dir.chdir(app_path) do
- `rails generate model user username:string password:string`
- `rails generate model product name:string`
- `rake db:migrate`
+ `rails generate model user username:string password:string;
+ rails generate model product name:string;
+ rake db:migrate`
end
require "#{rails_root}/config/environment"
@@ -123,20 +123,57 @@ module ApplicationTests
end
def test_scaffold_tests_pass_by_default
- content = Dir.chdir(app_path) do
- `rails generate scaffold user username:string password:string`
- `bundle exec rake db:migrate db:test:clone test`
+ output = Dir.chdir(app_path) do
+ `rails generate scaffold user username:string password:string;
+ bundle exec rake db:migrate db:test:clone test`
end
- assert_match(/\d+ tests, \d+ assertions, 0 failures, 0 errors/, content)
+ assert_match(/7 tests, 13 assertions, 0 failures, 0 errors/, output)
+ assert_no_match(/Errors running/, output)
+ end
+
+ def test_http_scaffold_tests_pass_by_default
+ add_to_config <<-RUBY
+ config.middleware.http_only!
+ config.generators.http_only!
+ RUBY
+
+ app_file "app/controllers/application_controller.rb", <<-RUBY
+ class ApplicationController < ActionController::HTTP
+ end
+ RUBY
+
+ output = Dir.chdir(app_path) do
+ `rails generate scaffold user username:string password:string;
+ bundle exec rake db:migrate db:test:clone test`
+ end
+
+ assert_match(/6 tests, 12 assertions, 0 failures, 0 errors/, output)
+ assert_no_match(/Errors running/, output)
end
def test_rake_dump_structure_should_respect_db_structure_env_variable
Dir.chdir(app_path) do
- `bundle exec rake db:migrate` # ensure we have a schema_migrations table to dump
- `bundle exec rake db:structure:dump DB_STRUCTURE=db/my_structure.sql`
+ # ensure we have a schema_migrations table to dump
+ `bundle exec rake db:migrate db:structure:dump DB_STRUCTURE=db/my_structure.sql`
end
assert File.exists?(File.join(app_path, 'db', 'my_structure.sql'))
end
+
+ def test_rake_dump_schema_cache
+ Dir.chdir(app_path) do
+ `rails generate model post title:string;
+ rails generate model product name:string;
+ bundle exec rake db:migrate db:schema:cache:dump`
+ end
+ assert File.exists?(File.join(app_path, 'db', 'schema_cache.dump'))
+ end
+
+ def test_rake_clear_schema_cache
+ Dir.chdir(app_path) do
+ `bundle exec rake db:schema:cache:dump db:schema:cache:clear`
+ end
+ assert !File.exists?(File.join(app_path, 'db', 'schema_cache.dump'))
+ end
end
end