summaryrefslogtreecommitdiff
path: root/lib/api/award_emoji.rb
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2017-02-28 11:29:02 +0530
committerTimothy Andrew <mail@timothyandrew.net>2017-03-07 13:55:59 +0530
commit70584e6925698f9d5be335059f90f63a51821089 (patch)
treedd8a752fb7f19dbb716f0eec1c10a984094100be /lib/api/award_emoji.rb
parent402e0a2dd7cd9aa6766500b9b6809c97dfd40912 (diff)
downloadgitlab-ce-70584e6925698f9d5be335059f90f63a51821089.tar.gz
Migrate the AwardEmoji API to use `merge_request_iid` and `issue_iid`
- Instead of `merge_request_id` and `issue_id` - The API also deals with `snippet_id`, which remains unchanged (since snippets don't have `iid`s - Duplicate the original `AwardEmoji` API (and spec) for use with the V3 API, since this is a breaking change.
Diffstat (limited to 'lib/api/award_emoji.rb')
-rw-r--r--lib/api/award_emoji.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/api/award_emoji.rb b/lib/api/award_emoji.rb
index 07a1bcdbe18..af16e016cdb 100644
--- a/lib/api/award_emoji.rb
+++ b/lib/api/award_emoji.rb
@@ -3,12 +3,16 @@ module API
include PaginationParams
before { authenticate! }
- AWARDABLES = %w[issue merge_request snippet].freeze
+ AWARDABLES = [
+ { type: 'issue', reference_by: :iid },
+ { type: 'merge_request', reference_by: :iid },
+ { type: 'snippet', reference_by: :id }
+ ].freeze
resource :projects do
- AWARDABLES.each do |awardable_type|
- awardable_string = awardable_type.pluralize
- awardable_id_string = "#{awardable_type}_id"
+ AWARDABLES.each do |awardable_params|
+ awardable_string = awardable_params[:type].pluralize
+ awardable_id_string = "#{awardable_params[:type]}_#{awardable_params[:reference_by]}"
params do
requires :id, type: String, desc: 'The ID of a project'
@@ -104,10 +108,10 @@ module API
note_id = params.delete(:note_id)
awardable.notes.find(note_id)
- elsif params.include?(:issue_id)
- user_project.issues.find(params[:issue_id])
- elsif params.include?(:merge_request_id)
- user_project.merge_requests.find(params[:merge_request_id])
+ elsif params.include?(:issue_iid)
+ user_project.issues.find_by!(iid: params[:issue_iid])
+ elsif params.include?(:merge_request_iid)
+ user_project.merge_requests.find_by!(iid: params[:merge_request_iid])
else
user_project.snippets.find(params[:snippet_id])
end