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
3657efe8
Commit
3657efe8
authored
May 18, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check create_issue permissions
Check create_issue permissions on create Alert Issue
parent
0fa3b527
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
app/services/alert_management/create_alert_issue_service.rb
app/services/alert_management/create_alert_issue_service.rb
+1
-1
spec/services/alert_management/create_alert_issue_service_spec.rb
...vices/alert_management/create_alert_issue_service_spec.rb
+11
-1
No files found.
app/services/alert_management/create_alert_issue_service.rb
View file @
3657efe8
...
@@ -30,7 +30,7 @@ module AlertManagement
...
@@ -30,7 +30,7 @@ module AlertManagement
def
allowed?
def
allowed?
Feature
.
enabled?
(
:alert_management_create_alert_issue
,
project
)
&&
Feature
.
enabled?
(
:alert_management_create_alert_issue
,
project
)
&&
user
.
can?
(
:
update_alert_management_alert
,
project
)
user
.
can?
(
:
create_issue
,
project
)
end
end
def
create_issue
(
alert
,
user
,
alert_payload
)
def
create_issue
(
alert
,
user
,
alert_payload
)
...
...
spec/services/alert_management/create_alert_issue_service_spec.rb
View file @
3657efe8
...
@@ -25,7 +25,7 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
...
@@ -25,7 +25,7 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
before
do
before
do
allow
(
user
).
to
receive
(
:can?
).
and_call_original
allow
(
user
).
to
receive
(
:can?
).
and_call_original
allow
(
user
).
to
receive
(
:can?
)
allow
(
user
).
to
receive
(
:can?
)
.
with
(
:
update_alert_management_alert
,
project
)
.
with
(
:
create_issue
,
project
)
.
and_return
(
can_create
)
.
and_return
(
can_create
)
end
end
...
@@ -62,6 +62,11 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
...
@@ -62,6 +62,11 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
end
end
it
'checks permissions'
do
execute
expect
(
user
).
to
have_received
(
:can?
).
with
(
:create_issue
,
project
)
end
context
'when the alert is prometheus alert'
do
context
'when the alert is prometheus alert'
do
let
(
:alert
)
{
prometheus_alert
}
let
(
:alert
)
{
prometheus_alert
}
...
@@ -133,6 +138,11 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
...
@@ -133,6 +138,11 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
context
'when a user is not allowed to create an issue'
do
context
'when a user is not allowed to create an issue'
do
let
(
:can_create
)
{
false
}
let
(
:can_create
)
{
false
}
it
'checks permissions'
do
execute
expect
(
user
).
to
have_received
(
:can?
).
with
(
:create_issue
,
project
)
end
it
'responds with error'
do
it
'responds with error'
do
expect
(
execute
).
to
be_error
expect
(
execute
).
to
be_error
expect
(
execute
.
message
).
to
eq
(
_
(
'You have no permissions'
))
expect
(
execute
.
message
).
to
eq
(
_
(
'You have no permissions'
))
...
...
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