[Git][noosfero/noosfero][stable-1.8] Merge branch 'template_validation' into 'master'
Rodrigo Souto
gitlab at mg.gitlab.com
Mon Jun 26 10:14:01 BRT 2017
Rodrigo Souto pushed to branch stable-1.8 at Noosfero / noosfero
Commits:
cd3c9b72 by Rodrigo Souto at 2017-06-26T13:12:56+00:00
Merge branch 'template_validation' into 'master'
Adds a validation when applying profile templates
Closes #191
See merge request !1253
- - - - -
2 changed files:
- app/models/profile.rb
- test/unit/profile_test.rb
Changes:
=====================================
app/models/profile.rb
=====================================
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -553,6 +553,8 @@ class Profile < ApplicationRecord
alias_method_chain :template, :default
def apply_template(template, options = {:copy_articles => true})
+ raise "#{template.identifier} is not a template" if !template.is_template
+
self.template = template
copy_blocks_from(template)
copy_articles_from(template) if options[:copy_articles]
=====================================
test/unit/profile_test.rb
=====================================
--- a/test/unit/profile_test.rb
+++ b/test/unit/profile_test.rb
@@ -1235,6 +1235,18 @@ class ProfileTest < ActiveSupport::TestCase
assert_equal false, p.public_profile
end
+ should 'not apply a template that is not a template' do
+ not_a_template = fast_create(Profile, :is_template => false)
+ not_a_template.layout_template = 'leftbar'
+ not_a_template.save!
+
+ p = fast_create(Profile)
+ assert_raise RuntimeError do
+ p.apply_template(not_a_template)
+ end
+ assert_equal 'default', p.layout_template
+ end
+
should 'destroy tasks requested to it when destroyed' do
p = Profile.create!(:name => 'test_profile', :identifier => 'test_profile')
View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/cd3c9b7279e6d4de35cc5b550d63083beefaac9d
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/cd3c9b7279e6d4de35cc5b550d63083beefaac9d
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170626/8220a99f/attachment-0001.html>
More information about the Noosfero-dev
mailing list