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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
d6097ca4
Commit
d6097ca4
authored
Mar 29, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend specs for build badge
parent
4cd1b9f4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
9 deletions
+48
-9
spec/lib/gitlab/badge/build_spec.rb
spec/lib/gitlab/badge/build_spec.rb
+48
-9
No files found.
spec/lib/gitlab/badge/build_spec.rb
View file @
d6097ca4
...
@@ -3,16 +3,18 @@ require 'spec_helper'
...
@@ -3,16 +3,18 @@ require 'spec_helper'
describe
Gitlab
::
Badge
::
Build
do
describe
Gitlab
::
Badge
::
Build
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:sha
)
{
project
.
commit
.
sha
}
let
(
:sha
)
{
project
.
commit
.
sha
}
let
(
:ci_commit
)
{
create
(
:ci_commit
,
project:
project
,
sha:
sha
)
}
let
(
:badge
)
{
described_class
.
new
(
project
,
'master'
)
}
let
(
:badge
)
{
described_class
.
new
(
project
,
'master'
)
}
let!
(
:build
)
{
create
(
:ci_build
,
commit:
ci_commit
)
}
describe
'#type'
do
describe
'#type'
do
subject
{
badge
.
type
}
subject
{
badge
.
type
}
it
{
is_expected
.
to
eq
'image/svg+xml'
}
it
{
is_expected
.
to
eq
'image/svg+xml'
}
end
end
context
'build exists'
do
let
(
:ci_commit
)
{
create
(
:ci_commit
,
project:
project
,
sha:
sha
)
}
let!
(
:build
)
{
create
(
:ci_build
,
commit:
ci_commit
)
}
context
'build success'
do
context
'build success'
do
before
{
build
.
success!
}
before
{
build
.
success!
}
...
@@ -23,11 +25,48 @@ describe Gitlab::Badge::Build do
...
@@ -23,11 +25,48 @@ describe Gitlab::Badge::Build do
describe
'#data'
do
describe
'#data'
do
let
(
:data
)
{
badge
.
data
}
let
(
:data
)
{
badge
.
data
}
let
(
:xml
)
{
Nokogiri
::
XML
.
parse
(
data
)
}
it
'contains infromation about success'
do
it
'contains infromation about success'
do
expect
(
xml
.
at
(
%Q{text:contains("success")}
)).
to
be_truthy
expect
(
status_node
(
data
,
'success'
)).
to
be_truthy
end
end
end
end
end
end
context
'build failed'
do
before
{
build
.
drop!
}
describe
'#to_s'
do
subject
{
badge
.
to_s
}
it
{
is_expected
.
to
eq
'build-failed'
}
end
describe
'#data'
do
let
(
:data
)
{
badge
.
data
}
it
'contains infromation about failure'
do
expect
(
status_node
(
data
,
'failed'
)).
to
be_truthy
end
end
end
end
context
'build does not exist'
do
describe
'#to_s'
do
subject
{
badge
.
to_s
}
it
{
is_expected
.
to
eq
'build-unknown'
}
end
describe
'#data'
do
let
(
:data
)
{
badge
.
data
}
it
'contains infromation about unknown build'
do
expect
(
status_node
(
data
,
'unknown'
)).
to
be_truthy
end
end
end
def
status_node
(
data
,
status
)
xml
=
Nokogiri
::
XML
.
parse
(
data
)
xml
.
at
(
%Q{text:contains("
#{
status
}
")}
)
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