summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2016-12-06 23:04:40 +0000
committerRobert Schilling <rschilling@student.tugraz.at>2016-12-06 23:04:40 +0000
commit73a066c216815f6b4faf9b186b917c3486b6d6e0 (patch)
tree264d2722344d8ba7c1b6774fcf3ad38911ea8b9d
parent180f87cab7c530852c049e130e9297267e006010 (diff)
parent51a921baf90be2a6654990b9b7d062f4c613a64b (diff)
downloadgitlab-ce-73a066c216815f6b4faf9b186b917c3486b6d6e0.tar.gz
Merge branch 'cleanup-7180' into 'master'
A simpler implementation of finding a merge request ## What does this MR do? This cleans up some code in the issues API as discussed in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7180#note_19501743 The helper method `merge_request_for_resolving_discussions` was no longer needed as it was only used once. That made it possible to simplify the implementation. ## Does this MR meet the acceptance criteria? - [x] ~~[Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added~~ - [x] ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~ - [x] ~~API support added~~ - Tests - [x] Added for this feature/bug - [ ] All builds are passing - [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if it does - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) ## What are the relevant issue numbers? !7180 See merge request !7955
-rw-r--r--lib/api/issues.rb15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index cfb7c45de8e..26c8f2fecd0 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -28,14 +28,6 @@ module API
new_params
end
-
- def merge_request_for_resolving_discussions
- return unless merge_request_iid = params[:merge_request_for_resolving_discussions]
-
- @merge_request_for_resolving_discussions ||= MergeRequestsFinder.new(current_user, project_id: user_project.id).
- execute.
- find_by(iid: merge_request_iid)
- end
end
resource :issues do
@@ -179,7 +171,12 @@ module API
attrs = attributes_for_keys(keys)
attrs[:labels] = params[:labels] if params[:labels]
- attrs[:merge_request_for_resolving_discussions] = merge_request_for_resolving_discussions if params[:merge_request_for_resolving_discussions]
+
+ if merge_request_iid = params[:merge_request_for_resolving_discussions]
+ attrs[:merge_request_for_resolving_discussions] = MergeRequestsFinder.new(current_user, project_id: user_project.id).
+ execute.
+ find_by(iid: merge_request_iid)
+ end
# Convert and filter out invalid confidential flags
attrs['confidential'] = to_boolean(attrs['confidential'])