summaryrefslogtreecommitdiff
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
parent82e551bdac7f2792e1d6aceb1b0b674dbd3dda81 (diff)
downloadgitlab-ce-08d21fe89927fa9ebd3695fde047a17d27893dbf.tar.gz
Add small improvements to constrainers and specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--lib/constraints/group_url_constrainer.rb2
-rw-r--r--lib/constraints/user_url_constrainer.rb2
-rw-r--r--spec/lib/constraints/group_url_constrainer_spec.rb2
-rw-r--r--spec/lib/constraints/user_url_constrainer_spec.rb2
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