Commit 2a669011 authored by raju249's avatar raju249

Incorporate review feedback

parent c9ed33fd
......@@ -2,7 +2,7 @@
## Sentry Error Tracking Project Settings
The Sentry Project Settings API allows you to retrieve Sentry Error Tracking Settings for a Project.
The Sentry Project Settings API allows you to retrieve Sentry Error Tracking Settings for a Project. Only for project maintainers.
### Retrieve Sentry Error Tracking Settings
......
......@@ -16,8 +16,11 @@ module API
get ':id/error_tracking/sentry_project_settings' do
authorize! :read_sentry_issue, user_project
sentry_project_settings = user_project.error_tracking_setting
present sentry_project_settings, with: Entities::SentryProjectErrorTrackingSettings
setting = user_project.error_tracking_setting
not_found!('Error Tracking Setting') unless setting
present setting, with: Entities::SentryProjectErrorTrackingSettings
end
end
end
......
......@@ -4,17 +4,31 @@ require 'spec_helper'
describe API::ErrorTracking do
describe "GET sentry project settings" do
let(:project_not_found_message) { "404 Project Not Found" }
let(:unauthorized_message) { "401 Unauthorized" }
let(:settings_not_found_message) { "404 Error Tracking Setting Not Found" }
let(:random_user) { create(:user) }
let(:project_error_tracking_setting) { create(:project_error_tracking_setting) }
let(:project) do
create(:project, :repository)
end
let(:project_with_settings) do
create(:project, :repository, error_tracking_setting: project_error_tracking_setting)
end
context 'when project has no settings' do
it 'returns 404' do
get api("/projects/#{project.id}/error_tracking/sentry_project_settings", project.creator)
expect(response).to have_gitlab_http_status(404)
expect(json_response["message"]).to eq(settings_not_found_message)
end
end
context 'when user has permission to view settings' do
it 'returns 200' do
get api("/projects/#{project.id}/error_tracking/sentry_project_settings", project.creator)
get api("/projects/#{project_with_settings.id}/error_tracking/sentry_project_settings", project_with_settings.creator)
expect(response).to have_gitlab_http_status(200)
expect(json_response["project_name"]).to eq(project_error_tracking_setting.project_name)
......@@ -26,7 +40,6 @@ describe API::ErrorTracking do
it 'returns 404' do
get api("/projects/#{project.id}/error_tracking/sentry_project_settings", random_user)
expect(response).to have_gitlab_http_status(404)
expect(json_response["message"]).to eq(project_not_found_message)
end
end
......
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