diff --git a/test/unit/answer_test.rb b/test/unit/answer_test.rb index 92dc082..abac15a 100644 --- a/test/unit/answer_test.rb +++ b/test/unit/answer_test.rb @@ -4,12 +4,7 @@ setup do @user = User.last - - @text_based_questions = QuestionFormat.joins(:questions).joins(:question_options)#.where("question_options.id IS NULL") - #@option_based_questions = QuestionFormat.joins(:questions).includes(:question_options).where("question_options.id IS NOT NULL") - puts @text_based_questions.inspect - @text_area_question = QuestionFormat.find_by(title: 'Text Area').questions.first @text_field_question = QuestionFormat.find_by(title: 'Text Field').questions.first @radio_button_question = QuestionFormat.find_by(title: 'Radio Button').questions.first @@ -24,7 +19,7 @@ assert_not Answer.new.valid? # Validate the creation of text based answers - [].each do |q| + [QuestionFormat.where(option_based: false)].each do |q| assert_not Answer.new(user: @user, question: q, text: 'Testing').valid?, "expected the 'plan' field to be required for a #{q.question_format.class.name}" assert_not Answer.new(plan: @plan, question: q, text: 'Testing').valid?, "expected the 'user' field to be required for a #{q.question_format.class.name}" assert_not Answer.new(user: @user, plan: @plan, text: 'Testing').valid?, "expected the 'question' field to be required for a #{q.question_format.class.name}" @@ -36,7 +31,7 @@ end # Validate the creation of option based answers (a selection is not required) - [@radio_button_question, @check_box_question, @select_box_question, @multi_select_box_question].each do |q| + [QuestionFormat.where(option_based: true].each do |q| assert_not Answer.new(user: @user, question: q).valid?, "expected the 'plan' field to be required for a #{q.question_format.class.name}" assert_not Answer.new(plan: @plan, question: q).valid?, "expected the 'user' field to be required for a #{q.question_format.class.name}" assert_not Answer.new(user: @user, plan: @plan).valid?, "expected the 'question' field to be required for a #{q.question_format.class.name}"