diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-10-27 15:51:34 +0100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-10-27 15:51:34 +0100 |
commit | e5950e687c42db006daf9147254e111f4e68c3f1 (patch) | |
tree | 17a53b50471c0ca6fad0f65bd9b14d6a8f6f889c /spec/lib | |
parent | f879319840949c1d4b363742cb9573d89abd1296 (diff) | |
parent | f9126fbe0a73aa6d8d61be2eb249260fa29ac461 (diff) | |
download | gitlab-ce-e5950e687c42db006daf9147254e111f4e68c3f1.tar.gz |
Merge branch '21645-mail_room_sentinel'
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/redis_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/lib/gitlab/redis_spec.rb b/spec/lib/gitlab/redis_spec.rb index 74ff85e132a..e5406fb2d33 100644 --- a/spec/lib/gitlab/redis_spec.rb +++ b/spec/lib/gitlab/redis_spec.rb @@ -116,6 +116,55 @@ describe Gitlab::Redis do end end + describe '#sentinels' do + subject { described_class.new(Rails.env).sentinels } + + context 'when sentinels are defined' do + let(:config) { Rails.root.join('spec/fixtures/config/redis_new_format_host.yml') } + + it 'returns an array of hashes with host and port keys' do + stub_const("#{described_class}::CONFIG_FILE", config) + + is_expected.to include(host: 'localhost', port: 26380) + is_expected.to include(host: 'slave2', port: 26381) + end + end + + context 'when sentinels are not defined' do + let(:config) { Rails.root.join('spec/fixtures/config/redis_old_format_host.yml') } + + it 'returns nil' do + stub_const("#{described_class}::CONFIG_FILE", config) + + is_expected.to be_nil + end + end + end + + describe '#sentinels?' do + subject { described_class.new(Rails.env).sentinels? } + + context 'when sentinels are defined' do + let(:config) { Rails.root.join('spec/fixtures/config/redis_new_format_host.yml') } + + it 'returns true' do + stub_const("#{described_class}::CONFIG_FILE", config) + + is_expected.to be_truthy + end + end + + context 'when sentinels are not defined' do + let(:config) { Rails.root.join('spec/fixtures/config/redis_old_format_host.yml') } + + it 'returns false' do + stub_const("#{described_class}::CONFIG_FILE", config) + + is_expected.to be_falsey + end + end + end + describe '#raw_config_hash' do it 'returns default redis url when no config file is present' do expect(subject).to receive(:fetch_config) { false } |