Commit e0429111 authored by Rémy Coutable's avatar Rémy Coutable

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
parents c90d3404 03ee488f
...@@ -5,13 +5,17 @@ module QA ...@@ -5,13 +5,17 @@ module QA
# set to 'false' to have Chrome run visibly instead of headless # set to 'false' to have Chrome run visibly instead of headless
def chrome_headless? def chrome_headless?
(ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i) != 0 enabled?(ENV['CHROME_HEADLESS'])
end end
def running_in_ci? def running_in_ci?
ENV['CI'] || ENV['CI_SERVER'] ENV['CI'] || ENV['CI_SERVER']
end end
def signup_disabled?
enabled?(ENV['SIGNUP_DISABLED'], default: false)
end
# specifies token that can be used for the api # specifies token that can be used for the api
def personal_access_token def personal_access_token
ENV['PERSONAL_ACCESS_TOKEN'] ENV['PERSONAL_ACCESS_TOKEN']
...@@ -83,6 +87,14 @@ module QA ...@@ -83,6 +87,14 @@ module QA
raise ArgumentError, "Please provide GITHUB_ACCESS_TOKEN" raise ArgumentError, "Please provide GITHUB_ACCESS_TOKEN"
end end
private
def enabled?(value, default: true)
return default if value.nil?
(value =~ /^(false|no|0)$/i) != 0
end
end end
end end
end end
...@@ -16,13 +16,13 @@ module QA ...@@ -16,13 +16,13 @@ module QA
end end
end end
context :manage do context :manage, :skip_signup_disabled do
describe 'standard' do describe 'standard' do
it_behaves_like 'registration and login' it_behaves_like 'registration and login'
end end
end end
context :manage, :orchestrated, :ldap do context :manage, :orchestrated, :ldap, :skip_signup_disabled do
describe 'while LDAP is enabled' do describe 'while LDAP is enabled' do
it_behaves_like 'registration and login' it_behaves_like 'registration and login'
end end
......
...@@ -23,6 +23,8 @@ module QA ...@@ -23,6 +23,8 @@ module QA
args.push(%w[--tag ~orchestrated]) unless (%w[-t --tag] & options).any? args.push(%w[--tag ~orchestrated]) unless (%w[-t --tag] & options).any?
end end
args.push(%w[--tag ~skip_signup_disabled]) if QA::Runtime::Env.signup_disabled?
args.push(options) args.push(options)
args.push(DEFAULT_TEST_PATH_ARGS) unless options.any? { |opt| opt =~ %r{/features/} } args.push(DEFAULT_TEST_PATH_ARGS) unless options.any? { |opt| opt =~ %r{/features/} }
......
describe QA::Runtime::Env do describe QA::Runtime::Env do
include Support::StubENV 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 context 'when there is an env variable set' do
it 'returns false when falsey values specified' do it 'returns false when falsey values specified' do
stub_env('CHROME_HEADLESS', 'false') stub_env(env_key, 'false')
expect(described_class.chrome_headless?).to be_falsey expect(described_class.public_send(method)).to be_falsey
stub_env('CHROME_HEADLESS', 'no') stub_env(env_key, 'no')
expect(described_class.chrome_headless?).to be_falsey expect(described_class.public_send(method)).to be_falsey
stub_env('CHROME_HEADLESS', '0') stub_env(env_key, '0')
expect(described_class.chrome_headless?).to be_falsey expect(described_class.public_send(method)).to be_falsey
end end
it 'returns true when anything else specified' do it 'returns true when anything else specified' do
stub_env('CHROME_HEADLESS', 'true') stub_env(env_key, 'true')
expect(described_class.chrome_headless?).to be_truthy expect(described_class.public_send(method)).to be_truthy
stub_env('CHROME_HEADLESS', '1') stub_env(env_key, '1')
expect(described_class.chrome_headless?).to be_truthy expect(described_class.public_send(method)).to be_truthy
stub_env('CHROME_HEADLESS', 'anything') stub_env(env_key, 'anything')
expect(described_class.chrome_headless?).to be_truthy expect(described_class.public_send(method)).to be_truthy
end end
end end
context 'when there is no env variable set' do context 'when there is no env variable set' do
it 'returns the default, true' do it "returns the default, #{default}" do
stub_env('CHROME_HEADLESS', nil) stub_env(env_key, nil)
expect(described_class.chrome_headless?).to be_truthy expect(described_class.public_send(method)).to be(default)
end end
end 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 describe '.running_in_ci?' do
context 'when there is an env variable set' do context 'when there is an env variable set' do
it 'returns true if CI' do it 'returns true if CI' do
......
...@@ -62,6 +62,20 @@ describe QA::Specs::Runner do ...@@ -62,6 +62,20 @@ describe QA::Specs::Runner do
end end
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) def expect_rspec_runner_arguments(arguments)
expect(RSpec::Core::Runner).to receive(:run) expect(RSpec::Core::Runner).to receive(:run)
.with(arguments, $stderr, $stdout) .with(arguments, $stderr, $stdout)
......
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