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
94c60821
Commit
94c60821
authored
Jun 24, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
a7bd14d4
a949cc35
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
13 deletions
+47
-13
doc/development/reusing_abstractions.md
doc/development/reusing_abstractions.md
+36
-0
lib/gitlab/ci/ansi2html.rb
lib/gitlab/ci/ansi2html.rb
+1
-3
spec/lib/gitlab/ci/ansi2html_spec.rb
spec/lib/gitlab/ci/ansi2html_spec.rb
+4
-4
spec/lib/gitlab/ci/trace/stream_spec.rb
spec/lib/gitlab/ci/trace/stream_spec.rb
+5
-5
spec/support/shared_examples/ci_trace_shared_examples.rb
spec/support/shared_examples/ci_trace_shared_examples.rb
+1
-1
No files found.
doc/development/reusing_abstractions.md
View file @
94c60821
...
...
@@ -127,6 +127,42 @@ Everything in `lib/api`.
Everything that resides in
`app/services`
.
#### ServiceResponse
Service classes usually have an
`execute`
method, which can return a
`ServiceResponse`
. You can use
`ServiceResponse.success`
and
`ServiceResponse.error`
to return a response in
`execute`
method.
In a successful case:
```
ruby
response
=
ServiceResponse
.
success
(
message:
'Branch was deleted'
)
response
.
success?
# => true
response
.
error?
# => false
response
.
status
# => :success
response
.
message
# => 'Branch was deleted'
```
In a failed case:
```
ruby
response
=
ServiceResponse
.
error
(
message:
'Unsupported operation'
)
response
.
success?
# => false
response
.
error?
# => true
response
.
status
# => :error
response
.
message
# => 'Unsupported operation'
```
An additional payload can also be attached:
```
ruby
response
=
ServiceResponse
.
success
(
payload:
{
issue:
issue
})
response
.
payload
[
:issue
]
# => issue
```
### Finders
Everything in
`app/finders`
, typically used for retrieving data from a database.
...
...
lib/gitlab/ci/ansi2html.rb
View file @
94c60821
...
...
@@ -200,9 +200,7 @@ module Gitlab
css_classes
=
%w[section line]
+
sections
.
map
{
|
section
|
"s_
#{
section
}
"
}
end
ensure_open_new_tag
write_raw
%{<br/>}
close_open_tags
write_in_tag
%{<br/>}
write_raw
%{<span class="#{css_classes.join(' ')}"></span>}
if
css_classes
.
any?
@lineno_in_section
+=
1
open_new_tag
...
...
spec/lib/gitlab/ci/ansi2html_spec.rb
View file @
94c60821
...
...
@@ -141,11 +141,11 @@ describe Gitlab::Ci::Ansi2html do
end
it
"replaces newlines with line break tags"
do
expect
(
convert_html
(
"
\n
"
)).
to
eq
(
'<span class=""><
/span><br/><span class=""
></span>'
)
expect
(
convert_html
(
"
\n
"
)).
to
eq
(
'<span class=""><
br/><span class=""></span
></span>'
)
end
it
"groups carriage returns with newlines"
do
expect
(
convert_html
(
"
\r\n
"
)).
to
eq
(
'<span class=""><
/span><br/><span class=""
></span>'
)
expect
(
convert_html
(
"
\r\n
"
)).
to
eq
(
'<span class=""><
br/><span class=""></span
></span>'
)
end
describe
"incremental update"
do
...
...
@@ -193,7 +193,7 @@ describe Gitlab::Ci::Ansi2html do
let
(
:pre_text
)
{
"Hello
\r
"
}
let
(
:pre_html
)
{
"<span class=
\"\"
>Hello
\r
</span>"
}
let
(
:text
)
{
"
\n
World"
}
let
(
:html
)
{
"<span class=
\"\"
><
/span><br/><span class=
\"\"
>World
</span>"
}
let
(
:html
)
{
"<span class=
\"\"
><
br/><span class=
\"\"
>World</span>
</span>"
}
it_behaves_like
'stateable converter'
end
...
...
@@ -232,7 +232,7 @@ describe Gitlab::Ci::Ansi2html do
it
'prints light red'
do
text
=
"
#{
section_start
}
\e
[91mHello
\e
[0m
\n
#{
section_end
}
"
header
=
%{<span class="term-fg-l-red section js-section-header section-header js-s-#{class_name(section_name)}">Hello</span>}
line_break
=
%{<span class="section js-section-header section-header js-s-#{class_name(section_name)}"><
/span><br/
>}
line_break
=
%{<span class="section js-section-header section-header js-s-#{class_name(section_name)}"><
br/></span
>}
line
=
%{<span class="section line s_#{class_name(section_name)}"></span>}
empty_line
=
%{<span class="section js-s-#{class_name(section_name)}"></span>}
html
=
"
#{
section_start_html
}#{
header
}#{
line_break
}#{
line
}#{
empty_line
}#{
section_end_html
}
"
...
...
spec/lib/gitlab/ci/trace/stream_spec.rb
View file @
94c60821
...
...
@@ -65,9 +65,9 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
result
=
stream
.
html
expect
(
result
).
to
eq
(
"<span class=
\"\"
>ヾ(´༎ຶД༎ຶ`)ノ<
/span><br/><span class=
\"\"
></span>"
\
"<span class=
\"
term-fg-green
\"
>許功蓋</span><span class=
\"\"
><
/span><
br/>"
\
"<span class=
\"\"
></span>"
)
"<span class=
\"\"
>ヾ(´༎ຶД༎ຶ`)ノ<
br/><span class=
\"\"
></span
></span>"
\
"<span class=
\"
term-fg-green
\"
>許功蓋</span><span class=
\"\"
><br/>"
\
"<span class=
\"\"
></span>
</span>
"
)
expect
(
result
.
encoding
).
to
eq
(
Encoding
.
default_external
)
end
end
...
...
@@ -306,8 +306,8 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
shared_examples_for
'htmls'
do
it
"returns html"
do
expect
(
stream
.
html
).
to
eq
(
"<span class=
\"\"
>12<
/span><br/><span class=
\"\"
>34</span>
<br/>"
\
"<span class=
\"\"
>56</span>"
)
"<span class=
\"\"
>12<
br/><span class=
\"\"
>34
<br/>"
\
"<span class=
\"\"
>56</span>
</span></span>
"
)
end
it
"returns html for last line only"
do
...
...
spec/support/shared_examples/ci_trace_shared_examples.rb
View file @
94c60821
...
...
@@ -5,7 +5,7 @@ shared_examples_for 'common trace features' do
end
it
"returns formatted html"
do
expect
(
trace
.
html
).
to
eq
(
"<span class=
\"\"
>12<
/span><br/><span class=
\"\"
>34
</span>"
)
expect
(
trace
.
html
).
to
eq
(
"<span class=
\"\"
>12<
br/><span class=
\"\"
>34</span>
</span>"
)
end
it
"returns last line of formatted html"
do
...
...
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