Commit 2aa95aa0 authored by James Lopez's avatar James Lopez

refactor code based on feedback

parent 47e17fe1
......@@ -988,6 +988,6 @@ Example response:
{
"user_agent": "AppleWebKit/537.36",
"ip_address": "127.0.0.1",
"submitted": false
"akismet_submitted": false
}
```
......@@ -257,6 +257,6 @@ Example response:
{
"user_agent": "AppleWebKit/537.36",
"ip_address": "127.0.0.1",
"submitted": false
"akismet_submitted": false
}
```
......@@ -879,7 +879,7 @@ module API
class UserAgentDetail < Grape::Entity
expose :user_agent
expose :ip_address
expose :submitted
expose :submitted, as: :akismet_submitted
end
end
end
......@@ -253,10 +253,9 @@ module API
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
present issue.user_agent_detail, with: Entities::UserAgentDetail
end
end
end
......
......@@ -150,9 +150,8 @@ module API
get ":id/user_agent_detail" do
authenticated_as_admin!
snippet = Snippet.find_by(id: params[:id])
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
......
......@@ -1471,7 +1471,7 @@ describe API::Issues do
expect(response).to have_http_status(200)
expect(json_response['user_agent']).to eq(user_agent_detail.user_agent)
expect(json_response['ip_address']).to eq(user_agent_detail.ip_address)
expect(json_response['submitted']).to be false
expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
end
it "returns unautorized for non-admin users" do
......
......@@ -283,7 +283,7 @@ describe API::Snippets do
expect(response).to have_http_status(200)
expect(json_response['user_agent']).to eq(user_agent_detail.user_agent)
expect(json_response['ip_address']).to eq(user_agent_detail.ip_address)
expect(json_response['submitted']).to be false
expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
end
it "returns unautorized for non-admin users" do
......
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