diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-21 18:09:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-21 18:09:01 +0300 |
commit | c39e93b52ed569635a9ae178115f77ae563b3332 (patch) | |
tree | d58e66290883100d57dc95bdb39a6169f90a0490 /spec/support | |
parent | 0c4570435d417b69efd433057f95f01810618837 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
4 files changed, 73 insertions, 3 deletions
diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml index 4168820a2b3..adee31ca644 100644 --- a/spec/support/rspec_order_todo.yml +++ b/spec/support/rspec_order_todo.yml @@ -4151,7 +4151,6 @@ - './spec/features/projects/settings/registry_settings_spec.rb' - './spec/features/projects/settings/repository_settings_spec.rb' - './spec/features/projects/settings/secure_files_spec.rb' -- './spec/features/projects/settings/service_desk_setting_spec.rb' - './spec/features/projects/settings/user_archives_project_spec.rb' - './spec/features/projects/settings/user_changes_avatar_spec.rb' - './spec/features/projects/settings/user_changes_default_branch_spec.rb' diff --git a/spec/support/shared_examples/controllers/internal_event_tracking_examples.rb b/spec/support/shared_examples/controllers/internal_event_tracking_examples.rb new file mode 100644 index 00000000000..e2a4fb31361 --- /dev/null +++ b/spec/support/shared_examples/controllers/internal_event_tracking_examples.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +# Requires a context containing: +# - subject +# - action +# - user +# Optionally, the context can contain: +# - project +# - namespace + +RSpec.shared_examples 'internal event tracking' do + let(:fake_tracker) { instance_spy(Gitlab::Tracking::Destinations::Snowplow) } + let(:namespace) { nil } + let(:proejct) { nil } + + before do + allow(Gitlab::Tracking).to receive(:tracker).and_return(fake_tracker) + + allow(Gitlab::Tracking::StandardContext).to receive(:new).and_call_original + allow(Gitlab::Tracking::ServicePingContext).to receive(:new).and_call_original + end + + it 'logs to Snowplow', :aggregate_failures do + subject + + expect(Gitlab::Tracking::StandardContext) + .to have_received(:new) + .with( + project_id: project&.id, + user_id: user.id, + namespace_id: namespace&.id, + plan_name: namespace&.actual_plan_name + ) + + expect(Gitlab::Tracking::ServicePingContext) + .to have_received(:new) + .with(data_source: :redis_hll, event: action) + + expect(fake_tracker).to have_received(:event) + .with( + 'InternalEventTracking', + action, + context: [ + an_instance_of(SnowplowTracker::SelfDescribingJson), + an_instance_of(SnowplowTracker::SelfDescribingJson) + ] + ) + .exactly(:once) + end +end diff --git a/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb b/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb index ba00e3e0610..3d3b619451d 100644 --- a/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb +++ b/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb @@ -6,7 +6,7 @@ # - category # - action # - namespace -# Optionaly, the context can contain: +# Optionally, the context can contain: # - project # - property # - user diff --git a/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb index 169fceced7a..9dc18555340 100644 --- a/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/usage_data_counters/issuable_activity_shared_examples.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.shared_examples 'tracked issuable snowplow and service ping events for given event params' do +RSpec.shared_examples 'tracked issuable events' do before do stub_application_setting(usage_ping_enabled: true) end @@ -21,6 +21,10 @@ RSpec.shared_examples 'tracked issuable snowplow and service ping events for giv it 'does not track edit actions if author is not present' do expect(track_action({ author: nil }.merge(track_params))).to be_nil end +end + +RSpec.shared_examples 'tracked issuable snowplow and service ping events for given event params' do + it_behaves_like 'tracked issuable events' it 'emits snowplow event' do track_action({ author: user1 }.merge(track_params)) @@ -29,6 +33,23 @@ RSpec.shared_examples 'tracked issuable snowplow and service ping events for giv end end +RSpec.shared_examples 'tracked issuable internal event for given event params' do + it_behaves_like 'tracked issuable events' + + it_behaves_like 'internal event tracking' do + subject(:track_event) { track_action({ author: user1 }.merge(track_params)) } + + let(:user) { user1 } + let(:namespace) { project&.namespace } + end +end + +RSpec.shared_examples 'tracked issuable internal event with project' do + it_behaves_like 'tracked issuable internal event for given event params' do + let(:track_params) { original_params || { project: project } } + end +end + RSpec.shared_examples 'tracked issuable snowplow and service ping events with project' do it_behaves_like 'tracked issuable snowplow and service ping events for given event params' do let(:context) do |