diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/services/onboarding_progress_service_spec.rb | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/services/onboarding_progress_service_spec.rb')
-rw-r--r-- | spec/services/onboarding_progress_service_spec.rb | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/spec/services/onboarding_progress_service_spec.rb b/spec/services/onboarding_progress_service_spec.rb index 340face4ae8..ef4f4f0d822 100644 --- a/spec/services/onboarding_progress_service_spec.rb +++ b/spec/services/onboarding_progress_service_spec.rb @@ -3,9 +3,49 @@ require 'spec_helper' RSpec.describe OnboardingProgressService do + describe '.async' do + let_it_be(:namespace) { create(:namespace) } + let_it_be(:action) { :git_pull } + + subject(:execute_service) { described_class.async(namespace.id).execute(action: action) } + + context 'when not onboarded' do + it 'does not schedule a worker' do + expect(Namespaces::OnboardingProgressWorker).not_to receive(:perform_async) + + execute_service + end + end + + context 'when onboarded' do + before do + OnboardingProgress.onboard(namespace) + end + + context 'when action is already completed' do + before do + OnboardingProgress.register(namespace, action) + end + + it 'does not schedule a worker' do + expect(Namespaces::OnboardingProgressWorker).not_to receive(:perform_async) + + execute_service + end + end + + context 'when action is not yet completed' do + it 'schedules a worker' do + expect(Namespaces::OnboardingProgressWorker).to receive(:perform_async) + + execute_service + end + end + end + end + describe '#execute' do - let(:namespace) { create(:namespace, parent: root_namespace) } - let(:root_namespace) { nil } + let(:namespace) { create(:namespace) } let(:action) { :namespace_action } subject(:execute_service) { described_class.new(namespace).execute(action: :subscription_created) } @@ -23,16 +63,16 @@ RSpec.describe OnboardingProgressService do end context 'when the namespace is not the root' do - let(:root_namespace) { build(:namespace) } + let(:group) { create(:group, :nested) } before do - OnboardingProgress.onboard(root_namespace) + OnboardingProgress.onboard(group) end - it 'registers a namespace onboarding progress action for the root namespace' do + it 'does not register a namespace onboarding progress action' do execute_service - expect(OnboardingProgress.completed?(root_namespace, :subscription_created)).to eq(true) + expect(OnboardingProgress.completed?(group, :subscription_created)).to be(nil) end end @@ -42,7 +82,7 @@ RSpec.describe OnboardingProgressService do it 'does not register a namespace onboarding progress action' do execute_service - expect(OnboardingProgress.completed?(root_namespace, :subscription_created)).to be(nil) + expect(OnboardingProgress.completed?(namespace, :subscription_created)).to be(nil) end end end |