2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::ErrorTrackingHelper do
|
|
|
|
include Gitlab::Routing.url_helpers
|
|
|
|
|
|
|
|
set(:project) { create(:project) }
|
2019-12-04 20:38:33 +05:30
|
|
|
set(:current_user) { create(: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) }
|
|
|
|
|
|
|
|
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',
|
2019-12-04 20:38:33 +05:30
|
|
|
'illustration-path' => match_asset_path('/assets/illustrations/cluster_popover.svg')
|
2019-02-15 15:39:39 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with error_tracking_setting' do
|
|
|
|
let(:error_tracking_setting) do
|
|
|
|
create(:project_error_tracking_setting, project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when enabled' do
|
|
|
|
before do
|
|
|
|
error_tracking_setting.update!(enabled: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
before do
|
|
|
|
error_tracking_setting.update!(enabled: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
end
|