From dd96f50d02fe92a2fef5f016d98db00c1e04aea0 Mon Sep 17 00:00:00 2001 From: Luke Baker Date: Fri, 6 Dec 2013 10:42:50 -0500 Subject: [PATCH] limit answer appearance test to valid answers --- lib/tasks/test_api.rake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/tasks/test_api.rake b/lib/tasks/test_api.rake index 24b3add..b5b4e8a 100644 --- a/lib/tasks/test_api.rake +++ b/lib/tasks/test_api.rake @@ -192,7 +192,7 @@ namespace :test_api do :wins_and_losses_equals_two_times_vote_count => "Verify that sum of wins and losses equals two times the vote count", :check_scores_over_above_fifty => "Check that there are some scores above fifty and some below", :generated_prompts_on_each_side_are_equal => "Verify that count of generated prompts on each side is equal", - :every_answer_has_an_appearances => "Verify that all answers have an appearance", + :every_valid_answer_has_an_appearances => "Verify that all valid answers have an appearance", :duplicate_answers_have_no_appearance => "Verify that duplicate answers have no appearance", :appearances_have_same_session_as_answer => "Appearances have the same session of their answer" } @@ -237,9 +237,10 @@ namespace :test_api do end return error_message.blank? ? [success_message, false] : [error_message, true] end - # every answer should have an appearance except for those that are attempts - # to answer an already answered appearance. - def every_answer_has_an_appearances(question) + + # some invalid answers could have appearances while other do not. + # we're only testing valid answers. + def every_valid_answer_has_an_appearances(question) error_message = "" success_message = "All valid answers have an appearance." votes_sql = "SELECT votes.id, votes.valid_record, votes.validity_information @@ -247,7 +248,7 @@ namespace :test_api do LEFT JOIN appearances ON (votes.question_id = appearances.question_id AND votes.id = appearances.answerable_id AND appearances.answerable_type = 'Vote') WHERE appearances.id IS NULL - AND (votes.validity_information IS NULL OR votes.validity_information NOT LIKE 'Appearance % already answered') + AND votes.valid_record = 1 AND votes.question_id = #{question.id}" bad_records = Vote.connection.select_all votes_sql bad_records.each do |record| @@ -258,7 +259,7 @@ namespace :test_api do LEFT JOIN appearances ON (skips.question_id = appearances.question_id AND skips.id = appearances.answerable_id AND appearances.answerable_type = 'Skip') WHERE appearances.id IS NULL - AND (skips.validity_information IS NULL OR skips.validity_information NOT LIKE 'Appearance % already answered') + AND skips.valid_record = 1 AND skips.question_id = #{question.id}" bad_records = Skip.connection.select_all skips_sql bad_records.each do |record| -- libgit2 0.21.2