summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2017-03-02 16:11:59 +0530
committerTimothy Andrew <mail@timothyandrew.net>2017-03-07 13:56:00 +0530
commit6384bf7a8804b41110bcbdf5e18f124dfcffca2e (patch)
tree07f8e74bb052cf8f82c4973f98ce25d87794e2d2
parent72ef8af7586b349df04fc722206c5eecb3ac58f6 (diff)
downloadgitlab-ce-6384bf7a8804b41110bcbdf5e18f124dfcffca2e.tar.gz
Implement review comments from @dbalexandre28251-mr-and-issue-iids-for-api-v4
- Typo in docs - Newline between test/expectation in `api/issues_spec` - Use `find_by` instead of `reference_by` in the structure defining awardables
-rw-r--r--doc/api/merge_requests.md2
-rw-r--r--lib/api/award_emoji.rb8
-rw-r--r--lib/api/v3/award_emoji.rb2
-rw-r--r--spec/requests/api/issues_spec.rb6
4 files changed, 12 insertions, 6 deletions
diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md
index 80ef5fbc51c..2e0545da1c4 100644
--- a/doc/api/merge_requests.md
+++ b/doc/api/merge_requests.md
@@ -87,7 +87,7 @@ GET /projects/:id/merge_requests/:merge_request_iid
Parameters:
-- `iid` (required) - The ID of a project
+- `id` (required) - The ID of a project
- `merge_request_iid` (required) - The internal ID of the merge request
```json
diff --git a/lib/api/award_emoji.rb b/lib/api/award_emoji.rb
index af16e016cdb..f9e0c2c4e16 100644
--- a/lib/api/award_emoji.rb
+++ b/lib/api/award_emoji.rb
@@ -4,15 +4,15 @@ module API
before { authenticate! }
AWARDABLES = [
- { type: 'issue', reference_by: :iid },
- { type: 'merge_request', reference_by: :iid },
- { type: 'snippet', reference_by: :id }
+ { type: 'issue', find_by: :iid },
+ { type: 'merge_request', find_by: :iid },
+ { type: 'snippet', find_by: :id }
].freeze
resource :projects do
AWARDABLES.each do |awardable_params|
awardable_string = awardable_params[:type].pluralize
- awardable_id_string = "#{awardable_params[:type]}_#{awardable_params[:reference_by]}"
+ awardable_id_string = "#{awardable_params[:type]}_#{awardable_params[:find_by]}"
params do
requires :id, type: String, desc: 'The ID of a project'
diff --git a/lib/api/v3/award_emoji.rb b/lib/api/v3/award_emoji.rb
index c558c745b8c..cf9e1551f60 100644
--- a/lib/api/v3/award_emoji.rb
+++ b/lib/api/v3/award_emoji.rb
@@ -84,7 +84,7 @@ module API
unauthorized! unless award.user == current_user || current_user.admin?
award.destroy
- present award, with: ::API::Entities::AwardEmoji
+ present award, with: Entities::AwardEmoji
end
end
end
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index e8a9bab297c..2fc11a3b782 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -799,16 +799,19 @@ describe API::Issues, api: true do
context 'confidential issues' do
it "returns 404 for non project members" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member)
+
expect(response).to have_http_status(404)
end
it "returns 404 for project members with guest role" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest)
+
expect(response).to have_http_status(404)
end
it "returns confidential issue for project members" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user)
+
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
@@ -816,6 +819,7 @@ describe API::Issues, api: true do
it "returns confidential issue for author" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author)
+
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
@@ -823,6 +827,7 @@ describe API::Issues, api: true do
it "returns confidential issue for assignee" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", assignee)
+
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
@@ -830,6 +835,7 @@ describe API::Issues, api: true do
it "returns confidential issue for admin" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin)
+
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)