Commit 42c6555b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Make user constrainer lookup same as controller and add more constrainer tests

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 10526031
......@@ -2,6 +2,6 @@ require 'constraints/namespace_url_constrainer'
class UserUrlConstrainer < NamespaceUrlConstrainer
def find_resource(id)
User.find_by_username(id)
User.find_by('lower(username) = ?', id.downcase)
end
end
require 'spec_helper'
describe GroupUrlConstrainer, lib: true do
let!(:username) { create(:group, path: 'gitlab-org') }
describe '#find_resource' do
it { expect(!!subject.find_resource('gitlab-org')).to be_truthy }
it { expect(!!subject.find_resource('gitlab-com')).to be_falsey }
end
end
......@@ -2,7 +2,6 @@ require 'spec_helper'
describe NamespaceUrlConstrainer, lib: true do
let!(:group) { create(:group, path: 'gitlab') }
subject { NamespaceUrlConstrainer.new }
describe '#matches?' do
context 'existing namespace' do
......
require 'spec_helper'
describe UserUrlConstrainer, lib: true do
let!(:username) { create(:user, username: 'dz') }
describe '#find_resource' do
it { expect(!!subject.find_resource('dz')).to be_truthy }
it { expect(!!subject.find_resource('john')).to be_falsey }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment