Hides not to vote at this time button if already voted

This commit is contained in:
decabeza
2018-06-20 14:38:23 +02:00
committed by Javi Martín
parent 170cc45a20
commit 17730a41dd
3 changed files with 43 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
$("#<%= dom_id(@poll) %> #actions").html("<%= j render("voted") %>"); $("#<%= dom_id(@poll) %> #actions").html("<%= j render("voted") %>");
$("#<%= dom_id(@poll) %> #can_vote_callout").hide(); $("#<%= dom_id(@poll) %> #can_vote_callout").hide();
$("#not_voted").hide();
$(".js-vote-collection").removeClass("is-hidden"); $(".js-vote-collection").removeClass("is-hidden");

View File

@@ -28,4 +28,8 @@
</table> </table>
<% end %> <% end %>
<%= link_to t("officing.voters.new.not_to_vote"), namespaced_root_path, class: "button" %> <% if Poll.votable_by(@user).any? %>
<div id="not_voted">
<%= link_to t("officing.voters.new.not_to_vote"), namespaced_root_path, class: "button" %>
</div>
<% end %>

View File

@@ -87,6 +87,43 @@ feature "Voter" do
end end
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 context "Trying to vote the same poll in booth and web" do
let!(:user) { create(:user, :in_census) } let!(:user) { create(:user, :in_census) }