2019-01-02 06:57:13 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-01-02 05:56:03 -05:00
|
|
|
require 'spec_helper'
|
2019-01-02 01:01:15 -05:00
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe Releases::Source do
|
2020-02-12 10:09:37 -05:00
|
|
|
let_it_be(:project) { create(:project, :repository, name: 'finance-cal') }
|
2019-01-02 01:01:15 -05:00
|
|
|
let(:tag_name) { 'v1.0' }
|
|
|
|
|
|
|
|
describe '.all' do
|
|
|
|
subject { described_class.all(project, tag_name) }
|
|
|
|
|
|
|
|
it 'returns all formats of sources' do
|
|
|
|
expect(subject.map(&:format))
|
2019-10-31 11:06:41 -04:00
|
|
|
.to match_array(Gitlab::Workhorse::ARCHIVE_FORMATS)
|
2019-01-02 01:01:15 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#url' do
|
|
|
|
subject { source.url }
|
|
|
|
|
|
|
|
let(:source) do
|
|
|
|
described_class.new(project: project, tag_name: tag_name, format: format)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:format) { 'zip' }
|
|
|
|
|
|
|
|
it 'returns zip archived source url' do
|
|
|
|
is_expected
|
|
|
|
.to eq("#{project.web_url}/-/archive/v1.0/finance-cal-v1.0.zip")
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when ref is directory structure' do
|
|
|
|
let(:tag_name) { 'beta/v1.0' }
|
|
|
|
|
|
|
|
it 'converts slash to dash' do
|
|
|
|
is_expected
|
|
|
|
.to eq("#{project.web_url}/-/archive/beta/v1.0/finance-cal-beta-v1.0.zip")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|