summaryrefslogtreecommitdiff
path: root/app/models/protectable_dropdown.rb
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2017-04-05 18:59:46 +0100
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2017-04-06 10:56:21 +0100
commitf16377e7dc762462817dd0b34e36811c55988b10 (patch)
tree0c2848cee6743f0648e2c3d9361d201aca7fbf1a /app/models/protectable_dropdown.rb
parent18506d4b8b8bc780b3b1e4c61339af38b5c49bb2 (diff)
downloadgitlab-ce-f16377e7dc762462817dd0b34e36811c55988b10.tar.gz
Protected Tags backend review changes
Added changelog
Diffstat (limited to 'app/models/protectable_dropdown.rb')
-rw-r--r--app/models/protectable_dropdown.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/protectable_dropdown.rb b/app/models/protectable_dropdown.rb
index c9b2b213cd2..122fbce257d 100644
--- a/app/models/protectable_dropdown.rb
+++ b/app/models/protectable_dropdown.rb
@@ -6,8 +6,7 @@ class ProtectableDropdown
# Tags/branches which are yet to be individually protected
def protectable_ref_names
- non_wildcard_protections = protections.reject(&:wildcard?)
- refs.map(&:name) - non_wildcard_protections.map(&:name)
+ @protectable_ref_names ||= ref_names - non_wildcard_protected_ref_names
end
def hash
@@ -20,7 +19,15 @@ class ProtectableDropdown
@project.repository.public_send(@ref_type)
end
+ def ref_names
+ refs.map(&:name)
+ end
+
def protections
@project.public_send("protected_#{@ref_type}")
end
+
+ def non_wildcard_protected_ref_names
+ protections.reject(&:wildcard?).map(&:name)
+ end
end