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
e4cac8a3
Commit
e4cac8a3
authored
Jan 06, 2020
by
Sean Arnold
Committed by
Douglas Barbosa Alexandre
Jan 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test that the polling header is set correctly
- Move shared examples into seperate file
parent
85cad651
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
15 deletions
+35
-15
app/controllers/projects/error_tracking/base_controller.rb
app/controllers/projects/error_tracking/base_controller.rb
+9
-0
app/controllers/projects/error_tracking/stack_traces_controller.rb
...ollers/projects/error_tracking/stack_traces_controller.rb
+2
-2
app/controllers/projects/error_tracking_controller.rb
app/controllers/projects/error_tracking_controller.rb
+2
-7
spec/controllers/projects/error_tracking/stack_traces_controller_spec.rb
...s/projects/error_tracking/stack_traces_controller_spec.rb
+4
-0
spec/controllers/projects/error_tracking_controller_spec.rb
spec/controllers/projects/error_tracking_controller_spec.rb
+11
-6
spec/support/shared_examples/controllers/error_tracking_shared_examples.rb
...ed_examples/controllers/error_tracking_shared_examples.rb
+7
-0
No files found.
app/controllers/projects/error_tracking/base_controller.rb
0 → 100644
View file @
e4cac8a3
# frozen_string_literal: true
class
Projects::ErrorTracking::BaseController
<
Projects
::
ApplicationController
POLLING_INTERVAL
=
1_000
def
set_polling_interval
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
POLLING_INTERVAL
)
end
end
app/controllers/projects/error_tracking/stack_traces_controller.rb
View file @
e4cac8a3
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
module
Projects
module
Projects
module
ErrorTracking
module
ErrorTracking
class
StackTracesController
<
Projects
::
Application
Controller
class
StackTracesController
<
Projects
::
ErrorTracking
::
Base
Controller
respond_to
:json
respond_to
:json
before_action
:authorize_read_sentry_issue!
before_action
:authorize_read_sentry_issue!
,
:set_polling_interval
def
index
def
index
result
=
fetch_latest_event_issue
result
=
fetch_latest_event_issue
...
...
app/controllers/projects/error_tracking_controller.rb
View file @
e4cac8a3
# frozen_string_literal: true
# frozen_string_literal: true
class
Projects::ErrorTrackingController
<
Projects
::
Application
Controller
class
Projects::ErrorTrackingController
<
Projects
::
ErrorTracking
::
Base
Controller
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
POLLING_INTERVAL
=
10_000
def
index
def
index
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
...
@@ -20,6 +18,7 @@ class Projects::ErrorTrackingController < Projects::ApplicationController
...
@@ -20,6 +18,7 @@ class Projects::ErrorTrackingController < Projects::ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
json
do
format
.
json
do
set_polling_interval
render_issue_detail_json
render_issue_detail_json
end
end
end
end
...
@@ -74,10 +73,6 @@ class Projects::ErrorTrackingController < Projects::ApplicationController
...
@@ -74,10 +73,6 @@ class Projects::ErrorTrackingController < Projects::ApplicationController
@issue_id
=
issue_details_params
[
:issue_id
]
@issue_id
=
issue_details_params
[
:issue_id
]
end
end
def
set_polling_interval
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
POLLING_INTERVAL
)
end
def
serialize_errors
(
errors
)
def
serialize_errors
(
errors
)
ErrorTracking
::
ErrorSerializer
ErrorTracking
::
ErrorSerializer
.
new
(
project:
project
,
user:
current_user
)
.
new
(
project:
project
,
user:
current_user
)
...
...
spec/controllers/projects/error_tracking/stack_traces_controller_spec.rb
View file @
e4cac8a3
...
@@ -34,6 +34,8 @@ describe Projects::ErrorTracking::StackTracesController do
...
@@ -34,6 +34,8 @@ describe Projects::ErrorTracking::StackTracesController do
it
'responds with no data'
do
it
'responds with no data'
do
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
it_behaves_like
'sets the polling header'
end
end
context
'service result is successful'
do
context
'service result is successful'
do
...
@@ -53,6 +55,8 @@ describe Projects::ErrorTracking::StackTracesController do
...
@@ -53,6 +55,8 @@ describe Projects::ErrorTracking::StackTracesController do
Gitlab
::
ErrorTracking
::
StackTraceHighlightDecorator
.
decorate
(
error_event
).
as_json
Gitlab
::
ErrorTracking
::
StackTraceHighlightDecorator
.
decorate
(
error_event
).
as_json
)
)
end
end
it_behaves_like
'sets the polling header'
end
end
context
'service result is erroneous'
do
context
'service result is erroneous'
do
...
...
spec/controllers/projects/error_tracking_controller_spec.rb
View file @
e4cac8a3
...
@@ -91,13 +91,13 @@ describe Projects::ErrorTrackingController do
...
@@ -91,13 +91,13 @@ describe Projects::ErrorTrackingController do
.
and_return
(
status: :success
,
issues:
[
error
],
pagination:
{})
.
and_return
(
status: :success
,
issues:
[
error
],
pagination:
{})
expect
(
list_issues_service
).
to
receive
(
:external_url
)
expect
(
list_issues_service
).
to
receive
(
:external_url
)
.
and_return
(
external_url
)
.
and_return
(
external_url
)
get
:index
,
params:
params
end
end
let
(
:error
)
{
build
(
:error_tracking_error
)
}
let
(
:error
)
{
build
(
:error_tracking_error
)
}
it
'returns a list of errors'
do
it
'returns a list of errors'
do
get
:index
,
params:
params
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'error_tracking/index'
)
expect
(
response
).
to
match_response_schema
(
'error_tracking/index'
)
expect
(
json_response
).
to
eq
(
expect
(
json_response
).
to
eq
(
...
@@ -106,6 +106,8 @@ describe Projects::ErrorTrackingController do
...
@@ -106,6 +106,8 @@ describe Projects::ErrorTrackingController do
'external_url'
=>
external_url
'external_url'
=>
external_url
)
)
end
end
it_behaves_like
'sets the polling header'
end
end
end
end
...
@@ -201,30 +203,33 @@ describe Projects::ErrorTrackingController do
...
@@ -201,30 +203,33 @@ describe Projects::ErrorTrackingController do
before
do
before
do
expect
(
issue_details_service
).
to
receive
(
:execute
)
expect
(
issue_details_service
).
to
receive
(
:execute
)
.
and_return
(
status: :error
,
http_status: :no_content
)
.
and_return
(
status: :error
,
http_status: :no_content
)
get
:details
,
params:
issue_params
(
issue_id:
issue_id
,
format: :json
)
end
end
it
'returns no data'
do
it
'returns no data'
do
get
:details
,
params:
issue_params
(
issue_id:
issue_id
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
end
it_behaves_like
'sets the polling header'
end
end
context
'service result is successful'
do
context
'service result is successful'
do
before
do
before
do
expect
(
issue_details_service
).
to
receive
(
:execute
)
expect
(
issue_details_service
).
to
receive
(
:execute
)
.
and_return
(
status: :success
,
issue:
error
)
.
and_return
(
status: :success
,
issue:
error
)
get
:details
,
params:
issue_params
(
issue_id:
issue_id
,
format: :json
)
end
end
let
(
:error
)
{
build
(
:detailed_error_tracking_error
)
}
let
(
:error
)
{
build
(
:detailed_error_tracking_error
)
}
it
'returns an error'
do
it
'returns an error'
do
get
:details
,
params:
issue_params
(
issue_id:
issue_id
,
format: :json
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'error_tracking/issue_detailed'
)
expect
(
response
).
to
match_response_schema
(
'error_tracking/issue_detailed'
)
expect
(
json_response
[
'error'
]).
to
eq
(
error
.
as_json
)
expect
(
json_response
[
'error'
]).
to
eq
(
error
.
as_json
)
end
end
it_behaves_like
'sets the polling header'
end
end
context
'service result is erroneous'
do
context
'service result is erroneous'
do
...
...
spec/support/shared_examples/controllers/error_tracking_shared_examples.rb
0 → 100644
View file @
e4cac8a3
# frozen_string_literal: true
shared_examples
'sets the polling header'
do
subject
{
response
.
headers
[
Gitlab
::
PollingInterval
::
HEADER_NAME
]
}
it
{
is_expected
.
to
eq
'1000'
}
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