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
iv
gitlab-ce
Commits
2c4daf1a
Commit
2c4daf1a
authored
Sep 14, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix part of specs
parent
4c53cc0e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
98 deletions
+100
-98
spec/requests/ci/builds_spec.rb
spec/requests/ci/builds_spec.rb
+1
-1
spec/requests/ci/commits_spec.rb
spec/requests/ci/commits_spec.rb
+1
-1
spec/services/ci/create_commit_service_spec.rb
spec/services/ci/create_commit_service_spec.rb
+98
-96
No files found.
spec/requests/ci/builds_spec.rb
View file @
2c4daf1a
...
@@ -9,7 +9,7 @@ describe "Builds" do
...
@@ -9,7 +9,7 @@ describe "Builds" do
describe
"GET /:project/builds/:id/status.json"
do
describe
"GET /:project/builds/:id/status.json"
do
before
do
before
do
get
status_project_build_path
(
@project
,
@build
),
format: :json
get
status_
ci_
project_build_path
(
@project
,
@build
),
format: :json
end
end
it
{
expect
(
response
.
status
).
to
eq
(
200
)
}
it
{
expect
(
response
.
status
).
to
eq
(
200
)
}
...
...
spec/requests/ci/commits_spec.rb
View file @
2c4daf1a
...
@@ -8,7 +8,7 @@ describe "Commits" do
...
@@ -8,7 +8,7 @@ describe "Commits" do
describe
"GET /:project/refs/:ref_name/commits/:id/status.json"
do
describe
"GET /:project/refs/:ref_name/commits/:id/status.json"
do
before
do
before
do
get
status_
project_ref_commit
_path
(
@project
,
@commit
.
ref
,
@commit
.
sha
),
format: :json
get
status_
ci_project_ref_commits
_path
(
@project
,
@commit
.
ref
,
@commit
.
sha
),
format: :json
end
end
it
{
expect
(
response
.
status
).
to
eq
(
200
)
}
it
{
expect
(
response
.
status
).
to
eq
(
200
)
}
...
...
spec/services/ci/create_commit_service_spec.rb
View file @
2c4daf1a
require
'spec_helper'
require
'spec_helper'
describe
Ci
::
CreateCommitService
do
module
Ci
let
(
:service
)
{
CreateCommitService
.
new
}
describe
CreateCommitService
do
let
(
:project
)
{
FactoryGirl
.
create
(
:project
)
}
let
(
:service
)
{
CreateCommitService
.
new
}
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
describe
:execute
do
context
'valid params'
do
describe
:execute
do
let
(
:commit
)
do
context
'valid params'
do
service
.
execute
(
project
,
let
(
:commit
)
do
ref:
'refs/heads/master'
,
service
.
execute
(
project
,
before:
'00000000'
,
ref:
'refs/heads/master'
,
after:
'31das312'
,
before:
'00000000'
,
ci_yaml_file:
gitlab_ci_yaml
,
after:
'31das312'
,
commits:
[
{
message:
"Message"
}
]
ci_yaml_file:
gitlab_ci_yaml
,
)
commits:
[
{
message:
"Message"
}
]
)
end
it
{
expect
(
commit
).
to
be_kind_of
(
Commit
)
}
it
{
expect
(
commit
).
to
be_valid
}
it
{
expect
(
commit
).
to
be_persisted
}
it
{
expect
(
commit
).
to
eq
(
project
.
commits
.
last
)
}
it
{
expect
(
commit
.
builds
.
first
).
to
be_kind_of
(
Build
)
}
end
end
it
{
commit
.
should
be_kind_of
(
Commit
)
}
context
"skip tag if there is no build for it"
do
it
{
commit
.
should
be_valid
}
it
"creates commit if there is appropriate job"
do
it
{
commit
.
should
be_persisted
}
result
=
service
.
execute
(
project
,
it
{
commit
.
should
==
project
.
commits
.
last
}
ref:
'refs/tags/0_1'
,
it
{
commit
.
builds
.
first
.
should
be_kind_of
(
Build
)
}
before:
'00000000'
,
end
after:
'31das312'
,
ci_yaml_file:
gitlab_ci_yaml
,
context
"skip tag if there is no build for it"
do
commits:
[
{
message:
"Message"
}
]
it
"creates commit if there is appropriate job"
do
)
result
=
service
.
execute
(
project
,
expect
(
result
).
to
be_persisted
ref:
'refs/tags/0_1'
,
end
before:
'00000000'
,
after:
'31das312'
,
it
"creates commit if there is no appropriate job but deploy job has right ref setting"
do
ci_yaml_file:
gitlab_ci_yaml
,
config
=
YAML
.
dump
({
deploy:
{
deploy:
"ls"
,
only:
[
"0_1"
]
}
})
commits:
[
{
message:
"Message"
}
]
)
result
=
service
.
execute
(
project
,
result
.
should
be_persisted
ref:
'refs/heads/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
ci_yaml_file:
config
,
commits:
[
{
message:
"Message"
}
]
)
expect
(
result
).
to
be_persisted
end
end
end
it
"creates commit if there is no appropriate job but deploy job has right ref setting"
do
describe
:ci_skip?
do
config
=
YAML
.
dump
({
deploy:
{
deploy:
"ls"
,
only:
[
"0_1"
]
}
})
it
"skips builds creation if there is [ci skip] tag in commit message"
do
commits
=
[{
message:
"some message[ci skip]"
}]
result
=
service
.
execute
(
project
,
commit
=
service
.
execute
(
project
,
ref:
'refs/heads/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
ci_yaml_file:
config
,
commits:
commits
,
commits:
[
{
message:
"Message"
}
]
ci_yaml_file:
gitlab_ci_yaml
)
)
result
.
should
be_persisted
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
end
it
"does not skips builds creation if there is no [ci skip] tag in commit message"
do
commits
=
[{
message:
"some message"
}]
commit
=
service
.
execute
(
project
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
,
ci_yaml_file:
gitlab_ci_yaml
)
expect
(
commit
.
builds
.
first
.
name
).
to
eq
(
"staging"
)
end
it
"skips builds creation if there is [ci skip] tag in commit message and yaml is invalid"
do
commits
=
[{
message:
"some message[ci skip]"
}]
commit
=
service
.
execute
(
project
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
,
ci_yaml_file:
"invalid: file"
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
end
end
end
end
describe
:ci_skip?
do
it
"skips build creation if there are already builds"
do
it
"skips builds creation if there is [ci skip] tag in commit message"
do
commits
=
[{
message:
"message"
}]
commits
=
[{
message:
"some message[ci skip]"
}]
commit
=
service
.
execute
(
project
,
commit
=
service
.
execute
(
project
,
ref:
'refs/
tags/0_1
'
,
ref:
'refs/
heads/master
'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
,
commits:
commits
,
ci_yaml_file:
gitlab_ci_yaml
ci_yaml_file:
gitlab_ci_yaml
)
)
commit
.
builds
.
any?
.
should
be_false
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
commit
.
status
.
should
==
"skipped"
end
it
"does not skips builds creation if there is no [ci skip] tag in commit message"
do
commits
=
[{
message:
"some message"
}]
commit
=
service
.
execute
(
project
,
commit
=
service
.
execute
(
project
,
ref:
'refs/
tags/0_1
'
,
ref:
'refs/
heads/master
'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
,
commits:
commits
,
ci_yaml_file:
gitlab_ci_yaml
ci_yaml_file:
gitlab_ci_yaml
)
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
commit
.
builds
.
first
.
name
.
should
==
"staging"
end
end
it
"skips builds creation if there is [ci skip] tag in commit message and yaml is invalid"
do
it
"creates commit with failed status if yaml is invalid"
do
commits
=
[{
message:
"some message[ci skip]"
}]
commits
=
[{
message:
"some message"
}]
commit
=
service
.
execute
(
project
,
commit
=
service
.
execute
(
project
,
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
...
@@ -86,45 +123,10 @@ describe Ci::CreateCommitService do
...
@@ -86,45 +123,10 @@ describe Ci::CreateCommitService do
commits:
commits
,
commits:
commits
,
ci_yaml_file:
"invalid: file"
ci_yaml_file:
"invalid: file"
)
)
commit
.
builds
.
any?
.
should
be_false
commit
.
status
.
should
==
"skipped"
end
end
it
"skips build creation if there are already builds"
do
commits
=
[{
message:
"message"
}]
commit
=
service
.
execute
(
project
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
,
ci_yaml_file:
gitlab_ci_yaml
)
commit
.
builds
.
count
(
:all
).
should
==
2
commit
=
service
.
execute
(
project
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
,
ci_yaml_file:
gitlab_ci_yaml
)
commit
.
builds
.
count
(
:all
).
should
==
2
end
it
"creates commit with failed status if yaml is invalid"
do
expect
(
commit
.
status
).
to
eq
(
"failed"
)
commits
=
[{
message:
"some message"
}]
expect
(
commit
.
builds
.
any?
).
to
be
false
end
commit
=
service
.
execute
(
project
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
,
ci_yaml_file:
"invalid: file"
)
commit
.
status
.
should
==
"failed"
commit
.
builds
.
any?
.
should
be_false
end
end
end
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