diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-03-07 16:44:50 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-03-07 16:44:50 -0800 |
commit | 447ecb08ca1bab594198282237c4e9a027f7a3f4 (patch) | |
tree | f294ae7de0f0246eca655ac6291b2392566f28d3 /railties/test | |
parent | b700153507b7d539a57a6e3bcf03c84776795051 (diff) | |
parent | 46c12172fe651980438e0b0663e2005cf3132079 (diff) | |
download | rails-447ecb08ca1bab594198282237c4e9a027f7a3f4.tar.gz rails-447ecb08ca1bab594198282237c4e9a027f7a3f4.tar.bz2 rails-447ecb08ca1bab594198282237c4e9a027f7a3f4.zip |
Merge pull request #5162 from kennyj/schema_cache_dump
[Proposal] Schema cache dump
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/initializers/frameworks_test.rb | 26 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 19 |
2 files changed, 45 insertions, 0 deletions
diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb index 8812685620..a0e88cd0f0 100644 --- a/railties/test/application/initializers/frameworks_test.rb +++ b/railties/test/application/initializers/frameworks_test.rb @@ -193,5 +193,31 @@ module ApplicationTests require "#{app_path}/config/environment" assert_nil defined?(ActiveRecord::Base) end + + test "use schema cache dump" do + Dir.chdir(app_path) do + `rails generate model post title:string` + `bundle exec rake db:migrate` + `bundle exec rake db:schema:cache:dump` + end + require "#{app_path}/config/environment" + ActiveRecord::Base.connection.drop_table("posts") # force drop posts table for test. + assert ActiveRecord::Base.connection.schema_cache.tables["posts"] + end + + test "expire schema cache dump" do + Dir.chdir(app_path) do + `rails generate model post title:string` + `bundle exec rake db:migrate` + `bundle exec rake db:schema:cache:dump` + + `bundle exec rake db:rollback` + end + silence_warnings { + require "#{app_path}/config/environment" + assert !ActiveRecord::Base.connection.schema_cache.tables["posts"] + } + end + end end diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index ff12b3e9fc..9515e40b6e 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -138,5 +138,24 @@ module ApplicationTests 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` + `bundle exec rake 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` + `bundle exec rake db:schema:cache:clear` + end + assert !File.exists?(File.join(app_path, 'db', 'schema_cache.dump')) + end + end end |