Fix percentage on mobile polls

This commit is contained in:
Steffen van Bergerem 2015-07-25 04:34:52 +02:00
parent 11a8ac614c
commit 9ca8005b27
2 changed files with 10 additions and 1 deletions

View file

@ -10,7 +10,7 @@
.result-head .result-head
- percentage = 0 - percentage = 0
- if poll.participation_count > 0 - if poll.participation_count > 0
- percentage = (answer.vote_count / poll.participation_count * 100).round - percentage = (answer.vote_count.to_f / poll.participation_count * 100).round
.percentage.pull-right .percentage.pull-right
= "#{percentage}%" = "#{percentage}%"
.answer .answer

View file

@ -11,6 +11,15 @@ describe PostsController, type: :request do
expect(response.body).to match(/div class='poll'/) expect(response.body).to match(/div class='poll'/)
expect(response.body).to match(/#{sm.poll.poll_answers.first.answer}/) expect(response.body).to match(/#{sm.poll.poll_answers.first.answer}/)
end end
it "displays the correct percentage for the answers" do
alice.participate_in_poll!(sm, sm.poll.poll_answers.first)
bob.participate_in_poll!(sm, sm.poll.poll_answers.last)
get "/posts/#{sm.id}", format: :mobile
expect(response.status).to eq(200)
expect(response.body).to match(/div class='percentage pull-right'>\n50%/)
end
end end
context "with a location" do context "with a location" do