diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2017-03-24 16:54:22 +0100 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2017-03-29 14:48:04 +0200 |
commit | c837da34391094b9d58763a67db5cfb706ca146f (patch) | |
tree | f8e37a66ab012b2a6ec0c40c18b7eb366b6b5c09 /spec/lib/gitlab | |
parent | b46ac16cc89d649bf5fba9a36f1911a575b41e1f (diff) | |
download | gitlab-ce-c837da34391094b9d58763a67db5cfb706ca146f.tar.gz |
Helper method for storage path stripping
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/repo_path_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/lib/gitlab/repo_path_spec.rb b/spec/lib/gitlab/repo_path_spec.rb new file mode 100644 index 00000000000..0fb5d7646f2 --- /dev/null +++ b/spec/lib/gitlab/repo_path_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe ::Gitlab::RepoPath do + describe '.strip_storage_path' do + before do + allow(Gitlab.config.repositories).to receive(:storages).and_return({ + 'storage1' => { 'path' => '/foo' }, + 'storage2' => { 'path' => '/bar' }, + }) + end + + it 'strips the storage path' do + expect(described_class.strip_storage_path('/bar/foo/qux/baz.git')).to eq('foo/qux/baz.git') + end + + it 'raises NotFoundError if no storage matches the path' do + expect { described_class.strip_storage_path('/doesnotexist/foo.git') }.to raise_error( + described_class::NotFoundError + ) + end + end +end |