Commit b658489f27454a130b813cad95b0bd3f9bdac1c8

Authored by Dmitriy Zaporozhets
1 parent dc825ae3

Fix bugs when discussion visible in wrong project

Because notes scope was not limited by project in
MergeRequest#mr_and_commit_notes it causes comments from project A
appears in discussions for MR in project B.
Showing 1 changed file with 5 additions and 1 deletions   Show diff stats
app/models/merge_request.rb
@@ -222,7 +222,11 @@ class MergeRequest < ActiveRecord::Base @@ -222,7 +222,11 @@ class MergeRequest < ActiveRecord::Base
222 222
223 def mr_and_commit_notes 223 def mr_and_commit_notes
224 commit_ids = commits.map(&:id) 224 commit_ids = commits.map(&:id)
225 - Note.where("(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))", mr_id: id, commit_ids: commit_ids) 225 + project.notes.where(
  226 + "(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))",
  227 + mr_id: id,
  228 + commit_ids: commit_ids
  229 + )
226 end 230 end
227 231
228 # Returns the raw diff for this merge request 232 # Returns the raw diff for this merge request