Commit 96313e86 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'enable-user-onboarding' into 'master'

Enable mock setup to make onboarding development easier

See merge request gitlab-org/gitlab-ee!15492
parents ac011fa1 30102587
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module OnboardingExperimentHelper module OnboardingExperimentHelper
def allow_access_to_onboarding? def allow_access_to_onboarding?
::Gitlab.com? && Feature.enabled?(:user_onboarding) ::Gitlab.dev_env_or_com? && Feature.enabled?(:user_onboarding)
end end
end end
......
...@@ -19,6 +19,13 @@ class Explore::OnboardingController < Explore::ApplicationController ...@@ -19,6 +19,13 @@ class Explore::OnboardingController < Explore::ApplicationController
end end
def get_onboarding_demo_project def get_onboarding_demo_project
Project.find_by_full_path("gitlab-org/gitlab-ce") if allow_access_to_onboarding? demo_project if allow_access_to_onboarding?
end
def demo_project
# gdk instances may not have the 'gitlab-ce' project seeded, so we will fallback
# to 'gitlab-test'
Project.find_by_full_path('gitlab-org/gitlab-ce') ||
Project.find_by_full_path('gitlab-org/gitlab-test')
end end
end end
...@@ -15,7 +15,7 @@ module EE ...@@ -15,7 +15,7 @@ module EE
jenkins_deprecated jenkins_deprecated
] ]
if ::Gitlab.com? || Rails.env.development? if ::Gitlab.dev_env_or_com?
ee_service_names.push('gitlab_slack_application') ee_service_names.push('gitlab_slack_application')
end end
......
- return unless Gitlab.com? || Rails.env.development? - return unless Gitlab.dev_env_or_com?
%section.settings.as-slack.no-animate#js-slack-settings{ class: ('expanded' if expanded) } %section.settings.as-slack.no-animate#js-slack-settings{ class: ('expanded' if expanded) }
.settings-header .settings-header
......
...@@ -4,21 +4,19 @@ require 'spec_helper' ...@@ -4,21 +4,19 @@ require 'spec_helper'
describe Explore::OnboardingController do describe Explore::OnboardingController do
let(:user) { create(:user, username: 'gitlab-org') } let(:user) { create(:user, username: 'gitlab-org') }
let(:project) { create(:project, path: 'gitlab-ce', namespace: user.namespace) }
before do before do
allow(Gitlab).to receive(:com?) { true }
sign_in(user) sign_in(user)
project.add_guest(user)
end end
describe 'GET #index' do shared_examples_for 'when the feature is enabled' do
context 'when the feature is enabled' do before do
before do stub_feature_flags(user_onboarding: true)
stub_feature_flags(user_onboarding: true)
end project.add_guest(user)
end
context 'feature enabled' do
it 'renders index with 200 status code and sets the session variable if the user is authenticated' do it 'renders index with 200 status code and sets the session variable if the user is authenticated' do
get :index get :index
...@@ -41,4 +39,29 @@ describe Explore::OnboardingController do ...@@ -41,4 +39,29 @@ describe Explore::OnboardingController do
end end
end end
end end
context 'when on .com' do
describe 'GET #index' do
before do
allow(Gitlab).to receive(:com?) { true }
end
it_behaves_like 'when the feature is enabled' do
let(:project) { create(:project, path: 'gitlab-ce', namespace: user.namespace) }
end
end
end
context 'is dev env' do
describe 'GET #index' do
before do
allow(Gitlab).to receive(:com?) { false }
allow(Gitlab).to receive(:dev_env_or_com?) { true }
end
it_behaves_like 'when the feature is enabled' do
let(:project) { create(:project, path: 'gitlab-test', namespace: user.namespace) }
end
end
end
end end
...@@ -56,7 +56,11 @@ module Gitlab ...@@ -56,7 +56,11 @@ module Gitlab
end end
def self.dev_env_org_or_com? def self.dev_env_org_or_com?
Rails.env.development? || org? || com? dev_env_or_com? || org?
end
def self.dev_env_or_com?
Rails.env.development? || com?
end end
def self.ee? def self.ee?
......
...@@ -4,17 +4,17 @@ require 'spec_helper' ...@@ -4,17 +4,17 @@ require 'spec_helper'
describe OnboardingExperimentHelper, type: :helper do describe OnboardingExperimentHelper, type: :helper do
describe '.allow_access_to_onboarding?' do describe '.allow_access_to_onboarding?' do
context "when we're not gitlab.com" do context "when we're not gitlab.com or dev env" do
it 'returns false' do it 'returns false' do
allow(::Gitlab).to receive(:com?).and_return(false) allow(::Gitlab).to receive(:dev_env_or_com?).and_return(false)
expect(helper.allow_access_to_onboarding?).to be(false) expect(helper.allow_access_to_onboarding?).to be(false)
end end
end end
context "when we're gitlab.com" do context "when we're gitlab.com or dev env" do
before do before do
allow(::Gitlab).to receive(:com?).and_return(true) allow(::Gitlab).to receive(:dev_env_or_com?).and_return(true)
end end
context 'and the :user_onboarding feature is not enabled' do context 'and the :user_onboarding feature is not enabled' do
......
...@@ -21,23 +21,23 @@ describe Gitlab do ...@@ -21,23 +21,23 @@ describe Gitlab do
context 'when a REVISION file exists' do context 'when a REVISION file exists' do
before do before do
expect(File).to receive(:exist?) expect(File).to receive(:exist?)
.with(described_class.root.join('REVISION')) .with(described_class.root.join('REVISION'))
.and_return(true) .and_return(true)
end end
it 'returns the actual Git revision' do it 'returns the actual Git revision' do
expect(File).to receive(:read) expect(File).to receive(:read)
.with(described_class.root.join('REVISION')) .with(described_class.root.join('REVISION'))
.and_return("abc123\n") .and_return("abc123\n")
expect(described_class.revision).to eq('abc123') expect(described_class.revision).to eq('abc123')
end end
it 'memoizes the revision' do it 'memoizes the revision' do
expect(File).to receive(:read) expect(File).to receive(:read)
.once .once
.with(described_class.root.join('REVISION')) .with(described_class.root.join('REVISION'))
.and_return("abc123\n") .and_return("abc123\n")
2.times { described_class.revision } 2.times { described_class.revision }
end end
...@@ -47,8 +47,8 @@ describe Gitlab do ...@@ -47,8 +47,8 @@ describe Gitlab do
context 'when the Git command succeeds' do context 'when the Git command succeeds' do
before do before do
expect(Gitlab::Popen).to receive(:popen_with_detail) expect(Gitlab::Popen).to receive(:popen_with_detail)
.with(cmd) .with(cmd)
.and_return(Gitlab::Popen::Result.new(cmd, 'abc123', '', double(success?: true))) .and_return(Gitlab::Popen::Result.new(cmd, 'abc123', '', double(success?: true)))
end end
it 'returns the actual Git revision' do it 'returns the actual Git revision' do
...@@ -59,8 +59,8 @@ describe Gitlab do ...@@ -59,8 +59,8 @@ describe Gitlab do
context 'when the Git command fails' do context 'when the Git command fails' do
before do before do
expect(Gitlab::Popen).to receive(:popen_with_detail) expect(Gitlab::Popen).to receive(:popen_with_detail)
.with(cmd) .with(cmd)
.and_return(Gitlab::Popen::Result.new(cmd, '', 'fatal: Not a git repository', double('Process::Status', success?: false))) .and_return(Gitlab::Popen::Result.new(cmd, '', 'fatal: Not a git repository', double('Process::Status', success?: false)))
end end
it 'returns "Unknown"' do it 'returns "Unknown"' do
...@@ -123,6 +123,27 @@ describe Gitlab do ...@@ -123,6 +123,27 @@ describe Gitlab do
end end
end end
describe '.dev_env_or_com?' do
it 'is true when on .com' do
allow(described_class).to receive(:com?).and_return(true)
expect(described_class.dev_env_or_com?).to eq true
end
it 'is true when dev env' do
allow(described_class).to receive(:com?).and_return(false)
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
expect(described_class.dev_env_or_com?).to eq true
end
it 'is false when not dev or com' do
allow(described_class).to receive(:com?).and_return(false)
expect(described_class.dev_env_or_com?).to eq false
end
end
describe '.ee?' do describe '.ee?' do
before do before do
described_class.instance_variable_set(:@is_ee, nil) described_class.instance_variable_set(:@is_ee, nil)
...@@ -138,12 +159,12 @@ describe Gitlab do ...@@ -138,12 +159,12 @@ describe Gitlab do
allow(described_class) allow(described_class)
.to receive(:root) .to receive(:root)
.and_return(root) .and_return(root)
allow(root) allow(root)
.to receive(:join) .to receive(:join)
.with('ee/app/models/license.rb') .with('ee/app/models/license.rb')
.and_return(license_path) .and_return(license_path)
expect(described_class.ee?).to eq(true) expect(described_class.ee?).to eq(true)
end end
...@@ -154,12 +175,12 @@ describe Gitlab do ...@@ -154,12 +175,12 @@ describe Gitlab do
allow(described_class) allow(described_class)
.to receive(:root) .to receive(:root)
.and_return(Pathname.new('dummy')) .and_return(Pathname.new('dummy'))
allow(root) allow(root)
.to receive(:join) .to receive(:join)
.with('ee/app/models/license.rb') .with('ee/app/models/license.rb')
.and_return(license_path) .and_return(license_path)
expect(described_class.ee?).to eq(false) expect(described_class.ee?).to eq(false)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment