summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordstull <dstull@gitlab.com>2019-08-21 14:09:39 -0400
committerdstull <dstull@gitlab.com>2019-08-28 10:47:59 -0400
commitfaace82f6debedb59b4d995e54017005c47f98ca (patch)
treee899448f2bd10ea246895e2d6f272c94cb57215e
parent4b23faab2c4428a9cde7f16a08b3e6059069890c (diff)
downloadgitlab-ce-ce-enable-user-onboarding.tar.gz
Enable mock setup for onboarding development easierce-enable-user-onboarding
- this is a ce backport of the ee changes for: - 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
-rw-r--r--app/helpers/onboarding_experiment_helper.rb2
-rw-r--r--lib/gitlab.rb6
-rw-r--r--spec/helpers/onboarding_experiment_helper_spec.rb8
-rw-r--r--spec/lib/gitlab_spec.rb55
4 files changed, 48 insertions, 23 deletions
diff --git a/app/helpers/onboarding_experiment_helper.rb b/app/helpers/onboarding_experiment_helper.rb
index ad49d333d7a..4b0b3cfb263 100644
--- a/app/helpers/onboarding_experiment_helper.rb
+++ b/app/helpers/onboarding_experiment_helper.rb
@@ -2,6 +2,6 @@
module OnboardingExperimentHelper
def allow_access_to_onboarding?
- ::Gitlab.com? && Feature.enabled?(:user_onboarding)
+ ::Gitlab.dev_env_or_com? && Feature.enabled?(:user_onboarding)
end
end
diff --git a/lib/gitlab.rb b/lib/gitlab.rb
index e8b938e46b1..ea0c0200f51 100644
--- a/lib/gitlab.rb
+++ b/lib/gitlab.rb
@@ -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?
diff --git a/spec/helpers/onboarding_experiment_helper_spec.rb b/spec/helpers/onboarding_experiment_helper_spec.rb
index 5b7d9b1c2e6..cada91bff3c 100644
--- a/spec/helpers/onboarding_experiment_helper_spec.rb
+++ b/spec/helpers/onboarding_experiment_helper_spec.rb
@@ -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
diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb
index 1fc363460ae..4d1fdf8fae0 100644
--- a/spec/lib/gitlab_spec.rb
+++ b/spec/lib/gitlab_spec.rb
@@ -23,23 +23,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
@@ -49,8 +49,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
@@ -61,8 +61,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
@@ -125,6 +125,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)
@@ -140,12 +161,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
@@ -156,12 +177,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