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
f963b5a9
Commit
f963b5a9
authored
Sep 29, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement presenter for pipeline failure reason
parent
c2b3559b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
2 deletions
+49
-2
app/presenters/ci/pipeline_presenter.rb
app/presenters/ci/pipeline_presenter.rb
+2
-0
app/serializers/pipeline_entity.rb
app/serializers/pipeline_entity.rb
+2
-2
config/application.rb
config/application.rb
+1
-0
ee/app/presenters/ee/ci/pipeline_presenter.rb
ee/app/presenters/ee/ci/pipeline_presenter.rb
+17
-0
spec/ee/spec/presenters/ci/pipeline_presenter_spec.rb
spec/ee/spec/presenters/ci/pipeline_presenter_spec.rb
+27
-0
No files found.
app/presenters/ci/pipeline_presenter.rb
View file @
f963b5a9
module
Ci
class
PipelinePresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
prepend
::
EE
::
Ci
::
PipelinePresenter
presents
:pipeline
def
status_title
...
...
app/serializers/pipeline_entity.rb
View file @
f963b5a9
...
...
@@ -44,6 +44,8 @@ class PipelineEntity < Grape::Entity
end
expose
:commit
,
using:
CommitEntity
expose
:yaml_errors
,
if:
->
(
pipeline
,
_
)
{
pipeline
.
has_yaml_errors?
}
expose
:failure_reason
,
if:
->
(
pipeline
,
_
)
{
pipeline
.
failure_reason?
}
expose
:retry_path
,
if:
->
(
*
)
{
can_retry?
}
do
|
pipeline
|
retry_project_pipeline_path
(
pipeline
.
project
,
pipeline
)
...
...
@@ -53,8 +55,6 @@ class PipelineEntity < Grape::Entity
cancel_project_pipeline_path
(
pipeline
.
project
,
pipeline
)
end
expose
:yaml_errors
,
if:
->
(
pipeline
,
_
)
{
pipeline
.
has_yaml_errors?
}
private
alias_method
:pipeline
,
:object
...
...
config/application.rb
View file @
f963b5a9
...
...
@@ -45,6 +45,7 @@ module Gitlab
#{
config
.
root
}
/ee/app/models/concerns
#{
config
.
root
}
/ee/app/policies
#{
config
.
root
}
/ee/app/serializers
#{
config
.
root
}
/ee/app/presenters
#{
config
.
root
}
/ee/app/services
#{
config
.
root
}
/ee/app/workers
]
)
...
...
ee/app/presenters/ee/ci/pipeline_presenter.rb
0 → 100644
View file @
f963b5a9
module
EE
module
Ci
module
PipelinePresenter
FAILURE_REASONS
=
{
activity_limit_exceeded:
'Pipeline activity limit exceeded!'
,
size_limit_exceeded:
'Pipeline size limit exceeded!'
}
def
failure_reason
return
unless
pipeline
.
failure_reason?
FAILURE_REASONS
[
pipeline
.
failure_reason
.
to_sym
]
||
pipeline
.
failure_reason
end
end
end
end
spec/ee/spec/presenters/ci/pipeline_presenter_spec.rb
0 → 100644
View file @
f963b5a9
require
'spec_helper'
describe
Ci
::
PipelinePresenter
do
set
(
:project
)
{
create
(
:project
)
}
set
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
subject
(
:presenter
)
do
described_class
.
new
(
pipeline
)
end
context
'#failure_reason'
do
context
'when pipeline has failure reason'
do
it
'represents a failure reason sentence'
do
pipeline
.
failure_reason
=
:activity_limit_exceeded
expect
(
presenter
.
failure_reason
)
.
to
eq
'Pipeline activity limit exceeded!'
end
end
context
'when pipeline does not have failure reason'
do
it
'returns nil'
do
expect
(
presenter
.
failure_reason
).
to
be_nil
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