adds specs
This commit is contained in:
@@ -126,5 +126,91 @@ feature 'Admin booths assignments' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Results' do
|
||||
poll = create(:poll)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll)
|
||||
|
||||
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)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: booth_assignment,
|
||||
question: question_1,
|
||||
answer: 'Yes',
|
||||
amount: 11)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: booth_assignment,
|
||||
question: question_1,
|
||||
answer: 'No',
|
||||
amount: 4)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: booth_assignment,
|
||||
question: question_2,
|
||||
answer: 'Today',
|
||||
amount: 5)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: booth_assignment,
|
||||
question: question_2,
|
||||
answer: 'Tomorrow',
|
||||
amount: 6)
|
||||
|
||||
create(:poll_recount,
|
||||
booth_assignment: booth_assignment,
|
||||
white_amount: 21,
|
||||
null_amount: 44,
|
||||
total_amount: 66)
|
||||
|
||||
visit admin_poll_booth_assignment_path(poll, booth_assignment)
|
||||
|
||||
click_link 'Results'
|
||||
|
||||
expect(page).to have_content(question_1.title)
|
||||
|
||||
within("#question_#{question_1.id}_0_result") do
|
||||
expect(page).to have_content("Yes")
|
||||
expect(page).to have_content(11)
|
||||
end
|
||||
|
||||
within("#question_#{question_1.id}_1_result") do
|
||||
expect(page).to have_content("No")
|
||||
expect(page).to have_content(4)
|
||||
end
|
||||
|
||||
expect(page).to have_content(question_2.title)
|
||||
|
||||
within("#question_#{question_2.id}_0_result") do
|
||||
expect(page).to have_content("Today")
|
||||
expect(page).to have_content(5)
|
||||
end
|
||||
|
||||
within("#question_#{question_2.id}_1_result") do
|
||||
expect(page).to have_content("Tomorrow")
|
||||
expect(page).to have_content(6)
|
||||
end
|
||||
|
||||
within('#white_results') { expect(page).to have_content('21') }
|
||||
within('#null_results') { expect(page).to have_content('44') }
|
||||
within('#total_results') { expect(page).to have_content('66') }
|
||||
end
|
||||
|
||||
scenario "No results" do
|
||||
poll = create(:poll)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll)
|
||||
|
||||
visit admin_poll_booth_assignment_path(poll, booth_assignment)
|
||||
|
||||
click_link "Results"
|
||||
|
||||
expect(page).to have_content "There are no results"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -311,6 +311,43 @@ feature 'Admin polls' do
|
||||
within('#null_results') { expect(page).to have_content('44') }
|
||||
within('#total_results') { expect(page).to have_content('66') }
|
||||
end
|
||||
|
||||
scenario "Link to results by booth" do
|
||||
poll = create(:poll)
|
||||
booth_assignment1 = create(:poll_booth_assignment, poll: poll)
|
||||
booth_assignment2 = create(:poll_booth_assignment, poll: poll)
|
||||
|
||||
question = create(:poll_question, poll: poll)
|
||||
create(:poll_question_answer, title: 'Yes', question: question)
|
||||
create(:poll_question_answer, title: 'No', question: question)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: booth_assignment1,
|
||||
question: question,
|
||||
answer: 'Yes',
|
||||
amount: 5)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: booth_assignment2,
|
||||
question: question,
|
||||
answer: 'Yes',
|
||||
amount: 6)
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
|
||||
click_link "Results"
|
||||
|
||||
expect(page).to have_link("See results", count: 2)
|
||||
|
||||
within("#booth_assignment_#{booth_assignment1.id}_result") do
|
||||
click_link "See results"
|
||||
end
|
||||
|
||||
expect(page).to have_content booth_assignment1.booth.name
|
||||
expect(page).to have_content "Results"
|
||||
expect(page).to have_content "Yes"
|
||||
expect(page).to have_content "5"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user