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
b08912db
Commit
b08912db
authored
Jun 07, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use block for before/after as we preferred
parent
781d35c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
22 deletions
+67
-22
spec/models/build_spec.rb
spec/models/build_spec.rb
+67
-22
No files found.
spec/models/build_spec.rb
View file @
b08912db
...
@@ -36,32 +36,44 @@ describe Ci::Build, models: true do
...
@@ -36,32 +36,44 @@ describe Ci::Build, models: true do
subject
{
build
.
ignored?
}
subject
{
build
.
ignored?
}
context
'if build is not allowed to fail'
do
context
'if build is not allowed to fail'
do
before
{
build
.
allow_failure
=
false
}
before
do
build
.
allow_failure
=
false
end
context
'and build.status is success'
do
context
'and build.status is success'
do
before
{
build
.
status
=
'success'
}
before
do
build
.
status
=
'success'
end
it
{
is_expected
.
to
be_falsey
}
it
{
is_expected
.
to
be_falsey
}
end
end
context
'and build.status is failed'
do
context
'and build.status is failed'
do
before
{
build
.
status
=
'failed'
}
before
do
build
.
status
=
'failed'
end
it
{
is_expected
.
to
be_falsey
}
it
{
is_expected
.
to
be_falsey
}
end
end
end
end
context
'if build is allowed to fail'
do
context
'if build is allowed to fail'
do
before
{
build
.
allow_failure
=
true
}
before
do
build
.
allow_failure
=
true
end
context
'and build.status is success'
do
context
'and build.status is success'
do
before
{
build
.
status
=
'success'
}
before
do
build
.
status
=
'success'
end
it
{
is_expected
.
to
be_falsey
}
it
{
is_expected
.
to
be_falsey
}
end
end
context
'and build.status is failed'
do
context
'and build.status is failed'
do
before
{
build
.
status
=
'failed'
}
before
do
build
.
status
=
'failed'
end
it
{
is_expected
.
to
be_truthy
}
it
{
is_expected
.
to
be_truthy
}
end
end
...
@@ -75,7 +87,9 @@ describe Ci::Build, models: true do
...
@@ -75,7 +87,9 @@ describe Ci::Build, models: true do
context
'if build.trace contains text'
do
context
'if build.trace contains text'
do
let
(
:text
)
{
'example output'
}
let
(
:text
)
{
'example output'
}
before
{
build
.
trace
=
text
}
before
do
build
.
trace
=
text
end
it
{
is_expected
.
to
include
(
text
)
}
it
{
is_expected
.
to
include
(
text
)
}
it
{
expect
(
subject
.
length
).
to
be
>=
text
.
length
}
it
{
expect
(
subject
.
length
).
to
be
>=
text
.
length
}
...
@@ -188,7 +202,9 @@ describe Ci::Build, models: true do
...
@@ -188,7 +202,9 @@ describe Ci::Build, models: true do
]
]
end
end
before
{
build
.
update_attributes
(
stage:
'stage'
)
}
before
do
build
.
update_attributes
(
stage:
'stage'
)
end
it
{
is_expected
.
to
eq
(
predefined_variables
+
yaml_variables
)
}
it
{
is_expected
.
to
eq
(
predefined_variables
+
yaml_variables
)
}
...
@@ -199,7 +215,9 @@ describe Ci::Build, models: true do
...
@@ -199,7 +215,9 @@ describe Ci::Build, models: true do
]
]
end
end
before
{
build
.
update_attributes
(
tag:
true
)
}
before
do
build
.
update_attributes
(
tag:
true
)
end
it
{
is_expected
.
to
eq
(
tag_variable
+
predefined_variables
+
yaml_variables
)
}
it
{
is_expected
.
to
eq
(
tag_variable
+
predefined_variables
+
yaml_variables
)
}
end
end
...
@@ -260,7 +278,9 @@ describe Ci::Build, models: true do
...
@@ -260,7 +278,9 @@ describe Ci::Build, models: true do
describe
'#can_be_served?'
do
describe
'#can_be_served?'
do
let
(
:runner
)
{
create
(
:ci_runner
)
}
let
(
:runner
)
{
create
(
:ci_runner
)
}
before
{
build
.
project
.
runners
<<
runner
}
before
do
build
.
project
.
runners
<<
runner
end
context
'when runner does not have tags'
do
context
'when runner does not have tags'
do
it
'can handle builds without tags'
do
it
'can handle builds without tags'
do
...
@@ -274,7 +294,9 @@ describe Ci::Build, models: true do
...
@@ -274,7 +294,9 @@ describe Ci::Build, models: true do
end
end
context
'when runner has tags'
do
context
'when runner has tags'
do
before
{
runner
.
tag_list
=
[
'bb'
,
'cc'
]
}
before
do
runner
.
tag_list
=
[
'bb'
,
'cc'
]
end
shared_examples
'tagged build picker'
do
shared_examples
'tagged build picker'
do
it
'can handle build with matching tags'
do
it
'can handle build with matching tags'
do
...
@@ -297,7 +319,9 @@ describe Ci::Build, models: true do
...
@@ -297,7 +319,9 @@ describe Ci::Build, models: true do
end
end
context
'when runner cannot pick untagged jobs'
do
context
'when runner cannot pick untagged jobs'
do
before
{
runner
.
run_untagged
=
false
}
before
do
runner
.
run_untagged
=
false
end
it
'cannot handle builds without tags'
do
it
'cannot handle builds without tags'
do
expect
(
build
.
can_be_served?
(
runner
)).
to
be_falsey
expect
(
build
.
can_be_served?
(
runner
)).
to
be_falsey
...
@@ -308,11 +332,15 @@ describe Ci::Build, models: true do
...
@@ -308,11 +332,15 @@ describe Ci::Build, models: true do
end
end
context
'when runner is locked'
do
context
'when runner is locked'
do
before
{
runner
.
locked
=
true
}
before
do
runner
.
locked
=
true
end
shared_examples
'locked build picker'
do
|
serve_matching_tags
|
shared_examples
'locked build picker'
do
|
serve_matching_tags
|
context
'when runner cannot pick untagged jobs'
do
context
'when runner cannot pick untagged jobs'
do
before
{
runner
.
run_untagged
=
false
}
before
do
runner
.
run_untagged
=
false
end
it
'cannot handle builds without tags'
do
it
'cannot handle builds without tags'
do
expect
(
build
.
can_be_served?
(
runner
)).
to
be_falsey
expect
(
build
.
can_be_served?
(
runner
)).
to
be_falsey
...
@@ -320,7 +348,9 @@ describe Ci::Build, models: true do
...
@@ -320,7 +348,9 @@ describe Ci::Build, models: true do
end
end
context
'when having runner tags'
do
context
'when having runner tags'
do
before
{
runner
.
tag_list
=
[
'bb'
,
'cc'
]
}
before
do
runner
.
tag_list
=
[
'bb'
,
'cc'
]
end
it
"
#{
serve_matching_tags
}
handle it for matching tags"
do
it
"
#{
serve_matching_tags
}
handle it for matching tags"
do
build
.
tag_list
=
[
'bb'
]
build
.
tag_list
=
[
'bb'
]
...
@@ -348,7 +378,9 @@ describe Ci::Build, models: true do
...
@@ -348,7 +378,9 @@ describe Ci::Build, models: true do
end
end
context
'serving a different project'
do
context
'serving a different project'
do
before
{
runner
.
runner_projects
.
destroy_all
}
before
do
runner
.
runner_projects
.
destroy_all
end
it
'cannot handle it'
do
it
'cannot handle it'
do
expect
(
build
.
can_be_served?
(
runner
)).
to
be_falsey
expect
(
build
.
can_be_served?
(
runner
)).
to
be_falsey
...
@@ -411,7 +443,9 @@ describe Ci::Build, models: true do
...
@@ -411,7 +443,9 @@ describe Ci::Build, models: true do
%w(pending)
.
each
do
|
state
|
%w(pending)
.
each
do
|
state
|
context
"if commit_status.status is
#{
state
}
"
do
context
"if commit_status.status is
#{
state
}
"
do
before
{
build
.
status
=
state
}
before
do
build
.
status
=
state
end
it
{
is_expected
.
to
be_truthy
}
it
{
is_expected
.
to
be_truthy
}
...
@@ -430,7 +464,9 @@ describe Ci::Build, models: true do
...
@@ -430,7 +464,9 @@ describe Ci::Build, models: true do
%w(success failed canceled running)
.
each
do
|
state
|
%w(success failed canceled running)
.
each
do
|
state
|
context
"if commit_status.status is
#{
state
}
"
do
context
"if commit_status.status is
#{
state
}
"
do
before
{
build
.
status
=
state
}
before
do
build
.
status
=
state
end
it
{
is_expected
.
to
be_falsey
}
it
{
is_expected
.
to
be_falsey
}
end
end
...
@@ -441,7 +477,10 @@ describe Ci::Build, models: true do
...
@@ -441,7 +477,10 @@ describe Ci::Build, models: true do
subject
{
build
.
artifacts?
}
subject
{
build
.
artifacts?
}
context
'artifacts archive does not exist'
do
context
'artifacts archive does not exist'
do
before
{
build
.
update_attributes
(
artifacts_file:
nil
)
}
before
do
build
.
update_attributes
(
artifacts_file:
nil
)
end
it
{
is_expected
.
to
be_falsy
}
it
{
is_expected
.
to
be_falsy
}
end
end
...
@@ -606,7 +645,9 @@ describe Ci::Build, models: true do
...
@@ -606,7 +645,9 @@ describe Ci::Build, models: true do
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:success
,
:artifacts
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:success
,
:artifacts
)
}
describe
'#erase'
do
describe
'#erase'
do
before
{
build
.
erase
(
erased_by:
user
)
}
before
do
build
.
erase
(
erased_by:
user
)
end
context
'erased by user'
do
context
'erased by user'
do
let!
(
:user
)
{
create
(
:user
,
username:
'eraser'
)
}
let!
(
:user
)
{
create
(
:user
,
username:
'eraser'
)
}
...
@@ -643,7 +684,9 @@ describe Ci::Build, models: true do
...
@@ -643,7 +684,9 @@ describe Ci::Build, models: true do
end
end
context
'build has been erased'
do
context
'build has been erased'
do
before
{
build
.
erase
}
before
do
build
.
erase
end
it
{
is_expected
.
to
be
true
}
it
{
is_expected
.
to
be
true
}
end
end
...
@@ -651,7 +694,9 @@ describe Ci::Build, models: true do
...
@@ -651,7 +694,9 @@ describe Ci::Build, models: true do
context
'metadata and build trace are not available'
do
context
'metadata and build trace are not available'
do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:artifacts
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:artifacts
)
}
before
{
build
.
remove_artifacts_metadata!
}
before
do
build
.
remove_artifacts_metadata!
end
describe
'#erase'
do
describe
'#erase'
do
it
'should not raise error'
do
it
'should not raise error'
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