Switch from valid_answers to question_answers on specs
This commit is contained in:
@@ -261,8 +261,13 @@ feature 'Admin polls' do
|
||||
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
|
||||
booth_assignment_3 = create(:poll_booth_assignment, poll: poll)
|
||||
|
||||
question_1 = create(:poll_question, poll: poll, valid_answers: "Yes,No")
|
||||
question_2 = create(:poll_question, poll: poll, valid_answers: "Today,Tomorrow")
|
||||
question_1 = create(:poll_question, poll: poll)
|
||||
create(:poll_question_answer, title: 'Yes', question: question_1)
|
||||
create(:poll_question_answer, title: 'No', question: question_1)
|
||||
|
||||
question_2 = create(:poll_question, poll: poll)
|
||||
create(:poll_question_answer, title: 'Today', question: question_2)
|
||||
create(:poll_question_answer, title: 'Tomorrow', question: question_2)
|
||||
|
||||
[booth_assignment_1, booth_assignment_2, booth_assignment_3].each do |ba|
|
||||
create(:poll_partial_result,
|
||||
@@ -287,17 +292,17 @@ feature 'Admin polls' do
|
||||
click_link "Results"
|
||||
|
||||
expect(page).to have_content(question_1.title)
|
||||
question_1.valid_answers.each_with_index do |answer, i|
|
||||
question_1.question_answers.each_with_index do |answer, i|
|
||||
within("#question_#{question_1.id}_#{i}_result") do
|
||||
expect(page).to have_content(answer)
|
||||
expect(page).to have_content(answer.title)
|
||||
expect(page).to have_content([33, 0][i])
|
||||
end
|
||||
end
|
||||
|
||||
expect(page).to have_content(question_2.title)
|
||||
question_2.valid_answers.each_with_index do |answer, i|
|
||||
question_2.question_answers.each_with_index do |answer, i|
|
||||
within("#question_#{question_2.id}_#{i}_result") do
|
||||
expect(page).to have_content(answer)
|
||||
expect(page).to have_content(answer.title)
|
||||
expect(page).to have_content([0, 15][i])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,8 +7,13 @@ feature 'Officing Results' do
|
||||
@officer_assignment = create(:poll_officer_assignment, :final, officer: @poll_officer)
|
||||
@poll = @officer_assignment.booth_assignment.poll
|
||||
@poll.update(ends_at: 1.day.ago)
|
||||
@question_1 = create(:poll_question, poll: @poll, valid_answers: "Yes,No")
|
||||
@question_2 = create(:poll_question, poll: @poll, valid_answers: "Today,Tomorrow")
|
||||
@question_1 = create(:poll_question, poll: @poll)
|
||||
create(:poll_question_answer, title: 'Yes', question: @question_1)
|
||||
create(:poll_question_answer, title: 'No', question: @question_1)
|
||||
@question_2 = create(:poll_question, poll: @poll)
|
||||
create(:poll_question_answer, title: 'Today', question: @question_2)
|
||||
create(:poll_question_answer, title: 'Tomorrow', question: @question_2)
|
||||
|
||||
login_as(@poll_officer.user)
|
||||
end
|
||||
|
||||
@@ -83,7 +88,7 @@ feature 'Officing Results' do
|
||||
booth_assignment: @officer_assignment.booth_assignment,
|
||||
date: @poll.starts_at,
|
||||
question: @question_1,
|
||||
answer: @question_1.valid_answers[0],
|
||||
answer: @question_1.question_answers.first.title,
|
||||
author: @poll_officer.user,
|
||||
amount: 7777)
|
||||
|
||||
@@ -143,13 +148,13 @@ feature 'Officing Results' do
|
||||
expect(page).to have_content(@officer_assignment.booth_assignment.booth.name)
|
||||
|
||||
expect(page).to have_content(@question_1.title)
|
||||
@question_1.valid_answers.each_with_index do |answer, i|
|
||||
within("#question_#{@question_1.id}_#{i}_result") { expect(page).to have_content(answer) }
|
||||
@question_1.question_answers.each_with_index do |answer, i|
|
||||
within("#question_#{@question_1.id}_#{i}_result") { expect(page).to have_content(answer.title) }
|
||||
end
|
||||
|
||||
expect(page).to have_content(@question_2.title)
|
||||
@question_2.valid_answers.each_with_index do |answer, i|
|
||||
within("#question_#{@question_2.id}_#{i}_result") { expect(page).to have_content(answer) }
|
||||
@question_2.question_answers.each_with_index do |answer, i|
|
||||
within("#question_#{@question_2.id}_#{i}_result") { expect(page).to have_content(answer.title) }
|
||||
end
|
||||
|
||||
within('#white_results') { expect(page).to have_content('21') }
|
||||
|
||||
@@ -25,9 +25,12 @@ describe Poll::Answer do
|
||||
expect(answer).to_not be_valid
|
||||
end
|
||||
|
||||
it "should be valid for answers included in the Poll::Question's list" do
|
||||
skip "review when removing valid_answers"
|
||||
question = create(:poll_question, valid_answers: 'One, Two, Three')
|
||||
it "should be valid for answers included in the Poll::Question's question_answers list" do
|
||||
question = create(:poll_question)
|
||||
create(:poll_question_answer, title: 'One', question: question)
|
||||
create(:poll_question_answer, title: 'Two', question: question)
|
||||
create(:poll_question_answer, title: 'Three', question: question)
|
||||
|
||||
expect(build(:poll_answer, question: question, answer: 'One')).to be_valid
|
||||
expect(build(:poll_answer, question: question, answer: 'Two')).to be_valid
|
||||
expect(build(:poll_answer, question: question, answer: 'Three')).to be_valid
|
||||
@@ -40,7 +43,7 @@ describe Poll::Answer do
|
||||
|
||||
let(:author) { create(:user, :level_two) }
|
||||
let(:poll) { create(:poll) }
|
||||
let(:question) { create(:poll_question, poll: poll, valid_answers: "Yes, No") }
|
||||
let(:question) { create(:poll_question, poll: poll) }
|
||||
|
||||
it "creates a poll_voter with user and poll data" do
|
||||
answer = create(:poll_answer, question: question, author: author, answer: "Yes")
|
||||
|
||||
@@ -4,12 +4,16 @@ describe Poll::PartialResult do
|
||||
|
||||
describe "validations" do
|
||||
it "validates that the answers are included in the Poll::Question's list" do
|
||||
q = create(:poll_question, valid_answers: 'One, Two, Three')
|
||||
expect(build(:poll_partial_result, question: q, answer: 'One')).to be_valid
|
||||
expect(build(:poll_partial_result, question: q, answer: 'Two')).to be_valid
|
||||
expect(build(:poll_partial_result, question: q, answer: 'Three')).to be_valid
|
||||
question = create(:poll_question)
|
||||
create(:poll_question_answer, title: 'One', question: question)
|
||||
create(:poll_question_answer, title: 'Two', question: question)
|
||||
create(:poll_question_answer, title: 'Three', question: question)
|
||||
|
||||
expect(build(:poll_partial_result, question: q, answer: 'Four')).to_not be_valid
|
||||
expect(build(:poll_partial_result, question: question, answer: 'One')).to be_valid
|
||||
expect(build(:poll_partial_result, question: question, answer: 'Two')).to be_valid
|
||||
expect(build(:poll_partial_result, question: question, answer: 'Three')).to be_valid
|
||||
|
||||
expect(build(:poll_partial_result, question: question, answer: 'Four')).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user