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
c82d8413
Commit
c82d8413
authored
Oct 13, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak some spec syntax
- Remove old file
parent
2d77fed6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
15 deletions
+20
-15
ee/app/workers/incident_management/incident_sla_exceeded_check_worker.rb
...incident_management/incident_sla_exceeded_check_worker.rb
+2
-3
ee/spec/models/issuable_sla_spec.rb
ee/spec/models/issuable_sla_spec.rb
+8
-5
ee/spec/services/incident_management/apply_incident_sla_exceeded_label_service_spec.rb
...agement/apply_incident_sla_exceeded_label_service_spec.rb
+6
-2
ee/spec/workers/incident_management/incident_sla_exceeded_check_worker_spec.rb
...ent_management/incident_sla_exceeded_check_worker_spec.rb
+4
-5
No files found.
ee/app/workers/incident_management/incident_sla_exceeded_check_worker.rb
View file @
c82d8413
...
...
@@ -5,16 +5,15 @@ module IncidentManagement
include
ApplicationWorker
include
CronjobQueue
# rubocop:disable Scalability/CronWorkerContext
idempotent!
feature_category
:incident_management
def
perform
I
ncidentSla
.
exceeded
.
find_in_batches
do
|
incident_slas
|
I
ssuableSla
.
exceeded_for_issues
.
find_in_batches
do
|
incident_slas
|
incident_slas
.
each
do
|
incident_sla
|
ApplyIncidentSlaExceededLabelService
.
new
(
incident_sla
.
issue
).
execute
rescue
StandardError
=>
e
rescue
StandardError
=>
e
Gitlab
::
AppLogger
.
error
(
"Error encountered in
#{
self
.
class
.
name
}
:
#{
e
}
"
)
end
end
...
...
ee/spec/models/issuable_sla_spec.rb
View file @
c82d8413
...
...
@@ -16,19 +16,22 @@ RSpec.describe IssuableSla do
subject
{
described_class
.
exceeded_for_issues
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let!
(
:issuable_sla
)
{
create
(
:issuable_sla
,
issue:
issue
,
due_at:
due_at
)
}
let
(
:due_at
)
{
Time
.
current
-
1
.
hour
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let_it_be_with_reload
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let_it_be_with_reload
(
:issuable_sla
)
{
create
(
:issuable_sla
,
issue:
issue
,
due_at:
Time
.
current
-
1
.
hour
)
}
context
'issue closed'
do
let
(
:issue
)
{
create
(
:issue
,
:closed
,
project:
project
)
}
before
do
issue
.
close!
end
it
{
is_expected
.
to
be_empty
}
end
context
'issue opened'
do
context
'due_at has not passed'
do
let
(
:due_at
)
{
Time
.
current
+
1
.
hour
}
before
do
issuable_sla
.
update!
(
due_at:
Time
.
current
+
1
.
hour
)
end
it
{
is_expected
.
to
be_empty
}
end
...
...
ee/spec/services/incident_management/apply_incident_sla_exceeded_label_service_spec.rb
View file @
c82d8413
...
...
@@ -12,7 +12,7 @@ RSpec.describe IncidentManagement::ApplyIncidentSlaExceededLabelService do
.
payload
[
:label
]
end
subject
{
described_class
.
new
(
incident
).
execute
}
subject
(
:apply_label
)
{
described_class
.
new
(
incident
).
execute
}
context
'label exists already'
do
before
do
...
...
@@ -25,7 +25,11 @@ RSpec.describe IncidentManagement::ApplyIncidentSlaExceededLabelService do
end
it
'adds a label to the incident'
do
expect
{
subject
}.
to
change
{
incident
.
labels
.
reload
.
count
}
expect
{
apply_label
}.
to
change
{
incident
.
labels
.
reload
.
count
}.
by
(
1
)
expected_props
=
IncidentManagement
::
CreateIncidentSlaExceededLabelService
::
LABEL_PROPERTIES
expect
(
apply_label
).
to
have_attributes
(
expected_props
)
end
it
'adds a note that the label was added'
do
...
...
ee/spec/workers/incident_management/incident_sla_exceeded_check_worker_spec.rb
View file @
c82d8413
...
...
@@ -8,9 +8,8 @@ RSpec.describe IncidentManagement::IncidentSlaExceededCheckWorker do
describe
'#perform'
do
subject
(
:perform
)
{
worker
.
perform
}
let_it_be
(
:incident_1
)
{
create
(
:incident_sla
,
:exceeded
)
}
let_it_be
(
:incident_2
)
{
create
(
:incident_sla
,
:exceeded
)
}
let_it_be
(
:incident_3
)
{
create
(
:incident_sla
,
:exceeded
)
}
let_it_be
(
:incident_sla
)
{
create
(
:issuable_sla
,
:exceeded
)
}
let_it_be
(
:other_incident_slas
)
{
create_list
(
:issuable_sla
,
2
,
:exceeded
)
}
let
(
:label_service_stub
)
{
instance_double
(
IncidentManagement
::
ApplyIncidentSlaExceededLabelService
,
execute:
true
)
}
...
...
@@ -33,13 +32,13 @@ RSpec.describe IncidentManagement::IncidentSlaExceededCheckWorker do
allow
(
IncidentManagement
::
ApplyIncidentSlaExceededLabelService
)
.
to
receive
(
:new
)
.
with
(
incident_
1
.
issue
)
.
with
(
incident_
sla
.
issue
)
.
and_raise
(
'test'
)
end
it
'logs the error and continues to run the others'
do
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
once
expect
(
label_service_stub
).
to
receive
(
:execute
).
exactly
(
2
).
times
expect
(
label_service_stub
).
to
receive
(
:execute
).
twice
perform
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