summaryrefslogtreecommitdiff
path: root/app/controllers/snippets_controller.rb
diff options
context:
space:
mode:
authorVinnie Okada <vokada@mrvinn.com>2015-03-07 12:47:06 -0700
committerVinnie Okada <vokada@mrvinn.com>2015-03-08 17:57:08 -0600
commit928fc94c3d900069902b097d6464acee712a886c (patch)
treee30cbea42055c082e76881bd36ccd94f72afac8e /app/controllers/snippets_controller.rb
parent285c5341855f8af6cbea5e964e3104a4698fa450 (diff)
downloadgitlab-ce-928fc94c3d900069902b097d6464acee712a886c.tar.gz
Enforce restricted visibilities for snippets
Add new service classes to create and update project and personal snippets. These classes are responsible for enforcing restricted visibility settings for non-admin users.
Diffstat (limited to 'app/controllers/snippets_controller.rb')
-rw-r--r--app/controllers/snippets_controller.rb18
1 files changed, 6 insertions, 12 deletions
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index 6ac048e4b83..dc0a5554723 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -42,25 +42,19 @@ class SnippetsController < ApplicationController
end
def create
- @snippet = PersonalSnippet.new(snippet_params)
- @snippet.author = current_user
+ @snippet = CreateSnippetService.new(nil, current_user,
+ snippet_params).execute
- if @snippet.save
- redirect_to snippet_path(@snippet)
- else
- respond_with @snippet
- end
+ respond_with @snippet.becomes(Snippet)
end
def edit
end
def update
- if @snippet.update_attributes(snippet_params)
- redirect_to snippet_path(@snippet)
- else
- respond_with @snippet
- end
+ UpdateSnippetService.new(nil, current_user, @snippet,
+ snippet_params).execute
+ respond_with @snippet.becomes(Snippet)
end
def show