diff --git a/spec/controllers/answer_questions_controller_spec.rb b/spec/controllers/answer_questions_controller_spec.rb index bfdfaa3d..6542cda3 100644 --- a/spec/controllers/answer_questions_controller_spec.rb +++ b/spec/controllers/answer_questions_controller_spec.rb @@ -2,9 +2,13 @@ require_relative "../support/devise" RSpec.describe AnswerQuestionsController, type: :controller do - let(:quiz) { build(:quiz, id: 1) } - let(:question) { build(:question, id: 1) } + let(:quiz) { create(:quiz) } + let(:question) { create(:question) } let(:answer) { create(:answer, id: 1, title_ee: "Title", title_en: "Title") } + let(:answer_t) { create(:answer, id: 2, title_ee: "Title", title_en: "Title") } + let(:user_answer) { build(:user_answer) } + let(:answer_question) { build(:answer_question, answer_id: 2, quiz_id: 6, question_id: 5, ) } + let(:answer_question_t) { build(:answer_question, answer_id: 3) } login_user @@ -16,4 +20,23 @@ expect(response).to have_http_status(:redirect) end end + + context 'interactions' do + it 'multiple answers' do + answer_question_params = {} + + user_answer.save + + answer_question_params[:answer_id] = [answer.id , answer_t.id] + answer_question_params[:quiz_id] = quiz.id + answer_question_params[:question_id] = question.id + + user_answer.answer_questions.empty? + + MultipleAnswerCreate.create_multiple_answer(answer_question_params: answer_question_params, + user_answer: user_answer) + + expect(user_answer.answer_questions.count).to eq(2) + end + end end \ No newline at end of file