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
d6528bb4
Commit
d6528bb4
authored
May 18, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor specs to reduce complexity
parent
f3697d79
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
16 deletions
+33
-16
spec/finders/alert_management/alerts_finder_spec.rb
spec/finders/alert_management/alerts_finder_spec.rb
+20
-9
spec/models/alert_management/alert_spec.rb
spec/models/alert_management/alert_spec.rb
+13
-7
No files found.
spec/finders/alert_management/alerts_finder_spec.rb
View file @
d6528bb4
...
...
@@ -224,32 +224,43 @@ describe AlertManagement::AlertsFinder, '#execute' do
end
context
'search query given'
do
let_it_be
(
:alert
)
do
create
(
:alert_management_alert
,
:with_fingerprint
,
project:
project
,
title:
'Title'
,
description:
'Desc'
,
service:
'Service'
,
monitoring_tool:
'Monitor'
)
end
context
'searching title'
do
let
(
:params
)
{
{
search:
alert
_1
.
title
}
}
let
(
:params
)
{
{
search:
alert
.
title
}
}
it
{
is_expected
.
to
match_array
([
alert
_1
])
}
it
{
is_expected
.
to
match_array
([
alert
])
}
end
context
'searching description'
do
let
(
:params
)
{
{
search:
alert
_1
.
description
}
}
let
(
:params
)
{
{
search:
alert
.
description
}
}
it
{
is_expected
.
to
match_array
([
alert
_1
])
}
it
{
is_expected
.
to
match_array
([
alert
])
}
end
context
'searching service'
do
let
(
:params
)
{
{
search:
alert
_1
.
service
}
}
let
(
:params
)
{
{
search:
alert
.
service
}
}
it
{
is_expected
.
to
match_array
([
alert
_1
])
}
it
{
is_expected
.
to
match_array
([
alert
])
}
end
context
'searching monitoring tool'
do
let
(
:params
)
{
{
search:
alert
_1
.
monitoring_tool
}
}
let
(
:params
)
{
{
search:
alert
.
monitoring_tool
}
}
it
{
is_expected
.
to
match_array
([
alert
_1
])
}
it
{
is_expected
.
to
match_array
([
alert
])
}
end
context
'searching something else'
do
let
(
:params
)
{
{
search:
alert
_1
.
fingerprint
}
}
let
(
:params
)
{
{
search:
alert
.
fingerprint
}
}
it
{
is_expected
.
to
be_empty
}
end
...
...
spec/models/alert_management/alert_spec.rb
View file @
d6528bb4
...
...
@@ -163,37 +163,43 @@ describe AlertManagement::Alert do
end
describe
'.search'
do
let
(
:query
)
{
'rspec'
}
let
(
:attribute_data
)
{
'RSPEC data'
}
let_it_be
(
:alert
)
do
create
(
:alert_management_alert
,
title:
'Title'
,
description:
'Desc'
,
service:
'Service'
,
monitoring_tool:
'Monitor'
)
end
subject
{
AlertManagement
::
Alert
.
search
(
query
)
}
context
'does not contain search string'
do
let
!
(
:alert
)
{
create
(
:alert_management_alert
)
}
let
(
:query
)
{
'something else'
}
it
{
is_expected
.
to
be_empty
}
end
context
'title includes query'
do
let
!
(
:alert
)
{
create
(
:alert_management_alert
,
title:
attribute_data
)
}
let
(
:query
)
{
alert
.
title
.
upcase
}
it
{
is_expected
.
to
contain_exactly
(
alert
)
}
end
context
'description includes query'
do
let
!
(
:alert
)
{
create
(
:alert_management_alert
,
description:
attribute_data
)
}
let
(
:query
)
{
alert
.
description
.
upcase
}
it
{
is_expected
.
to
contain_exactly
(
alert
)
}
end
context
'service includes query'
do
let
!
(
:alert
)
{
create
(
:alert_management_alert
,
service:
attribute_data
)
}
let
(
:query
)
{
alert
.
service
.
upcase
}
it
{
is_expected
.
to
contain_exactly
(
alert
)
}
end
context
'monitoring tool includes query'
do
let
!
(
:alert
)
{
create
(
:alert_management_alert
,
monitoring_tool:
attribute_data
)
}
let
(
:query
)
{
alert
.
monitoring_tool
.
upcase
}
it
{
is_expected
.
to
contain_exactly
(
alert
)
}
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