Commit 95df8663 authored by Valery Sizov's avatar Valery Sizov

Fix: Inability to reply to code comments in the MR view, if the MR comes from a fork

parent b97977af
...@@ -8,6 +8,7 @@ v 8.2.0 (unreleased) ...@@ -8,6 +8,7 @@ v 8.2.0 (unreleased)
- Improved performance of sorting milestone issues - Improved performance of sorting milestone issues
- Allow users to select the Files view as default project view (Cristian Bica) - Allow users to select the Files view as default project view (Cristian Bica)
- Show "Empty Repository Page" for repository without branches (Artem V. Navrotskiy) - 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 v 8.1.0
- Ensure MySQL CI limits DB migrations occur after the fields have been created (Stan Hu) - Ensure MySQL CI limits DB migrations occur after the fields have been created (Stan Hu)
......
...@@ -12,7 +12,7 @@ class Projects::CommitsController < Projects::ApplicationController ...@@ -12,7 +12,7 @@ class Projects::CommitsController < Projects::ApplicationController
@limit, @offset = (params[:limit] || 40), (params[:offset] || 0) @limit, @offset = (params[:limit] || 40), (params[:offset] || 0)
@commits = @repo.commits(@ref, @path, @limit, @offset) @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 group(:commit_id).count
respond_to do |format| respond_to do |format|
......
...@@ -257,7 +257,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -257,7 +257,7 @@ class MergeRequest < ActiveRecord::Base
Note.where( Note.where(
"(project_id = :target_project_id AND noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR" + "(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, mr_id: id,
commit_ids: commit_ids, commit_ids: commit_ids,
target_project_id: target_project_id, target_project_id: target_project_id,
......
...@@ -79,6 +79,12 @@ describe MergeRequest do ...@@ -79,6 +79,12 @@ describe MergeRequest do
expect(merge_request.commits).not_to be_empty expect(merge_request.commits).not_to be_empty
expect(merge_request.mr_and_commit_notes.count).to eq(2) expect(merge_request.mr_and_commit_notes.count).to eq(2)
end 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 end
describe '#is_being_reassigned?' do describe '#is_being_reassigned?' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment