diff options
Diffstat (limited to 'spec/services/service_ping/submit_service_ping_service_spec.rb')
-rw-r--r-- | spec/services/service_ping/submit_service_ping_service_spec.rb | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/spec/services/service_ping/submit_service_ping_service_spec.rb b/spec/services/service_ping/submit_service_ping_service_spec.rb index 7a8bd1910fe..b863b2a46b0 100644 --- a/spec/services/service_ping/submit_service_ping_service_spec.rb +++ b/spec/services/service_ping/submit_service_ping_service_spec.rb @@ -377,12 +377,15 @@ RSpec.describe ServicePing::SubmitService do stub_database_flavor_check stub_application_setting(usage_ping_enabled: true) stub_response(body: with_conv_index_params) + allow_next_instance_of(ServicePing::BuildPayload) do |service| + allow(service).to receive(:execute).and_return(payload) + end end - context 'with feature flag measure_service_ping_metric_collection turned on' do - let(:metric_double) { instance_double(Gitlab::Usage::ServicePing::LegacyMetricTimingDecorator, duration: 123) } - let(:payload) do - { + let(:metric_double) { instance_double(Gitlab::Usage::ServicePing::LegacyMetricTimingDecorator, duration: 123) } + let(:payload) do + { + uuid: 'uuid', metric_a: metric_double, metric_group: { metric_b: metric_double @@ -390,49 +393,27 @@ RSpec.describe ServicePing::SubmitService do metric_without_timing: "value", recorded_at: Time.current } - end + end - let(:metadata_payload) do - { - metadata: { + let(:metadata_payload) do + { + metadata: { + uuid: 'uuid', metrics: [ { name: 'metric_a', time_elapsed: 123 }, { name: 'metric_group.metric_b', time_elapsed: 123 } ] } } - end - - before do - stub_feature_flags(measure_service_ping_metric_collection: true) - - allow_next_instance_of(ServicePing::BuildPayload) do |service| - allow(service).to receive(:execute).and_return(payload) - end - end - - it 'submits metadata' do - response = stub_full_request(service_ping_metadata_url, method: :post) - .with(body: metadata_payload) - - subject.execute - - expect(response).to have_been_requested - end end - context 'with feature flag measure_service_ping_metric_collection turned off' do - before do - stub_feature_flags(measure_service_ping_metric_collection: false) - end + it 'submits metadata' do + response = stub_full_request(service_ping_metadata_url, method: :post) + .with(body: metadata_payload) - it 'does NOT submit metadata' do - response = stub_full_request(service_ping_metadata_url, method: :post) - - subject.execute + subject.execute - expect(response).not_to have_been_requested - end + expect(response).to have_been_requested end end |