Skip to content

Commit

Permalink
added test for interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Jul 30, 2021
1 parent 10b490f commit c15a7af
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions spec/controllers/answer_questions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

0 comments on commit c15a7af

Please sign in to comment.