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
Léo-Paul Géneau
gitlab-ce
Commits
71fc37c9
Commit
71fc37c9
authored
Sep 27, 2018
by
Shinya Maeda
Committed by
Alessio Caiazza
Oct 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for BuildScheduleWorker and RunScheduledBuildService
parent
80a92650
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
0 deletions
+102
-0
spec/services/ci/run_scheduled_build_service_spec.rb
spec/services/ci/run_scheduled_build_service_spec.rb
+62
-0
spec/workers/ci/build_schedule_worker_spec.rb
spec/workers/ci/build_schedule_worker_spec.rb
+40
-0
No files found.
spec/services/ci/run_scheduled_build_service_spec.rb
0 → 100644
View file @
71fc37c9
require
'spec_helper'
describe
Ci
::
RunScheduledBuildService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
subject
{
described_class
.
new
(
project
,
user
).
execute
(
build
)
}
context
'when user can update build'
do
before
do
project
.
add_developer
(
user
)
create
(
:protected_branch
,
:developers_can_merge
,
name:
pipeline
.
ref
,
project:
project
)
end
context
'when build is scheduled'
do
context
'when scheduled_at is expired'
do
let
(
:build
)
{
create
(
:ci_build
,
:expired_scheduled
,
user:
user
,
project:
project
,
pipeline:
pipeline
)
}
it
'can run the build'
do
expect
{
subject
}.
not_to
raise_error
expect
(
build
).
to
be_pending
end
end
context
'when scheduled_at is not expired'
do
let
(
:build
)
{
create
(
:ci_build
,
:scheduled
,
user:
user
,
project:
project
,
pipeline:
pipeline
)
}
it
'can run the build'
do
expect
{
subject
}.
to
raise_error
(
StateMachines
::
InvalidTransition
)
expect
(
build
).
to
be_scheduled
end
end
end
context
'when build is not scheduled'
do
let
(
:build
)
{
create
(
:ci_build
,
:created
,
user:
user
,
project:
project
,
pipeline:
pipeline
)
}
it
'can not run the build'
do
expect
{
subject
}.
to
raise_error
(
StateMachines
::
InvalidTransition
)
expect
(
build
).
to
be_created
end
end
end
context
'when user can not update build'
do
context
'when build is scheduled'
do
let
(
:build
)
{
create
(
:ci_build
,
:scheduled
,
user:
user
,
project:
project
,
pipeline:
pipeline
)
}
it
'can not run the build'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Access
::
AccessDeniedError
)
expect
(
build
).
to
be_scheduled
end
end
end
end
spec/workers/ci/build_schedule_worker_spec.rb
0 → 100644
View file @
71fc37c9
require
'spec_helper'
describe
Ci
::
BuildScheduleWorker
do
subject
{
described_class
.
new
.
perform
(
build
.
id
)
}
context
'when build is found'
do
context
'when build is scheduled'
do
let
(
:build
)
{
create
(
:ci_build
,
:scheduled
)
}
it
'executes RunScheduledBuildService'
do
expect_any_instance_of
(
Ci
::
RunScheduledBuildService
)
.
to
receive
(
:execute
).
once
subject
end
end
context
'when build is not scheduled'
do
let
(
:build
)
{
create
(
:ci_build
,
:created
)
}
it
'executes RunScheduledBuildService'
do
expect_any_instance_of
(
Ci
::
RunScheduledBuildService
)
.
not_to
receive
(
:execute
)
subject
end
end
end
context
'when build is not found'
do
let
(
:build
)
{
build_stubbed
(
:ci_build
,
:scheduled
)
}
it
'does nothing'
do
expect_any_instance_of
(
Ci
::
RunScheduledBuildService
)
.
not_to
receive
(
:execute
)
subject
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