Commit cfd92ee42f9cad6c7533d3e9019b5068cfa200ae
Committed by
Antonio Terceiro
1 parent
c3f4edc3
Exists in
master
and in
29 other branches
ActionItem1005: template application is not copying header/footer
Showing
2 changed files
with
14 additions
and
3 deletions
Show diff stats
app/models/profile.rb
| ... | ... | @@ -231,7 +231,7 @@ class Profile < ActiveRecord::Base |
| 231 | 231 | # instances. |
| 232 | 232 | def create_default_set_of_boxes |
| 233 | 233 | if template |
| 234 | - copy_blocks_from template | |
| 234 | + apply_template(template, :copy_articles => false) | |
| 235 | 235 | else |
| 236 | 236 | 3.times do |
| 237 | 237 | self.boxes << Box.new |
| ... | ... | @@ -264,9 +264,9 @@ class Profile < ActiveRecord::Base |
| 264 | 264 | nil |
| 265 | 265 | end |
| 266 | 266 | |
| 267 | - def apply_template(template) | |
| 267 | + def apply_template(template, options = {:copy_articles => true}) | |
| 268 | 268 | copy_blocks_from(template) |
| 269 | - copy_articles_from(template) | |
| 269 | + copy_articles_from(template) if options[:copy_articles] | |
| 270 | 270 | |
| 271 | 271 | # copy interesting attributes |
| 272 | 272 | self.layout_template = template.layout_template | ... | ... |
test/unit/profile_test.rb
| ... | ... | @@ -1359,6 +1359,17 @@ class ProfileTest < Test::Unit::TestCase |
| 1359 | 1359 | assert !profile.valid? |
| 1360 | 1360 | end |
| 1361 | 1361 | |
| 1362 | + should 'copy header and footer after create a person' do | |
| 1363 | + template = create_user('template').person | |
| 1364 | + template.custom_footer = "footer customized" | |
| 1365 | + template.custom_header = "header customized" | |
| 1366 | + Environment.any_instance.stubs(:person_template).returns(template) | |
| 1367 | + | |
| 1368 | + person = create_user('mytestuser').person | |
| 1369 | + assert_equal "footer customized", person.custom_footer | |
| 1370 | + assert_equal "header customized", person.custom_header | |
| 1371 | + end | |
| 1372 | + | |
| 1362 | 1373 | private |
| 1363 | 1374 | |
| 1364 | 1375 | def assert_invalid_identifier(id) | ... | ... |