diff options
author | Bob Van Landuyt <bob@gitlab.com> | 2017-04-05 13:44:23 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@gitlab.com> | 2017-05-01 11:14:23 +0200 |
commit | 536f2bdfd17ac3bab38851de2973dd1c89dccc3f (patch) | |
tree | 92767ac968ebaabb4caadeb26417530f715d2690 /spec/validators | |
parent | f76a5abb3462a4bfeacca254c0cbda4f313d4ecd (diff) | |
download | gitlab-ce-536f2bdfd17ac3bab38851de2973dd1c89dccc3f.tar.gz |
Add forbidden paths to the namespace validator
Diffstat (limited to 'spec/validators')
-rw-r--r-- | spec/validators/namespace_validator_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/validators/namespace_validator_spec.rb b/spec/validators/namespace_validator_spec.rb new file mode 100644 index 00000000000..e21b8ef5abd --- /dev/null +++ b/spec/validators/namespace_validator_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe NamespaceValidator do + describe 'RESERVED' do + it 'includes all the top level namespaces' do + all_top_level_routes = Rails.application.routes.routes.routes. + map { |r| r.path.spec.to_s }. + select { |p| p !~ %r{^/[:*]} }. + map { |p| p.split('/')[1] }. + compact. + map { |p| p.split('(', 2)[0] }. + uniq + + expect(described_class::RESERVED).to include(*all_top_level_routes) + end + end + + describe 'WILDCARD_ROUTES' do + it 'includes all paths that can be used after a namespace/project path' do + all_wildcard_paths = Rails.application.routes.routes.routes. + map { |r| r.path.spec.to_s }. + select { |p| p =~ %r{^/\*namespace_id/:(project_)?id/[^:*]} }. + map { |p| p.split('/')[3].split('(', 2)[0] }. + uniq + + expect(described_class::WILDCARD_ROUTES).to include(*all_wildcard_paths) + end + end +end |