summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-10-09 07:00:42 +0000
committerJan Provaznik <jprovaznik@gitlab.com>2018-10-10 14:09:15 +0200
commit5badd36e859fdcbf60350e92bf805ba5003e1d90 (patch)
tree7669dab0e27e7f6cfca0f66aeadbf89eb8d2d833
parentf1eba61fc40759b79c70d04df941a5ccb53514e5 (diff)
downloadgitlab-ce-5badd36e859fdcbf60350e92bf805ba5003e1d90.tar.gz
Merge branch 'ml-qa-skip-signup-disabled' into 'master'
QA: Allow the registration e2e test to be skipped See merge request gitlab-org/gitlab-ce!22205
-rw-r--r--qa/qa/runtime/env.rb14
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb4
-rw-r--r--qa/qa/specs/runner.rb2
-rw-r--r--qa/spec/runtime/env_spec.rb40
-rw-r--r--qa/spec/specs/runner_spec.rb14
5 files changed, 55 insertions, 19 deletions
diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb
index 27ba915961d..5bebb5ccec0 100644
--- a/qa/qa/runtime/env.rb
+++ b/qa/qa/runtime/env.rb
@@ -5,13 +5,17 @@ module QA
# set to 'false' to have Chrome run visibly instead of headless
def chrome_headless?
- (ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i) != 0
+ enabled?(ENV['CHROME_HEADLESS'])
end
def running_in_ci?
ENV['CI'] || ENV['CI_SERVER']
end
+ def signup_disabled?
+ enabled?(ENV['SIGNUP_DISABLED'], default: false)
+ end
+
# specifies token that can be used for the api
def personal_access_token
ENV['PERSONAL_ACCESS_TOKEN']
@@ -83,6 +87,14 @@ module QA
raise ArgumentError, "Please provide GITHUB_ACCESS_TOKEN"
end
+
+ private
+
+ def enabled?(value, default: true)
+ return default if value.nil?
+
+ (value =~ /^(false|no|0)$/i) != 0
+ end
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb
index 368c24d757f..fb6b4937554 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb
@@ -16,13 +16,13 @@ module QA
end
end
- context :manage do
+ context :manage, :skip_signup_disabled do
describe 'standard' do
it_behaves_like 'registration and login'
end
end
- context :manage, :orchestrated, :ldap do
+ context :manage, :orchestrated, :ldap, :skip_signup_disabled do
describe 'while LDAP is enabled' do
it_behaves_like 'registration and login'
end
diff --git a/qa/qa/specs/runner.rb b/qa/qa/specs/runner.rb
index fea0ef94df3..ad397c13f0c 100644
--- a/qa/qa/specs/runner.rb
+++ b/qa/qa/specs/runner.rb
@@ -23,6 +23,8 @@ module QA
args.push(%w[--tag ~orchestrated]) unless (%w[-t --tag] & options).any?
end
+ args.push(%w[--tag ~skip_signup_disabled]) if QA::Runtime::Env.signup_disabled?
+
args.push(options)
args.push(DEFAULT_TEST_PATH_ARGS) unless options.any? { |opt| opt =~ %r{/features/} }
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb
index d889d185a45..fda955f6600 100644
--- a/qa/spec/runtime/env_spec.rb
+++ b/qa/spec/runtime/env_spec.rb
@@ -1,39 +1,47 @@
describe QA::Runtime::Env do
include Support::StubENV
- describe '.chrome_headless?' do
+ shared_examples 'boolean method' do |method, env_key, default|
context 'when there is an env variable set' do
it 'returns false when falsey values specified' do
- stub_env('CHROME_HEADLESS', 'false')
- expect(described_class.chrome_headless?).to be_falsey
+ stub_env(env_key, 'false')
+ expect(described_class.public_send(method)).to be_falsey
- stub_env('CHROME_HEADLESS', 'no')
- expect(described_class.chrome_headless?).to be_falsey
+ stub_env(env_key, 'no')
+ expect(described_class.public_send(method)).to be_falsey
- stub_env('CHROME_HEADLESS', '0')
- expect(described_class.chrome_headless?).to be_falsey
+ stub_env(env_key, '0')
+ expect(described_class.public_send(method)).to be_falsey
end
it 'returns true when anything else specified' do
- stub_env('CHROME_HEADLESS', 'true')
- expect(described_class.chrome_headless?).to be_truthy
+ stub_env(env_key, 'true')
+ expect(described_class.public_send(method)).to be_truthy
- stub_env('CHROME_HEADLESS', '1')
- expect(described_class.chrome_headless?).to be_truthy
+ stub_env(env_key, '1')
+ expect(described_class.public_send(method)).to be_truthy
- stub_env('CHROME_HEADLESS', 'anything')
- expect(described_class.chrome_headless?).to be_truthy
+ stub_env(env_key, 'anything')
+ expect(described_class.public_send(method)).to be_truthy
end
end
context 'when there is no env variable set' do
- it 'returns the default, true' do
- stub_env('CHROME_HEADLESS', nil)
- expect(described_class.chrome_headless?).to be_truthy
+ it "returns the default, #{default}" do
+ stub_env(env_key, nil)
+ expect(described_class.public_send(method)).to be(default)
end
end
end
+ describe '.signup_disabled?' do
+ it_behaves_like 'boolean method', :signup_disabled?, 'SIGNUP_DISABLED', false
+ end
+
+ describe '.chrome_headless?' do
+ it_behaves_like 'boolean method', :chrome_headless?, 'CHROME_HEADLESS', true
+ end
+
describe '.running_in_ci?' do
context 'when there is an env variable set' do
it 'returns true if CI' do
diff --git a/qa/spec/specs/runner_spec.rb b/qa/spec/specs/runner_spec.rb
index cf22d1c9395..9ddaf7ab1b3 100644
--- a/qa/spec/specs/runner_spec.rb
+++ b/qa/spec/specs/runner_spec.rb
@@ -62,6 +62,20 @@ describe QA::Specs::Runner do
end
end
+ context 'when SIGNUP_DISABLED is true' do
+ before do
+ allow(QA::Runtime::Env).to receive(:signup_disabled?).and_return(true)
+ end
+
+ subject { described_class.new }
+
+ it 'it includes default args and excludes the skip_signup_disabled tag' do
+ expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~skip_signup_disabled', *described_class::DEFAULT_TEST_PATH_ARGS])
+
+ subject.perform
+ end
+ end
+
def expect_rspec_runner_arguments(arguments)
expect(RSpec::Core::Runner).to receive(:run)
.with(arguments, $stderr, $stdout)