diff options
author | Valery Sizov <valery@gitlab.com> | 2015-10-22 18:38:00 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-10-22 18:38:00 +0200 |
commit | 95df86638d364a87469550cce852871634ace262 (patch) | |
tree | 976d404874ff0b47e6bd779164d115fa79461a58 | |
parent | b97977afef26e8aaad9228c8c7dffecdbe1a8e59 (diff) | |
download | gitlab-ce-95df86638d364a87469550cce852871634ace262.tar.gz |
Fix: Inability to reply to code comments in the MR view, if the MR comes from a forkcomments_fix
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/projects/commits_controller.rb | 2 | ||||
-rw-r--r-- | app/models/merge_request.rb | 2 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 6 |
4 files changed, 9 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG index 3ca30375f6d..8cefa043113 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ v 8.2.0 (unreleased) - Improved performance of sorting milestone issues - Allow users to select the Files view as default project view (Cristian Bica) - Show "Empty Repository Page" for repository without branches (Artem V. Navrotskiy) + - Fix: Inability to reply to code comments in the MR view, if the MR comes from a fork v 8.1.0 - Ensure MySQL CI limits DB migrations occur after the fields have been created (Stan Hu) diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index d1c15174aea..58fb946dbc2 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -12,7 +12,7 @@ class Projects::CommitsController < Projects::ApplicationController @limit, @offset = (params[:limit] || 40), (params[:offset] || 0) @commits = @repo.commits(@ref, @path, @limit, @offset) - @note_counts = Note.where(commit_id: @commits.map(&:id)). + @note_counts = project.notes.where(commit_id: @commits.map(&:id)). group(:commit_id).count respond_to do |format| diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 21861a46a84..8d9ad44681d 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -257,7 +257,7 @@ class MergeRequest < ActiveRecord::Base Note.where( "(project_id = :target_project_id AND noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR" + - "(project_id = :source_project_id AND noteable_type = 'Commit' AND commit_id IN (:commit_ids))", + "((project_id = :source_project_id OR project_id = :target_project_id) AND noteable_type = 'Commit' AND commit_id IN (:commit_ids))", mr_id: id, commit_ids: commit_ids, target_project_id: target_project_id, diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 6aaf1c036b0..eed2cbc5412 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -79,6 +79,12 @@ describe MergeRequest do expect(merge_request.commits).not_to be_empty expect(merge_request.mr_and_commit_notes.count).to eq(2) end + + it "should include notes for commits from target project as well" do + create(:note, commit_id: merge_request.commits.first.id, noteable_type: 'Commit', project: merge_request.target_project) + expect(merge_request.commits).not_to be_empty + expect(merge_request.mr_and_commit_notes.count).to eq(3) + end end describe '#is_being_reassigned?' do |