2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ::Gitlab::GlRepository do
|
|
|
|
describe '.parse' do
|
2020-03-13 15:44:24 +05:30
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
2020-04-08 14:13:33 +05:30
|
|
|
let_it_be(:snippet) { create(:personal_snippet) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
it 'parses a project gl_repository' do
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(described_class.parse("project-#{project.id}")).to eq([project, project, Gitlab::GlRepository::PROJECT])
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it 'parses a project wiki gl_repository' do
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(described_class.parse("wiki-#{project.id}")).to eq([project, project, Gitlab::GlRepository::WIKI])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'parses a snippet gl_repository' do
|
|
|
|
expect(described_class.parse("snippet-#{snippet.id}")).to eq([snippet, nil, Gitlab::GlRepository::SNIPPET])
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
it 'parses a design gl_repository' do
|
|
|
|
expect(described_class.parse("design-#{project.id}")).to eq([project, project, Gitlab::GlRepository::DESIGN])
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it 'throws an argument error on an invalid gl_repository type' do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect { described_class.parse("badformat-#{project.id}") }.to raise_error(ArgumentError)
|
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
it 'throws an argument error on an invalid gl_repository id' do
|
|
|
|
expect { described_class.parse("project-foo") }.to raise_error(ArgumentError)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
describe 'DESIGN' do
|
|
|
|
it 'uses the design access checker' do
|
|
|
|
expect(described_class::DESIGN.access_checker_class).to eq(::Gitlab::GitAccessDesign)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'builds a design repository' do
|
|
|
|
expect(described_class::DESIGN.repository_resolver.call(create(:project)))
|
|
|
|
.to be_a(::DesignManagement::Repository)
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|