summaryrefslogtreecommitdiff
path: root/spec/roles
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-09-08 02:37:29 +0200
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-09-08 16:05:48 +0200
commit7b0c7ae52c299584e810fc4b1a33893ebdbb8ac3 (patch)
tree7d3c69a815f17bf93a80d1cf09ec4d385c067d8f /spec/roles
parent2e0d5c2250ad34273a0ad6e207f2717b9a98bd86 (diff)
downloadgitlab-ce-7b0c7ae52c299584e810fc4b1a33893ebdbb8ac3.tar.gz
Add votes_count
Diffstat (limited to 'spec/roles')
-rw-r--r--spec/roles/votes_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/roles/votes_spec.rb b/spec/roles/votes_spec.rb
index 43817999dc1..5c3548a58cf 100644
--- a/spec/roles/votes_spec.rb
+++ b/spec/roles/votes_spec.rb
@@ -50,4 +50,33 @@ describe Issue do
issue.downvotes.should == 2
end
end
+
+ describe "#votes_count" do
+ it "with no notes has a 0/0 score" do
+ issue.votes_count.should == 0
+ end
+
+ it "should recognize non notes" do
+ issue.notes << create(:note, note: "No +1 here")
+ issue.should have(1).note
+ issue.votes_count.should == 0
+ end
+
+ it "should recognize a single +1 note" do
+ issue.notes << create(:note, note: "+1 This is awesome")
+ issue.votes_count.should == 1
+ end
+
+ it "should recognize a single -1 note" do
+ issue.notes << create(:note, note: "-1 This is bad")
+ issue.votes_count.should == 1
+ end
+
+ it "should recognize multiple notes" do
+ issue.notes << create(:note, note: "+1 This is awesome")
+ issue.notes << create(:note, note: "-1 This is bad")
+ issue.notes << create(:note, note: "+1 I want this")
+ issue.votes_count.should == 3
+ end
+ end
end