Merge pull request #2011 from consul/show-poll-answers-after-booth-vote

Show poll answers in poll show view after voting on a booth
This commit is contained in:
Raimond Garcia
2017-10-07 18:20:29 +02:00
committed by GitHub
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