2019-11-08 03:06:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-28 16:52:09 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ::Gitlab::GlRepository do
|
|
|
|
describe '.parse' do
|
2020-01-27 15:08:51 +00:00
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
2020-03-05 00:07:49 +00:00
|
|
|
let_it_be(:snippet) { create(:personal_snippet) }
|
2017-04-28 16:52:09 +00:00
|
|
|
|
|
|
|
it 'parses a project gl_repository' do
|
2020-03-05 00:07:49 +00:00
|
|
|
expect(described_class.parse("project-#{project.id}")).to eq([project, project, Gitlab::GlRepository::PROJECT])
|
2017-04-28 16:52:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'parses a wiki gl_repository' do
|
2020-03-05 00:07:49 +00:00
|
|
|
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-04-28 16:52:09 +00:00
|
|
|
end
|
|
|
|
|
2020-01-27 15:08:51 +00:00
|
|
|
it 'throws an argument error on an invalid gl_repository type' do
|
2017-04-28 16:52:09 +00:00
|
|
|
expect { described_class.parse("badformat-#{project.id}") }.to raise_error(ArgumentError)
|
|
|
|
end
|
2020-01-27 15:08:51 +00:00
|
|
|
|
|
|
|
it 'throws an argument error on an invalid gl_repository id' do
|
|
|
|
expect { described_class.parse("project-foo") }.to raise_error(ArgumentError)
|
|
|
|
end
|
2017-04-28 16:52:09 +00:00
|
|
|
end
|
|
|
|
end
|