From 24aa4744f197002080af0c00564df9af218a2dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 23 Sep 2019 00:23:19 +0200 Subject: [PATCH] Simplify login for officer user in tests The same way it's done in other places. We also remove a useless assignment. --- spec/features/admin_spec.rb | 3 +-- spec/features/budget_polls/officing_spec.rb | 10 +++------- spec/features/officing_spec.rb | 10 ++++------ 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/spec/features/admin_spec.rb b/spec/features/admin_spec.rb index 7a6f38e30..47ac36eab 100644 --- a/spec/features/admin_spec.rb +++ b/spec/features/admin_spec.rb @@ -47,8 +47,7 @@ describe "Admin" do end scenario "Access as poll officer is not authorized" do - create(:poll_officer, user: user) - login_as(user) + login_as(create(:poll_officer).user) visit admin_root_path expect(page).not_to have_current_path(admin_root_path) diff --git a/spec/features/budget_polls/officing_spec.rb b/spec/features/budget_polls/officing_spec.rb index 5dab07e05..28094bc84 100644 --- a/spec/features/budget_polls/officing_spec.rb +++ b/spec/features/budget_polls/officing_spec.rb @@ -5,13 +5,11 @@ describe "Budget Poll Officing" do scenario "Show sidebar menus if officer has shifts assigned" do booth = create(:poll_booth) booth_assignment = create(:poll_booth_assignment, booth: booth) - - user = create(:user) - officer = create(:poll_officer, user: user) + officer = create(:poll_officer) create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :vote_collection) - login_as user + login_as officer.user visit officing_root_path expect(page).not_to have_content("You don't have officing shifts today") @@ -32,10 +30,8 @@ describe "Budget Poll Officing" do end scenario "Do not show sidebar menus if officer has no shifts assigned" do - user = create(:user) - officer = create(:poll_officer, user: user) + login_as(create(:poll_officer).user) - login_as user visit officing_root_path expect(page).to have_content("You don't have officing shifts today") diff --git a/spec/features/officing_spec.rb b/spec/features/officing_spec.rb index b0b1c2f72..ba1676f78 100644 --- a/spec/features/officing_spec.rb +++ b/spec/features/officing_spec.rb @@ -129,10 +129,8 @@ describe "Poll Officing" do booth = create(:poll_booth) booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth) - user1 = create(:user) - user2 = create(:user) - officer1 = create(:poll_officer, user: user1) - officer2 = create(:poll_officer, user: user2) + officer1 = create(:poll_officer) + officer2 = create(:poll_officer) 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) @@ -141,12 +139,12 @@ describe "Poll Officing" do officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer2) in_browser(:one) do - login_as user1 + login_as officer1.user visit officing_root_path end in_browser(:two) do - login_as user2 + login_as officer2.user visit officing_root_path end