2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Projects::ErrorTrackingHelper do
|
2019-02-15 15:39:39 +05:30
|
|
|
include Gitlab::Routing.url_helpers
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
let(:project) { build_stubbed(:project) }
|
|
|
|
let(:current_user) { build_stubbed(:user) }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
describe '#error_tracking_data' do
|
2019-12-04 20:38:33 +05:30
|
|
|
let(:can_enable_error_tracking) { true }
|
2019-02-15 15:39:39 +05:30
|
|
|
let(:setting_path) { project_settings_operations_path(project) }
|
2020-03-13 15:44:24 +05:30
|
|
|
let(:list_path) { project_error_tracking_index_path(project) }
|
|
|
|
let(:project_path) { project.full_path }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
let(:index_path) do
|
|
|
|
project_error_tracking_index_path(project, format: :json)
|
|
|
|
end
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
before do
|
|
|
|
allow(helper)
|
|
|
|
.to receive(:can?)
|
|
|
|
.with(current_user, :admin_operations, project)
|
|
|
|
.and_return(can_enable_error_tracking)
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
context 'without error_tracking_setting' do
|
|
|
|
it 'returns frontend configuration' do
|
2019-12-04 20:38:33 +05:30
|
|
|
expect(helper.error_tracking_data(current_user, project)).to match(
|
2019-02-15 15:39:39 +05:30
|
|
|
'index-path' => index_path,
|
2019-12-04 20:38:33 +05:30
|
|
|
'user-can-enable-error-tracking' => 'true',
|
2019-02-15 15:39:39 +05:30
|
|
|
'enable-error-tracking-link' => setting_path,
|
|
|
|
'error-tracking-enabled' => 'false',
|
2020-03-13 15:44:24 +05:30
|
|
|
'list-path' => list_path,
|
|
|
|
'project-path' => project_path,
|
2022-05-07 20:08:51 +05:30
|
|
|
'illustration-path' => match_asset_path('/assets/illustrations/cluster_popover.svg'),
|
|
|
|
'show-integrated-tracking-disabled-alert' => 'false'
|
2019-02-15 15:39:39 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with error_tracking_setting' do
|
2022-05-07 20:08:51 +05:30
|
|
|
let(:project) { build_stubbed(:project, :with_error_tracking_setting) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.error_tracking_setting.enabled = enabled
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'when enabled' do
|
2022-05-07 20:08:51 +05:30
|
|
|
let(:enabled) { true }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
it 'show error tracking enabled' do
|
2019-12-04 20:38:33 +05:30
|
|
|
expect(helper.error_tracking_data(current_user, project)).to include(
|
2019-02-15 15:39:39 +05:30
|
|
|
'error-tracking-enabled' => 'true'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when disabled' do
|
2022-05-07 20:08:51 +05:30
|
|
|
let(:enabled) { false }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
it 'show error tracking not enabled' do
|
2019-12-04 20:38:33 +05:30
|
|
|
expect(helper.error_tracking_data(current_user, project)).to include(
|
2019-02-15 15:39:39 +05:30
|
|
|
'error-tracking-enabled' => 'false'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2022-05-07 20:08:51 +05:30
|
|
|
|
|
|
|
context 'with integrated error tracking feature' do
|
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
|
|
|
where(:feature_flag, :enabled, :integrated, :show_alert) do
|
|
|
|
false | true | true | true
|
|
|
|
false | true | false | false
|
|
|
|
false | false | true | false
|
|
|
|
false | false | false | false
|
|
|
|
true | true | true | false
|
|
|
|
true | true | false | false
|
|
|
|
true | false | true | false
|
|
|
|
true | false | false | false
|
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(integrated_error_tracking: feature_flag)
|
|
|
|
|
|
|
|
project.error_tracking_setting.attributes = {
|
|
|
|
enabled: enabled,
|
|
|
|
integrated: integrated
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
|
|
|
expect(helper.error_tracking_data(current_user, project)).to include(
|
|
|
|
'show-integrated-tracking-disabled-alert' => show_alert.to_s
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
context 'when user is not maintainer' do
|
|
|
|
let(:can_enable_error_tracking) { false }
|
|
|
|
|
|
|
|
it 'shows error tracking enablement as disabled' do
|
|
|
|
expect(helper.error_tracking_data(current_user, project)).to include(
|
|
|
|
'user-can-enable-error-tracking' => 'false'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
describe '#error_details_data' do
|
|
|
|
let(:issue_id) { 1234 }
|
|
|
|
let(:route_params) { [project.owner, project, issue_id, { format: :json }] }
|
2020-03-13 15:44:24 +05:30
|
|
|
let(:project_path) { project.full_path }
|
2019-12-26 22:10:19 +05:30
|
|
|
let(:stack_trace_path) { stack_trace_namespace_project_error_tracking_index_path(*route_params) }
|
2020-01-01 13:55:28 +05:30
|
|
|
let(:issues_path) { project_issues_path(project) }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
let(:result) { helper.error_details_data(project, issue_id) }
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it 'returns the correct issue id' do
|
|
|
|
expect(result['issue-id']).to eq issue_id
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the correct project path' do
|
|
|
|
expect(result['project-path']).to eq project_path
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the correct stack trace path' do
|
|
|
|
expect(result['issue-stack-trace-path']).to eq stack_trace_path
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
it 'creates an issue and redirects to issue show page' do
|
|
|
|
expect(result['project-issues-path']).to eq issues_path
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|