Add new OnboardingExperimentHelper modules

OnboardingExperimentHelpers take care of
determining if the current_user should or should
not see the new onboarding feature.
This commit is contained in:
Ash McKenzie 2019-06-27 13:48:04 +10:00
parent 36451a753a
commit 83b1fd120a
No known key found for this signature in database
GPG key ID: A1253B4953E8D3E6
2 changed files with 45 additions and 0 deletions

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
module OnboardingExperimentHelper
def allow_access_to_onboarding?
::Gitlab.com? && Feature.enabled?(:user_onboarding)
end
end

View file

@ -0,0 +1,38 @@
# frozen_string_literal: true
require 'spec_helper'
describe OnboardingExperimentHelper, type: :helper do
describe '.allow_access_to_onboarding?' do
context "when we're not gitlab.com" do
it 'returns false' do
allow(::Gitlab).to receive(:com?).and_return(false)
expect(helper.allow_access_to_onboarding?).to be(false)
end
end
context "when we're gitlab.com" do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
context 'and the :user_onboarding feature is not enabled' do
it 'returns false' do
stub_feature_flags(user_onboarding: false)
expect(helper.allow_access_to_onboarding?).to be(false)
end
end
context 'and the :user_onboarding feature is enabled' do
it 'returns true' do
stub_feature_flags(user_onboarding: true)
allow(helper).to receive(:current_user).and_return(create(:user))
expect(helper.allow_access_to_onboarding?).to be(true)
end
end
end
end
end