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
9160e428
Commit
9160e428
authored
Jul 08, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak & fix alert specs
- Add more cases - Simplify contexts - Fix creating of existing_alert
parent
d61cc087
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
33 deletions
+31
-33
spec/models/alert_management/alert_spec.rb
spec/models/alert_management/alert_spec.rb
+31
-33
No files found.
spec/models/alert_management/alert_spec.rb
View file @
9160e428
...
...
@@ -83,52 +83,50 @@ RSpec.describe AlertManagement::Alert do
end
describe
'fingerprint'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:fingerprint
)
{
'fingerprint'
}
let_it_be
(
:existing_alert
)
{
create
(
:alert_management_alert
,
fingerprint:
fingerprint
)
}
let
(
:new_alert
)
{
build
(
:alert_management_alert
,
fingerprint:
fingerprint
,
project:
project
)
}
subject
{
new_alert
}
context
'adding an alert with the same fingerprint'
do
context
'same project'
do
let
(
:project
)
{
existing_alert
.
project
}
it
{
is_expected
.
not_to
be_valid
}
context
'various states'
do
using
RSpec
::
Parameterized
::
TableSyntax
# We are only validating uniqueness for non-resolved alerts
where
(
:existing_status
,
:new_status
,
:valid
)
do
:resolved
|
:triggered
|
true
:resolved
|
:resolved
|
true
:triggered
|
:triggered
|
false
:triggered
|
:acknowledged
|
false
:triggered
|
:ignored
|
false
:triggered
|
:resolved
|
true
:acknowledged
|
:triggered
|
false
:acknowledged
|
:acknowledged
|
false
:acknowledged
|
:ignored
|
false
:acknowledged
|
:resolved
|
true
:ignored
|
:triggered
|
false
:ignored
|
:acknowledged
|
false
:ignored
|
:ignored
|
false
:ignored
|
:resolved
|
true
end
context
'same project, various states'
do
using
RSpec
::
Parameterized
::
TableSyntax
# We are only validating uniqueness for non-resolved alerts
where
(
:existing_status
,
:new_status
,
:valid
)
do
:resolved
|
:triggered
|
true
:resolved
|
:acknowledged
|
true
:resolved
|
:ignored
|
true
:resolved
|
:resolved
|
true
:triggered
|
:triggered
|
false
:triggered
|
:acknowledged
|
false
:triggered
|
:ignored
|
false
:triggered
|
:resolved
|
true
:acknowledged
|
:triggered
|
false
:acknowledged
|
:acknowledged
|
false
:acknowledged
|
:ignored
|
false
:acknowledged
|
:resolved
|
true
:ignored
|
:triggered
|
false
:ignored
|
:acknowledged
|
false
:ignored
|
:ignored
|
false
:ignored
|
:resolved
|
true
end
with_them
do
let
(
:existing_alert
)
{
create
(
:alert_management_alert
,
existing_status
,
fingerprint:
fingerprin
t
)
}
let
(
:new_alert
)
{
build
(
:alert_management_alert
,
new_status
,
fingerprint:
fingerprint
,
project:
project
)
}
with_them
do
let!
(
:existing_alert
)
{
create
(
:alert_management_alert
,
existing_status
,
fingerprint:
fingerprint
,
project:
projec
t
)
}
let
(
:new_alert
)
{
build
(
:alert_management_alert
,
new_status
,
fingerprint:
fingerprint
,
project:
project
)
}
it
'gives the correct validity'
do
expect
(
new_alert
.
valid?
).
to
eq
(
valid
)
end
if
params
[
:valid
]
it
{
is_expected
.
to
be_valid
}
else
it
{
is_expected
.
to
be_invalid
}
end
end
end
context
'different project'
do
let
(
:project
)
{
create
(
:projec
t
)
}
let
!
(
:existing_alert
)
{
create
(
:alert_management_alert
,
fingerprint:
fingerprin
t
)
}
it
{
is_expected
.
to
be_valid
}
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