Commit 6384bf7a authored by Timothy Andrew's avatar Timothy Andrew

Implement review comments from @dbalexandre

- Typo in docs
- Newline between test/expectation in `api/issues_spec`
- Use `find_by` instead of `reference_by` in the structure defining awardables
parent 72ef8af7
...@@ -87,7 +87,7 @@ GET /projects/:id/merge_requests/:merge_request_iid ...@@ -87,7 +87,7 @@ GET /projects/:id/merge_requests/:merge_request_iid
Parameters: 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 - `merge_request_iid` (required) - The internal ID of the merge request
```json ```json
......
...@@ -4,15 +4,15 @@ module API ...@@ -4,15 +4,15 @@ module API
before { authenticate! } before { authenticate! }
AWARDABLES = [ AWARDABLES = [
{ type: 'issue', reference_by: :iid }, { type: 'issue', find_by: :iid },
{ type: 'merge_request', reference_by: :iid }, { type: 'merge_request', find_by: :iid },
{ type: 'snippet', reference_by: :id } { type: 'snippet', find_by: :id }
].freeze ].freeze
resource :projects do resource :projects do
AWARDABLES.each do |awardable_params| AWARDABLES.each do |awardable_params|
awardable_string = awardable_params[:type].pluralize 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 params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
......
...@@ -84,7 +84,7 @@ module API ...@@ -84,7 +84,7 @@ module API
unauthorized! unless award.user == current_user || current_user.admin? unauthorized! unless award.user == current_user || current_user.admin?
award.destroy award.destroy
present award, with: ::API::Entities::AwardEmoji present award, with: Entities::AwardEmoji
end end
end end
end end
......
...@@ -799,16 +799,19 @@ describe API::Issues, api: true do ...@@ -799,16 +799,19 @@ describe API::Issues, api: true do
context 'confidential issues' do context 'confidential issues' do
it "returns 404 for non project members" do it "returns 404 for non project members" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member) get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member)
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
end end
it "returns 404 for project members with guest role" do it "returns 404 for project members with guest role" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest) get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest)
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
end end
it "returns confidential issue for project members" do it "returns confidential issue for project members" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user) get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid) expect(json_response['iid']).to eq(confidential_issue.iid)
...@@ -816,6 +819,7 @@ describe API::Issues, api: true do ...@@ -816,6 +819,7 @@ describe API::Issues, api: true do
it "returns confidential issue for author" do it "returns confidential issue for author" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author) get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid) expect(json_response['iid']).to eq(confidential_issue.iid)
...@@ -823,6 +827,7 @@ describe API::Issues, api: true do ...@@ -823,6 +827,7 @@ describe API::Issues, api: true do
it "returns confidential issue for assignee" do it "returns confidential issue for assignee" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", assignee) get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", assignee)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid) expect(json_response['iid']).to eq(confidential_issue.iid)
...@@ -830,6 +835,7 @@ describe API::Issues, api: true do ...@@ -830,6 +835,7 @@ describe API::Issues, api: true do
it "returns confidential issue for admin" do it "returns confidential issue for admin" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin) get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid) expect(json_response['iid']).to eq(confidential_issue.iid)
......
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