Merge branch 'master' into polls_minor_changes

This commit is contained in:
María Checa
2017-10-03 16:22:33 +02:00
47 changed files with 559 additions and 173 deletions

View File

@@ -30,13 +30,13 @@ feature 'Admin shifts' do
expect(page).to have_content officer.name
end
scenario "Create Vote Collection Shift", :js do
scenario "Create Vote Collection Shift and Recount & Scrutiny Shift on same date", :js do
poll = create(:poll, :current)
vote_collection_dates = (poll.starts_at.to_date..poll.ends_at.to_date).to_a.map { |date| I18n.l(date, format: :long) }
booth = create(:poll_booth)
assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
officer = create(:poll_officer)
vote_collection_dates = (poll.starts_at.to_date..poll.ends_at.to_date).to_a.map { |date| I18n.l(date, format: :long) }
recount_scrutiny_dates = (poll.ends_at.to_date..poll.ends_at.to_date + 1.week).to_a.map { |date| I18n.l(date, format: :long) }
visit available_admin_booths_path
@@ -61,15 +61,6 @@ feature 'Admin shifts' do
expect(page).to have_content("Collect Votes")
expect(page).to have_content(officer.name)
end
end
scenario "Create Recount & Scrutiny Shift", :js do
poll = create(:poll, :current)
recount_scrutiny_dates = (poll.ends_at.to_date..poll.ends_at.to_date + 1.week).to_a.map { |date| I18n.l(date, format: :long) }
booth = create(:poll_booth)
assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
officer = create(:poll_officer)
visit available_admin_booths_path
@@ -91,7 +82,7 @@ feature 'Admin shifts' do
expect(page).to have_content "Shift added"
within("#shifts") do
expect(page).to have_css(".shift", count: 1)
expect(page).to have_css(".shift", count: 2)
expect(page).to have_content(I18n.l(poll.ends_at.to_date + 4.days, format: :long))
expect(page).to have_content("Recount & Scrutiny")
expect(page).to have_content(officer.name)

View File

@@ -22,11 +22,6 @@ feature "Home" do
feature "For signed in users" do
before do
# user = create(:user)
# login_as(user)
end
feature "Recommended" do
background do

View File

@@ -184,6 +184,7 @@ feature 'Polls' do
poll.geozones << geozone
create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca')
user = create(:user, :level_two, geozone: geozone)
login_as user
visit poll_path(poll)
@@ -193,5 +194,25 @@ feature 'Polls' do
expect(page).to have_link('Chewbacca')
end
scenario 'Level 2 users changing answer', :js do
poll.update(geozone_restricted: true)
poll.geozones << geozone
create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca')
user = create(:user, :level_two, geozone: geozone)
login_as user
visit poll_path(poll)
click_link 'Han Solo'
expect(page).to_not have_link('Han Solo')
expect(page).to have_link('Chewbacca')
click_link 'Chewbacca'
expect(page).to_not have_link('Chewbacca')
expect(page).to have_link('Han Solo')
end
end
end

View File

@@ -0,0 +1,94 @@
require 'rails_helper'
feature "Voter" do
context "Origin" do
scenario "Voting via web", :js do
poll = create(:poll)
question = create(:poll_question, poll: poll, valid_answers: 'Yes, No')
user = create(:user, :level_two)
login_as user
visit question_path(question)
click_link 'Answer this question'
click_link 'Yes'
expect(page).to_not have_link('Yes')
expect(Poll::Voter.count).to eq(1)
expect(Poll::Voter.first.origin).to eq("web")
end
scenario "Voting in booth", :js do
user = create(:user, :in_census)
create(:geozone, :in_census)
poll = create(:poll)
officer = create(:poll_officer)
ba = create(:poll_booth_assignment, poll: poll)
create(:poll_officer_assignment, officer: officer, booth_assignment: ba)
login_through_form_as_officer(officer.user)
visit new_officing_residence_path
officing_verify_residence
expect(page).to have_content poll.name
first(:button, "Confirm vote").click
expect(page).to have_content "Vote introduced!"
expect(Poll::Voter.count).to eq(1)
expect(Poll::Voter.first.origin).to eq("booth")
end
context "Trying to vote the same poll in booth and web" do
let(:poll) { create(:poll) }
let(:question) { create(:poll_question, poll: poll, valid_answers: 'Yes, No') }
let!(:user) { create(:user, :in_census) }
let(:officer) { create(:poll_officer) }
let(:ba) { create(:poll_booth_assignment, poll: poll) }
let!(:oa) { create(:poll_officer_assignment, officer: officer, booth_assignment: ba) }
scenario "Trying to vote in web and then in booth", :js do
login_as user
vote_for_poll_via_web
click_link "Sign out"
login_through_form_as_officer(officer.user)
visit new_officing_residence_path
officing_verify_residence
expect(page).to have_content poll.name
expect(page).to_not have_button "Confirm vote"
expect(page).to have_content "Has already participated in this poll"
end
scenario "Trying to vote in booth and then in web", :js do
login_through_form_as_officer(officer.user)
vote_for_poll_via_booth
visit root_path
click_link "Sign out"
login_as user
visit question_path(question)
click_link 'Answer this question'
expect(page).to_not have_link('Yes')
expect(page).to have_content "You have already participated in a booth for this poll."
expect(Poll::Voter.count).to eq(1)
end
end
end
end