Commit 8c161d7b authored by Douwe Maan's avatar Douwe Maan

Fix bug where commit comment would not show up in the right discussion on the MR page

parent d80f9036
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
class Discussion class Discussion
include ResolvableDiscussion include ResolvableDiscussion
attr_reader :notes, :noteable attr_reader :notes, :context_noteable
delegate :created_at, delegate :created_at,
:project, :project,
...@@ -16,12 +16,12 @@ class Discussion ...@@ -16,12 +16,12 @@ class Discussion
to: :first_note to: :first_note
def self.build(notes, noteable = nil) def self.build(notes, context_noteable = nil)
notes.first.discussion_class(noteable).new(notes, noteable) notes.first.discussion_class(context_noteable).new(notes, context_noteable)
end end
def self.build_collection(notes, noteable = nil) def self.build_collection(notes, context_noteable = nil)
notes.group_by { |n| n.discussion_id(noteable) }.values.map { |notes| build(notes, noteable) } notes.group_by { |n| n.discussion_id(context_noteable) }.values.map { |notes| build(notes, context_noteable) }
end end
# Returns an alphanumeric discussion ID based on `build_discussion_id` # Returns an alphanumeric discussion ID based on `build_discussion_id`
...@@ -60,14 +60,14 @@ class Discussion ...@@ -60,14 +60,14 @@ class Discussion
DiscussionNote DiscussionNote
end end
def initialize(notes, noteable = nil) def initialize(notes, context_noteable = nil)
@notes = notes @notes = notes
@noteable = noteable @context_noteable = context_noteable
end end
def ==(other) def ==(other)
other.class == self.class && other.class == self.class &&
other.noteable == self.noteable && other.context_noteable == self.context_noteable &&
other.id == self.id && other.id == self.id &&
other.notes == self.notes other.notes == self.notes
end end
...@@ -81,7 +81,7 @@ class Discussion ...@@ -81,7 +81,7 @@ class Discussion
end end
def id def id
first_note.discussion_id(noteable) first_note.discussion_id(context_noteable)
end end
alias_method :to_param, :id alias_method :to_param, :id
......
...@@ -102,8 +102,8 @@ class Note < ActiveRecord::Base ...@@ -102,8 +102,8 @@ class Note < ActiveRecord::Base
ActiveModel::Name.new(self, nil, 'note') ActiveModel::Name.new(self, nil, 'note')
end end
def discussions(noteable = nil) def discussions(context_noteable = nil)
Discussion.build_collection(fresh, noteable) Discussion.build_collection(fresh, context_noteable)
end end
def find_discussion(discussion_id) def find_discussion(discussion_id)
......
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