summaryrefslogtreecommitdiff
path: root/spec/lib/constraints
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-10-06 15:14:24 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-10-06 19:50:48 +0300
commit6b90ccb9fd57401912e1978cbad28cc693a2e0a1 (patch)
tree9e540eb6676f1d870d9e1276206f06d4fed10b48 /spec/lib/constraints
parent7c8c80880995e0bce822a6809fe514ce0f3fda36 (diff)
downloadgitlab-ce-6b90ccb9fd57401912e1978cbad28cc693a2e0a1.tar.gz
Change user & group landing page routing from /u/:name & /groups/:name to /:name
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/lib/constraints')
-rw-r--r--spec/lib/constraints/namespace_url_constrainer_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/constraints/namespace_url_constrainer_spec.rb b/spec/lib/constraints/namespace_url_constrainer_spec.rb
new file mode 100644
index 00000000000..8940fd6b94e
--- /dev/null
+++ b/spec/lib/constraints/namespace_url_constrainer_spec.rb
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+describe NamespaceUrlConstrainer, lib: true do
+ let!(:group) { create(:group, path: 'gitlab') }
+ subject { NamespaceUrlConstrainer.new }
+
+ describe '#matches?' do
+ context 'existing namespace' do
+ it { expect(subject.matches?(request '/gitlab')).to be_truthy }
+ it { expect(subject.matches?(request '/gitlab.atom')).to be_truthy }
+ it { expect(subject.matches?(request '/gitlab/')).to be_truthy }
+ it { expect(subject.matches?(request '//gitlab/')).to be_truthy }
+ end
+
+ context 'non-existing namespace' do
+ it { expect(subject.matches?(request '/gitlab-ce')).to be_falsey }
+ it { expect(subject.matches?(request '/gitlab.ce')).to be_falsey }
+ it { expect(subject.matches?(request '/g/gitlab')).to be_falsey }
+ it { expect(subject.matches?(request '/.gitlab')).to be_falsey }
+ end
+ end
+
+ def request(path)
+ OpenStruct.new(path: path)
+ end
+end