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
a067865d
Commit
a067865d
authored
Jun 25, 2020
by
Allison Browne
Committed by
Heinrich Lee Yu
Jun 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs and namespace BuildsHelper
BuildsHelper => Ci::BuildsHelper
parent
a24a69ac
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
151 additions
and
38 deletions
+151
-38
app/helpers/builds_helper.rb
app/helpers/builds_helper.rb
+0
-38
app/helpers/ci/builds_helper.rb
app/helpers/ci/builds_helper.rb
+40
-0
spec/helpers/ci/builds_helper_spec.rb
spec/helpers/ci/builds_helper_spec.rb
+111
-0
No files found.
app/helpers/builds_helper.rb
deleted
100644 → 0
View file @
a24a69ac
# frozen_string_literal: true
module
BuildsHelper
def
build_summary
(
build
,
skip:
false
)
if
build
.
has_trace?
if
skip
link_to
_
(
"View job log"
),
pipeline_job_url
(
build
.
pipeline
,
build
)
else
build
.
trace
.
html
(
last_lines:
10
).
html_safe
end
else
_
(
"No job log"
)
end
end
def
sidebar_build_class
(
build
,
current_build
)
build_class
=
[]
build_class
<<
'active'
if
build
.
id
===
current_build
.
id
build_class
<<
'retried'
if
build
.
retried?
build_class
.
join
(
' '
)
end
def
javascript_build_options
{
page_path:
project_job_path
(
@project
,
@build
),
build_status:
@build
.
status
,
build_stage:
@build
.
stage
,
log_state:
''
}
end
def
build_failed_issue_options
{
title:
_
(
"Job Failed #%{build_id}"
)
%
{
build_id:
@build
.
id
},
description:
project_job_url
(
@project
,
@build
)
}
end
end
app/helpers/ci/builds_helper.rb
0 → 100644
View file @
a067865d
# frozen_string_literal: true
module
Ci
module
BuildsHelper
def
build_summary
(
build
,
skip:
false
)
if
build
.
has_trace?
if
skip
link_to
_
(
'View job log'
),
pipeline_job_url
(
build
.
pipeline
,
build
)
else
build
.
trace
.
html
(
last_lines:
10
).
html_safe
end
else
_
(
'No job log'
)
end
end
def
sidebar_build_class
(
build
,
current_build
)
build_class
=
[]
build_class
<<
'active'
if
build
.
id
===
current_build
.
id
build_class
<<
'retried'
if
build
.
retried?
build_class
.
join
(
' '
)
end
def
javascript_build_options
{
page_path:
project_job_path
(
@project
,
@build
),
build_status:
@build
.
status
,
build_stage:
@build
.
stage
,
log_state:
''
}
end
def
build_failed_issue_options
{
title:
_
(
"Job Failed #%{build_id}"
)
%
{
build_id:
@build
.
id
},
description:
project_job_url
(
@project
,
@build
)
}
end
end
end
spec/helpers/ci/builds_helper_spec.rb
0 → 100644
View file @
a067865d
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Ci
::
BuildsHelper
do
describe
'#build_summary'
do
subject
{
helper
.
build_summary
(
build
,
skip:
skip
)
}
context
'when build has no trace'
do
let
(
:build
)
{
instance_double
(
Ci
::
Build
,
has_trace?:
false
)
}
context
'when skip is false'
do
let
(
:skip
)
{
false
}
it
'returns no job log'
do
expect
(
subject
).
to
eq
(
'No job log'
)
end
end
context
'when skip is true'
do
let
(
:skip
)
{
true
}
it
'returns no job log'
do
expect
(
subject
).
to
eq
(
'No job log'
)
end
end
end
context
'when build has trace'
do
let
(
:build
)
{
create
(
:ci_build
,
:trace_live
)
}
context
'when skip is true'
do
let
(
:skip
)
{
true
}
it
'returns link to logs'
do
expect
(
subject
).
to
include
(
'View job log'
)
expect
(
subject
).
to
include
(
pipeline_job_url
(
build
.
pipeline
,
build
))
end
end
context
'when skip is false'
do
let
(
:skip
)
{
false
}
it
'returns log lines'
do
expect
(
subject
).
to
include
(
build
.
trace
.
html
(
last_lines:
10
).
html_safe
)
end
end
end
end
describe
'#sidebar_build_class'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:build_id
,
:current_build_id
,
:retried
,
:expected_result
)
do
1
|
1
|
true
|
'active retried'
1
|
1
|
false
|
'active'
1
|
2
|
false
|
''
1
|
2
|
true
|
'retried'
end
let
(
:build
)
{
instance_double
(
Ci
::
Build
,
retried?:
retried
,
id:
build_id
)
}
let
(
:current_build
)
{
instance_double
(
Ci
::
Build
,
retried?:
true
,
id:
current_build_id
)
}
subject
{
helper
.
sidebar_build_class
(
build
,
current_build
)
}
with_them
do
it
'builds sidebar html class'
do
expect
(
subject
).
to
eq
(
expected_result
)
end
end
end
describe
'#javascript_build_options'
do
subject
{
helper
.
javascript_build_options
}
it
'returns build options'
do
project
=
assign_project
ci_build
=
assign_build
expect
(
subject
).
to
eq
({
page_path:
project_job_path
(
project
,
ci_build
),
build_status:
ci_build
.
status
,
build_stage:
ci_build
.
stage
,
log_state:
''
})
end
end
describe
'#build_failed_issue_options'
do
subject
{
helper
.
build_failed_issue_options
}
it
'returns failed title and description'
do
project
=
assign_project
ci_build
=
assign_build
expect
(
subject
).
to
eq
(
title:
"Job Failed
\#
#{
ci_build
.
id
}
"
,
description:
project_job_url
(
project
,
ci_build
))
end
end
def
assign_project
build
(
:project
).
tap
do
|
project
|
assign
(
:project
,
project
)
end
end
def
assign_build
create
(
:ci_build
).
tap
do
|
ci_build
|
assign
(
:build
,
ci_build
)
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