annotate .svn/pristine/8b/8b0c72afd0d7787739416aa1510d0e28d12a95ed.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents cbb26bc654de
children
rev   line source
Chris@909 1 require File.dirname(__FILE__) + '/../test_helper'
Chris@909 2 require 'rails_generator'
Chris@909 3 require 'rails_generator/scripts/generate'
Chris@909 4
Chris@909 5 class MigrationsTest < Test::Unit::TestCase
Chris@909 6
Chris@909 7 @@migration_dir = "#{RAILS_ROOT}/db/migrate"
Chris@909 8
Chris@909 9 def setup
Chris@909 10 ActiveRecord::Migration.verbose = false
Chris@909 11 Engines.plugins[:test_migration].migrate(0)
Chris@909 12 end
Chris@909 13
Chris@909 14 def teardown
Chris@909 15 FileUtils.rm_r(@@migration_dir) if File.exist?(@@migration_dir)
Chris@909 16 end
Chris@909 17
Chris@909 18 def test_engine_migrations_can_run_down
Chris@909 19 assert !table_exists?('tests'), ActiveRecord::Base.connection.tables.inspect
Chris@909 20 assert !table_exists?('others'), ActiveRecord::Base.connection.tables.inspect
Chris@909 21 assert !table_exists?('extras'), ActiveRecord::Base.connection.tables.inspect
Chris@909 22 end
Chris@909 23
Chris@909 24 def test_engine_migrations_can_run_up
Chris@909 25 Engines.plugins[:test_migration].migrate(3)
Chris@909 26 assert table_exists?('tests')
Chris@909 27 assert table_exists?('others')
Chris@909 28 assert table_exists?('extras')
Chris@909 29 end
Chris@909 30
Chris@909 31 def test_engine_migrations_can_upgrade_incrementally
Chris@909 32 Engines.plugins[:test_migration].migrate(1)
Chris@909 33 assert table_exists?('tests')
Chris@909 34 assert !table_exists?('others')
Chris@909 35 assert !table_exists?('extras')
Chris@909 36 assert_equal 1, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration])
Chris@909 37
Chris@909 38
Chris@909 39 Engines.plugins[:test_migration].migrate(2)
Chris@909 40 assert table_exists?('others')
Chris@909 41 assert_equal 2, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration])
Chris@909 42
Chris@909 43
Chris@909 44 Engines.plugins[:test_migration].migrate(3)
Chris@909 45 assert table_exists?('extras')
Chris@909 46 assert_equal 3, Engines::Plugin::Migrator.current_version(Engines.plugins[:test_migration])
Chris@909 47 end
Chris@909 48
Chris@909 49 def test_generator_creates_plugin_migration_file
Chris@909 50 Rails::Generator::Scripts::Generate.new.run(['plugin_migration', 'test_migration'], :quiet => true)
Chris@909 51 assert migration_file, "migration file is missing"
Chris@909 52 end
Chris@909 53
Chris@909 54 private
Chris@909 55
Chris@909 56 def table_exists?(table)
Chris@909 57 ActiveRecord::Base.connection.tables.include?(table)
Chris@909 58 end
Chris@909 59
Chris@909 60 def migration_file
Chris@909 61 Dir["#{@@migration_dir}/*test_migration_to_version_3.rb"][0]
Chris@909 62 end
Chris@909 63 end