Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'qa/spec/scenario/template_spec.rb')
-rw-r--r--qa/spec/scenario/template_spec.rb72
1 files changed, 48 insertions, 24 deletions
diff --git a/qa/spec/scenario/template_spec.rb b/qa/spec/scenario/template_spec.rb
index 9800f92b306..56521cc13bc 100644
--- a/qa/spec/scenario/template_spec.rb
+++ b/qa/spec/scenario/template_spec.rb
@@ -1,35 +1,49 @@
# frozen_string_literal: true
RSpec.describe QA::Scenario::Template do
- let(:feature) { spy('Runtime::Feature') }
- let(:release) { spy('Runtime::Release') }
+ let(:release) { spy('QA::Runtime::Release') } # rubocop:disable RSpec/VerifiedDoubles
+ let(:feature) { class_spy('QA::Runtime::Feature') }
+ let(:scenario) { class_spy('QA::Runtime::Scenario') }
+ let(:runner) { class_spy('QA::Specs::Runner') }
+
let(:gitlab_address) { 'https://gitlab.com/' }
+ let(:gitlab_address_from_env) { 'https://staging.gitlab.com/' }
before do
stub_const('QA::Runtime::Release', release)
stub_const('QA::Runtime::Feature', feature)
- allow(QA::Specs::Runner).to receive(:perform)
- allow(QA::Runtime::Address).to receive(:valid?).and_return(true)
+ stub_const('QA::Runtime::Scenario', scenario)
+ stub_const('QA::Specs::Runner', runner)
+
+ allow(QA::Runtime::Env).to receive(:knapsack?).and_return(false)
+ allow(QA::Runtime::Env).to receive(:gitlab_url).and_return(gitlab_address_from_env)
+
+ allow(QA::Runtime::Browser).to receive(:configure!)
+
+ allow(scenario).to receive(:attributes).and_return({ gitlab_address: gitlab_address })
+ allow(scenario).to receive(:define)
+
+ QA::Support::GitlabAddress.instance_variable_set(:@initialized, false)
end
it 'allows a feature to be enabled' do
subject.perform({ gitlab_address: gitlab_address, enable_feature: 'a-feature' })
expect(feature).to have_received(:enable).with('a-feature')
+ expect(feature).to have_received(:disable).with('a-feature')
end
it 'allows a feature to be disabled' do
- allow(QA::Runtime::Feature).to receive(:enabled?)
- .with('another-feature').and_return(true)
+ allow(QA::Runtime::Feature).to receive(:enabled?).with('another-feature').and_return(true)
subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' })
expect(feature).to have_received(:disable).with('another-feature')
+ expect(feature).to have_received(:enable).with('another-feature')
end
it 'does not disable a feature if already disabled' do
- allow(QA::Runtime::Feature).to receive(:enabled?)
- .with('another-feature').and_return(false)
+ allow(QA::Runtime::Feature).to receive(:enabled?).with('another-feature').and_return(false)
subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' })
@@ -39,7 +53,8 @@ RSpec.describe QA::Scenario::Template do
it 'ensures an enabled feature is disabled afterwards' do
allow(QA::Specs::Runner).to receive(:perform).and_raise('failed test')
- expect { subject.perform({ gitlab_address: gitlab_address, enable_feature: 'a-feature' }) }.to raise_error('failed test')
+ expect { subject.perform({ gitlab_address: gitlab_address, enable_feature: 'a-feature' }) }
+ .to raise_error('failed test')
expect(feature).to have_received(:enable).with('a-feature')
expect(feature).to have_received(:disable).with('a-feature')
@@ -47,11 +62,10 @@ RSpec.describe QA::Scenario::Template do
it 'ensures a disabled feature is enabled afterwards' do
allow(QA::Specs::Runner).to receive(:perform).and_raise('failed test')
+ allow(QA::Runtime::Feature).to receive(:enabled?).with('another-feature').and_return(true)
- allow(QA::Runtime::Feature).to receive(:enabled?)
- .with('another-feature').and_return(true)
-
- expect { subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' }) }.to raise_error('failed test')
+ expect { subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' }) }
+ .to raise_error('failed test')
expect(feature).to have_received(:disable).with('another-feature')
expect(feature).to have_received(:enable).with('another-feature')
@@ -59,25 +73,35 @@ RSpec.describe QA::Scenario::Template do
it 'ensures a disabled feature is not enabled afterwards if it was disabled earlier' do
allow(QA::Specs::Runner).to receive(:perform).and_raise('failed test')
+ allow(QA::Runtime::Feature).to receive(:enabled?).with('another-feature').and_return(false)
- allow(QA::Runtime::Feature).to receive(:enabled?)
- .with('another-feature').and_return(false)
-
- expect { subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' }) }.to raise_error('failed test')
+ expect { subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' }) }
+ .to raise_error('failed test')
expect(feature).not_to have_received(:disable).with('another-feature')
expect(feature).not_to have_received(:enable).with('another-feature')
end
- it 'defines an about address by default' do
- subject.perform( { gitlab_address: gitlab_address })
+ it 'defines gitlab address from positional argument' do
+ allow(scenario).to receive(:attributes).and_return({})
+
+ subject.perform({}, gitlab_address)
+
+ expect(scenario).to have_received(:define).with(:gitlab_address, gitlab_address)
+ expect(scenario).to have_received(:define).with(:about_address, 'https://about.gitlab.com/')
+ end
- expect(QA::Runtime::Scenario.gitlab_address).to eq(gitlab_address)
- expect(QA::Runtime::Scenario.about_address).to eq('https://about.gitlab.com/')
+ it "defaults to gitlab address from env" do
+ allow(scenario).to receive(:attributes).and_return({})
+
+ subject.perform({})
+
+ expect(scenario).to have_received(:define).with(:gitlab_address, gitlab_address_from_env)
+ end
- subject.perform({ gitlab_address: 'http://gitlab-abc.test/' })
+ it 'defines klass attribute' do
+ subject.perform({ gitlab_address: gitlab_address })
- expect(QA::Runtime::Scenario.gitlab_address).to eq('http://gitlab-abc.test/')
- expect(QA::Runtime::Scenario.about_address).to eq('http://about.gitlab-abc.test/')
+ expect(scenario).to have_received(:define).with(:klass, 'QA::Scenario::Template')
end
end