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
8ce4bf20
Commit
8ce4bf20
authored
Jul 30, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve CommitStatusPresenter
parent
8ce03988
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
7 deletions
+34
-7
app/presenters/commit_status_presenter.rb
app/presenters/commit_status_presenter.rb
+8
-7
spec/presenters/commit_status_presenter_spec.rb
spec/presenters/commit_status_presenter_spec.rb
+26
-0
No files found.
app/presenters/commit_status_presenter.rb
View file @
8ce4bf20
...
...
@@ -2,18 +2,19 @@
class
CommitStatusPresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
CALLOUT_FAILURE_MESSAGES
=
{
unknown_failure:
'There is an unknown failure, please try again'
,
api_failure:
'There has been an API failure, please try again'
,
stuck_or_timeout_failure:
'There has been a timeout failure or the job got stuck. Check your timeout limits or try again'
,
runner_system_failure:
'There has been a runner system failure, please try again'
,
missing_dependency_failure:
'There has been a missing dependency failure'
,
# COMMENTED to check if tests gonna fail: runner_unsupported: 'Your runner is unsupported. Upgrade runner to use new features of your Pipeline',
unknown_failure:
'There is an unknown failure, please try again'
,
script_failure:
nil
,
api_failure:
'There has been an API failure, please try again'
,
stuck_or_timeout_failure:
'There has been a timeout failure or the job got stuck. Check your timeout limits or try again'
,
runner_system_failure:
'There has been a runner system failure, please try again'
,
missing_dependency_failure:
'There has been a missing dependency failure'
,
runner_unsupported:
'Your runner is outdated, please upgrade your runner'
}.
freeze
presents
:build
def
callout_failure_message
CALLOUT_FAILURE_MESSAGES
[
failure_reason
.
to_sym
]
CALLOUT_FAILURE_MESSAGES
.
fetch
(
failure_reason
.
to_sym
)
end
def
recoverable?
...
...
spec/presenters/commit_status_presenter_spec.rb
View file @
8ce4bf20
...
...
@@ -12,4 +12,30 @@ describe CommitStatusPresenter do
it
'inherits from Gitlab::View::Presenter::Delegated'
do
expect
(
described_class
.
superclass
).
to
eq
(
Gitlab
::
View
::
Presenter
::
Delegated
)
end
describe
'covers all failure reasons'
do
let
(
:message
)
{
presenter
.
callout_failure_message
}
CommitStatus
.
failure_reasons
.
keys
.
each
do
|
failure_reason
|
context
failure_reason
do
before
do
build
.
failure_reason
=
failure_reason
end
it
"is a valid status"
do
expect
{
message
}.
not_to
raise_error
end
end
end
context
'invalid failure message'
do
before
do
expect
(
build
).
to
receive
(
:failure_reason
)
{
'invalid failure message'
}
end
it
"is an invalid status"
do
expect
{
message
}.
to
raise_error
(
/key not found:/
)
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