2015-02-08 18:01:31 -05:00
|
|
|
|
# coding: utf-8
|
2014-07-08 11:15:23 -04:00
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
2015-12-09 05:55:36 -05:00
|
|
|
|
describe Gitlab::Regex, lib: true do
|
2016-11-30 02:13:42 -05:00
|
|
|
|
describe '.project_path_regex' do
|
|
|
|
|
subject { described_class.project_path_regex }
|
2014-07-08 11:15:23 -04:00
|
|
|
|
|
2016-11-30 02:13:42 -05:00
|
|
|
|
it { is_expected.to match('gitlab-ce') }
|
|
|
|
|
it { is_expected.to match('gitlab_git') }
|
|
|
|
|
it { is_expected.to match('_underscore.js') }
|
|
|
|
|
it { is_expected.to match('100px.com') }
|
|
|
|
|
it { is_expected.not_to match('?gitlab') }
|
|
|
|
|
it { is_expected.not_to match('git lab') }
|
|
|
|
|
it { is_expected.not_to match('gitlab.git') }
|
2014-07-08 11:15:23 -04:00
|
|
|
|
end
|
2016-02-01 10:20:49 -05:00
|
|
|
|
|
2016-11-30 02:13:42 -05:00
|
|
|
|
describe '.project_name_regex' do
|
|
|
|
|
subject { described_class.project_name_regex }
|
|
|
|
|
|
|
|
|
|
it { is_expected.to match('gitlab-ce') }
|
|
|
|
|
it { is_expected.to match('GitLab CE') }
|
|
|
|
|
it { is_expected.to match('100 lines') }
|
|
|
|
|
it { is_expected.to match('gitlab.git') }
|
|
|
|
|
it { is_expected.to match('Český název') }
|
|
|
|
|
it { is_expected.to match('Dash – is this') }
|
|
|
|
|
it { is_expected.not_to match('?gitlab') }
|
2016-02-01 10:20:49 -05:00
|
|
|
|
end
|
|
|
|
|
|
2016-11-30 02:13:42 -05:00
|
|
|
|
describe '.file_name_regex' do
|
|
|
|
|
subject { described_class.file_name_regex }
|
|
|
|
|
|
|
|
|
|
it { is_expected.to match('foo@bar') }
|
2016-02-01 10:20:49 -05:00
|
|
|
|
end
|
2016-12-07 20:09:18 -05:00
|
|
|
|
|
2016-11-30 02:13:42 -05:00
|
|
|
|
describe '.environment_slug_regex' do
|
|
|
|
|
subject { described_class.environment_slug_regex }
|
2016-12-07 20:09:18 -05:00
|
|
|
|
|
2016-11-30 02:13:42 -05:00
|
|
|
|
it { is_expected.to match('foo') }
|
|
|
|
|
it { is_expected.to match('foo-1') }
|
|
|
|
|
it { is_expected.not_to match('FOO') }
|
|
|
|
|
it { is_expected.not_to match('foo/1') }
|
|
|
|
|
it { is_expected.not_to match('foo.1') }
|
|
|
|
|
it { is_expected.not_to match('foo*1') }
|
|
|
|
|
it { is_expected.not_to match('9foo') }
|
|
|
|
|
it { is_expected.not_to match('foo-') }
|
2016-12-07 20:09:18 -05:00
|
|
|
|
end
|
2017-02-13 06:26:33 -05:00
|
|
|
|
|
2017-02-23 18:55:01 -05:00
|
|
|
|
describe 'FULL_NAMESPACE_REGEX_STR' do
|
|
|
|
|
subject { %r{\A#{Gitlab::Regex::FULL_NAMESPACE_REGEX_STR}\z} }
|
2017-02-13 06:26:33 -05:00
|
|
|
|
|
|
|
|
|
it { is_expected.to match('gitlab.org') }
|
|
|
|
|
it { is_expected.to match('gitlab.org/gitlab-git') }
|
|
|
|
|
it { is_expected.not_to match('gitlab.org.') }
|
|
|
|
|
it { is_expected.not_to match('gitlab.org/') }
|
|
|
|
|
it { is_expected.not_to match('/gitlab.org') }
|
|
|
|
|
it { is_expected.not_to match('gitlab.git') }
|
|
|
|
|
it { is_expected.not_to match('gitlab git') }
|
|
|
|
|
end
|
2014-07-08 11:15:23 -04:00
|
|
|
|
end
|