Commit 6ee87aea authored by James Lopez's avatar James Lopez

add user agent details API endpoints to issues and snippets

parent e0345c8d
......@@ -241,6 +241,23 @@ module API
present paginate(merge_requests), with: Entities::MergeRequestBasic, current_user: current_user, project: user_project
end
desc 'Get the user agent details for an issue' do
success Entities::UserAgentDetail
end
params do
requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
end
get ":id/issues/:issue_iid/user_agent_detail" do
authenticated_as_admin!
issue = find_project_issue(params[:issue_iid])
return not_found!('Issue') unless issue
return not_found!('UserAgentDetail') unless issue.user_agent_detail
present issue.user_agent_detail, with: Entities::UserAgentDetail, current_user: current_user, project: user_project
end
end
end
end
......@@ -140,6 +140,23 @@ module API
content_type 'text/plain'
present snippet.content
end
desc 'Get the user agent details for a snippet' do
success Entities::UserAgentDetail
end
params do
requires :id, type: Integer, desc: 'The ID of a snippet'
end
get ":id/user_agent_detail" do
authenticated_as_admin!
snippet = Snippet.find_by(id: params[:id])
return not_found!('Snippet') unless snippet
return not_found!('UserAgentDetail') unless snippet.user_agent_detail
present snippet.user_agent_detail, with: Entities::UserAgentDetail
end
end
end
end
......@@ -1463,7 +1463,7 @@ describe API::Issues do
end
describe "GET /projects/:id/issues/:issue_iid/user_agent_detail" do
let(:user_agent_detail) { create(:user_agent_detail, subject: issue) }
let!(:user_agent_detail) { create(:user_agent_detail, subject: issue) }
it 'exposes known attributes' do
get api("/projects/#{project.id}/issues/#{issue.iid}/user_agent_detail", admin)
......
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