Welcome to mirror list, hosted at ThFree Co, Russian Federation.

onboarding_progress_service_spec.rb « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: de4c0d2a3ba415a069a554fdacbe7e2b22973a75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe OnboardingProgressService do
  describe '#execute' do
    let(:namespace) { create(:namespace, parent: root_namespace) }
    let(:root_namespace) { nil }
    let(:action) { :namespace_action }

    subject(:execute_service) { described_class.new(namespace).execute(action: :subscription_created) }

    context 'when the namespace is a root' do
      it 'records a namespace onboarding progress action fot the given namespace' do
        expect(NamespaceOnboardingAction).to receive(:create_action)
          .with(namespace, :subscription_created).and_call_original

        expect { execute_service }.to change(NamespaceOnboardingAction, :count).by(1)
      end
    end

    context 'when the namespace is not the root' do
      let(:root_namespace) { build(:namespace) }

      it 'records a namespace onboarding progress action for the root namespace' do
        expect(NamespaceOnboardingAction).to receive(:create_action)
          .with(root_namespace, :subscription_created).and_call_original

        expect { execute_service }.to change(NamespaceOnboardingAction, :count).by(1)
      end
    end

    context 'when no namespace is passed' do
      let(:namespace) { nil }

      it 'does not record a namespace onboarding progress action' do
        expect(NamespaceOnboardingAction).not_to receive(:create_action)

        execute_service
      end
    end
  end
end