diff options
Diffstat (limited to 'spec/workers/namespaces')
-rw-r--r-- | spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb | 32 | ||||
-rw-r--r-- | spec/workers/namespaces/onboarding_user_added_worker_spec.rb | 10 |
2 files changed, 40 insertions, 2 deletions
diff --git a/spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb b/spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb new file mode 100644 index 00000000000..f1789fa8fbd --- /dev/null +++ b/spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Namespaces::OnboardingPipelineCreatedWorker, '#perform' do + include AfterNextHelpers + + let_it_be(:ci_pipeline) { create(:ci_pipeline) } + + before do + OnboardingProgress.onboard(ci_pipeline.project.namespace) + end + + it 'registers an onboarding progress action' do + expect_next(OnboardingProgressService, ci_pipeline.project.namespace) + .to receive(:execute).with(action: :pipeline_created).and_call_original + + subject.perform(ci_pipeline.project.namespace_id) + + expect(OnboardingProgress.completed?(ci_pipeline.project.namespace, :pipeline_created)).to eq(true) + end + + context "when a namespace doesn't exist" do + it 'does not register an onboarding progress action' do + expect_next(OnboardingProgressService, ci_pipeline.project.namespace).not_to receive(:execute) + + subject.perform(nil) + + expect(OnboardingProgress.completed?(ci_pipeline.project.namespace, :pipeline_created)).to eq(false) + end + end +end diff --git a/spec/workers/namespaces/onboarding_user_added_worker_spec.rb b/spec/workers/namespaces/onboarding_user_added_worker_spec.rb index 03c668259f8..a773e160fab 100644 --- a/spec/workers/namespaces/onboarding_user_added_worker_spec.rb +++ b/spec/workers/namespaces/onboarding_user_added_worker_spec.rb @@ -7,10 +7,16 @@ RSpec.describe Namespaces::OnboardingUserAddedWorker, '#perform' do let_it_be(:group) { create(:group) } - it 'records the event' do + before do + OnboardingProgress.onboard(group) + end + + it 'registers an onboarding progress action' do expect_next(OnboardingProgressService, group) .to receive(:execute).with(action: :user_added).and_call_original - expect { subject.perform(group.id) }.to change(NamespaceOnboardingAction, :count).by(1) + subject.perform(group.id) + + expect(OnboardingProgress.completed?(group, :user_added)).to be(true) end end |