diff options
author | Riyad Preukschas <riyad@informatik.uni-bremen.de> | 2012-09-08 02:30:47 +0200 |
---|---|---|
committer | Riyad Preukschas <riyad@informatik.uni-bremen.de> | 2012-09-08 16:05:48 +0200 |
commit | 2e0d5c2250ad34273a0ad6e207f2717b9a98bd86 (patch) | |
tree | 4fccfbf9381d70f2fe881481331e6be4fca342af /spec/roles | |
parent | a2a0060034171e22962129d53cc74fb7bde54476 (diff) | |
download | gitlab-ce-2e0d5c2250ad34273a0ad6e207f2717b9a98bd86.tar.gz |
Add downvotes
Diffstat (limited to 'spec/roles')
-rw-r--r-- | spec/roles/votes_spec.rb | 60 |
1 files changed, 43 insertions, 17 deletions
diff --git a/spec/roles/votes_spec.rb b/spec/roles/votes_spec.rb index 24288ada0fe..43817999dc1 100644 --- a/spec/roles/votes_spec.rb +++ b/spec/roles/votes_spec.rb @@ -1,27 +1,53 @@ require 'spec_helper' -describe Issue, "Upvote" do +describe Issue do let(:issue) { create(:issue) } - it "with no notes has a 0/0 score" do - issue.upvotes.should == 0 - end + describe "#upvotes" do + it "with no notes has a 0/0 score" do + issue.upvotes.should == 0 + end - it "should recognize non-+1 notes" do - issue.notes << create(:note, note: "No +1 here") - issue.should have(1).note - issue.notes.first.upvote?.should be_false - issue.upvotes.should == 0 - end + it "should recognize non-+1 notes" do + issue.notes << create(:note, note: "No +1 here") + issue.should have(1).note + issue.notes.first.upvote?.should be_false + issue.upvotes.should == 0 + end + + it "should recognize a single +1 note" do + issue.notes << create(:note, note: "+1 This is awesome") + issue.upvotes.should == 1 + end - it "should recognize a single +1 note" do - issue.notes << create(:note, note: "+1 This is awesome") - issue.upvotes.should == 1 + it "should recognize multiple +1 notes" do + issue.notes << create(:note, note: "+1 This is awesome") + issue.notes << create(:note, note: "+1 I want this") + issue.upvotes.should == 2 + end end - it "should recognize multiple +1 notes" do - issue.notes << create(:note, note: "+1 This is awesome") - issue.notes << create(:note, note: "+1 I want this") - issue.upvotes.should == 2 + describe "#downvotes" do + it "with no notes has a 0/0 score" do + issue.downvotes.should == 0 + end + + it "should recognize non--1 notes" do + issue.notes << create(:note, note: "Almost got a -1") + issue.should have(1).note + issue.notes.first.downvote?.should be_false + issue.downvotes.should == 0 + end + + it "should recognize a single -1 note" do + issue.notes << create(:note, note: "-1 This is bad") + issue.downvotes.should == 1 + end + + it "should recognize multiple -1 notes" do + issue.notes << create(:note, note: "-1 This is bad") + issue.notes << create(:note, note: "-1 Away with this") + issue.downvotes.should == 2 + end end end |