Commit 7b0c7ae52c299584e810fc4b1a33893ebdbb8ac3
1 parent
2e0d5c22
Exists in
master
and in
4 other branches
Add votes_count
Showing
2 changed files
with
34 additions
and
0 deletions
Show diff stats
app/roles/votes.rb
spec/roles/votes_spec.rb
... | ... | @@ -50,4 +50,33 @@ describe Issue do |
50 | 50 | issue.downvotes.should == 2 |
51 | 51 | end |
52 | 52 | end |
53 | + | |
54 | + describe "#votes_count" do | |
55 | + it "with no notes has a 0/0 score" do | |
56 | + issue.votes_count.should == 0 | |
57 | + end | |
58 | + | |
59 | + it "should recognize non notes" do | |
60 | + issue.notes << create(:note, note: "No +1 here") | |
61 | + issue.should have(1).note | |
62 | + issue.votes_count.should == 0 | |
63 | + end | |
64 | + | |
65 | + it "should recognize a single +1 note" do | |
66 | + issue.notes << create(:note, note: "+1 This is awesome") | |
67 | + issue.votes_count.should == 1 | |
68 | + end | |
69 | + | |
70 | + it "should recognize a single -1 note" do | |
71 | + issue.notes << create(:note, note: "-1 This is bad") | |
72 | + issue.votes_count.should == 1 | |
73 | + end | |
74 | + | |
75 | + it "should recognize multiple notes" do | |
76 | + issue.notes << create(:note, note: "+1 This is awesome") | |
77 | + issue.notes << create(:note, note: "-1 This is bad") | |
78 | + issue.notes << create(:note, note: "+1 I want this") | |
79 | + issue.votes_count.should == 3 | |
80 | + end | |
81 | + end | |
53 | 82 | end | ... | ... |