summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-04-28 13:52:09 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-05-03 17:37:30 -0300
commitc45341c816d78d51aee84a6068d778b9cbc502c8 (patch)
tree769202931229d2e799bdd0f4a8d7c6e8f9ba8ff8 /spec/lib
parentc1e2da9293bb036280c05ee6b99952b067bdc316 (diff)
downloadgitlab-ce-c45341c816d78d51aee84a6068d778b9cbc502c8.tar.gz
Generate and handle a gl_repository param to pass around components
This new param allows us to share project information between components that don't share or don't have access to the same filesystem mountpoints, for example between Gitaly and Rails or between Rails and Gitlab-Shell hooks. The previous parameters are still supported, but if found, gl_repository is prefered. The old parameters should be deprecated once all components support the new format.
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/gl_repository_spec.rb19
-rw-r--r--spec/lib/gitlab/repo_path_spec.rb24
2 files changed, 43 insertions, 0 deletions
diff --git a/spec/lib/gitlab/gl_repository_spec.rb b/spec/lib/gitlab/gl_repository_spec.rb
new file mode 100644
index 00000000000..ac3558ab386
--- /dev/null
+++ b/spec/lib/gitlab/gl_repository_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe ::Gitlab::GlRepository do
+ describe '.parse' do
+ set(:project) { create(:project) }
+
+ it 'parses a project gl_repository' do
+ expect(described_class.parse("project-#{project.id}")).to eq([project, false])
+ end
+
+ it 'parses a wiki gl_repository' do
+ expect(described_class.parse("wiki-#{project.id}")).to eq([project, true])
+ end
+
+ it 'throws an argument error on an invalid gl_repository' do
+ expect { described_class.parse("badformat-#{project.id}") }.to raise_error(ArgumentError)
+ end
+ end
+end
diff --git a/spec/lib/gitlab/repo_path_spec.rb b/spec/lib/gitlab/repo_path_spec.rb
index 0fb5d7646f2..f94c9c2e315 100644
--- a/spec/lib/gitlab/repo_path_spec.rb
+++ b/spec/lib/gitlab/repo_path_spec.rb
@@ -1,6 +1,30 @@
require 'spec_helper'
describe ::Gitlab::RepoPath do
+ describe '.parse' do
+ set(:project) { create(:project) }
+
+ it 'parses a full repository path' do
+ expect(described_class.parse(project.repository.path)).to eq([project, false])
+ end
+
+ it 'parses a full wiki path' do
+ expect(described_class.parse(project.wiki.repository.path)).to eq([project, true])
+ end
+
+ it 'parses a relative repository path' do
+ expect(described_class.parse(project.full_path + '.git')).to eq([project, false])
+ end
+
+ it 'parses a relative wiki path' do
+ expect(described_class.parse(project.full_path + '.wiki.git')).to eq([project, true])
+ end
+
+ it 'parses a relative path starting with /' do
+ expect(described_class.parse('/' + project.full_path + '.git')).to eq([project, false])
+ end
+ end
+
describe '.strip_storage_path' do
before do
allow(Gitlab.config.repositories).to receive(:storages).and_return({