aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/migration_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/migration_test.rb')
-rw-r--r--activerecord/test/cases/migration_test.rb49
1 files changed, 25 insertions, 24 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index af34fd47bf..59cb6c1fe7 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -1,11 +1,12 @@
-require 'abstract_unit'
+require "cases/helper"
require 'bigdecimal/util'
require 'models/person'
require 'models/topic'
-require 'migrations/valid/1_people_have_last_names'
-require 'migrations/valid/2_we_need_reminders'
-require 'migrations/decimal/1_give_me_big_numbers'
+
+require MIGRATIONS_ROOT + "/valid/1_people_have_last_names"
+require MIGRATIONS_ROOT + "/valid/2_we_need_reminders"
+require MIGRATIONS_ROOT + "/decimal/1_give_me_big_numbers"
if ActiveRecord::Base.connection.supports_migrations?
class BigNumber < ActiveRecord::Base; end
@@ -22,7 +23,7 @@ if ActiveRecord::Base.connection.supports_migrations?
end
end
- class MigrationTest < ActiveSupport::TestCase
+ class MigrationTest < ActiveRecord::TestCase
self.use_transactional_fixtures = false
fixtures :people
@@ -695,7 +696,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert !Person.column_methods_hash.include?(:last_name)
assert !Reminder.table_exists?
- ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/../migrations/valid')
+ ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid")
assert_equal 3, ActiveRecord::Migrator.current_version
Person.reset_column_information
@@ -703,7 +704,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
assert_equal "hello world", Reminder.find(:first).content
- ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/../migrations/valid')
+ ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid")
assert_equal 0, ActiveRecord::Migrator.current_version
Person.reset_column_information
@@ -715,22 +716,22 @@ if ActiveRecord::Base.connection.supports_migrations?
assert !Person.column_methods_hash.include?(:last_name)
assert !Reminder.table_exists?
- ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/../migrations/valid', 1)
+ ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1)
Person.reset_column_information
assert Person.column_methods_hash.include?(:last_name)
assert !Reminder.table_exists?
- ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/../migrations/valid', 2)
+ ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 2)
assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
assert_equal "hello world", Reminder.find(:first).content
end
def test_migrator_one_down
- ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/../migrations/valid')
+ ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid")
- ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/../migrations/valid', 1)
+ ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 1)
Person.reset_column_information
assert Person.column_methods_hash.include?(:last_name)
@@ -738,39 +739,39 @@ if ActiveRecord::Base.connection.supports_migrations?
end
def test_migrator_one_up_one_down
- ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/../migrations/valid', 1)
- ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/../migrations/valid', 0)
+ ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1)
+ ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 0)
assert !Person.column_methods_hash.include?(:last_name)
assert !Reminder.table_exists?
end
def test_migrator_verbosity
- ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/../migrations/valid', 1)
+ ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1)
assert PeopleHaveLastNames.message_count > 0
PeopleHaveLastNames.message_count = 0
- ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/../migrations/valid', 0)
+ ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 0)
assert PeopleHaveLastNames.message_count > 0
PeopleHaveLastNames.message_count = 0
end
def test_migrator_verbosity_off
PeopleHaveLastNames.verbose = false
- ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/../migrations/valid', 1)
+ ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1)
assert PeopleHaveLastNames.message_count.zero?
- ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/../migrations/valid', 0)
+ ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 0)
assert PeopleHaveLastNames.message_count.zero?
end
def test_migrator_going_down_due_to_version_target
- ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/../migrations/valid', 1)
- ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/../migrations/valid', 0)
+ ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1)
+ ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 0)
assert !Person.column_methods_hash.include?(:last_name)
assert !Reminder.table_exists?
- ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/../migrations/valid')
+ ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid")
Person.reset_column_information
assert Person.column_methods_hash.include?(:last_name)
@@ -863,16 +864,16 @@ if ActiveRecord::Base.connection.supports_migrations?
def test_migrator_with_duplicates
assert_raises(ActiveRecord::DuplicateMigrationVersionError) do
- ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/../migrations/duplicate', nil)
+ ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/duplicate", nil)
end
end
def test_migrator_with_missing_version_numbers
- ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/../migrations/missing', 500)
+ ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/missing", 500)
assert !Person.column_methods_hash.include?(:middle_name)
assert_equal 4, ActiveRecord::Migrator.current_version
- ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/../migrations/missing', 2)
+ ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/missing", 2)
Person.reset_column_information
assert !Reminder.table_exists?
assert Person.column_methods_hash.include?(:last_name)
@@ -918,7 +919,7 @@ if ActiveRecord::Base.connection.supports_migrations?
end
uses_mocha 'Sexy migration tests' do
- class SexyMigrationsTest < ActiveSupport::TestCase
+ class SexyMigrationsTest < ActiveRecord::TestCase
def test_references_column_type_adds_id
with_new_table do |t|
t.expects(:column).with('customer_id', :integer, {})