debian-mirror-gitlab/qa/spec/scenario/template_spec.rb

84 lines
3.3 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2021-01-03 14:25:43 +05:30
RSpec.describe QA::Scenario::Template do
2019-07-07 11:18:12 +05:30
let(:feature) { spy('Runtime::Feature') }
let(:release) { spy('Runtime::Release') }
2021-06-08 01:23:25 +05:30
let(:gitlab_address) { 'https://gitlab.com/' }
2019-07-07 11:18:12 +05:30
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)
end
it 'allows a feature to be enabled' do
2021-06-08 01:23:25 +05:30
subject.perform({ gitlab_address: gitlab_address, enable_feature: 'a-feature' })
2019-07-07 11:18:12 +05:30
expect(feature).to have_received(:enable).with('a-feature')
end
2020-10-24 23:57:45 +05:30
it 'allows a feature to be disabled' do
allow(QA::Runtime::Feature).to receive(:enabled?)
.with('another-feature').and_return(true)
2021-06-08 01:23:25 +05:30
subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' })
2020-10-24 23:57:45 +05:30
expect(feature).to have_received(:disable).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)
2021-06-08 01:23:25 +05:30
subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' })
2020-10-24 23:57:45 +05:30
expect(feature).not_to have_received(:disable).with('another-feature')
end
2019-07-07 11:18:12 +05:30
it 'ensures an enabled feature is disabled afterwards' do
allow(QA::Specs::Runner).to receive(:perform).and_raise('failed test')
2021-06-08 01:23:25 +05:30
expect { subject.perform({ gitlab_address: gitlab_address, enable_feature: 'a-feature' }) }.to raise_error('failed test')
2019-07-07 11:18:12 +05:30
expect(feature).to have_received(:enable).with('a-feature')
expect(feature).to have_received(:disable).with('a-feature')
end
2020-10-24 23:57:45 +05:30
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)
2021-06-08 01:23:25 +05:30
expect { subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' }) }.to raise_error('failed test')
2020-10-24 23:57:45 +05:30
expect(feature).to have_received(:disable).with('another-feature')
expect(feature).to have_received(:enable).with('another-feature')
end
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)
2021-06-08 01:23:25 +05:30
expect { subject.perform({ gitlab_address: gitlab_address, disable_feature: 'another-feature' }) }.to raise_error('failed test')
2020-10-24 23:57:45 +05:30
expect(feature).not_to have_received(:disable).with('another-feature')
expect(feature).not_to have_received(:enable).with('another-feature')
end
2021-06-08 01:23:25 +05:30
it 'defines an about address by default' do
subject.perform( { gitlab_address: gitlab_address })
expect(QA::Runtime::Scenario.gitlab_address).to eq(gitlab_address)
expect(QA::Runtime::Scenario.about_address).to eq('https://about.gitlab.com/')
subject.perform({ gitlab_address: 'http://gitlab-abc.test/' })
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/')
end
2019-07-07 11:18:12 +05:30
end