diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-07-11 20:38:27 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-07-11 23:49:57 +0300 |
commit | b904a7dbd208f069f618e5ea60de56d8687c606c (patch) | |
tree | 46bfc84ec564c9b9e0149728456bd0f8e9870347 /spec | |
parent | 2a5d2ecfbfa4494b1b58e869a9d8988af2f8a2b4 (diff) |
Make `Redis::Wrapper#_raw_config` and `#fetch_config` more resilient
These two methods now handle two additional real-world possibilities:
1. `config/resque.yml` not being present
2. `config/resque.yml` being present but not containing YAML
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/34941
Diffstat (limited to 'spec')
-rw-r--r-- | spec/support/redis/redis_shared_examples.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/spec/support/redis/redis_shared_examples.rb b/spec/support/redis/redis_shared_examples.rb index 95a5df181c1..f9552e41894 100644 --- a/spec/support/redis/redis_shared_examples.rb +++ b/spec/support/redis/redis_shared_examples.rb @@ -65,14 +65,6 @@ RSpec.shared_examples "redis_shared_examples" do end describe '.url' do - it 'withstands mutation' do - url1 = described_class.url - url2 = described_class.url - url1 << 'foobar' - - expect(url2).not_to end_with('foobar') - end - context 'when yml file with env variable' do let(:config_file_name) { config_with_environment_variable_inside } @@ -97,6 +89,12 @@ RSpec.shared_examples "redis_shared_examples" do it 'returns false when the file does not exist' do expect(subject).to eq(false) end + + it "returns false when the filename can't be determined" do + expect(described_class).to receive(:config_file_name).and_return(nil) + + expect(subject).to eq(false) + end end describe '.with' do @@ -192,7 +190,13 @@ RSpec.shared_examples "redis_shared_examples" do it 'returns false when no config file is present' do allow(described_class).to receive(:_raw_config) { false } - expect(subject.send(:fetch_config)).to be_falsey + expect(subject.send(:fetch_config)).to eq false + end + + it 'returns false when config file is present but has invalid YAML' do + allow(described_class).to receive(:_raw_config) { "# development: true" } + + expect(subject.send(:fetch_config)).to eq false end end |