diff --git a/spec/support/common_actions/users.rb b/spec/support/common_actions/users.rb index a9582225f..20b024c3d 100644 --- a/spec/support/common_actions/users.rb +++ b/spec/support/common_actions/users.rb @@ -34,13 +34,8 @@ module Users click_button "Enter" end - def login_through_form_as_officer(user) - visit root_path - click_link "Sign in" - - fill_in "user_login", with: user.email - fill_in "user_password", with: user.password - click_button "Enter" + def login_through_form_as_officer(officer) + login_through_form_as(officer.user) expect(page).to have_content "You have been signed in successfully" end diff --git a/spec/system/budget_polls/voter_spec.rb b/spec/system/budget_polls/voter_spec.rb index 0d6854d0c..6d14c1157 100644 --- a/spec/system/budget_polls/voter_spec.rb +++ b/spec/system/budget_polls/voter_spec.rb @@ -16,7 +16,7 @@ describe "BudgetPolls", :with_frozen_time do context "Offline" do scenario "A citizen can cast a paper vote" do - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence @@ -46,7 +46,7 @@ describe "BudgetPolls", :with_frozen_time do end scenario "A citizen cannot vote offline again" do - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence @@ -66,7 +66,7 @@ describe "BudgetPolls", :with_frozen_time do end scenario "A citizen cannot vote online after voting offline" do - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence @@ -127,7 +127,7 @@ describe "BudgetPolls", :with_frozen_time do end logout - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence diff --git a/spec/system/officing/booth_spec.rb b/spec/system/officing/booth_spec.rb index 010582140..fde34e0a9 100644 --- a/spec/system/officing/booth_spec.rb +++ b/spec/system/officing/booth_spec.rb @@ -4,7 +4,7 @@ describe "Booth", :with_frozen_time do scenario "Officer with no booth assignments today" do officer = create(:poll_officer) - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path expect(page).to have_content "You don't have officing shifts today" @@ -14,7 +14,7 @@ describe "Booth", :with_frozen_time do officer = create(:poll_officer) create(:poll_officer_assignment, officer: officer, date: Date.current + 1.day) - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path expect(page).to have_content "You don't have officing shifts today" @@ -28,7 +28,7 @@ describe "Booth", :with_frozen_time do create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth, date: Date.current) - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path within("#officing-booth") do @@ -46,7 +46,7 @@ describe "Booth", :with_frozen_time do create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth1, date: Date.current) create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth2, date: Date.current) - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path expect(page).to have_content "Choose your booth" @@ -72,7 +72,7 @@ describe "Booth", :with_frozen_time do create(:poll_officer_assignment, officer: officer, poll: poll2, booth: booth2, date: Date.current) create(:poll_officer_assignment, officer: officer, poll: poll2, booth: booth2, date: Date.current) - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path expect(page).to have_content "Choose your booth" diff --git a/spec/system/officing/residence_spec.rb b/spec/system/officing/residence_spec.rb index 5fe96ddca..61f650daf 100644 --- a/spec/system/officing/residence_spec.rb +++ b/spec/system/officing/residence_spec.rb @@ -22,7 +22,7 @@ describe "Residence", :with_frozen_time do describe "Assigned officers" do before do create(:poll_officer_assignment, officer: officer) - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit officing_root_path end @@ -112,7 +112,7 @@ describe "Residence", :with_frozen_time do scenario "by default (without custom census) not display date_of_birth and postal_code" do Setting["feature.remote_census"] = false - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit officing_root_path within("#side_menu") do @@ -127,7 +127,7 @@ describe "Residence", :with_frozen_time do end scenario "with all custom census not display year_of_birth" do - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit officing_root_path within("#side_menu") do @@ -145,7 +145,7 @@ describe "Residence", :with_frozen_time do scenario "can verify voter with date_of_birth and postal_code fields" do mock_valid_remote_census_response - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit officing_root_path within("#side_menu") do diff --git a/spec/system/officing/voters_spec.rb b/spec/system/officing/voters_spec.rb index ff26448a1..c98c38c5e 100644 --- a/spec/system/officing/voters_spec.rb +++ b/spec/system/officing/voters_spec.rb @@ -73,7 +73,7 @@ describe "Voters" do expect(user).not_to be_level_two_verified logout - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence diff --git a/spec/system/polls/voter_spec.rb b/spec/system/polls/voter_spec.rb index eed5f51b3..d44b0b576 100644 --- a/spec/system/polls/voter_spec.rb +++ b/spec/system/polls/voter_spec.rb @@ -74,7 +74,7 @@ describe "Voter" do end scenario "Voting in booth" do - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence @@ -107,7 +107,7 @@ describe "Voter" do before { create(:user, :in_census) } scenario "Show not to vote at this time button" do - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence @@ -119,7 +119,7 @@ describe "Voter" do end scenario "Hides not to vote at this time button if already voted" do - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence @@ -148,7 +148,7 @@ describe "Voter" do expect(Poll::Voter.count).to eq(1) logout - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence @@ -159,7 +159,7 @@ describe "Voter" do end scenario "Trying to vote in booth and then in web" do - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) vote_for_poll_via_booth @@ -192,7 +192,7 @@ describe "Voter" do allow_any_instance_of(Verification::Sms).to receive(:generate_confirmation_code).and_return("1357") user = create(:user) - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) vote_for_poll_via_booth logout @@ -228,7 +228,7 @@ describe "Voter" do context "Side menu" do scenario "'Validate document' menu item with votable polls" do - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence @@ -252,7 +252,7 @@ describe "Voter" do scenario "'Validate document' menu item without votable polls" do create(:poll_voter, poll: poll, user: create(:user, :in_census)) - login_through_form_as_officer(officer.user) + login_through_form_as_officer(officer) visit new_officing_residence_path officing_verify_residence