Commit 394460bd authored by Sean Arnold's avatar Sean Arnold

Merge branch 'pl-spec-helper-error-tracking-stubbed' into 'master'

Use stubbed objects in error_tracking_helper spec

See merge request gitlab-org/gitlab!82719
parents b680da0e b0b3ce40
......@@ -388,6 +388,10 @@ FactoryBot.define do
service_desk_enabled { true }
end
trait :with_error_tracking_setting do
error_tracking_setting { association :project_error_tracking_setting }
end
# Project with empty repository
#
# This is a case when you just created a project
......
......@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe Projects::ErrorTrackingHelper do
include Gitlab::Routing.url_helpers
let_it_be(:project, reload: true) { create(:project) }
let_it_be(:current_user) { create(:user) }
let(:project) { build_stubbed(:project) }
let(:current_user) { build_stubbed(:user) }
describe '#error_tracking_data' do
let(:can_enable_error_tracking) { true }
......@@ -41,14 +41,14 @@ RSpec.describe Projects::ErrorTrackingHelper do
end
context 'with error_tracking_setting' do
let(:error_tracking_setting) do
create(:project_error_tracking_setting, project: project)
let(:project) { build_stubbed(:project, :with_error_tracking_setting) }
before do
project.error_tracking_setting.enabled = enabled
end
context 'when enabled' do
before do
error_tracking_setting.update!(enabled: true)
end
let(:enabled) { true }
it 'show error tracking enabled' do
expect(helper.error_tracking_data(current_user, project)).to include(
......@@ -58,9 +58,7 @@ RSpec.describe Projects::ErrorTrackingHelper do
end
context 'when disabled' do
before do
error_tracking_setting.update!(enabled: false)
end
let(:enabled) { false }
it 'show error tracking not enabled' do
expect(helper.error_tracking_data(current_user, project)).to include(
......@@ -86,10 +84,11 @@ RSpec.describe Projects::ErrorTrackingHelper do
with_them do
before do
stub_feature_flags(integrated_error_tracking: feature_flag)
error_tracking_setting.update_columns(
project.error_tracking_setting.attributes = {
enabled: enabled,
integrated: integrated
)
}
end
specify do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment