Skip to content

Instantly share code, notes, and snippets.

@hone
Created October 23, 2009 22:13
Show Gist options
  • Select an option

  • Save hone/217218 to your computer and use it in GitHub Desktop.

Select an option

Save hone/217218 to your computer and use it in GitHub Desktop.
describe "suite_id_to_suite_ownership_id migration" do
before(:all) do
Spec::Runner.configure do |config|
config.use_transactional_fixtures = false
end
end
after(:all) do
Spec::Runner.configure do |config|
config.use_transactional_fixtures = true
end
end
before(:each) do
ChangeSuiteIdToSuiteOwnershipIdOnEventAvailability.down
ActiveRecord::Base.connection.increment_open_transactions
ActiveRecord::Base.connection.begin_db_transaction do
venue = Factory(:venue_with_valid_creation_attributes)
venue_director = Factory(:user_with_valid_creation_attributes)
venue_director.user_groups << UserGroup.find_by_name("Venue Director")
Factory(:venue_directorship, :venue => venue, :user => venue_director)
suite_owner = Factory(:user_with_valid_creation_attributes)
suite_owner.activate!
suite_owner.send_invite!
suite_owner.accept!
suite_owner.user_groups << UserGroup.find_by_name("Suite Owner")
@suites = Array(1..2).collect do
suite = Factory(:suite,
:venue => venue)
Factory(:suite_ownership,
:user => suite_owner,
:suite => suite)
suite
end
event = Factory(:event,
:eventable => venue)
@suites.each do |suite|
Factory(:event_availability, :suite_id => suite_ownership.id, :user => user)
end
end
end
after(:each) do
ActiveRecord::Base.connection.rollback_db_transaction
ActiveRecord::Base.connection.decrement_open_transactions
ChangeSuiteIdToSuiteOwnershipIdOnEventAvailability.up
end
it "should migrate properly" do
EventAvailability.find(:all, :order => 'id ASC').each_with_index do |ea, index|
suite_ownership = SuiteOwnership.find(ea.suite_ownership_id)
suite_ownership.suite.should == @suites[index]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment