Class: MigrationsTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
vendor/plugins/engines/test/unit/migration_test.rb

Constant Summary

@@migration_dir =
"#{RAILS_ROOT}/db/migrate"

Instance Method Summary

Instance Method Details

- (Object) setup



9
10
11
12
# File 'vendor/plugins/engines/test/unit/migration_test.rb', line 9

def setup
  ActiveRecord::Migration.verbose = false
  Engines.plugins[:test_migration].migrate(0)
end

- (Object) teardown



14
15
16
# File 'vendor/plugins/engines/test/unit/migration_test.rb', line 14

def teardown
  FileUtils.rm_r(@@migration_dir) if File.exist?(@@migration_dir)
end

- (Object) test_engine_migrations_can_run_down



18
19
20
21
22
# File 'vendor/plugins/engines/test/unit/migration_test.rb', line 18

def test_engine_migrations_can_run_down
  assert !table_exists?('tests'), ActiveRecord::Base.connection.tables.inspect
  assert !table_exists?('others'), ActiveRecord::Base.connection.tables.inspect
  assert !table_exists?('extras'), ActiveRecord::Base.connection.tables.inspect
end

- (Object) test_engine_migrations_can_run_up



24
25
26
27
28
29
# File 'vendor/plugins/engines/test/unit/migration_test.rb', line 24

def test_engine_migrations_can_run_up
  Engines.plugins[:test_migration].migrate(3)
  assert table_exists?('tests')
  assert table_exists?('others')
  assert table_exists?('extras')
end

- (Object) test_engine_migrations_can_upgrade_incrementally



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'vendor/plugins/engines/test/unit/migration_test.rb', line 31

def test_engine_migrations_can_upgrade_incrementally
  Engines.plugins[:test_migration].migrate(1)
  assert table_exists?('tests')
  assert !table_exists?('others')
  assert !table_exists?('extras')
  assert_equal 1, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration])
  
  
  Engines.plugins[:test_migration].migrate(2)
  assert table_exists?('others')
  assert_equal 2, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration])
  
  
  Engines.plugins[:test_migration].migrate(3)
  assert table_exists?('extras')
  assert_equal 3, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration])
end

- (Object) test_generator_creates_plugin_migration_file



49
50
51
52
# File 'vendor/plugins/engines/test/unit/migration_test.rb', line 49

def test_generator_creates_plugin_migration_file
  Rails::Generator::Scripts::Generate.new.run(['plugin_migration', 'test_migration'], :quiet => true)
  assert migration_file, "migration file is missing"
end