diff options
-rw-r--r-- | lib/constraints/group_url_constrainer.rb | 2 | ||||
-rw-r--r-- | lib/constraints/user_url_constrainer.rb | 2 | ||||
-rw-r--r-- | spec/lib/constraints/group_url_constrainer_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/constraints/user_url_constrainer_spec.rb | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/lib/constraints/group_url_constrainer.rb b/lib/constraints/group_url_constrainer.rb index 2bf973a73da..2af6e1a11c8 100644 --- a/lib/constraints/group_url_constrainer.rb +++ b/lib/constraints/group_url_constrainer.rb @@ -7,7 +7,7 @@ class GroupUrlConstrainer id = extract_resource_path(request.path) if id =~ Gitlab::Regex.namespace_regex - !!Group.find_by_path(id) + Group.find_by(path: id).present? else false end diff --git a/lib/constraints/user_url_constrainer.rb b/lib/constraints/user_url_constrainer.rb index 9583cace022..4d722ad5af2 100644 --- a/lib/constraints/user_url_constrainer.rb +++ b/lib/constraints/user_url_constrainer.rb @@ -7,7 +7,7 @@ class UserUrlConstrainer id = extract_resource_path(request.path) if id =~ Gitlab::Regex.namespace_regex - !!User.find_by('lower(username) = ?', id.downcase) + User.find_by('lower(username) = ?', id.downcase).present? else false end diff --git a/spec/lib/constraints/group_url_constrainer_spec.rb b/spec/lib/constraints/group_url_constrainer_spec.rb index be69a36c2b6..42299b17c2b 100644 --- a/spec/lib/constraints/group_url_constrainer_spec.rb +++ b/spec/lib/constraints/group_url_constrainer_spec.rb @@ -14,6 +14,6 @@ describe GroupUrlConstrainer, lib: true do end def request(path) - OpenStruct.new(path: path) + double(:request, path: path) end end diff --git a/spec/lib/constraints/user_url_constrainer_spec.rb b/spec/lib/constraints/user_url_constrainer_spec.rb index d7b7d5664ff..b3f8530c609 100644 --- a/spec/lib/constraints/user_url_constrainer_spec.rb +++ b/spec/lib/constraints/user_url_constrainer_spec.rb @@ -11,6 +11,6 @@ describe UserUrlConstrainer, lib: true do end def request(path) - OpenStruct.new(path: path) + double(:request, path: path) end end |