summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-10-06 15:07:36 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-10-06 15:07:36 +0300
commit46b7a3f8f550bce35a206ef8e36c9d1072eac746 (patch)
tree158e2b9b1657a451247c171709576026686b2ebe /spec
parent90c96d1dc0ee68c89989b44967e1e94000058d38 (diff)
downloadgitlab-ce-46b7a3f8f550bce35a206ef8e36c9d1072eac746.tar.gz
Prevent PG::Error exception when check commit reference on commit
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/models/note_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index c88a03beb0c..eeecd714a28 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -258,6 +258,17 @@ describe Note do
its(:commit_id) { should == commit.id }
its(:note) { should == "_mentioned in issue ##{issue.iid}_" }
end
+
+ context 'commit from commit' do
+ let(:parent_commit) { commit.parents.first }
+ subject { Note.create_cross_reference_note(commit, parent_commit, author, project) }
+
+ it { should be_valid }
+ its(:noteable_type) { should == "Commit" }
+ its(:noteable_id) { should be_nil }
+ its(:commit_id) { should == commit.id }
+ its(:note) { should == "_mentioned in commit #{parent_commit.id[0...6]}_" }
+ end
end
describe '#cross_reference_exists?' do
@@ -278,6 +289,15 @@ describe Note do
it 'detects if a mentionable has not already been mentioned' do
Note.cross_reference_exists?(issue, commit1).should be_false
end
+
+ context 'commit on commit' do
+ before do
+ Note.create_cross_reference_note(commit0, commit1, author, project)
+ end
+
+ it { Note.cross_reference_exists?(commit0, commit1).should be_true }
+ it { Note.cross_reference_exists?(commit1, commit0).should be_false }
+ end
end
describe '#system?' do