summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-07-24 15:31:15 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-07-24 15:50:12 -0400
commit37bc7bac19599092b25f5aa30705fb1bf89e4f42 (patch)
tree0236b656d759154296a649c16b27b26c9a79d043 /app
parentb5e6ffa6165e9bbb999dd6b69e6161da80f66e7f (diff)
downloadgitlab-ce-37bc7bac19599092b25f5aa30705fb1bf89e4f42.tar.gz
Add Issuable#to_ability_name
Diffstat (limited to 'app')
-rw-r--r--app/models/concerns/issuable.rb10
-rw-r--r--app/views/shared/issuable/_context.html.haml4
2 files changed, 12 insertions, 2 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 97846b06d72..c21e7fd0e3b 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -159,6 +159,16 @@ module Issuable
end
end
+ # Convert this Issuable class name to a format usable by Ability definitions
+ #
+ # Examples:
+ #
+ # issuable.class # => MergeRequest
+ # issuable.to_ability_name # => "merge_request"
+ def to_ability_name
+ self.class.to_s.underscore
+ end
+
private
def filter_superceded_votes(votes, notes)
diff --git a/app/views/shared/issuable/_context.html.haml b/app/views/shared/issuable/_context.html.haml
index d1bd5ef968d..19e8c31975b 100644
--- a/app/views/shared/issuable/_context.html.haml
+++ b/app/views/shared/issuable/_context.html.haml
@@ -8,7 +8,7 @@
- else
none
.issuable-context-selectbox
- - if can?(current_user, :"admin_#{issuable.class.to_s.underscore}", @project)
+ - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
= users_select_tag("#{issuable.class.table_name.singularize}[assignee_id]", placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: issuable.assignee_id, project: @target_project, null_user: true)
%div.prepend-top-20.clearfix
@@ -24,7 +24,7 @@
- else
none
.issuable-context-selectbox
- - if can?(current_user, :"admin_#{issuable.class.to_s.underscore}", @project)
+ - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
= f.select(:milestone_id, milestone_options(issuable), { include_blank: 'Select milestone' }, {class: 'select2 select2-compact js-select2 js-milestone'})
= hidden_field_tag :issuable_context
= f.submit class: 'btn hide'