Namespace
- CLASS ActiveRecord::InvertibleMigrationTest::InvertibleByPartsMigration
- CLASS ActiveRecord::InvertibleMigrationTest::InvertibleMigration
- CLASS ActiveRecord::InvertibleMigrationTest::InvertibleRevertMigration
- CLASS ActiveRecord::InvertibleMigrationTest::LegacyMigration
- CLASS ActiveRecord::InvertibleMigrationTest::NestedRevertWholeMigration
- CLASS ActiveRecord::InvertibleMigrationTest::NonInvertibleMigration
- CLASS ActiveRecord::InvertibleMigrationTest::RemoveIndexMigration1
- CLASS ActiveRecord::InvertibleMigrationTest::RemoveIndexMigration2
- CLASS ActiveRecord::InvertibleMigrationTest::RevertNamedIndexMigration1
- CLASS ActiveRecord::InvertibleMigrationTest::RevertNamedIndexMigration2
- CLASS ActiveRecord::InvertibleMigrationTest::RevertWholeMigration
- CLASS ActiveRecord::InvertibleMigrationTest::SilentMigration
Methods
- T
-
- test_down,
- test_exception_on_removing_index_without_column_option,
- test_legacy_down,
- test_legacy_up,
- test_migrate_down,
- test_migrate_down_with_table_name_prefix,
- test_migrate_nested_revert_whole_migration,
- test_migrate_revert,
- test_migrate_revert_add_index_with_name,
- test_migrate_revert_by_part,
- test_migrate_revert_whole_migration,
- test_migrate_up,
- test_no_reverse,
- test_revert_order,
- test_up
Instance Public methods
test_down()
Link
test_exception_on_removing_index_without_column_option()
Link
# File activerecord/test/cases/invertible_migration_test.rb, line 146 def test_exception_on_removing_index_without_column_option RemoveIndexMigration1.new.migrate(:up) migration = RemoveIndexMigration2.new migration.migrate(:up) assert_raises(IrreversibleMigration) do migration.migrate(:down) end end
test_legacy_down()
Link
test_legacy_up()
Link
test_migrate_down()
Link
test_migrate_down_with_table_name_prefix()
Link
# File activerecord/test/cases/invertible_migration_test.rb, line 268 def test_migrate_down_with_table_name_prefix ActiveRecord::Base.table_name_prefix = 'p_' ActiveRecord::Base.table_name_suffix = '_s' migration = InvertibleMigration.new migration.migrate(:up) assert_nothing_raised { migration.migrate(:down) } assert !ActiveRecord::Base.connection.table_exists?("p_horses_s"), "p_horses_s should not exist" ensure ActiveRecord::Base.table_name_prefix = ActiveRecord::Base.table_name_suffix = '' end
test_migrate_nested_revert_whole_migration()
Link
# File activerecord/test/cases/invertible_migration_test.rb, line 214 def test_migrate_nested_revert_whole_migration revert = NestedRevertWholeMigration.new(InvertibleRevertMigration) revert.migrate :down assert revert.connection.table_exists?("horses") revert.migrate :up assert !revert.connection.table_exists?("horses") end
test_migrate_revert()
Link
# File activerecord/test/cases/invertible_migration_test.rb, line 169 def test_migrate_revert migration = InvertibleMigration.new revert = InvertibleRevertMigration.new migration.migrate :up revert.migrate :up assert !migration.connection.table_exists?("horses") revert.migrate :down assert migration.connection.table_exists?("horses") migration.migrate :down assert !migration.connection.table_exists?("horses") end
test_migrate_revert_add_index_with_name()
Link
# File activerecord/test/cases/invertible_migration_test.rb, line 281 def test_migrate_revert_add_index_with_name RevertNamedIndexMigration1.new.migrate(:up) RevertNamedIndexMigration2.new.migrate(:up) RevertNamedIndexMigration2.new.migrate(:down) connection = ActiveRecord::Base.connection assert connection.index_exists?(:horses, :content), "index on content should exist" assert !connection.index_exists?(:horses, :content, name: "horses_index_named"), "horses_index_named index should not exist" end
test_migrate_revert_by_part()
Link
# File activerecord/test/cases/invertible_migration_test.rb, line 181 def test_migrate_revert_by_part InvertibleMigration.new.migrate :up received = [] migration = InvertibleByPartsMigration.new migration.test = ->(dir){ assert migration.connection.table_exists?("horses") assert migration.connection.table_exists?("new_horses") received << dir } migration.migrate :up assert_equal [:both, :up], received assert !migration.connection.table_exists?("horses") assert migration.connection.table_exists?("new_horses") migration.migrate :down assert_equal [:both, :up, :both, :down], received assert migration.connection.table_exists?("horses") assert !migration.connection.table_exists?("new_horses") end
test_migrate_revert_whole_migration()
Link
# File activerecord/test/cases/invertible_migration_test.rb, line 200 def test_migrate_revert_whole_migration migration = InvertibleMigration.new [LegacyMigration, InvertibleMigration].each do |klass| revert = RevertWholeMigration.new(klass) migration.migrate :up revert.migrate :up assert !migration.connection.table_exists?("horses") revert.migrate :down assert migration.connection.table_exists?("horses") migration.migrate :down assert !migration.connection.table_exists?("horses") end end
test_migrate_up()
Link
test_no_reverse()
Link
test_revert_order()
Link
# File activerecord/test/cases/invertible_migration_test.rb, line 222 def test_revert_order block = Proc.new{|t| t.string :name } recorder = ActiveRecord::Migration::CommandRecorder.new(ActiveRecord::Base.connection) recorder.instance_eval do create_table("apples", &block) revert do create_table("bananas", &block) revert do create_table("clementines") create_table("dates") end create_table("elderberries") end revert do create_table("figs") create_table("grapes") end end assert_equal [[:create_table, ["apples"], block], [:drop_table, ["elderberries"], nil], [:create_table, ["clementines"], nil], [:create_table, ["dates"], nil], [:drop_table, ["bananas"], block], [:drop_table, ["grapes"], nil], [:drop_table, ["figs"], nil]], recorder.commands end