refactor code based on feedback

This commit is contained in:
James Lopez 2017-07-06 15:19:14 +02:00
parent 47e17fe12a
commit 2aa95aa018
7 changed files with 7 additions and 9 deletions

View File

@ -988,6 +988,6 @@ Example response:
{
"user_agent": "AppleWebKit/537.36",
"ip_address": "127.0.0.1",
"submitted": false
"akismet_submitted": false
}
```

View File

@ -257,6 +257,6 @@ Example response:
{
"user_agent": "AppleWebKit/537.36",
"ip_address": "127.0.0.1",
"submitted": false
"akismet_submitted": false
}
```

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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