diff --git a/app/views/officing/voters/create.js.erb b/app/views/officing/voters/create.js.erb index 676d153bd..eebdb9100 100644 --- a/app/views/officing/voters/create.js.erb +++ b/app/views/officing/voters/create.js.erb @@ -1,3 +1,4 @@ $("#<%= dom_id(@poll) %> #actions").html("<%= j render("voted") %>"); $("#<%= dom_id(@poll) %> #can_vote_callout").hide(); +$("#not_voted").hide(); $(".js-vote-collection").removeClass("is-hidden"); diff --git a/app/views/officing/voters/new.html.erb b/app/views/officing/voters/new.html.erb index 474b3c2a6..a61f4f842 100644 --- a/app/views/officing/voters/new.html.erb +++ b/app/views/officing/voters/new.html.erb @@ -28,4 +28,8 @@ <% end %> -<%= link_to t("officing.voters.new.not_to_vote"), namespaced_root_path, class: "button" %> +<% if Poll.votable_by(@user).any? %> +
+ <%= link_to t("officing.voters.new.not_to_vote"), namespaced_root_path, class: "button" %> +
+<% end %> diff --git a/spec/features/polls/voter_spec.rb b/spec/features/polls/voter_spec.rb index 9c9f6cd1e..9310c2438 100644 --- a/spec/features/polls/voter_spec.rb +++ b/spec/features/polls/voter_spec.rb @@ -87,6 +87,43 @@ feature "Voter" do end end + context "The person has decided not to vote at this time" do + let!(:user) { create(:user, :in_census) } + + scenario "Show not to vote at this time button" do + login_through_form_as_officer(officer.user) + + visit new_officing_residence_path + officing_verify_residence + + expect(page).to have_content poll.name + expect(page).to have_button "Confirm vote" + expect(page).to have_content "Can vote" + expect(page).to have_link "The person has decided not to vote at this time" + end + + scenario "Hides not to vote at this time button if already voted", :js do + login_through_form_as_officer(officer.user) + + visit new_officing_residence_path + officing_verify_residence + + within("#poll_#{poll.id}") do + click_button("Confirm vote") + expect(page).not_to have_button("Confirm vote") + expect(page).to have_content "Vote introduced!" + expect(page).not_to have_content "The person has decided not to vote at this time" + end + + visit new_officing_residence_path + officing_verify_residence + + expect(page).to have_content "Has already participated in this poll" + expect(page).not_to have_content "The person has decided not to vote at this time" + end + + end + context "Trying to vote the same poll in booth and web" do let!(:user) { create(:user, :in_census) }