Simplify login for officer user in tests

The same way it's done in other places. We also remove a useless
assignment.
This commit is contained in:
Javi Martín
2019-09-23 00:23:19 +02:00
parent 175163adb6
commit 24aa4744f1
3 changed files with 8 additions and 15 deletions

View File

@@ -47,8 +47,7 @@ describe "Admin" do
end end
scenario "Access as poll officer is not authorized" do scenario "Access as poll officer is not authorized" do
create(:poll_officer, user: user) login_as(create(:poll_officer).user)
login_as(user)
visit admin_root_path visit admin_root_path
expect(page).not_to have_current_path(admin_root_path) expect(page).not_to have_current_path(admin_root_path)

View File

@@ -5,13 +5,11 @@ describe "Budget Poll Officing" do
scenario "Show sidebar menus if officer has shifts assigned" do scenario "Show sidebar menus if officer has shifts assigned" do
booth = create(:poll_booth) booth = create(:poll_booth)
booth_assignment = create(:poll_booth_assignment, booth: booth) booth_assignment = create(:poll_booth_assignment, booth: booth)
officer = create(:poll_officer)
user = create(:user)
officer = create(:poll_officer, user: user)
create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :vote_collection) create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :vote_collection)
login_as user login_as officer.user
visit officing_root_path visit officing_root_path
expect(page).not_to have_content("You don't have officing shifts today") expect(page).not_to have_content("You don't have officing shifts today")
@@ -32,10 +30,8 @@ describe "Budget Poll Officing" do
end end
scenario "Do not show sidebar menus if officer has no shifts assigned" do scenario "Do not show sidebar menus if officer has no shifts assigned" do
user = create(:user) login_as(create(:poll_officer).user)
officer = create(:poll_officer, user: user)
login_as user
visit officing_root_path visit officing_root_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")

View File

@@ -129,10 +129,8 @@ describe "Poll Officing" do
booth = create(:poll_booth) booth = create(:poll_booth)
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth) booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
user1 = create(:user) officer1 = create(:poll_officer)
user2 = create(:user) officer2 = create(:poll_officer)
officer1 = create(:poll_officer, user: user1)
officer2 = create(:poll_officer, user: user2)
create(:poll_shift, officer: officer1, booth: booth, date: Date.current, task: :vote_collection) create(:poll_shift, officer: officer1, booth: booth, date: Date.current, task: :vote_collection)
create(:poll_shift, officer: officer2, booth: booth, date: Date.current, task: :vote_collection) create(:poll_shift, officer: officer2, booth: booth, date: Date.current, task: :vote_collection)
@@ -141,12 +139,12 @@ describe "Poll Officing" do
officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer2) officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer2)
in_browser(:one) do in_browser(:one) do
login_as user1 login_as officer1.user
visit officing_root_path visit officing_root_path
end end
in_browser(:two) do in_browser(:two) do
login_as user2 login_as officer2.user
visit officing_root_path visit officing_root_path
end end