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
fff6afba
Commit
fff6afba
authored
Apr 06, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use change direction in spec
parent
059ec792
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
20 deletions
+13
-20
spec/workers/trigger_schedule_worker_spec.rb
spec/workers/trigger_schedule_worker_spec.rb
+13
-20
No files found.
spec/workers/trigger_schedule_worker_spec.rb
View file @
fff6afba
...
@@ -8,58 +8,51 @@ describe TriggerScheduleWorker do
...
@@ -8,58 +8,51 @@ describe TriggerScheduleWorker do
end
end
context
'when there is a scheduled trigger within next_run_at'
do
context
'when there is a scheduled trigger within next_run_at'
do
let!
(
:trigger_schedule
)
{
create
(
:ci_trigger_schedule
,
:nightly
)
}
let
(
:next_time
)
{
Gitlab
::
Ci
::
CronParser
.
new
(
trigger_schedule
.
cron
,
trigger_schedule
.
cron_timezone
).
next_time_from
(
@time_future
)
}
before
do
before
do
@time_future
=
Time
.
now
+
10
.
days
trigger_schedule
=
create
(
:ci_trigger_schedule
,
:nightly
)
allow
(
Time
).
to
receive
(
:now
).
and_return
(
@time_future
)
time_future
=
Time
.
now
+
10
.
days
worker
.
perform
allow
(
Time
).
to
receive
(
:now
).
and_return
(
time_future
)
@next_time
=
Gitlab
::
Ci
::
CronParser
.
new
(
trigger_schedule
.
cron
,
trigger_schedule
.
cron_timezone
).
next_time_from
(
time_future
)
end
end
it
'creates a new trigger request'
do
it
'creates a new trigger request'
do
expect
(
trigger_schedule
.
trigger
.
id
).
to
eq
(
Ci
::
TriggerRequest
.
first
.
trigger_id
)
expect
{
worker
.
perform
}.
to
change
{
Ci
::
TriggerRequest
.
count
}.
by
(
1
)
end
end
it
'creates a new pipeline'
do
it
'creates a new pipeline'
do
expect
{
worker
.
perform
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
1
)
expect
(
Ci
::
Pipeline
.
last
).
to
be_pending
expect
(
Ci
::
Pipeline
.
last
).
to
be_pending
end
end
it
'updates next_run_at'
do
it
'updates next_run_at'
do
expect
(
Ci
::
TriggerSchedule
.
last
.
next_run_at
).
to
eq
(
next_time
)
expect
{
worker
.
perform
}.
to
change
{
Ci
::
TriggerSchedule
.
last
.
next_run_at
}.
to
(
@
next_time
)
end
end
end
end
context
'when there are no scheduled triggers within next_run_at'
do
context
'when there are no scheduled triggers within next_run_at'
do
let!
(
:trigger_schedule
)
{
create
(
:ci_trigger_schedule
,
:nightly
)
}
before
{
create
(
:ci_trigger_schedule
,
:nightly
)
}
before
do
worker
.
perform
end
it
'does not create a new pipeline'
do
it
'does not create a new pipeline'
do
expect
(
Ci
::
Pipeline
.
count
).
to
eq
(
0
)
expect
{
worker
.
perform
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
end
end
it
'does not update next_run_at'
do
it
'does not update next_run_at'
do
expect
(
trigger_schedule
.
next_run_at
).
to
eq
(
Ci
::
TriggerSchedule
.
last
.
next_run_at
)
expect
{
worker
.
perform
}.
not_to
change
{
Ci
::
TriggerSchedule
.
last
.
next_run_at
}
end
end
end
end
context
'when next_run_at is nil'
do
context
'when next_run_at is nil'
do
let!
(
:trigger_schedule
)
{
create
(
:ci_trigger_schedule
,
:nightly
)
}
before
do
before
do
trigger_schedule
=
create
(
:ci_trigger_schedule
,
:nightly
)
trigger_schedule
.
update_attribute
(
:next_run_at
,
nil
)
trigger_schedule
.
update_attribute
(
:next_run_at
,
nil
)
worker
.
perform
end
end
it
'does not create a new pipeline'
do
it
'does not create a new pipeline'
do
expect
(
Ci
::
Pipeline
.
count
).
to
eq
(
0
)
expect
{
worker
.
perform
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
end
end
it
'does not update next_run_at'
do
it
'does not update next_run_at'
do
expect
(
trigger_schedule
.
next_run_at
).
to
eq
(
Ci
::
TriggerSchedule
.
last
.
next_run_at
)
expect
{
worker
.
perform
}.
not_to
change
{
Ci
::
TriggerSchedule
.
last
.
next_run_at
}
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