[24839] Avoid saving nil textile body

pull/6827/head
Oliver Günther 8 years ago
parent cd4f57b84f
commit e88abd9152
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 2
      .travis.yml
  2. 5
      app/controllers/my_projects_overviews_controller.rb
  3. 4
      app/models/my_projects_overview.rb
  4. 1
      config/locales/en.yml

@ -59,7 +59,7 @@ env:
- COVERAGE=true
matrix:
- "TEST_SUITE=plugins:spec DB=mysql GROUP_SIZE=1 GROUP=1"
- "TEST_SUITE=plugins:specs DB=mysql GROUP_SIZE=1 GROUP=1"
- "TEST_SUITE=npm"

@ -53,12 +53,15 @@ class MyProjectsOverviewsController < ApplicationController
end
end
overview.save_custom_element(block_name, block_title, textile)
if overview.save_custom_element(block_name, block_title, textile)
render(partial: "block_textilizable",
locals: { project: project,
block_title: block_title,
block_name: block_name,
textile: textile })
else
render text: t(:error_textile_not_saved), status: 400
end
end
# Add a block to user's page

@ -59,7 +59,9 @@ class MyProjectsOverview < ActiveRecord::Base
def save_custom_element(name, title, new_content)
el = custom_elements.detect {|x| x.first == name}
return unless el
return false unless el
return false unless title && new_content
el[1] = title
el[2] = new_content
save

@ -21,6 +21,7 @@
en:
button_edit_this_page: "Edit this page"
error_saving_changes: "The changes could not be saved: %{errors}"
error_textile_not_saved: "The textile block could not be saved."
label_hidden_elements: "Hidden elements"
label_visible_elements: "Visible elements"
label_project_description: "Project description"

Loading…
Cancel
Save