Skip to content
Snippets Groups Projects
Commit 6dc8c0ea authored by Riyad Preukschas's avatar Riyad Preukschas
Browse files

Make MRs also count and display its commits' notes

parent 77bde9a0
No related branches found
No related tags found
1 merge request!1629Show numer of notes for commits and merge requests
Loading
Loading
@@ -186,6 +186,11 @@ class MergeRequest < ActiveRecord::Base
 
patch_path
end
def mr_and_commit_notes
commit_ids = commits.map(&:id)
Note.where("(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND noteable_id IN (:commit_ids))", mr_id: id, commit_ids: commit_ids)
end
end
 
# == Schema Information
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@
- if merge_request.notes.any?
%span.btn.small.disabled.grouped
%i.icon-comment
= merge_request.notes.count
= merge_request.mr_and_commit_notes.count
%span.btn.small.disabled.grouped
= merge_request.source_branch
&rarr;
Loading
Loading
Loading
Loading
@@ -35,4 +35,19 @@ describe MergeRequest do
it { should include_module(IssueCommonality) }
it { should include_module(Votes) }
end
describe "#mr_and_commit_notes" do
let!(:merge_request) { Factory.create(:merge_request) }
before do
merge_request.stub(:commits) { [merge_request.project.commit] }
Factory.create(:note, noteable: merge_request.commits.first)
Factory.create(:note, noteable: merge_request)
end
it "should include notes for commits" do
merge_request.commits.should_not be_empty
merge_request.mr_and_commit_notes.count.should == 2
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment