Commit 30102587 authored by Doug Stull's avatar Doug Stull Committed by Lin Jen-Shin

Enable mock setup for onboarding development easier

- it used to be complicated to setup your local environment
  in order to work on the onboarding tour.  Full of
  temporary changes that would need backed out
- now we can work on it merely by enabling the Feature flag
  :user_onboarding
parent ac011fa1
......@@ -2,7 +2,7 @@
module OnboardingExperimentHelper
def allow_access_to_onboarding?
::Gitlab.com? && Feature.enabled?(:user_onboarding)
::Gitlab.dev_env_or_com? && Feature.enabled?(:user_onboarding)
end
end
......
......@@ -19,6 +19,13 @@ class Explore::OnboardingController < Explore::ApplicationController
end
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
......@@ -15,7 +15,7 @@ module EE
jenkins_deprecated
]
if ::Gitlab.com? || Rails.env.development?
if ::Gitlab.dev_env_or_com?
ee_service_names.push('gitlab_slack_application')
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) }
.settings-header
......
......@@ -4,21 +4,19 @@ require 'spec_helper'
describe Explore::OnboardingController do
let(:user) { create(:user, username: 'gitlab-org') }
let(:project) { create(:project, path: 'gitlab-ce', namespace: user.namespace) }
before do
allow(Gitlab).to receive(:com?) { true }
sign_in(user)
project.add_guest(user)
end
describe 'GET #index' do
context 'when the feature is enabled' do
before do
stub_feature_flags(user_onboarding: true)
end
shared_examples_for 'when the feature is enabled' do
before do
stub_feature_flags(user_onboarding: true)
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
get :index
......@@ -41,4 +39,29 @@ describe Explore::OnboardingController do
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
......@@ -56,7 +56,11 @@ module Gitlab
end
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
def self.ee?
......
......@@ -4,17 +4,17 @@ require 'spec_helper'
describe OnboardingExperimentHelper, type: :helper 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
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)
end
end
context "when we're gitlab.com" do
context "when we're gitlab.com or dev env" do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(true)
end
context 'and the :user_onboarding feature is not enabled' do
......
......@@ -21,23 +21,23 @@ describe Gitlab do
context 'when a REVISION file exists' do
before do
expect(File).to receive(:exist?)
.with(described_class.root.join('REVISION'))
.and_return(true)
.with(described_class.root.join('REVISION'))
.and_return(true)
end
it 'returns the actual Git revision' do
expect(File).to receive(:read)
.with(described_class.root.join('REVISION'))
.and_return("abc123\n")
.with(described_class.root.join('REVISION'))
.and_return("abc123\n")
expect(described_class.revision).to eq('abc123')
end
it 'memoizes the revision' do
expect(File).to receive(:read)
.once
.with(described_class.root.join('REVISION'))
.and_return("abc123\n")
.once
.with(described_class.root.join('REVISION'))
.and_return("abc123\n")
2.times { described_class.revision }
end
......@@ -47,8 +47,8 @@ describe Gitlab do
context 'when the Git command succeeds' do
before do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with(cmd)
.and_return(Gitlab::Popen::Result.new(cmd, 'abc123', '', double(success?: true)))
.with(cmd)
.and_return(Gitlab::Popen::Result.new(cmd, 'abc123', '', double(success?: true)))
end
it 'returns the actual Git revision' do
......@@ -59,8 +59,8 @@ describe Gitlab do
context 'when the Git command fails' do
before do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with(cmd)
.and_return(Gitlab::Popen::Result.new(cmd, '', 'fatal: Not a git repository', double('Process::Status', success?: false)))
.with(cmd)
.and_return(Gitlab::Popen::Result.new(cmd, '', 'fatal: Not a git repository', double('Process::Status', success?: false)))
end
it 'returns "Unknown"' do
......@@ -123,6 +123,27 @@ describe Gitlab do
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
before do
described_class.instance_variable_set(:@is_ee, nil)
......@@ -138,12 +159,12 @@ describe Gitlab do
allow(described_class)
.to receive(:root)
.and_return(root)
.and_return(root)
allow(root)
.to receive(:join)
.with('ee/app/models/license.rb')
.and_return(license_path)
.with('ee/app/models/license.rb')
.and_return(license_path)
expect(described_class.ee?).to eq(true)
end
......@@ -154,12 +175,12 @@ describe Gitlab do
allow(described_class)
.to receive(:root)
.and_return(Pathname.new('dummy'))
.and_return(Pathname.new('dummy'))
allow(root)
.to receive(:join)
.with('ee/app/models/license.rb')
.and_return(license_path)
.with('ee/app/models/license.rb')
.and_return(license_path)
expect(described_class.ee?).to eq(false)
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