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
993c3d14
Commit
993c3d14
authored
Feb 20, 2017
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove shared example for pagination
parent
bc0b438d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
6 additions
and
44 deletions
+6
-44
spec/requests/api/commit_statuses_spec.rb
spec/requests/api/commit_statuses_spec.rb
+1
-4
spec/requests/api/deployments_spec.rb
spec/requests/api/deployments_spec.rb
+0
-4
spec/requests/api/environments_spec.rb
spec/requests/api/environments_spec.rb
+0
-4
spec/requests/api/notes_spec.rb
spec/requests/api/notes_spec.rb
+0
-4
spec/requests/api/pipelines_spec.rb
spec/requests/api/pipelines_spec.rb
+1
-4
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+4
-4
spec/support/api/pagination_shared_examples.rb
spec/support/api/pagination_shared_examples.rb
+0
-20
No files found.
spec/requests/api/commit_statuses_spec.rb
View file @
993c3d14
...
@@ -21,10 +21,6 @@ describe API::CommitStatuses, api: true do
...
@@ -21,10 +21,6 @@ describe API::CommitStatuses, api: true do
let!
(
:master
)
{
project
.
pipelines
.
create
(
sha:
commit
.
id
,
ref:
'master'
)
}
let!
(
:master
)
{
project
.
pipelines
.
create
(
sha:
commit
.
id
,
ref:
'master'
)
}
let!
(
:develop
)
{
project
.
pipelines
.
create
(
sha:
commit
.
id
,
ref:
'develop'
)
}
let!
(
:develop
)
{
project
.
pipelines
.
create
(
sha:
commit
.
id
,
ref:
'develop'
)
}
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
get_url
,
reporter
)
}
end
context
"reporter user"
do
context
"reporter user"
do
let
(
:statuses_id
)
{
json_response
.
map
{
|
status
|
status
[
'id'
]
}
}
let
(
:statuses_id
)
{
json_response
.
map
{
|
status
|
status
[
'id'
]
}
}
...
@@ -45,6 +41,7 @@ describe API::CommitStatuses, api: true do
...
@@ -45,6 +41,7 @@ describe API::CommitStatuses, api: true do
it
'returns latest commit statuses'
do
it
'returns latest commit statuses'
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
statuses_id
).
to
contain_exactly
(
status3
.
id
,
status4
.
id
,
status5
.
id
,
status6
.
id
)
expect
(
statuses_id
).
to
contain_exactly
(
status3
.
id
,
status4
.
id
,
status5
.
id
,
status6
.
id
)
json_response
.
sort_by!
{
|
status
|
status
[
'id'
]
}
json_response
.
sort_by!
{
|
status
|
status
[
'id'
]
}
...
...
spec/requests/api/deployments_spec.rb
View file @
993c3d14
...
@@ -14,10 +14,6 @@ describe API::Deployments, api: true do
...
@@ -14,10 +14,6 @@ describe API::Deployments, api: true do
describe
'GET /projects/:id/deployments'
do
describe
'GET /projects/:id/deployments'
do
context
'as member of the project'
do
context
'as member of the project'
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
user
)
}
end
it
'returns projects deployments'
do
it
'returns projects deployments'
do
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/deployments"
,
user
)
...
...
spec/requests/api/environments_spec.rb
View file @
993c3d14
...
@@ -14,10 +14,6 @@ describe API::Environments, api: true do
...
@@ -14,10 +14,6 @@ describe API::Environments, api: true do
describe
'GET /projects/:id/environments'
do
describe
'GET /projects/:id/environments'
do
context
'as member of the project'
do
context
'as member of the project'
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
}
end
it
'returns project environments'
do
it
'returns project environments'
do
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
...
...
spec/requests/api/notes_spec.rb
View file @
993c3d14
...
@@ -32,10 +32,6 @@ describe API::Notes, api: true do
...
@@ -32,10 +32,6 @@ describe API::Notes, api: true do
before
{
project
.
team
<<
[
user
,
:reporter
]
}
before
{
project
.
team
<<
[
user
,
:reporter
]
}
describe
"GET /projects/:id/noteable/:noteable_id/notes"
do
describe
"GET /projects/:id/noteable/:noteable_id/notes"
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
/notes"
,
user
)
}
end
context
"when noteable is an Issue"
do
context
"when noteable is an Issue"
do
it
"returns an array of issue notes"
do
it
"returns an array of issue notes"
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
/notes"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
/notes"
,
user
)
...
...
spec/requests/api/pipelines_spec.rb
View file @
993c3d14
...
@@ -15,15 +15,12 @@ describe API::Pipelines, api: true do
...
@@ -15,15 +15,12 @@ describe API::Pipelines, api: true do
before
{
project
.
team
<<
[
user
,
:master
]
}
before
{
project
.
team
<<
[
user
,
:master
]
}
describe
'GET /projects/:id/pipelines '
do
describe
'GET /projects/:id/pipelines '
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
"/projects/
#{
project
.
id
}
/pipelines"
,
user
)
}
end
context
'authorized user'
do
context
'authorized user'
do
it
'returns project pipelines'
do
it
'returns project pipelines'
do
get
api
(
"/projects/
#{
project
.
id
}
/pipelines"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/pipelines"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'sha'
]).
to
match
/\A\h{40}\z/
expect
(
json_response
.
first
[
'sha'
]).
to
match
/\A\h{40}\z/
expect
(
json_response
.
first
[
'id'
]).
to
eq
pipeline
.
id
expect
(
json_response
.
first
[
'id'
]).
to
eq
pipeline
.
id
...
...
spec/requests/api/users_spec.rb
View file @
993c3d14
...
@@ -1093,14 +1093,14 @@ describe API::Users, api: true do
...
@@ -1093,14 +1093,14 @@ describe API::Users, api: true do
end
end
context
"as a user than can see the event's project"
do
context
"as a user than can see the event's project"
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
"/users/
#{
user
.
id
}
/events"
,
user
)
}
end
context
'joined event'
do
context
'joined event'
do
it
'returns the "joined" event'
do
it
'returns the "joined" event'
do
get
api
(
"/users/
#{
user
.
id
}
/events"
,
user
)
get
api
(
"/users/
#{
user
.
id
}
/events"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
comment_event
=
json_response
.
find
{
|
e
|
e
[
'action_name'
]
==
'commented on'
}
comment_event
=
json_response
.
find
{
|
e
|
e
[
'action_name'
]
==
'commented on'
}
expect
(
comment_event
[
'project_id'
].
to_i
).
to
eq
(
project
.
id
)
expect
(
comment_event
[
'project_id'
].
to_i
).
to
eq
(
project
.
id
)
...
...
spec/support/api/pagination_shared_examples.rb
deleted
100644 → 0
View file @
bc0b438d
# Specs for paginated resources.
#
# Requires an API request:
# let(:request) { get api("/projects/#{project.id}/repository/branches", user) }
shared_examples
'a paginated resources'
do
before
do
# Fires the request
request
end
it
'has pagination headers'
do
expect
(
response
.
headers
).
to
include
(
'X-Total'
)
expect
(
response
.
headers
).
to
include
(
'X-Total-Pages'
)
expect
(
response
.
headers
).
to
include
(
'X-Per-Page'
)
expect
(
response
.
headers
).
to
include
(
'X-Page'
)
expect
(
response
.
headers
).
to
include
(
'X-Next-Page'
)
expect
(
response
.
headers
).
to
include
(
'X-Prev-Page'
)
expect
(
response
.
headers
).
to
include
(
'Link'
)
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