debian-mirror-gitlab/spec/services/onboarding_progress_service_spec.rb

50 lines
1.4 KiB
Ruby
Raw Normal View History

2021-02-22 17:27:13 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe OnboardingProgressService do
describe '#execute' do
let(:namespace) { create(:namespace, parent: root_namespace) }
2021-03-08 18:12:59 +05:30
let(:root_namespace) { nil }
let(:action) { :namespace_action }
2021-02-22 17:27:13 +05:30
subject(:execute_service) { described_class.new(namespace).execute(action: :subscription_created) }
context 'when the namespace is a root' do
2021-03-08 18:12:59 +05:30
before do
OnboardingProgress.onboard(namespace)
end
2021-02-22 17:27:13 +05:30
2021-03-08 18:12:59 +05:30
it 'registers a namespace onboarding progress action for the given namespace' do
execute_service
2021-02-22 17:27:13 +05:30
2021-03-08 18:12:59 +05:30
expect(OnboardingProgress.completed?(namespace, :subscription_created)).to eq(true)
2021-02-22 17:27:13 +05:30
end
end
context 'when the namespace is not the root' do
2021-03-08 18:12:59 +05:30
let(:root_namespace) { build(:namespace) }
before do
OnboardingProgress.onboard(root_namespace)
end
it 'registers a namespace onboarding progress action for the root namespace' do
execute_service
expect(OnboardingProgress.completed?(root_namespace, :subscription_created)).to eq(true)
end
end
context 'when no namespace is passed' do
let(:namespace) { nil }
2021-02-22 17:27:13 +05:30
2021-03-08 18:12:59 +05:30
it 'does not register a namespace onboarding progress action' do
execute_service
2021-02-22 17:27:13 +05:30
2021-03-08 18:12:59 +05:30
expect(OnboardingProgress.completed?(root_namespace, :subscription_created)).to be(nil)
2021-02-22 17:27:13 +05:30
end
end
end
end