2016-06-22 17:04:51 -04:00
require 'spec_helper'
2016-07-18 17:28:26 -04:00
require_relative '../../config/initializers/6_validations.rb'
2016-06-22 17:04:51 -04:00
describe '6_validations' , lib : true do
2016-07-11 21:29:13 -04:00
before :all do
FileUtils . mkdir_p ( 'tmp/tests/paths/a/b/c/d' )
FileUtils . mkdir_p ( 'tmp/tests/paths/a/b/c2' )
FileUtils . mkdir_p ( 'tmp/tests/paths/a/b/d' )
end
after :all do
FileUtils . rm_rf ( 'tmp/tests/paths' )
end
2016-06-22 17:04:51 -04:00
context 'with correct settings' do
before do
2016-07-11 21:29:13 -04:00
mock_storages ( 'foo' = > 'tmp/tests/paths/a/b/c' , 'bar' = > 'tmp/tests/paths/a/b/d' )
2016-06-22 17:04:51 -04:00
end
it 'passes through' do
2016-07-18 17:28:26 -04:00
expect { validate_storages } . not_to raise_error
2016-06-22 17:04:51 -04:00
end
end
context 'with invalid storage names' do
before do
2016-07-11 21:29:13 -04:00
mock_storages ( 'name with spaces' = > 'tmp/tests/paths/a/b/c' )
2016-06-22 17:04:51 -04:00
end
it 'throws an error' do
2016-07-18 17:28:26 -04:00
expect { validate_storages } . to raise_error ( '"name with spaces" is not a valid storage name. Please fix this in your gitlab.yml before starting GitLab.' )
2016-06-22 17:04:51 -04:00
end
end
context 'with nested storage paths' do
before do
2016-07-11 21:29:13 -04:00
mock_storages ( 'foo' = > 'tmp/tests/paths/a/b/c' , 'bar' = > 'tmp/tests/paths/a/b/c/d' )
2016-06-22 17:04:51 -04:00
end
it 'throws an error' do
2016-07-18 17:28:26 -04:00
expect { validate_storages } . to raise_error ( 'bar is a nested path of foo. Nested paths are not supported for repository storages. Please fix this in your gitlab.yml before starting GitLab.' )
2016-06-22 17:04:51 -04:00
end
end
2016-07-11 21:29:13 -04:00
context 'with similar but un-nested storage paths' do
before do
mock_storages ( 'foo' = > 'tmp/tests/paths/a/b/c' , 'bar' = > 'tmp/tests/paths/a/b/c2' )
end
it 'passes through' do
2016-07-18 17:28:26 -04:00
expect { validate_storages } . not_to raise_error
2016-07-11 21:29:13 -04:00
end
end
2016-06-22 17:04:51 -04:00
def mock_storages ( storages )
allow ( Gitlab . config . repositories ) . to receive ( :storages ) . and_return ( storages )
end
end