Commit dd96f50d02fe92a2fef5f016d98db00c1e04aea0

Authored by Luke Baker
1 parent ad18d470

limit answer appearance test to valid answers

Showing 1 changed file with 7 additions and 6 deletions   Show diff stats
lib/tasks/test_api.rake
... ... @@ -192,7 +192,7 @@ namespace :test_api do
192 192 :wins_and_losses_equals_two_times_vote_count => "Verify that sum of wins and losses equals two times the vote count",
193 193 :check_scores_over_above_fifty => "Check that there are some scores above fifty and some below",
194 194 :generated_prompts_on_each_side_are_equal => "Verify that count of generated prompts on each side is equal",
195   - :every_answer_has_an_appearances => "Verify that all answers have an appearance",
  195 + :every_valid_answer_has_an_appearances => "Verify that all valid answers have an appearance",
196 196 :duplicate_answers_have_no_appearance => "Verify that duplicate answers have no appearance",
197 197 :appearances_have_same_session_as_answer => "Appearances have the same session of their answer"
198 198 }
... ... @@ -237,9 +237,10 @@ namespace :test_api do
237 237 end
238 238 return error_message.blank? ? [success_message, false] : [error_message, true]
239 239 end
240   - # every answer should have an appearance except for those that are attempts
241   - # to answer an already answered appearance.
242   - def every_answer_has_an_appearances(question)
  240 +
  241 + # some invalid answers could have appearances while other do not.
  242 + # we're only testing valid answers.
  243 + def every_valid_answer_has_an_appearances(question)
243 244 error_message = ""
244 245 success_message = "All valid answers have an appearance."
245 246 votes_sql = "SELECT votes.id, votes.valid_record, votes.validity_information
... ... @@ -247,7 +248,7 @@ namespace :test_api do
247 248 LEFT JOIN appearances
248 249 ON (votes.question_id = appearances.question_id AND votes.id = appearances.answerable_id AND appearances.answerable_type = 'Vote')
249 250 WHERE appearances.id IS NULL
250   - AND (votes.validity_information IS NULL OR votes.validity_information NOT LIKE 'Appearance % already answered')
  251 + AND votes.valid_record = 1
251 252 AND votes.question_id = #{question.id}"
252 253 bad_records = Vote.connection.select_all votes_sql
253 254 bad_records.each do |record|
... ... @@ -258,7 +259,7 @@ namespace :test_api do
258 259 LEFT JOIN appearances
259 260 ON (skips.question_id = appearances.question_id AND skips.id = appearances.answerable_id AND appearances.answerable_type = 'Skip')
260 261 WHERE appearances.id IS NULL
261   - AND (skips.validity_information IS NULL OR skips.validity_information NOT LIKE 'Appearance % already answered')
  262 + AND skips.valid_record = 1
262 263 AND skips.question_id = #{question.id}"
263 264 bad_records = Skip.connection.select_all skips_sql
264 265 bad_records.each do |record|
... ...