Add support for FTP assets for releases

Extend the list of supported protocols to include FTP.
This commit is contained in:
Robert Schilling 2019-02-13 10:51:12 +00:00 committed by Kamil Trzciński
parent 2b68d0cdb3
commit b178443854
4 changed files with 31 additions and 1 deletions

View File

@ -6,7 +6,7 @@ module Releases
belongs_to :release
validates :url, presence: true, url: true, uniqueness: { scope: :release }
validates :url, presence: true, url: { protocols: %w(http https ftp) }, uniqueness: { scope: :release }
validates :name, presence: true, uniqueness: { scope: :release }
scope :sorted, -> { order(created_at: :desc) }

View File

@ -0,0 +1,5 @@
---
title: Add support for FTP assets for releases
merge_request: 25071
author: Robert Schilling
type: added

View File

@ -3,6 +3,7 @@
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/41766) in GitLab 11.7.
Using this API you can manipulate GitLab's [Release](../../user/project/releases/index.md) links. For manipulating other Release assets, see [Release API](index.md).
GitLab supports links links to `http`, `https`, and `ftp` assets.
## Get links

View File

@ -77,4 +77,28 @@ describe Releases::Link do
it { is_expected.to be_truthy }
end
describe 'supported protocols' do
where(:protocol) do
%w(http https ftp)
end
with_them do
let(:link) { build(:release_link, url: protocol + '://assets.com/download') }
it 'will be valid' do
expect(link).to be_valid
end
end
end
describe 'unsupported protocol' do
context 'for torrent' do
let(:link) { build(:release_link, url: 'torrent://assets.com/download') }
it 'will be invalid' do
expect(link).to be_invalid
end
end
end
end