Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 03:09:12 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 03:09:12 +0300
commit0b881f91159cc97ccb7328a2e52977a60ea83fbe (patch)
treed6b683cb935112aee47121f46e3c5dc84de24f2c /spec/models
parent7671216b60e2796a050358ff808b4a0c2de3d22f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/releases/link_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/models/releases/link_spec.rb b/spec/models/releases/link_spec.rb
index 4dd26c976cc..7533d1e6e5c 100644
--- a/spec/models/releases/link_spec.rb
+++ b/spec/models/releases/link_spec.rb
@@ -13,6 +13,7 @@ describe Releases::Link do
describe 'validation' do
it { is_expected.to validate_presence_of(:url) }
it { is_expected.to validate_presence_of(:name) }
+ it { is_expected.to validate_length_of(:filepath).is_at_most(128) }
context 'when url is invalid' do
let(:link) { build(:release_link, url: 'hoge') }
@@ -43,6 +44,16 @@ describe Releases::Link do
end
end
+ context 'when duplicate filepath is added to a release' do
+ let!(:link) { create(:release_link, filepath: '/binaries/gitlab-runner-linux-amd64', release: release) }
+
+ it 'raises an error' do
+ expect do
+ create(:release_link, filepath: '/binaries/gitlab-runner-linux-amd64', release: release)
+ end.to raise_error(ActiveRecord::RecordInvalid)
+ end
+ end
+
describe '.sorted' do
subject { described_class.sorted }
@@ -101,4 +112,38 @@ describe Releases::Link do
end
end
end
+
+ describe 'FILEPATH_REGEX with table' do
+ using RSpec::Parameterized::TableSyntax
+
+ let(:link) { build(:release_link)}
+
+ where(:reason, :filepath, :result) do
+ 'cannot contain `//`' | '/https//www.example.com' | be_invalid
+ 'cannot start with `//`' | '//www.example.com' | be_invalid
+ 'cannot contain a `?`' | '/example.com/?stuff=true' | be_invalid
+ 'cannot contain a `:`' | '/example:5000' | be_invalid
+ 'cannot end in a `-`' | '/binaries/awesome-app.dmg-' | be_invalid
+ 'cannot end in a `.`' | '/binaries/awesome-app.dmg.' | be_invalid
+ 'cannot end in a `_`' | '/binaries/awesome-app.dmg_' | be_invalid
+ 'cannot start with a `.`' | '.binaries/awesome-app.dmg' | be_invalid
+ 'cannot start with a `-`' | '-binaries/awesome-app.dmg' | be_invalid
+ 'cannot start with a `_`' | '_binaries/awesome-app.dmg' | be_invalid
+ 'cannot start with a number' | '3binaries/awesome-app.dmg' | be_invalid
+ 'cannot start with a letter' | 'binaries/awesome-app.dmg' | be_invalid
+ 'cannot contain accents' | '/binarïes/âwésome-app.dmg' | be_invalid
+ 'can end in a character' | '/binaries/awesome-app.dmg' | be_valid
+ 'can end in a number' | '/binaries/awesome-app-1' | be_valid
+ 'can contain one or more dots, dashes or underscores' | '/sub_tr__ee.ex..ample-2--1/v99.com' | be_valid
+ 'can contain multiple non-sequential slashes' | '/example.com/path/to/file.exe' | be_valid
+ 'can be nil' | nil | be_valid
+ end
+
+ with_them do
+ specify do
+ link.filepath = filepath
+ expect(link).to result
+ end
+ end
+ end
end