From 18e57b96620db052c1422082ee113b3f394da8ff Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 20 Jun 2018 14:37:36 +0200 Subject: [PATCH] Hides sibebar menu if officer has no shifts --- app/helpers/officers_helper.rb | 2 +- spec/features/budget_polls/officing_spec.rb | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/helpers/officers_helper.rb b/app/helpers/officers_helper.rb index e069cb9aa..06dd041ed 100644 --- a/app/helpers/officers_helper.rb +++ b/app/helpers/officers_helper.rb @@ -5,7 +5,7 @@ module OfficersHelper end def vote_collection_shift? - current_user.poll_officer.officer_assignments.where(date: Time.current.to_date).any? + current_user.poll_officer.officer_assignments.voting_days.where(date: Time.current.to_date).any? end def final_recount_shift? diff --git a/spec/features/budget_polls/officing_spec.rb b/spec/features/budget_polls/officing_spec.rb index 7f77b5caa..7b91eec12 100644 --- a/spec/features/budget_polls/officing_spec.rb +++ b/spec/features/budget_polls/officing_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" feature "Budget Poll Officing" do - scenario "Show sidebar menu if officer has shifts assigned" do + scenario "Show sidebar menus if officer has shifts assigned" do poll = create(:poll) booth = create(:poll_booth) booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth) @@ -10,13 +10,21 @@ feature "Budget Poll Officing" do user = create(:user) officer = create(:poll_officer, user: user) + create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :vote_collection) + + login_as user + visit officing_root_path + + expect(page).not_to have_content("You don't have officing shifts today") + expect(page).to have_content("Validate document") + expect(page).not_to have_content("Total recounts and results") + create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :recount_scrutiny) officer_assignment = create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer) - login_as user visit officing_root_path expect(page).not_to have_content("You don't have officing shifts today") @@ -24,7 +32,7 @@ feature "Budget Poll Officing" do expect(page).to have_content("Total recounts and results") end - scenario "Do not show sidebar menu if officer has no shifts assigned" do + scenario "Do not show sidebar menus if officer has no shifts assigned" do user = create(:user) officer = create(:poll_officer, user: user)