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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3ec4637b
Commit
3ec4637b
authored
Jul 25, 2019
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract resource_label_events API shared examples
This will allow us to reuse them in an EE-only spec.
parent
d3b210ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
42 deletions
+43
-42
spec/requests/api/resource_label_events_spec.rb
spec/requests/api/resource_label_events_spec.rb
+0
-42
spec/support/shared_examples/resource_label_events_api.rb
spec/support/shared_examples/resource_label_events_api.rb
+43
-0
No files found.
spec/requests/api/resource_label_events_spec.rb
View file @
3ec4637b
...
...
@@ -11,48 +11,6 @@ describe API::ResourceLabelEvents do
project
.
add_developer
(
user
)
end
shared_examples
'resource_label_events API'
do
|
parent_type
,
eventable_type
,
id_name
|
describe
"GET /
#{
parent_type
}
/:id/
#{
eventable_type
}
/:noteable_id/resource_label_events"
do
it
"returns an array of resource label events"
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
eventable_type
}
/
#{
eventable
[
id_name
]
}
/resource_label_events"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
event
.
id
)
end
it
"returns a 404 error when eventable id not found"
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
eventable_type
}
/12345/resource_label_events"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
"returns 404 when not authorized"
do
parent
.
update!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
eventable_type
}
/
#{
eventable
[
id_name
]
}
/resource_label_events"
,
private_user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
describe
"GET /
#{
parent_type
}
/:id/
#{
eventable_type
}
/:noteable_id/resource_label_events/:event_id"
do
it
"returns a resource label event by id"
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
eventable_type
}
/
#{
eventable
[
id_name
]
}
/resource_label_events/
#{
event
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'id'
]).
to
eq
(
event
.
id
)
end
it
"returns a 404 error if resource label event not found"
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
eventable_type
}
/
#{
eventable
[
id_name
]
}
/resource_label_events/12345"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
context
'when eventable is an Issue'
do
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
...
...
spec/support/shared_examples/resource_label_events_api.rb
0 → 100644
View file @
3ec4637b
# frozen_string_literal: true
shared_examples
'resource_label_events API'
do
|
parent_type
,
eventable_type
,
id_name
|
describe
"GET /
#{
parent_type
}
/:id/
#{
eventable_type
}
/:noteable_id/resource_label_events"
do
it
"returns an array of resource label events"
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
eventable_type
}
/
#{
eventable
[
id_name
]
}
/resource_label_events"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
event
.
id
)
end
it
"returns a 404 error when eventable id not found"
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
eventable_type
}
/12345/resource_label_events"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
"returns 404 when not authorized"
do
parent
.
update!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
eventable_type
}
/
#{
eventable
[
id_name
]
}
/resource_label_events"
,
private_user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
describe
"GET /
#{
parent_type
}
/:id/
#{
eventable_type
}
/:noteable_id/resource_label_events/:event_id"
do
it
"returns a resource label event by id"
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
eventable_type
}
/
#{
eventable
[
id_name
]
}
/resource_label_events/
#{
event
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'id'
]).
to
eq
(
event
.
id
)
end
it
"returns a 404 error if resource label event not found"
do
get
api
(
"/
#{
parent_type
}
/
#{
parent
.
id
}
/
#{
eventable_type
}
/
#{
eventable
[
id_name
]
}
/resource_label_events/12345"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
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