Simplify login through form as officer in tests
We were always passing `officer.user` to this method, so we might as well pass the officer (since the "officer" is in the name of the method) and call `officer.user` inside the method. We're also calling `login_through_form_as` in order to remove the duplication between these two methods.
This commit is contained in:
@@ -34,13 +34,8 @@ module Users
|
|||||||
click_button "Enter"
|
click_button "Enter"
|
||||||
end
|
end
|
||||||
|
|
||||||
def login_through_form_as_officer(user)
|
def login_through_form_as_officer(officer)
|
||||||
visit root_path
|
login_through_form_as(officer.user)
|
||||||
click_link "Sign in"
|
|
||||||
|
|
||||||
fill_in "user_login", with: user.email
|
|
||||||
fill_in "user_password", with: user.password
|
|
||||||
click_button "Enter"
|
|
||||||
|
|
||||||
expect(page).to have_content "You have been signed in successfully"
|
expect(page).to have_content "You have been signed in successfully"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ describe "BudgetPolls", :with_frozen_time do
|
|||||||
|
|
||||||
context "Offline" do
|
context "Offline" do
|
||||||
scenario "A citizen can cast a paper vote" 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
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
@@ -46,7 +46,7 @@ describe "BudgetPolls", :with_frozen_time do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "A citizen cannot vote offline again" do
|
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
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
@@ -66,7 +66,7 @@ describe "BudgetPolls", :with_frozen_time do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "A citizen cannot vote online after voting offline" do
|
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
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
@@ -127,7 +127,7 @@ describe "BudgetPolls", :with_frozen_time do
|
|||||||
end
|
end
|
||||||
|
|
||||||
logout
|
logout
|
||||||
login_through_form_as_officer(officer.user)
|
login_through_form_as_officer(officer)
|
||||||
|
|
||||||
visit new_officing_residence_path
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ describe "Booth", :with_frozen_time do
|
|||||||
scenario "Officer with no booth assignments today" do
|
scenario "Officer with no booth assignments today" do
|
||||||
officer = create(:poll_officer)
|
officer = create(:poll_officer)
|
||||||
|
|
||||||
login_through_form_as_officer(officer.user)
|
login_through_form_as_officer(officer)
|
||||||
visit new_officing_residence_path
|
visit new_officing_residence_path
|
||||||
|
|
||||||
expect(page).to have_content "You don't have officing shifts today"
|
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)
|
officer = create(:poll_officer)
|
||||||
create(:poll_officer_assignment, officer: officer, date: Date.current + 1.day)
|
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
|
visit new_officing_residence_path
|
||||||
|
|
||||||
expect(page).to have_content "You don't have officing shifts today"
|
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)
|
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
|
visit new_officing_residence_path
|
||||||
|
|
||||||
within("#officing-booth") do
|
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: booth1, date: Date.current)
|
||||||
create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth2, 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
|
visit new_officing_residence_path
|
||||||
|
|
||||||
expect(page).to have_content "Choose your booth"
|
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)
|
||||||
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
|
visit new_officing_residence_path
|
||||||
|
|
||||||
expect(page).to have_content "Choose your booth"
|
expect(page).to have_content "Choose your booth"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ describe "Residence", :with_frozen_time do
|
|||||||
describe "Assigned officers" do
|
describe "Assigned officers" do
|
||||||
before do
|
before do
|
||||||
create(:poll_officer_assignment, officer: officer)
|
create(:poll_officer_assignment, officer: officer)
|
||||||
login_through_form_as_officer(officer.user)
|
login_through_form_as_officer(officer)
|
||||||
visit officing_root_path
|
visit officing_root_path
|
||||||
end
|
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
|
scenario "by default (without custom census) not display date_of_birth and postal_code" do
|
||||||
Setting["feature.remote_census"] = false
|
Setting["feature.remote_census"] = false
|
||||||
|
|
||||||
login_through_form_as_officer(officer.user)
|
login_through_form_as_officer(officer)
|
||||||
visit officing_root_path
|
visit officing_root_path
|
||||||
|
|
||||||
within("#side_menu") do
|
within("#side_menu") do
|
||||||
@@ -127,7 +127,7 @@ describe "Residence", :with_frozen_time do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "with all custom census not display year_of_birth" do
|
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
|
visit officing_root_path
|
||||||
|
|
||||||
within("#side_menu") do
|
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
|
scenario "can verify voter with date_of_birth and postal_code fields" do
|
||||||
mock_valid_remote_census_response
|
mock_valid_remote_census_response
|
||||||
|
|
||||||
login_through_form_as_officer(officer.user)
|
login_through_form_as_officer(officer)
|
||||||
visit officing_root_path
|
visit officing_root_path
|
||||||
|
|
||||||
within("#side_menu") do
|
within("#side_menu") do
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ describe "Voters" do
|
|||||||
expect(user).not_to be_level_two_verified
|
expect(user).not_to be_level_two_verified
|
||||||
|
|
||||||
logout
|
logout
|
||||||
login_through_form_as_officer(officer.user)
|
login_through_form_as_officer(officer)
|
||||||
|
|
||||||
visit new_officing_residence_path
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ describe "Voter" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Voting in booth" do
|
scenario "Voting in booth" do
|
||||||
login_through_form_as_officer(officer.user)
|
login_through_form_as_officer(officer)
|
||||||
|
|
||||||
visit new_officing_residence_path
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
@@ -107,7 +107,7 @@ describe "Voter" do
|
|||||||
before { create(:user, :in_census) }
|
before { create(:user, :in_census) }
|
||||||
|
|
||||||
scenario "Show not to vote at this time button" do
|
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
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
@@ -119,7 +119,7 @@ describe "Voter" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Hides not to vote at this time button if already voted" do
|
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
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
@@ -148,7 +148,7 @@ describe "Voter" do
|
|||||||
expect(Poll::Voter.count).to eq(1)
|
expect(Poll::Voter.count).to eq(1)
|
||||||
|
|
||||||
logout
|
logout
|
||||||
login_through_form_as_officer(officer.user)
|
login_through_form_as_officer(officer)
|
||||||
|
|
||||||
visit new_officing_residence_path
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
@@ -159,7 +159,7 @@ describe "Voter" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Trying to vote in booth and then in web" do
|
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
|
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")
|
allow_any_instance_of(Verification::Sms).to receive(:generate_confirmation_code).and_return("1357")
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
|
|
||||||
login_through_form_as_officer(officer.user)
|
login_through_form_as_officer(officer)
|
||||||
vote_for_poll_via_booth
|
vote_for_poll_via_booth
|
||||||
|
|
||||||
logout
|
logout
|
||||||
@@ -228,7 +228,7 @@ describe "Voter" do
|
|||||||
|
|
||||||
context "Side menu" do
|
context "Side menu" do
|
||||||
scenario "'Validate document' menu item with votable polls" 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
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
@@ -252,7 +252,7 @@ describe "Voter" do
|
|||||||
scenario "'Validate document' menu item without votable polls" do
|
scenario "'Validate document' menu item without votable polls" do
|
||||||
create(:poll_voter, poll: poll, user: create(:user, :in_census))
|
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
|
visit new_officing_residence_path
|
||||||
officing_verify_residence
|
officing_verify_residence
|
||||||
|
|||||||
Reference in New Issue
Block a user