Merge pull request #101 from AyuntamientoMadrid/show-0-votes

shows "0%" when there's zero votes
This commit is contained in:
Enrique García
2015-08-06 12:00:37 +02:00
2 changed files with 15 additions and 1 deletions

View File

@@ -5,7 +5,7 @@ module ApplicationHelper
end
def percentage(vote, debate)
return if debate.total_votes == 0
return "0%" if debate.total_votes == 0
debate.send(vote).percent_of(debate.total_votes).to_s + "%"
end

View File

@@ -13,6 +13,20 @@ feature 'Votes' do
visit debate_path(@debate)
end
scenario 'Show no votes' do
visit debate_path(@debate)
expect(page).to have_content "0 votes"
within('#in_favor') do
expect(page).to have_content "0%"
end
within('#against') do
expect(page).to have_content "0%"
end
end
scenario 'Show' do
vote = create(:vote, voter: @manuela, votable: @debate, vote_flag: true)
vote = create(:vote, voter: @pablo, votable: @debate, vote_flag: false)