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
3aa5317d
Commit
3aa5317d
authored
May 08, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-failed-jobs-tab' into 'master'
Fix failed jobs tab See merge request gitlab-org/gitlab-ce!18520
parents
0eb74426
6776fac6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
12 deletions
+60
-12
app/controllers/projects/pipelines_controller.rb
app/controllers/projects/pipelines_controller.rb
+1
-1
app/presenters/ci/pipeline_presenter.rb
app/presenters/ci/pipeline_presenter.rb
+10
-0
app/views/projects/pipelines/_with_tabs.html.haml
app/views/projects/pipelines/_with_tabs.html.haml
+5
-6
spec/features/projects/pipelines/pipeline_spec.rb
spec/features/projects/pipelines/pipeline_spec.rb
+44
-5
No files found.
app/controllers/projects/pipelines_controller.rb
View file @
3aa5317d
...
@@ -87,7 +87,7 @@ class Projects::PipelinesController < Projects::ApplicationController
...
@@ -87,7 +87,7 @@ class Projects::PipelinesController < Projects::ApplicationController
end
end
def
failures
def
failures
if
@pipeline
.
statuses
.
latest
.
failed
.
present?
if
@pipeline
.
failed_builds
.
present?
render_show
render_show
else
else
redirect_to
pipeline_path
(
@pipeline
)
redirect_to
pipeline_path
(
@pipeline
)
...
...
app/presenters/ci/pipeline_presenter.rb
View file @
3aa5317d
module
Ci
module
Ci
class
PipelinePresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
class
PipelinePresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
include
Gitlab
::
Utils
::
StrongMemoize
FAILURE_REASONS
=
{
FAILURE_REASONS
=
{
config_error:
'CI/CD YAML configuration error!'
config_error:
'CI/CD YAML configuration error!'
}.
freeze
}.
freeze
presents
:pipeline
presents
:pipeline
def
failed_builds
return
[]
unless
can?
(
current_user
,
:read_build
,
pipeline
)
strong_memoize
(
:failed_builds
)
do
pipeline
.
builds
.
latest
.
failed
end
end
def
failure_reason
def
failure_reason
return
unless
pipeline
.
failure_reason?
return
unless
pipeline
.
failure_reason?
...
...
app/views/projects/pipelines/_with_tabs.html.haml
View file @
3aa5317d
-
failed_builds
=
@pipeline
.
statuses
.
latest
.
failed
.tabs-holder
.tabs-holder
%ul
.pipelines-tabs.nav-links.no-top.no-bottom.mobile-separator
%ul
.pipelines-tabs.nav-links.no-top.no-bottom.mobile-separator
%li
.js-pipeline-tab-link
%li
.js-pipeline-tab-link
...
@@ -9,11 +7,11 @@
...
@@ -9,11 +7,11 @@
=
link_to
builds_project_pipeline_path
(
@project
,
@pipeline
),
data:
{
target:
'#js-tab-builds'
,
action:
'builds'
,
toggle:
'tab'
},
class:
'builds-tab'
do
=
link_to
builds_project_pipeline_path
(
@project
,
@pipeline
),
data:
{
target:
'#js-tab-builds'
,
action:
'builds'
,
toggle:
'tab'
},
class:
'builds-tab'
do
=
_
(
"Jobs"
)
=
_
(
"Jobs"
)
%span
.badge.js-builds-counter
=
pipeline
.
total_size
%span
.badge.js-builds-counter
=
pipeline
.
total_size
-
if
failed_builds
.
present?
-
if
@pipeline
.
failed_builds
.
present?
%li
.js-failures-tab-link
%li
.js-failures-tab-link
=
link_to
failures_project_pipeline_path
(
@project
,
@pipeline
),
data:
{
target:
'#js-tab-failures'
,
action:
'failures'
,
toggle:
'tab'
},
class:
'failures-tab'
do
=
link_to
failures_project_pipeline_path
(
@project
,
@pipeline
),
data:
{
target:
'#js-tab-failures'
,
action:
'failures'
,
toggle:
'tab'
},
class:
'failures-tab'
do
=
_
(
"Failed Jobs"
)
=
_
(
"Failed Jobs"
)
%span
.badge.js-failures-counter
=
failed_builds
.
count
%span
.badge.js-failures-counter
=
@pipeline
.
failed_builds
.
count
.tab-content
.tab-content
#js-tab-pipeline
.tab-pane
#js-tab-pipeline
.tab-pane
...
@@ -43,9 +41,10 @@
...
@@ -43,9 +41,10 @@
%th
Coverage
%th
Coverage
%th
%th
=
render
partial:
"projects/stage/stage"
,
collection:
pipeline
.
legacy_stages
,
as: :stage
=
render
partial:
"projects/stage/stage"
,
collection:
pipeline
.
legacy_stages
,
as: :stage
-
if
failed_builds
.
present?
-
if
@pipeline
.
failed_builds
.
present?
#js-tab-failures
.build-failures.tab-pane
#js-tab-failures
.build-failures.tab-pane
-
failed_builds
.
each_with_index
do
|
build
,
index
|
-
@pipeline
.
failed_builds
.
each_with_index
do
|
build
,
index
|
.build-state
.build-state
%span
.ci-status-icon-failed
=
custom_icon
(
'icon_status_failed'
)
%span
.ci-status-icon-failed
=
custom_icon
(
'icon_status_failed'
)
%span
.stage
%span
.stage
...
...
spec/features/projects/pipelines/pipeline_spec.rb
View file @
3aa5317d
...
@@ -3,10 +3,11 @@ require 'spec_helper'
...
@@ -3,10 +3,11 @@ require 'spec_helper'
describe
'Pipeline'
,
:js
do
describe
'Pipeline'
,
:js
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:role
)
{
:developer
}
before
do
before
do
sign_in
(
user
)
sign_in
(
user
)
project
.
add_
developer
(
user
)
project
.
add_
role
(
user
,
role
)
end
end
shared_context
'pipeline builds'
do
shared_context
'pipeline builds'
do
...
@@ -153,9 +154,10 @@ describe 'Pipeline', :js do
...
@@ -153,9 +154,10 @@ describe 'Pipeline', :js do
end
end
context
'page tabs'
do
context
'page tabs'
do
it
'shows Pipeline
an
d Jobs tabs with link'
do
it
'shows Pipeline
, Jobs and Faile
d Jobs tabs with link'
do
expect
(
page
).
to
have_link
(
'Pipeline'
)
expect
(
page
).
to
have_link
(
'Pipeline'
)
expect
(
page
).
to
have_link
(
'Jobs'
)
expect
(
page
).
to
have_link
(
'Jobs'
)
expect
(
page
).
to
have_link
(
'Failed Jobs'
)
end
end
it
'shows counter in Jobs tab'
do
it
'shows counter in Jobs tab'
do
...
@@ -165,6 +167,16 @@ describe 'Pipeline', :js do
...
@@ -165,6 +167,16 @@ describe 'Pipeline', :js do
it
'shows Pipeline tab as active'
do
it
'shows Pipeline tab as active'
do
expect
(
page
).
to
have_css
(
'.js-pipeline-tab-link.active'
)
expect
(
page
).
to
have_css
(
'.js-pipeline-tab-link.active'
)
end
end
context
'without permission to access builds'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
public_builds:
false
)
}
let
(
:role
)
{
:guest
}
it
'does not show failed jobs tab pane'
do
expect
(
page
).
to
have_link
(
'Pipeline'
)
expect
(
page
).
not_to
have_content
(
'Failed Jobs'
)
end
end
end
end
context
'retrying jobs'
do
context
'retrying jobs'
do
...
@@ -308,8 +320,7 @@ describe 'Pipeline', :js do
...
@@ -308,8 +320,7 @@ describe 'Pipeline', :js do
end
end
describe
'GET /:project/pipelines/:id/failures'
do
describe
'GET /:project/pipelines/:id/failures'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
ref:
'master'
,
sha:
'1234'
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
ref:
'master'
,
sha:
project
.
commit
.
id
)
}
let
(
:pipeline_failures_page
)
{
failures_project_pipeline_path
(
project
,
pipeline
)
}
let
(
:pipeline_failures_page
)
{
failures_project_pipeline_path
(
project
,
pipeline
)
}
let!
(
:failed_build
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
let!
(
:failed_build
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
...
@@ -340,11 +351,39 @@ describe 'Pipeline', :js do
...
@@ -340,11 +351,39 @@ describe 'Pipeline', :js do
visit
pipeline_failures_page
visit
pipeline_failures_page
end
end
it
'includes failed jobs'
do
it
'shows jobs tab pane as active'
do
expect
(
page
).
to
have_content
(
'Failed Jobs'
)
expect
(
page
).
to
have_css
(
'#js-tab-failures.active'
)
end
it
'lists failed builds'
do
expect
(
page
).
to
have_content
(
failed_build
.
name
)
expect
(
page
).
to
have_content
(
failed_build
.
stage
)
end
it
'does not show trace'
do
expect
(
page
).
to
have_content
(
'No job trace'
)
expect
(
page
).
to
have_content
(
'No job trace'
)
end
end
end
end
context
'without permission to access builds'
do
let
(
:role
)
{
:guest
}
before
do
project
.
update
(
public_builds:
false
)
end
context
'when accessing failed jobs page'
do
before
do
visit
pipeline_failures_page
end
it
'fails to access the page'
do
expect
(
page
).
to
have_content
(
'Access Denied'
)
end
end
end
context
'without failures'
do
context
'without failures'
do
before
do
before
do
failed_build
.
update!
(
status: :success
)
failed_build
.
update!
(
status: :success
)
...
...
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