Show poll answers in poll show view after voting on a booth

If the user votes in a booth, it can see the poll and answers but can't see what he/she voted and the answers are inactive (no link, inactive ui style).
This commit is contained in:
María Checa
2017-10-07 17:33:27 +02:00
parent a08d5bdba9
commit 8b2f6d454c
3 changed files with 14 additions and 10 deletions

View File

@@ -1,8 +1,8 @@
<div class="poll-question-answers">
<% if can?(:answer, question) %>
<% if can?(:answer, question) && !question.poll.voted_in_booth?(current_user) %>
<% question.question_answers.each do |answer| %>
<% if @answers_by_question_id[question.id] == answer.title &&
(!voted_before_sign_in(question) ||
<% if @answers_by_question_id[question.id] == answer.title &&
(!voted_before_sign_in(question) ||
question.poll.voted_in_booth?(current_user)) %>
<span class="button answered"
title="<%= t("poll_questions.show.voted", answer: answer.title)%>">

View File

@@ -50,10 +50,10 @@
<%= t("polls.show.already_voted_in_web") %>
</div>
<% end %>
<% end %>
<% @questions.each do |question| %>
<%= render 'polls/questions/question', question: question, token: @token %>
<% end %>
<% @questions.each do |question| %>
<%= render 'polls/questions/question', question: question, token: @token %>
<% end %>
</div>
</div>

View File

@@ -319,10 +319,14 @@ feature 'Polls' do
visit poll_path(poll)
expect(page).to have_content "You have already participated in a physical booth. You can not participate again."
expect(page).to have_content('Han Solo')
expect(page).to have_content('Chewbacca')
expect(page).to_not have_link('Han Solo')
expect(page).to_not have_link('Chewbacca')
within("#poll_question_#{question.id}_answers") do
expect(page).to have_content('Han Solo')
expect(page).to have_content('Chewbacca')
expect(page).to_not have_link('Han Solo')
expect(page).to_not have_link('Chewbacca')
end
end
end