aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2011-12-09 20:53:55 +0100
committerPiotr Sarnacki <drogus@gmail.com>2011-12-09 22:00:51 +0100
commit35a1744a45501fe79660ba11fbee35a7bf099bce (patch)
tree4aabbe1efd034f5f019f7ee6f99e3455e984aad9 /railties/test/application
parentf0b782d060f76647e36adc40fe5fe818ec8e2c66 (diff)
downloadrails-35a1744a45501fe79660ba11fbee35a7bf099bce.tar.gz
rails-35a1744a45501fe79660ba11fbee35a7bf099bce.tar.bz2
rails-35a1744a45501fe79660ba11fbee35a7bf099bce.zip
Allow to run migrations with given scope, with SCOPE=<scope>
Scope in migrations can be defined by adding suffix in filename, like: 01_a_migration.blog.rb. Such migration have blog scope. Scope is automatically added while copying migrations from engine, so if you want to revert all of the migrations from given engine, you can just run db:migrate with SCOPE, like: rake db:migrate SCOPE=blog
Diffstat (limited to 'railties/test/application')
-rw-r--r--railties/test/application/rake/migrations_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb
index 4ec6f1b67c..3d3e01cdc0 100644
--- a/railties/test/application/rake/migrations_test.rb
+++ b/railties/test/application/rake/migrations_test.rb
@@ -12,6 +12,30 @@ module ApplicationTests
def teardown
teardown_app
end
+
+ test 'running migrations with given scope' do
+ Dir.chdir(app_path) do
+ `rails generate model user username:string password:string`
+ end
+ app_file "db/migrate/01_a_migration.bukkits.rb", <<-MIGRATION
+ class AMigration < ActiveRecord::Migration
+ end
+ MIGRATION
+
+ output = Dir.chdir(app_path) { `rake db:migrate SCOPE=bukkits` }
+ assert_no_match(/create_table\(:users\)/, output)
+ assert_no_match(/CreateUsers/, output)
+ assert_no_match(/add_column\(:users, :email, :string\)/, output)
+
+ assert_match(/AMigration: migrated/, output)
+
+ output = Dir.chdir(app_path) { `rake db:migrate SCOPE=bukkits VERSION=0` }
+ assert_no_match(/drop_table\(:users\)/, output)
+ assert_no_match(/CreateUsers/, output)
+ assert_no_match(/remove_column\(:users, :email\)/, output)
+
+ assert_match(/AMigration: reverted/, output)
+ end
test 'model and migration generator with change syntax' do
Dir.chdir(app_path) do