diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/workers/gitlab_service_ping_worker_spec.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/workers/gitlab_service_ping_worker_spec.rb')
-rw-r--r-- | spec/workers/gitlab_service_ping_worker_spec.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/spec/workers/gitlab_service_ping_worker_spec.rb b/spec/workers/gitlab_service_ping_worker_spec.rb index c88708dc50a..f17847a7b33 100644 --- a/spec/workers/gitlab_service_ping_worker_spec.rb +++ b/spec/workers/gitlab_service_ping_worker_spec.rb @@ -14,21 +14,36 @@ RSpec.describe GitlabServicePingWorker, :clean_gitlab_redis_shared_state do allow(subject).to receive(:sleep) end - it 'does not run for GitLab.com' do + it 'does not run for GitLab.com when triggered from cron' do allow(Gitlab).to receive(:com?).and_return(true) expect(ServicePing::SubmitService).not_to receive(:new) subject.perform end + it 'runs for GitLab.com when triggered manually' do + allow(Gitlab).to receive(:com?).and_return(true) + expect(ServicePing::SubmitService).to receive(:new) + + subject.perform('triggered_from_cron' => false) + end + it 'delegates to ServicePing::SubmitService' do - expect_next_instance_of(ServicePing::SubmitService, payload: payload) do |service| + expect_next_instance_of(ServicePing::SubmitService, payload: payload, skip_db_write: false) do |service| expect(service).to receive(:execute) end subject.perform end + it 'passes Hash arguments to ServicePing::SubmitService' do + expect_next_instance_of(ServicePing::SubmitService, payload: payload, skip_db_write: true) do |service| + expect(service).to receive(:execute) + end + + subject.perform('skip_db_write' => true) + end + context 'payload computation' do it 'creates RawUsageData entry when there is NO entry with the same recorded_at timestamp' do expect { subject.perform }.to change { RawUsageData.count }.by(1) @@ -46,7 +61,7 @@ RSpec.describe GitlabServicePingWorker, :clean_gitlab_redis_shared_state do allow(::ServicePing::BuildPayload).to receive(:new).and_raise(error) expect(::Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).with(error) - expect_next_instance_of(::ServicePing::SubmitService, payload: nil) do |service| + expect_next_instance_of(::ServicePing::SubmitService, payload: nil, skip_db_write: false) do |service| expect(service).to receive(:execute) end |