moves helper method to votes helper and adds spec

This commit is contained in:
Juanjo Bazán
2015-09-15 14:44:12 +02:00
parent 1c5f77def2
commit 26da253a5d
3 changed files with 20 additions and 9 deletions

View File

@@ -18,4 +18,15 @@ describe VotesHelper do
end
end
describe "#votes_percentage" do
it "should always sum 100%" do
debate = create(:debate)
create_list(:vote, 8, votable: debate, vote_flag: true)
create_list(:vote, 3, votable: debate, vote_flag: false)
expect(votes_percentage('likes', debate)).to eq("72%")
expect(votes_percentage('dislikes', debate)).to eq("28%")
end
end
end