Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
4c735e1b
Commit
4c735e1b
authored
Jul 07, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix spec order issue
parent
a9e8af33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
23 deletions
+22
-23
spec/requests/api/project_snippets_spec.rb
spec/requests/api/project_snippets_spec.rb
+22
-23
No files found.
spec/requests/api/project_snippets_spec.rb
View file @
4c735e1b
...
@@ -5,6 +5,26 @@ describe API::ProjectSnippets do
...
@@ -5,6 +5,26 @@ describe API::ProjectSnippets do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:admin
)
{
create
(
:admin
)
}
describe
"GET /projects/:project_id/snippets/:id/user_agent_detail"
do
let
(
:snippet
)
{
create
(
:project_snippet
,
:public
,
project:
project
)
}
let!
(
:user_agent_detail
)
{
create
(
:user_agent_detail
,
subject:
snippet
)
}
it
'exposes known attributes'
do
get
api
(
"/projects/
#{
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
describe
'GET /projects/:project_id/snippets/'
do
describe
'GET /projects/:project_id/snippets/'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
...
@@ -20,7 +40,7 @@ describe API::ProjectSnippets do
...
@@ -20,7 +40,7 @@ describe API::ProjectSnippets do
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
3
)
expect
(
json_response
.
size
).
to
eq
(
3
)
expect
(
json_response
.
map
{
|
snippet
|
snippet
[
'id'
]}
).
to
include
(
public_snippet
.
id
,
internal_snippet
.
id
,
private_snippet
.
id
)
expect
(
json_response
.
map
{
|
snippet
|
snippet
[
'id'
]
}
).
to
include
(
public_snippet
.
id
,
internal_snippet
.
id
,
private_snippet
.
id
)
expect
(
json_response
.
last
).
to
have_key
(
'web_url'
)
expect
(
json_response
.
last
).
to
have_key
(
'web_url'
)
end
end
...
@@ -38,7 +58,7 @@ describe API::ProjectSnippets do
...
@@ -38,7 +58,7 @@ describe API::ProjectSnippets do
describe
'GET /projects/:project_id/snippets/:id'
do
describe
'GET /projects/:project_id/snippets/:id'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:snippet
)
{
create
(
:project_snippet
,
:public
,
project:
project
)
}
let
(
:snippet
)
{
create
(
:project_snippet
,
:public
,
project:
project
)
}
it
'returns snippet json'
do
it
'returns snippet json'
do
get
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/snippets/
#{
snippet
.
id
}
"
,
user
)
...
@@ -242,25 +262,4 @@ describe API::ProjectSnippets do
...
@@ -242,25 +262,4 @@ describe API::ProjectSnippets do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Snippet Not Found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Snippet Not Found'
)
end
end
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
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment