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
f793677f
Commit
f793677f
authored
Aug 27, 2020
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use parameterized syntax to simplify test cases
parent
a99ddab6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
37 deletions
+12
-37
ee/spec/presenters/merge_request_presenter_spec.rb
ee/spec/presenters/merge_request_presenter_spec.rb
+12
-37
No files found.
ee/spec/presenters/merge_request_presenter_spec.rb
View file @
f793677f
...
...
@@ -113,47 +113,22 @@ RSpec.describe MergeRequestPresenter do
subject
(
:missing_security_scan_types
)
{
presenter
.
missing_security_scan_types
}
before
do
stub_feature_flags
(
missing_mr_security_scan_types:
feature_enabled?
)
allow
(
merge_request
).
to
receive
(
:actual_head_pipeline
).
and_return
(
pipeline
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_pipeline
,
pipeline
).
and_return
(
can_read_pipeline?
)
where
(
:feature_flag_enabled?
,
:can_read_pipeline?
,
:attribute_value
)
do
false
|
false
|
nil
false
|
true
|
nil
true
|
false
|
nil
true
|
true
|
%w(sast)
end
context
'when the `missing_mr_security_scan_types` feature flag is not enabled'
do
let
(
:feature_enabled?
)
{
false
}
context
'when the `current_user` can not read the pipeline'
do
let
(
:can_read_pipeline?
)
{
false
}
it
{
is_expected
.
to
be_nil
}
end
context
'when the `current_user` can read the pipeline'
do
let
(
:can_read_pipeline?
)
{
true
}
it
{
is_expected
.
to
be_nil
}
end
end
context
'when the `missing_mr_security_scan_types` feature flag is enabled'
do
let
(
:feature_enabled?
)
{
true
}
context
'when the `current_user` can not read the pipeline'
do
let
(
:can_read_pipeline?
)
{
false
}
it
{
is_expected
.
to
be_nil
}
with_them
do
before
do
stub_feature_flags
(
missing_mr_security_scan_types:
feature_flag_enabled?
)
allow
(
merge_request
).
to
receive
(
:actual_head_pipeline
).
and_return
(
pipeline
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_pipeline
,
pipeline
).
and_return
(
can_read_pipeline?
)
allow
(
merge_request
).
to
receive
(
:missing_security_scan_types
).
and_return
(
%w(sast)
)
end
context
'when the `current_user` can read the pipeline'
do
let
(
:can_read_pipeline?
)
{
true
}
let
(
:missing_types
)
{
%w(sast)
}
before
do
allow
(
merge_request
).
to
receive
(
:missing_security_scan_types
).
and_return
(
missing_types
)
end
it
{
is_expected
.
to
eq
(
missing_types
)
}
end
it
{
is_expected
.
to
eq
(
attribute_value
)
}
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