diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-09-02 09:59:24 +0300 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-09-06 22:07:20 +0300 |
commit | 9fc10b1bf33ddede32a4a8e0217144383831cee6 (patch) | |
tree | 07bbbb4624cbb855af07f0fe044d68447587135f /app/services/concerns/update_visibility_level.rb | |
parent | c2c6c4c69e40bca205d3c442cd7e2ce00383fb10 (diff) |
Dry up method for code climate
Diffstat (limited to 'app/services/concerns/update_visibility_level.rb')
-rw-r--r-- | app/services/concerns/update_visibility_level.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/services/concerns/update_visibility_level.rb b/app/services/concerns/update_visibility_level.rb new file mode 100644 index 00000000000..f67b5474627 --- /dev/null +++ b/app/services/concerns/update_visibility_level.rb @@ -0,0 +1,15 @@ +module UpdateVisibilityLevel + def visibility_level_allowed?(target, new_visibility) + # check that user is allowed to set specified visibility_level + if new_visibility && new_visibility.to_i != target.visibility_level + unless can?(current_user, :change_visibility_level, target) && + Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility) + + deny_visibility_level(target, new_visibility) + return false + end + end + + true + end +end |