aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration_test.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-10-09 10:28:46 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-10-09 21:32:34 +0200
commit022205be1d677d446437af0618697434472157e8 (patch)
treed310646fb489b71199f631aaae757cb983db6b5a /activerecord/test/cases/migration_test.rb
parent4377f8eba2dde51fe5d3bc50248c0089e24c8d24 (diff)
downloadrails-022205be1d677d446437af0618697434472157e8.tar.gz
rails-022205be1d677d446437af0618697434472157e8.tar.bz2
rails-022205be1d677d446437af0618697434472157e8.zip
Add callback on skipped migration while copying migrations
Diffstat (limited to 'activerecord/test/cases/migration_test.rb')
-rw-r--r--activerecord/test/cases/migration_test.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 9635ab25fc..ef949300b0 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -1912,7 +1912,7 @@ if ActiveRecord::Base.connection.supports_migrations?
copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy"})
assert File.exists?(@migrations_path + "/4_people_have_hobbies.rb")
assert File.exists?(@migrations_path + "/5_people_have_descriptions.rb")
- assert_equal [@migrations_path + "/4_people_have_hobbies.rb", @migrations_path + "/5_people_have_descriptions.rb"], copied
+ assert_equal [@migrations_path + "/4_people_have_hobbies.rb", @migrations_path + "/5_people_have_descriptions.rb"], copied.map(&:filename)
files_count = Dir[@migrations_path + "/*.rb"].length
copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy"})
@@ -1953,7 +1953,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.rb")
expected = [@migrations_path + "/20100726101010_people_have_hobbies.rb",
@migrations_path + "/20100726101011_people_have_descriptions.rb"]
- assert_equal expected, copied
+ assert_equal expected, copied.map(&:filename)
files_count = Dir[@migrations_path + "/*.rb"].length
copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"})
@@ -2006,6 +2006,24 @@ if ActiveRecord::Base.connection.supports_migrations?
clear
end
+ def test_skipping_migrations
+ @migrations_path = MIGRATIONS_ROOT + "/valid_with_timestamps"
+ @existing_migrations = Dir[@migrations_path + "/*.rb"]
+
+ sources = ActiveSupport::OrderedHash.new
+ sources[:bukkits] = sources[:omg] = MIGRATIONS_ROOT + "/to_copy_with_timestamps"
+
+ skipped = []
+ on_skip = Proc.new { |name, migration| skipped << "#{name} #{migration.name}" }
+ copied = ActiveRecord::Migration.copy(@migrations_path, sources, :on_skip => on_skip)
+ assert_equal 2, copied.length
+
+ assert_equal 2, skipped.length
+ assert_equal ["bukkits PeopleHaveHobbies", "bukkits PeopleHaveDescriptions"], skipped
+ ensure
+ clear
+ end
+
def test_copying_migrations_to_empty_directory
@migrations_path = MIGRATIONS_ROOT + "/empty"
@existing_migrations = []