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
f494f271
Commit
f494f271
authored
May 16, 2018
by
Mayra Cabrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respect the inheritance chain between Ci::Build and CommitStatus
Also moves the assertions were they belong
parent
86ef8221
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
31 deletions
+48
-31
app/presenters/ci/build_presenter.rb
app/presenters/ci/build_presenter.rb
+1
-24
app/presenters/commit_status_presenter.rb
app/presenters/commit_status_presenter.rb
+23
-1
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+2
-5
spec/models/generic_commit_status_spec.rb
spec/models/generic_commit_status_spec.rb
+6
-0
spec/presenters/ci/build_presenter_spec.rb
spec/presenters/ci/build_presenter_spec.rb
+1
-1
spec/presenters/commit_status_presenter_spec.rb
spec/presenters/commit_status_presenter_spec.rb
+15
-0
No files found.
app/presenters/ci/build_presenter.rb
View file @
f494f271
module
Ci
class
BuildPresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
CALLOUT_FAILURE_MESSAGES
=
{
unknown_failure:
'There is an unknown failure, please try again'
,
script_failure:
'There has been a script failure. Check the job log for more information'
,
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, check the job log for more information'
}.
freeze
presents
:build
class
BuildPresenter
<
CommitStatusPresenter
def
erased_by_user?
# Build can be erased through API, therefore it does not have
# `erased_by` user assigned in that case.
...
...
@@ -44,14 +33,6 @@ module Ci
"
#{
subject
.
name
}
-
#{
detailed_status
.
status_tooltip
}
"
end
def
callout_failure_message
CALLOUT_FAILURE_MESSAGES
[
failure_reason
.
to_sym
]
end
def
recoverable?
failed?
&&
!
unrecoverable?
end
private
def
tooltip_for_badge
...
...
@@ -61,9 +42,5 @@ module Ci
def
detailed_status
@detailed_status
||=
subject
.
detailed_status
(
user
)
end
def
unrecoverable?
script_failure?
||
missing_dependency_failure?
end
end
end
app/presenters/commit_status_presenter.rb
View file @
f494f271
class
CommitStatusPresenter
<
Ci
::
BuildPresenter
class
CommitStatusPresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
CALLOUT_FAILURE_MESSAGES
=
{
unknown_failure:
'There is an unknown failure, please try again'
,
script_failure:
'There has been a script failure. Check the job log for more information'
,
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, check the job log for more information'
}.
freeze
presents
:build
def
callout_failure_message
CALLOUT_FAILURE_MESSAGES
[
failure_reason
.
to_sym
]
end
def
recoverable?
failed?
&&
!
unrecoverable?
end
def
unrecoverable?
script_failure?
||
missing_dependency_failure?
end
end
spec/models/commit_status_spec.rb
View file @
f494f271
...
...
@@ -567,11 +567,8 @@ describe CommitStatus do
end
describe
'#present'
do
let
(
:generic_commit_status
)
{
create
(
:generic_commit_status
)
}
subject
{
commit_status
.
present
}
it
'returns a presenter'
do
expect
(
commit_status
.
present
).
to
be_a
(
Ci
::
BuildPresenter
)
expect
(
generic_commit_status
.
present
).
to
be_a
(
Ci
::
BuildPresenter
)
end
it
{
is_expected
.
to
be_a
(
CommitStatusPresenter
)
}
end
end
spec/models/generic_commit_status_spec.rb
View file @
f494f271
...
...
@@ -78,4 +78,10 @@ describe GenericCommitStatus do
it
{
is_expected
.
not_to
be_nil
}
end
end
describe
'#present'
do
subject
{
generic_commit_status
.
present
}
it
{
is_expected
.
to
be_a
(
GenericCommitStatusPresenter
)
}
end
end
spec/presenters/ci/build_presenter_spec.rb
View file @
f494f271
...
...
@@ -10,7 +10,7 @@ describe Ci::BuildPresenter do
end
it
'inherits from Gitlab::View::Presenter::Delegated'
do
expect
(
described_class
.
superclass
).
to
eq
(
Gitlab
::
View
::
Presenter
::
Delegated
)
expect
(
described_class
.
ancestors
).
to
include
(
Gitlab
::
View
::
Presenter
::
Delegated
)
end
describe
'#initialize'
do
...
...
spec/presenters/commit_status_presenter_spec.rb
0 → 100644
View file @
f494f271
require
'spec_helper'
describe
CommitStatusPresenter
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
subject
(
:presenter
)
do
described_class
.
new
(
build
)
end
it
'inherits from Gitlab::View::Presenter::Delegated'
do
expect
(
described_class
.
superclass
).
to
eq
(
Gitlab
::
View
::
Presenter
::
Delegated
)
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