Skip to content

Commit

Permalink
Setup test database using migration instead of auto_migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
sr committed Apr 1, 2009
1 parent 2292554 commit 9aba760
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
3 changes: 2 additions & 1 deletion lib/integrity/migrations.rb
Expand Up @@ -143,7 +143,8 @@ class ::Integrity::Build
end

down do
modify_table(:integrity_notifiers) { remove_column :enabled }
# TODO: sqlite doesn't support DROP COLUMN ...
# modify_table(:integrity_notifiers) { drop_column :enabled }
end
end
end
Expand Down
19 changes: 6 additions & 13 deletions test/helpers.rb
Expand Up @@ -68,27 +68,20 @@ class << self
end

before(:each) do
require "integrity/migrations"
[Project, Build, Commit, Notifier].each(&:auto_migrate_down!)
capture_stdout { Integrity.migrate_db }

RR.reset
DataMapper.auto_migrate!

Notifier.available.each { |n|
Notifier.send(:remove_const, n.to_s.split(":").last.to_sym)
}
Integrity.instance_variable_set(:@config, nil)
Integrity.instance_variable_set(:@notifiers, nil)

repository(:default) do
transaction = DataMapper::Transaction.new(repository)
transaction.begin
repository.adapter.push_transaction(transaction)
end
end

after(:each) do
repository(:default) do
while repository.adapter.current_transaction
repository.adapter.current_transaction.rollback
repository.adapter.pop_transaction
end
end
capture_stdout { Integrity::Migrations.migrate_down! }
end
end
1 change: 1 addition & 0 deletions test/unit/migrations_test.rb
Expand Up @@ -24,6 +24,7 @@ def load_initial_migration_fixture

before(:each) do
[Project, Build, Commit, Notifier].each(&:auto_migrate_down!)
database_adapter.execute("DROP TABLE migration_info")
assert !table_exists?("migration_info") # just to be sure
end

Expand Down

0 comments on commit 9aba760

Please sign in to comment.