diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-26 18:18:40 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-26 18:18:40 +0300 |
commit | 083d4604c49abfec8bf368fe0541d88dcc9bb6ed (patch) | |
tree | 6bc4f32563e87a787ffeca79f49521e0ade0ff91 /app | |
parent | d63371ad783db055da840be37ddac0cdcb49db2c (diff) |
Change dynamic abilities to new format
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ability.rb | 18 | ||||
-rw-r--r-- | app/services/update_snippet_service.rb | 4 |
2 files changed, 9 insertions, 13 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index 6e727ca7b56..b4a9adb5ffc 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -246,20 +246,16 @@ class Ability [:issue, :note, :project_snippet, :personal_snippet, :merge_request].each do |name| define_method "#{name}_abilities" do |user, subject| - if subject.author == user || user.is_admin? - rules = [ + if user.is_admin? + [ :"read_#{name}", - :"write_#{name}", - :"modify_#{name}", + :"update_#{name}", :"admin_#{name}" ] - rules.push(:change_visibility_level) if subject.is_a?(Snippet) - rules - elsif subject.respond_to?(:assignee) && subject.assignee == user + elsif subject.author == user || (subject.respond_to?(:assignee) && subject.assignee == user) [ :"read_#{name}", - :"write_#{name}", - :"modify_#{name}", + :"update_#{name}", ] else if subject.respond_to?(:project) && subject.project @@ -299,8 +295,8 @@ class Ability def named_abilities(name) [ :"read_#{name}", - :"write_#{name}", - :"modify_#{name}", + :"create_#{name}", + :"update_#{name}", :"admin_#{name}" ] end diff --git a/app/services/update_snippet_service.rb b/app/services/update_snippet_service.rb index 9d181c2d2ab..e9328bb7323 100644 --- a/app/services/update_snippet_service.rb +++ b/app/services/update_snippet_service.rb @@ -9,9 +9,9 @@ class UpdateSnippetService < BaseService def execute # check that user is allowed to set specified visibility_level new_visibility = params[:visibility_level] + if new_visibility && new_visibility.to_i != snippet.visibility_level - unless can?(current_user, :change_visibility_level, snippet) && - Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility) + unless Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility) deny_visibility_level(snippet, new_visibility) return snippet end |