diff options
-rw-r--r-- | app/helpers/application_settings_helper.rb | 3 | ||||
-rw-r--r-- | lib/api/project_snippets.rb | 8 |
2 files changed, 6 insertions, 5 deletions
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 2b0d8860f9b..241d6075c9f 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -29,7 +29,8 @@ module ApplicationSettingsHelper checkbox_name = 'application_setting[restricted_visibility_levels][]' label_tag(checkbox_name, class: css_class) do - check_box_tag(checkbox_name, level, checked, autocomplete: 'off', + check_box_tag(checkbox_name, level, checked, + autocomplete: 'off', 'aria-describedby' => help_block_id) + name end end diff --git a/lib/api/project_snippets.rb b/lib/api/project_snippets.rb index 25f34a3dab5..54f2555903f 100644 --- a/lib/api/project_snippets.rb +++ b/lib/api/project_snippets.rb @@ -51,13 +51,13 @@ module API attrs = attributes_for_keys [:title, :file_name, :visibility_level] attrs[:content] = params[:code] if params[:code].present? - @snippet = CreateSnippetservice.new(user_project, current_user, + @snippet = CreateSnippetService.new(user_project, current_user, attrs).execute - if @snippet.saved? - present @snippet, with: Entities::ProjectSnippet - else + if @snippet.errors.any? render_validation_error!(@snippet) + else + present @snippet, with: Entities::ProjectSnippet end end |