summaryrefslogtreecommitdiff
path: root/app/models/diff_discussion.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/diff_discussion.rb')
-rw-r--r--app/models/diff_discussion.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/app/models/diff_discussion.rb b/app/models/diff_discussion.rb
index 4a65738214b..bd6af622bfb 100644
--- a/app/models/diff_discussion.rb
+++ b/app/models/diff_discussion.rb
@@ -22,12 +22,14 @@ class DiffDiscussion < Discussion
def merge_request_version_params
return unless for_merge_request?
- return {} if active?
- if on_merge_request_commit?
- { commit_id: commit_id }
- else
- noteable.version_params_for(position.diff_refs)
+ version_params = get_params
+
+ return version_params unless on_merge_request_commit? && commit_id
+
+ version_params ||= {}
+ version_params.tap do |params|
+ params[:commit_id] = commit_id
end
end
@@ -37,4 +39,12 @@ class DiffDiscussion < Discussion
position: position.to_json
)
end
+
+ private
+
+ def get_params
+ return {} if active?
+
+ noteable.version_params_for(position.diff_refs)
+ end
end