mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-08-20 14:11:11 +00:00
Add small improvements to constrainers and specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
@ -7,7 +7,7 @@ class GroupUrlConstrainer
|
|||||||
id = extract_resource_path(request.path)
|
id = extract_resource_path(request.path)
|
||||||
|
|
||||||
if id =~ Gitlab::Regex.namespace_regex
|
if id =~ Gitlab::Regex.namespace_regex
|
||||||
!!Group.find_by_path(id)
|
Group.find_by(path: id).present?
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@ class UserUrlConstrainer
|
|||||||
id = extract_resource_path(request.path)
|
id = extract_resource_path(request.path)
|
||||||
|
|
||||||
if id =~ Gitlab::Regex.namespace_regex
|
if id =~ Gitlab::Regex.namespace_regex
|
||||||
!!User.find_by('lower(username) = ?', id.downcase)
|
User.find_by('lower(username) = ?', id.downcase).present?
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,6 @@ describe GroupUrlConstrainer, lib: true do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def request(path)
|
def request(path)
|
||||||
OpenStruct.new(path: path)
|
double(:request, path: path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,6 +11,6 @@ describe UserUrlConstrainer, lib: true do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def request(path)
|
def request(path)
|
||||||
OpenStruct.new(path: path)
|
double(:request, path: path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user