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
988e0b53
Commit
988e0b53
authored
Feb 01, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add patch api for enabling error tracking settings
parent
e1531b35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
6 deletions
+50
-6
lib/api/error_tracking.rb
lib/api/error_tracking.rb
+12
-6
spec/requests/api/error_tracking_spec.rb
spec/requests/api/error_tracking_spec.rb
+38
-0
No files found.
lib/api/error_tracking.rb
View file @
988e0b53
...
...
@@ -39,12 +39,18 @@ module API
not_found!
(
'Error Tracking Setting'
)
unless
setting
update_params
=
{
error_tracking_setting_attributes:
{
enabled:
params
[
:active
]
}
}
result
=
::
Projects
::
Operations
::
UpdateService
.
new
(
user_project
,
current_user
,
update_params
).
execute
present
result
,
with:
Entities
::
ErrorTracking
::
ProjectSetting
# update_params = {
# error_tracking_setting_attributes: { enabled: params[:active] }
# }
# result = ::Projects::Operations::UpdateService.new(user_project, current_user, update_params).execute
setting
.
enabled
=
params
[
:active
]
setting
.
save!
# if result[:status] == :success
present
setting
,
with:
Entities
::
ErrorTracking
::
ProjectSetting
# else
# result
# end
end
end
end
...
...
spec/requests/api/error_tracking_spec.rb
View file @
988e0b53
...
...
@@ -12,6 +12,10 @@ describe API::ErrorTracking do
get
api
(
"/projects/
#{
project
.
id
}
/error_tracking/settings"
,
user
)
end
def
make_patch_request
(
active
)
patch
api
(
"/projects/
#{
project
.
id
}
/error_tracking/settings"
,
user
),
params:
{
active:
active
}
end
context
'when authenticated as maintainer'
do
before
do
project
.
add_maintainer
(
user
)
...
...
@@ -28,6 +32,14 @@ describe API::ErrorTracking do
'api_url'
=>
setting
.
api_url
)
end
it
'returns active is invalid if non boolean'
do
make_patch_request
(
"randomstring"
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'error'
])
.
to
eq
(
'active is invalid'
)
end
end
context
'without a project setting'
do
...
...
@@ -44,6 +56,14 @@ describe API::ErrorTracking do
expect
(
json_response
[
'message'
])
.
to
eq
(
'404 Error Tracking Setting Not Found'
)
end
it
'returns 404 for update request'
do
make_patch_request
(
true
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
[
'message'
])
.
to
eq
(
'404 Error Tracking Setting Not Found'
)
end
end
context
'when authenticated as reporter'
do
...
...
@@ -56,6 +76,12 @@ describe API::ErrorTracking do
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
it
'returns 403 for update request'
do
make_patch_request
(
true
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'when authenticated as non-member'
do
...
...
@@ -64,6 +90,12 @@ describe API::ErrorTracking do
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
it
'returns 404 for update request'
do
make_patch_request
(
false
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'when unauthenticated'
do
...
...
@@ -74,6 +106,12 @@ describe API::ErrorTracking do
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
it
'returns 401 for update request'
do
make_patch_request
(
true
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
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