debian-mirror-gitlab/app/services/update_snippet_service.rb

23 lines
610 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class UpdateSnippetService < BaseService
attr_accessor :snippet
def initialize(project, user, snippet, params)
super(project, user, params)
@snippet = snippet
end
def execute
# check that user is allowed to set specified visibility_level
new_visibility = params[:visibility_level]
2016-08-24 12:49:21 +05:30
2015-04-26 12:48:37 +05:30
if new_visibility && new_visibility.to_i != snippet.visibility_level
2015-09-11 14:41:01 +05:30
unless Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility)
2015-04-26 12:48:37 +05:30
deny_visibility_level(snippet, new_visibility)
return snippet
end
end
snippet.update_attributes(params)
end
end