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
e98d69bc
Commit
e98d69bc
authored
Jan 09, 2020
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@master
parent
007aba8b
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
273 additions
and
42 deletions
+273
-42
CHANGELOG.md
CHANGELOG.md
+0
-4
app/controllers/projects/error_tracking_controller.rb
app/controllers/projects/error_tracking_controller.rb
+17
-0
app/helpers/projects/error_tracking_helper.rb
app/helpers/projects/error_tracking_helper.rb
+1
-0
app/models/concerns/awardable.rb
app/models/concerns/awardable.rb
+3
-1
app/models/error_tracking/project_error_tracking_setting.rb
app/models/error_tracking/project_error_tracking_setting.rb
+34
-22
app/services/error_tracking/issue_update_service.rb
app/services/error_tracking/issue_update_service.rb
+22
-0
changelogs/unreleased/121670-redis-cache-read-error-prevents-cas-users-from-remaining-signed-in.yml
...ead-error-prevents-cas-users-from-remaining-signed-in.yml
+5
-0
changelogs/unreleased/39825-resolve-sentry-error-backend.yml
changelogs/unreleased/39825-resolve-sentry-error-backend.yml
+5
-0
changelogs/unreleased/ab-projects-api-created-at-indexes.yml
changelogs/unreleased/ab-projects-api-created-at-indexes.yml
+5
-0
config/application.rb
config/application.rb
+4
-0
config/routes/project.rb
config/routes/project.rb
+3
-0
db/migrate/20200108155731_create_indexes_for_project_api_created_at_order.rb
...155731_create_indexes_for_project_api_created_at_order.rb
+21
-0
db/schema.rb
db/schema.rb
+3
-2
lib/sentry/client.rb
lib/sentry/client.rb
+1
-1
lib/sentry/client/issue.rb
lib/sentry/client/issue.rb
+4
-4
qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb
...res/browser_ui/3_create/web_ide/add_file_template_spec.rb
+1
-1
qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb
...er_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb
+1
-1
spec/controllers/projects/error_tracking_controller_spec.rb
spec/controllers/projects/error_tracking_controller_spec.rb
+52
-0
spec/fixtures/api/schemas/error_tracking/update_issue.json
spec/fixtures/api/schemas/error_tracking/update_issue.json
+16
-0
spec/lib/sentry/client/issue_spec.rb
spec/lib/sentry/client/issue_spec.rb
+39
-4
spec/models/error_tracking/project_error_tracking_setting_spec.rb
...els/error_tracking/project_error_tracking_setting_spec.rb
+34
-0
spec/support/helpers/sentry_client_helpers.rb
spec/support/helpers/sentry_client_helpers.rb
+2
-2
No files found.
CHANGELOG.md
View file @
e98d69bc
...
@@ -2,10 +2,6 @@
...
@@ -2,10 +2,6 @@
documentation
](
doc/development/changelog.md
)
for instructions on adding your own
documentation
](
doc/development/changelog.md
)
for instructions on adding your own
entry.
entry.
## 12.6.3
-
No changes.
## 12.6.2
## 12.6.2
### Security (6 changes)
### Security (6 changes)
...
...
app/controllers/projects/error_tracking_controller.rb
View file @
e98d69bc
# frozen_string_literal: true
# frozen_string_literal: true
class
Projects::ErrorTrackingController
<
Projects
::
ErrorTracking
::
BaseController
class
Projects::ErrorTrackingController
<
Projects
::
ErrorTracking
::
BaseController
respond_to
:json
before_action
:authorize_read_sentry_issue!
before_action
:authorize_read_sentry_issue!
before_action
:set_issue_id
,
only: :details
before_action
:set_issue_id
,
only: :details
...
@@ -24,6 +26,17 @@ class Projects::ErrorTrackingController < Projects::ErrorTracking::BaseControlle
...
@@ -24,6 +26,17 @@ class Projects::ErrorTrackingController < Projects::ErrorTracking::BaseControlle
end
end
end
end
def
update
service
=
ErrorTracking
::
IssueUpdateService
.
new
(
project
,
current_user
,
issue_update_params
)
result
=
service
.
execute
return
if
handle_errors
(
result
)
render
json:
{
result:
result
}
end
private
private
def
render_index_json
def
render_index_json
...
@@ -65,6 +78,10 @@ class Projects::ErrorTrackingController < Projects::ErrorTracking::BaseControlle
...
@@ -65,6 +78,10 @@ class Projects::ErrorTrackingController < Projects::ErrorTracking::BaseControlle
params
.
permit
(
:search_term
,
:sort
,
:cursor
)
params
.
permit
(
:search_term
,
:sort
,
:cursor
)
end
end
def
issue_update_params
params
.
permit
(
:issue_id
,
:status
)
end
def
issue_details_params
def
issue_details_params
params
.
permit
(
:issue_id
)
params
.
permit
(
:issue_id
)
end
end
...
...
app/helpers/projects/error_tracking_helper.rb
View file @
e98d69bc
...
@@ -20,6 +20,7 @@ module Projects::ErrorTrackingHelper
...
@@ -20,6 +20,7 @@ module Projects::ErrorTrackingHelper
{
{
'project-issues-path'
=>
project_issues_path
(
project
),
'project-issues-path'
=>
project_issues_path
(
project
),
'issue-details-path'
=>
details_project_error_tracking_index_path
(
*
opts
),
'issue-details-path'
=>
details_project_error_tracking_index_path
(
*
opts
),
'issue-update-path'
=>
update_project_error_tracking_index_path
(
*
opts
),
'issue-stack-trace-path'
=>
stack_trace_project_error_tracking_index_path
(
*
opts
)
'issue-stack-trace-path'
=>
stack_trace_project_error_tracking_index_path
(
*
opts
)
}
}
end
end
...
...
app/models/concerns/awardable.rb
View file @
e98d69bc
...
@@ -67,7 +67,9 @@ module Awardable
...
@@ -67,7 +67,9 @@ module Awardable
)
)
).
join_sources
).
join_sources
joins
(
join_clause
).
group
(
awardable_table
[
:id
]).
reorder
(
"COUNT(award_emoji.id)
#{
direction
}
"
)
joins
(
join_clause
).
group
(
awardable_table
[
:id
]).
reorder
(
Arel
.
sql
(
"COUNT(award_emoji.id)
#{
direction
}
"
)
)
end
end
end
end
...
...
app/models/error_tracking/project_error_tracking_setting.rb
View file @
e98d69bc
...
@@ -101,30 +101,27 @@ module ErrorTracking
...
@@ -101,30 +101,27 @@ module ErrorTracking
end
end
end
end
def
update_issue
(
opts
=
{}
)
handle_exceptions
do
{
updated:
sentry_client
.
update_issue
(
opts
)
}
end
end
def
calculate_reactive_cache
(
request
,
opts
)
def
calculate_reactive_cache
(
request
,
opts
)
case
request
handle_exceptions
do
when
'list_issues'
case
request
sentry_client
.
list_issues
(
**
opts
.
symbolize_keys
)
when
'list_issues'
when
'issue_details'
sentry_client
.
list_issues
(
**
opts
.
symbolize_keys
)
{
when
'issue_details'
issue:
sentry_client
.
issue_details
(
**
opts
.
symbolize_keys
)
{
}
issue:
sentry_client
.
issue_details
(
**
opts
.
symbolize_keys
)
when
'issue_latest_event'
}
{
when
'issue_latest_event'
latest_event:
sentry_client
.
issue_latest_event
(
**
opts
.
symbolize_keys
)
{
}
latest_event:
sentry_client
.
issue_latest_event
(
**
opts
.
symbolize_keys
)
}
end
end
end
rescue
Sentry
::
Client
::
Error
=>
e
{
error:
e
.
message
,
error_type:
SENTRY_API_ERROR_TYPE_NON_20X_RESPONSE
}
rescue
Sentry
::
Client
::
MissingKeysError
=>
e
{
error:
e
.
message
,
error_type:
SENTRY_API_ERROR_TYPE_MISSING_KEYS
}
rescue
Sentry
::
Client
::
ResponseInvalidSizeError
=>
e
{
error:
e
.
message
,
error_type:
SENTRY_API_ERROR_INVALID_SIZE
}
rescue
Sentry
::
Client
::
BadRequestError
=>
e
{
error:
e
.
message
,
error_type:
SENTRY_API_ERROR_TYPE_BAD_REQUEST
}
rescue
StandardError
=>
e
Gitlab
::
ErrorTracking
.
track_exception
(
e
)
{
error:
'Unexpected Error'
}
end
end
# http://HOST/api/0/projects/ORG/PROJECT
# http://HOST/api/0/projects/ORG/PROJECT
...
@@ -143,6 +140,21 @@ module ErrorTracking
...
@@ -143,6 +140,21 @@ module ErrorTracking
private
private
def
handle_exceptions
yield
rescue
Sentry
::
Client
::
Error
=>
e
{
error:
e
.
message
,
error_type:
SENTRY_API_ERROR_TYPE_NON_20X_RESPONSE
}
rescue
Sentry
::
Client
::
MissingKeysError
=>
e
{
error:
e
.
message
,
error_type:
SENTRY_API_ERROR_TYPE_MISSING_KEYS
}
rescue
Sentry
::
Client
::
ResponseInvalidSizeError
=>
e
{
error:
e
.
message
,
error_type:
SENTRY_API_ERROR_INVALID_SIZE
}
rescue
Sentry
::
Client
::
BadRequestError
=>
e
{
error:
e
.
message
,
error_type:
SENTRY_API_ERROR_TYPE_BAD_REQUEST
}
rescue
StandardError
=>
e
Gitlab
::
ErrorTracking
.
track_exception
(
e
)
{
error:
'Unexpected Error'
}
end
def
project_name_from_slug
def
project_name_from_slug
@project_name_from_slug
||=
project_slug_from_api_url
&
.
titleize
@project_name_from_slug
||=
project_slug_from_api_url
&
.
titleize
end
end
...
...
app/services/error_tracking/issue_update_service.rb
0 → 100644
View file @
e98d69bc
# frozen_string_literal: true
module
ErrorTracking
class
IssueUpdateService
<
ErrorTracking
::
BaseService
private
def
fetch
project_error_tracking_setting
.
update_issue
(
issue_id:
params
[
:issue_id
],
params:
update_params
)
end
def
update_params
params
.
except
(
:issue_id
)
end
def
parse_response
(
response
)
{
updated:
response
[
:updated
].
present?
}
end
end
end
changelogs/unreleased/121670-redis-cache-read-error-prevents-cas-users-from-remaining-signed-in.yml
0 → 100644
View file @
e98d69bc
---
title
:
Fix CAS users being signed out repeatedly
merge_request
:
22704
author
:
type
:
fixed
changelogs/unreleased/39825-resolve-sentry-error-backend.yml
0 → 100644
View file @
e98d69bc
---
title
:
Add internal API to update Sentry error status
merge_request
:
22454
author
:
type
:
added
changelogs/unreleased/ab-projects-api-created-at-indexes.yml
0 → 100644
View file @
e98d69bc
---
title
:
Create optimal indexes for created_at order (Projects API)
merge_request
:
22623
author
:
type
:
performance
config/application.rb
View file @
e98d69bc
...
@@ -261,6 +261,10 @@ module Gitlab
...
@@ -261,6 +261,10 @@ module Gitlab
caching_config_hash
[
:pool_timeout
]
=
1
caching_config_hash
[
:pool_timeout
]
=
1
end
end
# Overrides RedisCacheStore's default value of 0
# This makes the default value the same with Gitlab::Redis::Cache
caching_config_hash
[
:reconnect_attempts
]
||=
::
Redis
::
Client
::
DEFAULTS
[
:reconnect_attempts
]
config
.
cache_store
=
:redis_cache_store
,
caching_config_hash
config
.
cache_store
=
:redis_cache_store
,
caching_config_hash
config
.
active_job
.
queue_adapter
=
:sidekiq
config
.
active_job
.
queue_adapter
=
:sidekiq
...
...
config/routes/project.rb
View file @
e98d69bc
...
@@ -275,6 +275,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
...
@@ -275,6 +275,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get
':issue_id/stack_trace'
,
get
':issue_id/stack_trace'
,
to:
'error_tracking/stack_traces#index'
,
to:
'error_tracking/stack_traces#index'
,
as:
'stack_trace'
as:
'stack_trace'
put
':issue_id'
,
to:
'error_tracking#update'
,
as:
'update'
end
end
end
end
...
...
db/migrate/20200108155731_create_indexes_for_project_api_created_at_order.rb
0 → 100644
View file @
e98d69bc
# frozen_string_literal: true
class
CreateIndexesForProjectApiCreatedAtOrder
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_concurrent_index
:projects
,
%i(visibility_level created_at id)
,
order:
{
id: :desc
},
name:
'index_projects_on_visibility_level_created_at_id_desc'
add_concurrent_index
:projects
,
%i(visibility_level created_at id)
,
order:
{
created_at: :desc
,
id: :desc
},
name:
'index_projects_on_visibility_level_created_at_desc_id_desc'
remove_concurrent_index_by_name
:projects
,
'index_projects_on_visibility_level_and_created_at_and_id'
end
def
down
add_concurrent_index
:projects
,
%i(visibility_level created_at id)
,
name:
'index_projects_on_visibility_level_and_created_at_and_id'
remove_concurrent_index_by_name
:projects
,
'index_projects_on_visibility_level_created_at_id_desc'
remove_concurrent_index_by_name
:projects
,
'index_projects_on_visibility_level_created_at_desc_id_desc'
end
end
db/schema.rb
View file @
e98d69bc
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2020_01_08_1
00603
)
do
ActiveRecord
::
Schema
.
define
(
version:
2020_01_08_1
55731
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"pg_trgm"
enable_extension
"pg_trgm"
...
@@ -3376,7 +3376,8 @@ ActiveRecord::Schema.define(version: 2020_01_08_100603) do
...
@@ -3376,7 +3376,8 @@ ActiveRecord::Schema.define(version: 2020_01_08_100603) do
t
.
index
[
"runners_token"
],
name:
"index_projects_on_runners_token"
t
.
index
[
"runners_token"
],
name:
"index_projects_on_runners_token"
t
.
index
[
"runners_token_encrypted"
],
name:
"index_projects_on_runners_token_encrypted"
t
.
index
[
"runners_token_encrypted"
],
name:
"index_projects_on_runners_token_encrypted"
t
.
index
[
"star_count"
],
name:
"index_projects_on_star_count"
t
.
index
[
"star_count"
],
name:
"index_projects_on_star_count"
t
.
index
[
"visibility_level"
,
"created_at"
,
"id"
],
name:
"index_projects_on_visibility_level_and_created_at_and_id"
t
.
index
[
"visibility_level"
,
"created_at"
,
"id"
],
name:
"index_projects_on_visibility_level_created_at_desc_id_desc"
,
order:
{
created_at: :desc
,
id: :desc
}
t
.
index
[
"visibility_level"
,
"created_at"
,
"id"
],
name:
"index_projects_on_visibility_level_created_at_id_desc"
,
order:
{
id: :desc
}
end
end
create_table
"prometheus_alert_events"
,
force: :cascade
do
|
t
|
create_table
"prometheus_alert_events"
,
force: :cascade
do
|
t
|
...
...
lib/sentry/client.rb
View file @
e98d69bc
...
@@ -43,7 +43,7 @@ module Sentry
...
@@ -43,7 +43,7 @@ module Sentry
def
http_put
(
url
,
params
=
{})
def
http_put
(
url
,
params
=
{})
http_request
do
http_request
do
Gitlab
::
HTTP
.
put
(
url
,
**
request_params
.
merge
(
{
body:
params
}
))
Gitlab
::
HTTP
.
put
(
url
,
**
request_params
.
merge
(
body:
params
))
end
end
end
end
...
...
lib/sentry/client/issue.rb
View file @
e98d69bc
...
@@ -34,6 +34,10 @@ module Sentry
...
@@ -34,6 +34,10 @@ module Sentry
map_to_detailed_error
(
issue
)
map_to_detailed_error
(
issue
)
end
end
def
update_issue
(
issue_id
:,
params
:)
http_put
(
issue_api_url
(
issue_id
),
params
)[
:body
]
end
private
private
def
get_issues
(
**
keyword_args
)
def
get_issues
(
**
keyword_args
)
...
@@ -71,10 +75,6 @@ module Sentry
...
@@ -71,10 +75,6 @@ module Sentry
http_get
(
issue_api_url
(
issue_id
))[
:body
]
http_get
(
issue_api_url
(
issue_id
))[
:body
]
end
end
def
update_issue
(
issue_id
:,
params
:)
http_put
(
issue_api_url
(
issue_id
),
params
)[
:body
]
end
def
issues_api_url
def
issues_api_url
issues_url
=
URI
(
"
#{
url
}
/issues/"
)
issues_url
=
URI
(
"
#{
url
}
/issues/"
)
issues_url
.
path
.
squeeze!
(
'/'
)
issues_url
.
path
.
squeeze!
(
'/'
)
...
...
qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb
View file @
e98d69bc
# frozen_string_literal: true
# frozen_string_literal: true
module
QA
module
QA
context
'Create'
do
context
'Create'
,
quarantine:
'https://gitlab.com/gitlab-org/gitlab/issues/196034'
do
describe
'Web IDE file templates'
do
describe
'Web IDE file templates'
do
include
Runtime
::
Fixtures
include
Runtime
::
Fixtures
...
...
qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb
View file @
e98d69bc
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
require
'digest/sha1'
require
'digest/sha1'
module
QA
module
QA
context
'Release'
,
:docker
do
context
'Release'
,
:docker
,
quarantine:
'https://gitlab.com/gitlab-org/gitlab/issues/196047'
do
describe
'Git clone using a deploy key'
do
describe
'Git clone using a deploy key'
do
before
do
before
do
Flow
::
Login
.
sign_in
Flow
::
Login
.
sign_in
...
...
spec/controllers/projects/error_tracking_controller_spec.rb
View file @
e98d69bc
...
@@ -271,6 +271,58 @@ describe Projects::ErrorTrackingController do
...
@@ -271,6 +271,58 @@ describe Projects::ErrorTrackingController do
end
end
end
end
describe
'PUT #update'
do
let
(
:issue_id
)
{
1234
}
let
(
:issue_update_service
)
{
spy
(
:issue_update_service
)
}
let
(
:permitted_params
)
do
ActionController
::
Parameters
.
new
(
{
issue_id:
issue_id
.
to_s
,
status:
'resolved'
}
).
permit!
end
subject
(
:update_issue
)
do
put
:update
,
params:
issue_params
(
issue_id:
issue_id
,
status:
'resolved'
,
format: :json
)
end
before
do
expect
(
ErrorTracking
::
IssueUpdateService
)
.
to
receive
(
:new
).
with
(
project
,
user
,
permitted_params
)
.
and_return
(
issue_update_service
)
end
describe
'format json'
do
context
'update result is successful'
do
before
do
expect
(
issue_update_service
).
to
receive
(
:execute
)
.
and_return
(
status: :success
,
updated:
true
)
update_issue
end
it
'returns a success'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'error_tracking/update_issue'
)
end
end
context
'update result is erroneous'
do
let
(
:error_message
)
{
'error message'
}
before
do
expect
(
issue_update_service
).
to
receive
(
:execute
)
.
and_return
(
status: :error
,
message:
error_message
)
update_issue
end
it
'returns 400 with message'
do
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
eq
(
error_message
)
end
end
end
end
private
private
def
issue_params
(
opts
=
{})
def
issue_params
(
opts
=
{})
...
...
spec/fixtures/api/schemas/error_tracking/update_issue.json
0 → 100644
View file @
e98d69bc
{
"type"
:
"object"
,
"required"
:
[
"result"
],
"properties"
:
{
"result"
:
{
"type"
:
"object"
,
"properties"
:
{
"status"
:
{
"type"
:
"string"
},
"updated"
:
{
"type"
:
"boolean"
}
}
}
},
"additionalProperties"
:
false
}
spec/lib/sentry/client/issue_spec.rb
View file @
e98d69bc
...
@@ -6,7 +6,9 @@ describe Sentry::Client::Issue do
...
@@ -6,7 +6,9 @@ describe Sentry::Client::Issue do
include
SentryClientHelpers
include
SentryClientHelpers
let
(
:token
)
{
'test-token'
}
let
(
:token
)
{
'test-token'
}
let
(
:sentry_url
)
{
'https://sentrytest.gitlab.com/api/0'
}
let
(
:client
)
{
Sentry
::
Client
.
new
(
sentry_url
,
token
)
}
let
(
:client
)
{
Sentry
::
Client
.
new
(
sentry_url
,
token
)
}
let
(
:issue_id
)
{
503504
}
describe
'#list_issues'
do
describe
'#list_issues'
do
shared_examples
'issues have correct return type'
do
|
klass
|
shared_examples
'issues have correct return type'
do
|
klass
|
...
@@ -225,15 +227,11 @@ describe Sentry::Client::Issue do
...
@@ -225,15 +227,11 @@ describe Sentry::Client::Issue do
)
)
end
end
let
(
:issue_id
)
{
503504
}
let
(
:sentry_url
)
{
'https://sentrytest.gitlab.com/api/0'
}
let
(
:sentry_request_url
)
{
"
#{
sentry_url
}
/issues/
#{
issue_id
}
/"
}
let
(
:sentry_request_url
)
{
"
#{
sentry_url
}
/issues/
#{
issue_id
}
/"
}
let!
(
:sentry_api_request
)
{
stub_sentry_request
(
sentry_request_url
,
body:
issue_sample_response
)
}
let!
(
:sentry_api_request
)
{
stub_sentry_request
(
sentry_request_url
,
body:
issue_sample_response
)
}
subject
{
client
.
issue_details
(
issue_id:
issue_id
)
}
subject
{
client
.
issue_details
(
issue_id:
issue_id
)
}
it_behaves_like
'calls sentry api'
it
'escapes issue ID'
do
it
'escapes issue ID'
do
allow
(
CGI
).
to
receive
(
:escape
).
and_call_original
allow
(
CGI
).
to
receive
(
:escape
).
and_call_original
...
@@ -290,4 +288,41 @@ describe Sentry::Client::Issue do
...
@@ -290,4 +288,41 @@ describe Sentry::Client::Issue do
end
end
end
end
end
end
describe
'#update_issue'
do
let
(
:sentry_url
)
{
'https://sentrytest.gitlab.com/api/0'
}
let
(
:sentry_request_url
)
{
"
#{
sentry_url
}
/issues/
#{
issue_id
}
/"
}
before
do
stub_sentry_request
(
sentry_request_url
,
:put
)
end
let
(
:params
)
do
{
status:
'resolved'
}
end
subject
{
client
.
update_issue
(
issue_id:
issue_id
,
params:
params
)
}
it_behaves_like
'calls sentry api'
do
let
(
:sentry_api_request
)
{
stub_sentry_request
(
sentry_request_url
,
:put
)
}
end
it
'returns a truthy result'
do
expect
(
subject
).
to
be_truthy
end
context
'error encountered'
do
let
(
:error
)
{
StandardError
.
new
(
'error'
)
}
before
do
allow
(
client
).
to
receive
(
:update_issue
).
and_raise
(
error
)
end
it
'raises the error'
do
expect
{
subject
}.
to
raise_error
(
error
)
end
end
end
end
end
spec/models/error_tracking/project_error_tracking_setting_spec.rb
View file @
e98d69bc
...
@@ -210,6 +210,40 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
...
@@ -210,6 +210,40 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
end
end
end
describe
'#update_issue'
do
let
(
:opts
)
do
{
status:
'resolved'
}
end
let
(
:result
)
do
subject
.
update_issue
(
**
opts
)
end
let
(
:sentry_client
)
{
spy
(
:sentry_client
)
}
context
'successful call to sentry'
do
before
do
allow
(
subject
).
to
receive
(
:sentry_client
).
and_return
(
sentry_client
)
allow
(
sentry_client
).
to
receive
(
:update_issue
).
with
(
opts
).
and_return
(
true
)
end
it
'returns the successful response'
do
expect
(
result
).
to
eq
(
updated:
true
)
end
end
context
'sentry raises an error'
do
before
do
allow
(
subject
).
to
receive
(
:sentry_client
).
and_return
(
sentry_client
)
allow
(
sentry_client
).
to
receive
(
:update_issue
).
with
(
opts
).
and_raise
(
StandardError
)
end
it
'returns the successful response'
do
expect
(
result
).
to
eq
(
error:
'Unexpected Error'
)
end
end
end
context
'slugs'
do
context
'slugs'
do
shared_examples_for
'slug from api_url'
do
|
method
,
slug
|
shared_examples_for
'slug from api_url'
do
|
method
,
slug
|
context
'when api_url is correct'
do
context
'when api_url is correct'
do
...
...
spec/support/helpers/sentry_client_helpers.rb
View file @
e98d69bc
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
module
SentryClientHelpers
module
SentryClientHelpers
private
private
def
stub_sentry_request
(
url
,
body:
{},
status:
200
,
headers:
{})
def
stub_sentry_request
(
url
,
http_method
=
:get
,
body:
{},
status:
200
,
headers:
{})
stub_request
(
:get
,
url
)
stub_request
(
http_method
,
url
)
.
to_return
(
.
to_return
(
status:
status
,
status:
status
,
headers:
{
'Content-Type'
=>
'application/json'
}.
merge
(
headers
),
headers:
{
'Content-Type'
=>
'application/json'
}.
merge
(
headers
),
...
...
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