summaryrefslogtreecommitdiff
path: root/lib/constraints
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-11-08 14:32:42 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-11-08 14:32:42 +0200
commit08d21fe89927fa9ebd3695fde047a17d27893dbf (patch)
tree4c6cecf395a202d41efb6390d5e8abb9975bb89d /lib/constraints
parent82e551bdac7f2792e1d6aceb1b0b674dbd3dda81 (diff)
downloadgitlab-ce-08d21fe89927fa9ebd3695fde047a17d27893dbf.tar.gz
Add small improvements to constrainers and specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/constraints')
-rw-r--r--lib/constraints/group_url_constrainer.rb2
-rw-r--r--lib/constraints/user_url_constrainer.rb2
2 files changed, 2 insertions, 2 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