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
787d3514
Commit
787d3514
authored
Jul 21, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip auth check when creating incident label
parent
874e714c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
28 deletions
+10
-28
app/services/incident_management/create_incident_label_service.rb
...ices/incident_management/create_incident_label_service.rb
+1
-19
spec/services/incident_management/create_incident_label_service_spec.rb
...incident_management/create_incident_label_service_spec.rb
+9
-1
spec/support/shared_examples/create_alert_issue_shared_examples.rb
...ort/shared_examples/create_alert_issue_shared_examples.rb
+0
-8
No files found.
app/services/incident_management/create_incident_label_service.rb
View file @
787d3514
...
...
@@ -14,27 +14,9 @@ module IncidentManagement
def
execute
label
=
Labels
::
FindOrCreateService
.
new
(
current_user
,
project
,
**
LABEL_PROPERTIES
)
.
execute
if
label
.
invalid?
log_invalid_label_info
(
label
)
return
ServiceResponse
.
error
(
payload:
{
label:
label
},
message:
full_error_message
(
label
))
end
.
execute
(
skip_authorization:
true
)
ServiceResponse
.
success
(
payload:
{
label:
label
})
end
private
def
log_invalid_label_info
(
label
)
log_info
<<~
TEXT
.
chomp
Cannot create incident label "
#{
label
.
title
}
" \
for "
#{
label
.
project
.
full_name
}
":
#{
full_error_message
(
label
)
}
.
TEXT
end
def
full_error_message
(
label
)
label
.
errors
.
full_messages
.
to_sentence
end
end
end
spec/services/incident_management/create_incident_label_service_spec.rb
View file @
787d3514
...
...
@@ -52,7 +52,15 @@ RSpec.describe IncidentManagement::CreateIncidentLabelService do
end
context
'without label'
do
context
'when user has permissions to create labels'
do
it_behaves_like
'new label'
end
context
'when user has no permissions to create labels'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
it_behaves_like
'new label'
end
end
end
end
spec/support/shared_examples/create_alert_issue_shared_examples.rb
View file @
787d3514
...
...
@@ -16,12 +16,4 @@ RSpec.shared_examples 'create alert issue sets issue labels' do
expect
(
issue
.
labels
).
to
eq
([
label
])
end
end
context
'when create incident label responds with error'
do
let
(
:label_service_response
)
{
ServiceResponse
.
error
(
payload:
{
label:
label
},
message:
'label error'
)
}
it
'creates an issue without labels'
do
expect
(
issue
.
labels
).
to
be_empty
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