Skip to content

Commit

Permalink
Display 'validate document' menu item only when applicable
Browse files Browse the repository at this point in the history
We are trying to avoid Officers from forgetting to click the “Confirm
vote” button, which is necessary to keep track of who has voted a Poll

To do that, we are not displaying the menu item to go back to the next
person that wants to vote, until the Officer clicks the “Confirm Vote”
button or the “The user has decided not to vote” button

Note: Due to mobile version we have duplicate ids, so using classes for
the menu items to hide them without errors

Note2: We are only hidding the menu item, if there are votable polls,
otherwise the “Confirm vote” button does not appear, and there is no
way of going back to help the next person that wants to vote
  • Loading branch information
voodoorai2000 authored and javierm committed Mar 6, 2019
1 parent 8125d47 commit 1512399
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/views/officing/_menu.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<div class="admin-sidebar" data-equalizer-watch>
<ul id="officing_menu">
<% if vote_collection_shift? %>
<li <%= "class=is-active" if controller_name == "voters" %>>
<li class="<%= "js-vote-collection" %>
<%= " is-active" if controller_name == "voters" %>
<%= " is-hidden" if controller_name == "voters" && Poll.votable_by(@user).any? %>">
<%= link_to new_officing_residence_path do %>
<span class="icon-user"></span>
<%= t("officing.menu.voters") %>
Expand Down
3 changes: 2 additions & 1 deletion app/views/officing/voters/create.js.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
$("#<%= dom_id(@poll) %> #actions").html('<%= j render("voted") %>');
$("#<%= dom_id(@poll) %> #can_vote_callout").hide();
$("#<%= dom_id(@poll) %> #can_vote_callout").hide();
$(".js-vote-collection").removeClass("is-hidden");
44 changes: 43 additions & 1 deletion spec/features/polls/voter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,48 @@
expect(Poll::Voter.count).to eq(1)
end

end
context "Side menu" do
scenario "'Validate document' menu item with votable polls", :js do
login_through_form_as_officer(officer.user)

visit new_officing_residence_path
officing_verify_residence

expect(page).to have_content poll.name

within("#side_menu") do
expect(page).not_to have_content("Validate document")
end

within("#poll_#{poll.id}") do
click_button("Confirm vote")
expect(page).to have_content "Vote introduced!"
end

within("#side_menu") do
expect(page).to have_content("Validate document")
end
end

scenario "'Validate document' menu item without votable polls", :js do
create(:poll_voter, poll: poll, user: create(:user, :in_census))

login_through_form_as_officer(officer.user)

visit new_officing_residence_path
officing_verify_residence

expect(page).to have_content poll.name

within("#poll_#{poll.id}") do
expect(page).to have_content "Has already participated in this poll"
end

within("#side_menu") do
expect(page).to have_content("Validate document")
end
end

end
end
end

0 comments on commit 1512399

Please sign in to comment.