diff options
author | James Lopez <james@jameslopez.es> | 2017-07-07 15:54:39 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-07-07 15:54:39 +0200 |
commit | a9e8af3386f47cee657a95f0094095f5f4cc1b4e (patch) | |
tree | 44bf6a97c7ec3743668c2e1fd4ccc52a032998a6 /spec | |
parent | 5173955fd49ab9748a9878203b691732198091aa (diff) | |
download | gitlab-ce-a9e8af3386f47cee657a95f0094095f5f4cc1b4e.tar.gz |
add spec and project snippet user agent details endpoint
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/project_snippets_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb index 518639f45a2..c7a2dfbea51 100644 --- a/spec/requests/api/project_snippets_spec.rb +++ b/spec/requests/api/project_snippets_spec.rb @@ -242,4 +242,25 @@ describe API::ProjectSnippets do expect(json_response['message']).to eq('404 Snippet Not Found') end end + + describe "GET /projects/:project_id/snippets/:id/user_agent_detail" do + let(:admin) { create(:admin) } + let(:snippet) { create(:project_snippet, author: admin) } + let!(:user_agent_detail) { create(:user_agent_detail, subject: snippet) } + + it 'exposes known attributes' do + get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/user_agent_detail", admin) + + 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['akismet_submitted']).to eq(user_agent_detail.submitted) + end + + it "returns unautorized for non-admin users" do + get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/user_agent_detail", user) + + expect(response).to have_http_status(403) + end + end end |