#
# bazodanowe testy prby usuwania skorelowanego rekordu
#

def test_db_prevents_invalid_theatre_destroy
  st = MovieShowtime.create!(
    :theatre => @theatre,
    :movie => @movie,
    :auditorium => '1',
    :start_time => Time.now.xmlschema)
  test_for_db_error "Baza danych nie zapobiega usuniciu skorelowanego rekordu kina" do
    @theatre.destroy_without_callbacks
end

def test_db_prevents_invalid_movie_destroy
  st = MovieShowtime.create!(
    :theatre => @theatre,
    :movie => @movie,
    :auditorium => '1',
    :start_time => Time.now.xmlschema)
  test_for_db_error "Baza danych nie zapobiega usuniciu skorelowanego rekordu filmu" do
    @movie.destroy_without_callbacks
end

#
# modelowe testy prby usuwania skorelowanego rekordu
#

def test_prevents_invalid_theatre_destroy
  st = MovieShowtime.create!(
    :theatre => @theatre,
    :movie => @movie,
    :auditorium => '1',
    :start_time => Time.now.xmlschema)
  @theatre.destroy
  dependent_showtimes_count = MovieShowtime.find_all_by_theatre_id(@theatre_id).size
  assert dependent_showtimes_count == 0, 
            "Klasa modelowa nie zapobiega usuniciu skorelowanego rekordu kina"
end

def test_prevents_invalid_movie_destroy
  st = MovieShowtime.create!(
    :theatre => @theatre,
    :movie => @movie,
    :auditorium => '1',
    :start_time => Time.now.xmlschema)
  @movie.destroy
  dependent_showtimes_count = MovieShowtime.find_all_by_theatre_id(@movie_id).size
  assert dependent_showtimes_count == 0, 
            "Klasa modelowa nie zapobiega usuniciu skorelowanego rekordu filmu"
end


