Commit 30cbc3ef authored by nnelson's avatar nnelson Committed by Mayra Cabrera

Fix gitaly_address method

The `Gitlab::GitalyClient::StorageSettings#gitaly_address` currently
fails, because the GitLab configuration in production defines the
gitaly address entry for each node using a string key, and the method
actually tries to fetch the value based on a symbolic key.

Interestingly enough, the `config/gitlab.yml.example` uses a symbolic
key.

Use `with_indifferent_access` instead of fallback.

Add spec tests and fix fall-back settings fetch.
parent 4cea6101
......@@ -53,7 +53,7 @@ module Gitlab
@legacy_disk_path = File.expand_path(storage['path'], Rails.root) if storage['path']
storage['path'] = Deprecated
@hash = storage
@hash = storage.with_indifferent_access
end
def gitaly_address
......
......@@ -27,6 +27,38 @@ describe Gitlab::GitalyClient::StorageSettings do
end
end
describe '.gitaly_address' do
context 'when the storage settings have no gitaly address but one is requested' do
it 'raises an error' do
expect do
described_class.new("path" => Rails.root).gitaly_address
end.to raise_error("key not found: \"gitaly_address\"")
end
end
context 'when the storage settings have a gitaly address and one is requested' do
it 'returns the setting value' do
expect(described_class.new("path" => Rails.root, "gitaly_address" => "test").gitaly_address).to eq("test")
end
end
context 'when the storage settings have a gitaly address keyed symbolically' do
it 'raises no error' do
expect do
described_class.new("path" => Rails.root, :gitaly_address => "test").gitaly_address
end.not_to raise_error
end
end
context 'when the storage settings have a gitaly address keyed with a string' do
it 'raises no error' do
expect do
described_class.new("path" => Rails.root, "gitaly_address" => "test").gitaly_address
end.not_to raise_error
end
end
end
describe '.disk_access_denied?' do
context 'when Rugged is enabled', :enable_rugged do
it 'returns false' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment