summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-26 23:59:52 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-26 23:59:52 +0200
commitdaa90e1182c1991b088f4feed1a633c35bdde0f9 (patch)
tree4db1cb37408c0c16bcd5886b410b9edd3e5cec53
parent5ea5e8f5d6fa6721af10839b7c81a87fc49c7843 (diff)
downloadgitlab-ce-daa90e1182c1991b088f4feed1a633c35bdde0f9.tar.gz
Fix 500 error when try to create project snippet without content
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/controllers/projects/snippets_controller.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb
index 64306637423..b07a2a8db2f 100644
--- a/app/controllers/projects/snippets_controller.rb
+++ b/app/controllers/projects/snippets_controller.rb
@@ -30,9 +30,14 @@ class Projects::SnippetsController < Projects::ApplicationController
def create
@snippet = CreateSnippetService.new(@project, current_user,
snippet_params).execute
- respond_with(@snippet,
- location: namespace_project_snippet_path(@project.namespace,
- @project, @snippet))
+
+ if @snippet.valid?
+ respond_with(@snippet,
+ location: namespace_project_snippet_path(@project.namespace,
+ @project, @snippet))
+ else
+ render :new
+ end
end
def edit