diff options
author | Riyad Preukschas <riyad@informatik.uni-bremen.de> | 2012-10-30 06:27:36 +0400 |
---|---|---|
committer | Riyad Preukschas <riyad@informatik.uni-bremen.de> | 2012-12-04 01:51:56 +0400 |
commit | ae067ee322e6702fb5ef0fd4f0cc4d4d5106cbde (patch) | |
tree | 28f76dc83a291a23488a6351bf2d2a555d884c68 /spec/models/note_spec.rb | |
parent | 6c6f415cae54be4dae4522e901ed55c9dae04a15 (diff) |
Fix vote counting
Diffstat (limited to 'spec/models/note_spec.rb')
-rw-r--r-- | spec/models/note_spec.rb | 86 |
1 files changed, 56 insertions, 30 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 4f9352b9a14..4c1afd8a3b4 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -43,79 +43,105 @@ describe Note do let(:project) { create(:project) } it "recognizes a neutral note" do - note = create(:note, note: "This is not a +1 note") + note = create(:votable_note, note: "This is not a +1 note") note.should_not be_upvote note.should_not be_downvote end it "recognizes a neutral emoji note" do - note = build(:note, note: "I would :+1: this, but I don't want to") + note = build(:votable_note, note: "I would :+1: this, but I don't want to") note.should_not be_upvote note.should_not be_downvote end it "recognizes a +1 note" do - note = create(:note, note: "+1 for this") + note = create(:votable_note, note: "+1 for this") note.should be_upvote end it "recognizes a +1 emoji as a vote" do - note = build(:note, note: ":+1: for this") + note = build(:votable_note, note: ":+1: for this") note.should be_upvote end it "recognizes a -1 note" do - note = create(:note, note: "-1 for this") + note = create(:votable_note, note: "-1 for this") note.should be_downvote end it "recognizes a -1 emoji as a vote" do - note = build(:note, note: ":-1: for this") + note = build(:votable_note, note: ":-1: for this") note.should be_downvote end end - let(:project) { create(:project) } - let(:commit) { project.commit } - describe "Commit notes" do - before do - @note = create(:note, - noteable_id: commit.id, - noteable_type: "Commit") - end + let!(:note) { create(:note_on_commit, note: "+1 from me") } + let!(:commit) { note.noteable } it "should be accessible through #noteable" do - @note.noteable_id.should == commit.id - @note.noteable.should be_a(Commit) - @note.noteable.should == commit + note.noteable_id.should == commit.id + note.noteable.should be_a(Commit) + note.noteable.should == commit end it "should save a valid note" do - @note.noteable_id.should == commit.id - @note.noteable == commit + note.noteable_id.should == commit.id + note.noteable == commit end it "should be recognized by #for_commit?" do - @note.should be_for_commit + note.should be_for_commit end - end - describe "Pre-line commit notes" do - before do - @note = create(:note, - noteable_id: commit.id, - noteable_type: "Commit", - line_code: "0_16_1") + it "should not be votable" do + note.should_not be_votable end + end + + describe "Commit diff line notes" do + let!(:note) { create(:note_on_commit_line, note: "+1 from me") } + let!(:commit) { note.noteable } it "should save a valid note" do - @note.noteable_id.should == commit.id - @note.noteable.id.should == commit.id + note.noteable_id.should == commit.id + note.noteable.id.should == commit.id end it "should be recognized by #for_diff_line?" do - @note.should be_for_diff_line + note.should be_for_diff_line + end + + it "should be recognized by #for_commit_diff_line?" do + note.should be_for_commit_diff_line + end + + it "should not be votable" do + note.should_not be_votable + end + end + + describe "Issue notes" do + let!(:note) { create(:note_on_issue, note: "+1 from me") } + + it "should not be votable" do + note.should be_votable + end + end + + describe "Merge request notes" do + let!(:note) { create(:note_on_merge_request, note: "+1 from me") } + + it "should not be votable" do + note.should be_votable + end + end + + describe "Merge request diff line notes" do + let!(:note) { create(:note_on_merge_request_line, note: "+1 from me") } + + it "should not be votable" do + note.should_not be_votable end end |