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
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
Hide 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,31 +3,70 @@ require 'spec_helper'
...
@@ -3,31 +3,70 @@ 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 success'
do
context
'build exists'
do
before
{
build
.
success!
}
let
(
:ci_commit
)
{
create
(
:ci_commit
,
project:
project
,
sha:
sha
)
}
let!
(
:build
)
{
create
(
:ci_build
,
commit:
ci_commit
)
}
context
'build success'
do
before
{
build
.
success!
}
describe
'#to_s'
do
subject
{
badge
.
to_s
}
it
{
is_expected
.
to
eq
'build-success'
}
end
describe
'#data'
do
let
(
:data
)
{
badge
.
data
}
it
'contains infromation about success'
do
expect
(
status_node
(
data
,
'success'
)).
to
be_truthy
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
describe
'#to_s'
do
subject
{
badge
.
to_s
}
subject
{
badge
.
to_s
}
it
{
is_expected
.
to
eq
'build-
success
'
}
it
{
is_expected
.
to
eq
'build-
unknown
'
}
end
end
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
unknown build
'
do
expect
(
xml
.
at
(
%Q{text:contains("success")}
)).
to
be_truthy
expect
(
status_node
(
data
,
'unknown'
)).
to
be_truthy
end
end
end
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