def setup
  @m = Movie.create!(
         :name => 'Casablanca',
         :length_minutes => 120,
         :rating => Rating::PG13)
  @t = Theatre.create!(
         :name => 'Kendall Cinema',
         :phone_number => '5555555555')

  @a = Auditorium.create!(
         :theatre => @t,
         :auditorium => @a,
         :seats_available => 100)

  @ms = MovieShowtime.create!(
         :movie => @m,
         :theatre => @t,
         :auditorium = @a,
         :start_time => Time.new)

  @o = Order.create!(
         :movie_showtime => @ms,
         :movie => @m
         :theatre => @t,
         :auditorium = @a,
         :start_time => @ms.start_time,
         :purchaser_name => 'Ja Fasola')
end

def test_deferrable_constraints
  MovieShowtime.transaction do
    @ms.start_time = @ms.start_time + 1.hour
    @ms.save!
    Order.update_all(["start_time = ?", @ms.start_time],
                     ["movie_showtime_id = ?", @ms.id ])
  end
end
