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
Jérome Perrin
gitlab-ce
Commits
30c73d2d
Commit
30c73d2d
authored
Jan 27, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add controller test for merge requests pipelines API
parent
6b3f52b4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
app/serializers/pipeline_serializer.rb
app/serializers/pipeline_serializer.rb
+2
-1
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+32
-1
No files found.
app/serializers/pipeline_serializer.rb
View file @
30c73d2d
class
PipelineSerializer
<
BaseSerializer
class
PipelineSerializer
<
BaseSerializer
entity
PipelineEntity
class
InvalidResourceError
<
StandardError
;
end
class
InvalidResourceError
<
StandardError
;
end
include
API
::
Helpers
::
Pagination
include
API
::
Helpers
::
Pagination
Struct
.
new
(
'Pagination'
,
:request
,
:response
)
Struct
.
new
(
'Pagination'
,
:request
,
:response
)
entity
PipelineEntity
def
represent
(
resource
,
opts
=
{})
def
represent
(
resource
,
opts
=
{})
if
paginated?
if
paginated?
raise
InvalidResourceError
unless
resource
.
respond_to?
(
:page
)
raise
InvalidResourceError
unless
resource
.
respond_to?
(
:page
)
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
30c73d2d
...
@@ -668,9 +668,40 @@ describe Projects::MergeRequestsController do
...
@@ -668,9 +668,40 @@ describe Projects::MergeRequestsController do
end
end
describe
'GET pipelines'
do
describe
'GET pipelines'
do
before
do
create
(
:ci_pipeline
,
project:
merge_request
.
source_project
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
)
end
context
'when using HTML format'
do
it_behaves_like
"loads labels"
,
:pipelines
it_behaves_like
"loads labels"
,
:pipelines
end
end
context
'when using JSON format'
do
before
do
get
:pipelines
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
merge_request
.
iid
,
format: :json
end
let
(
:json_response
)
{
JSON
.
parse
(
response
.
body
)
}
it
'responds with a rendered HTML partial'
do
expect
(
response
)
.
to
render_template
(
'projects/merge_requests/show/_pipelines'
)
expect
(
json_response
).
to
have_key
'html'
end
it
'responds with serialized pipelines'
do
expect
(
json_response
).
to
have_key
'pipelines'
expect
(
json_response
[
'pipelines'
]).
not_to
be_empty
end
end
end
describe
'GET conflicts'
do
describe
'GET conflicts'
do
let
(
:json_response
)
{
JSON
.
parse
(
response
.
body
)
}
let
(
:json_response
)
{
JSON
.
parse
(
response
.
body
)
}
...
...
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