diff options
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 |