diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-05 03:07:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-05 03:07:49 +0300 |
commit | 77237c5a6b9044f58beabc54d3589e5fa09cbfba (patch) | |
tree | f43188047fe8955f6cf78e05ae9c2e8f6a019e0b /spec/lib/gitlab/path_regex_spec.rb | |
parent | 2fd92f2dc784ade9cb4e1c33dd60cbfad7b86818 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/path_regex_spec.rb')
-rw-r--r-- | spec/lib/gitlab/path_regex_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/lib/gitlab/path_regex_spec.rb b/spec/lib/gitlab/path_regex_spec.rb index 3cbcae4cdeb..8dabe5a756b 100644 --- a/spec/lib/gitlab/path_regex_spec.rb +++ b/spec/lib/gitlab/path_regex_spec.rb @@ -411,4 +411,37 @@ describe Gitlab::PathRegex do it { is_expected.not_to match('git lab') } it { is_expected.not_to match('gitlab.git') } end + + shared_examples 'invalid snippet routes' do + it { is_expected.not_to match('gitlab-org/gitlab/snippets/1.git') } + it { is_expected.not_to match('snippets/1.git') } + it { is_expected.not_to match('gitlab-org/gitlab/snippets/') } + it { is_expected.not_to match('/gitlab-org/gitlab/snippets/1') } + it { is_expected.not_to match('gitlab-org/gitlab/snippets/foo') } + it { is_expected.not_to match('root/snippets/1') } + it { is_expected.not_to match('/snippets/1') } + it { is_expected.not_to match('snippets/') } + it { is_expected.not_to match('snippets/foo') } + end + + describe '.full_snippets_repository_path_regex' do + subject { described_class.full_snippets_repository_path_regex } + + it { is_expected.to match('gitlab-org/gitlab/snippets/1') } + it { is_expected.to match('snippets/1') } + + it_behaves_like 'invalid snippet routes' + end + + describe '.personal_and_project_snippets_path_regex' do + subject { %r{\A#{described_class.personal_and_project_snippets_path_regex}\z} } + + it { is_expected.to match('gitlab-org/gitlab/snippets') } + it { is_expected.to match('snippets') } + + it { is_expected.not_to match('gitlab-org/gitlab/snippets/1') } + it { is_expected.not_to match('snippets/1') } + + it_behaves_like 'invalid snippet routes' + end end |