diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /spec/lib/feature_spec.rb | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'spec/lib/feature_spec.rb')
-rw-r--r-- | spec/lib/feature_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/feature_spec.rb b/spec/lib/feature_spec.rb index 82580d5d700..8c546390201 100644 --- a/spec/lib/feature_spec.rb +++ b/spec/lib/feature_spec.rb @@ -3,12 +3,40 @@ require 'spec_helper' RSpec.describe Feature, stub_feature_flags: false do + include StubVersion + before do # reset Flipper AR-engine Feature.reset skip_feature_flags_yaml_validation end + describe '.feature_flags_available?' do + it 'returns false on connection error' do + expect(ActiveRecord::Base.connection).to receive(:active?).and_raise(PG::ConnectionBad) # rubocop:disable Database/MultipleDatabases + + expect(described_class.feature_flags_available?).to eq(false) + end + + it 'returns false when connection is not active' do + expect(ActiveRecord::Base.connection).to receive(:active?).and_return(false) # rubocop:disable Database/MultipleDatabases + + expect(described_class.feature_flags_available?).to eq(false) + end + + it 'returns false when the flipper table does not exist' do + expect(Feature::FlipperFeature).to receive(:table_exists?).and_return(false) + + expect(described_class.feature_flags_available?).to eq(false) + end + + it 'returns false on NoDatabaseError' do + expect(Feature::FlipperFeature).to receive(:table_exists?).and_raise(ActiveRecord::NoDatabaseError) + + expect(described_class.feature_flags_available?).to eq(false) + end + end + describe '.get' do let(:feature) { double(:feature) } let(:key) { 'my_feature' } @@ -585,6 +613,10 @@ RSpec.describe Feature, stub_feature_flags: false do context 'when flag is new and not feature_flag_state_logs' do let(:milestone) { "14.6" } + before do + stub_version('14.5.123', 'deadbeef') + end + it { is_expected.to be_truthy } end |