summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-01-13 16:08:48 +0000
committerRémy Coutable <remy@rymai.me>2017-01-13 16:08:48 +0000
commit5384c720c9c7443fc1f12ea15d55541e14feeb85 (patch)
tree95e874857f9122d4005935e59f09605b7b8093bf /spec
parent7a3ddc5214618dd9a1b761acde3502d78a66ba8c (diff)
parenta532c6040c1c150810122b172a2fad30d1753dfd (diff)
downloadgitlab-ce-5384c720c9c7443fc1f12ea15d55541e14feeb85.tar.gz
Merge branch 'env-var-in-redis-config' into 'master'
Allow to use ENV variables in redis config See merge request !8073
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/config/redis_config_with_env.yml2
-rw-r--r--spec/lib/gitlab/redis_spec.rb16
2 files changed, 17 insertions, 1 deletions
diff --git a/spec/fixtures/config/redis_config_with_env.yml b/spec/fixtures/config/redis_config_with_env.yml
new file mode 100644
index 00000000000..f5860f37e47
--- /dev/null
+++ b/spec/fixtures/config/redis_config_with_env.yml
@@ -0,0 +1,2 @@
+test:
+ url: <%= ENV['TEST_GITLAB_REDIS_URL'] %>
diff --git a/spec/lib/gitlab/redis_spec.rb b/spec/lib/gitlab/redis_spec.rb
index e5406fb2d33..917c5c46db1 100644
--- a/spec/lib/gitlab/redis_spec.rb
+++ b/spec/lib/gitlab/redis_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe Gitlab::Redis do
- let(:redis_config) { Rails.root.join('config', 'resque.yml').to_s }
+ include StubENV
before(:each) { clear_raw_config }
after(:each) { clear_raw_config }
@@ -72,6 +72,20 @@ describe Gitlab::Redis do
expect(url2).not_to end_with('foobar')
end
+
+ context 'when yml file with env variable' do
+ let(:redis_config) { Rails.root.join('spec/fixtures/config/redis_config_with_env.yml') }
+
+ before do
+ stub_env('TEST_GITLAB_REDIS_URL', 'redis://redishost:6379')
+ end
+
+ it 'reads redis url from env variable' do
+ stub_const("#{described_class}::CONFIG_FILE", redis_config)
+
+ expect(described_class.url).to eq 'redis://redishost:6379'
+ end
+ end
end
describe '._raw_config' do