Commit d250d0073bf7e67996d513e80c584a1985ff7a98
1 parent
650f72e7
Exists in
master
and in
28 other branches
ActionItem1060: when applying template, copy title blocks
Showing
2 changed files
with
29 additions
and
1 deletions
Show diff stats
app/models/profile.rb
| ... | ... | @@ -249,7 +249,7 @@ class Profile < ActiveRecord::Base |
| 249 | 249 | profile.boxes.each do |box| |
| 250 | 250 | self.boxes << Box.new(:position => box.position) |
| 251 | 251 | box.blocks.each do |block| |
| 252 | - self.boxes[-1].blocks << block.class.new(:title => block.title, :settings => block.settings, :position => block.position) | |
| 252 | + self.boxes[-1].blocks << block.class.new(:title => block[:title], :settings => block.settings, :position => block.position) | |
| 253 | 253 | end |
| 254 | 254 | end |
| 255 | 255 | end | ... | ... |
test/unit/profile_test.rb
| ... | ... | @@ -1090,6 +1090,34 @@ class ProfileTest < Test::Unit::TestCase |
| 1090 | 1090 | assert_equal 'some xyz article', Profile['test_profile'].home_page.name |
| 1091 | 1091 | end |
| 1092 | 1092 | |
| 1093 | + should 'not copy blocks default_title when applying template' do | |
| 1094 | + template = Profile.create!(:name => 'test template', :identifier => 'test_template') | |
| 1095 | + template.boxes.destroy_all | |
| 1096 | + template.boxes << Box.new | |
| 1097 | + b = Block.new() | |
| 1098 | + template.boxes[0].blocks << b | |
| 1099 | + p = Profile.create!(:name => 'test prof', :identifier => 'test_prof') | |
| 1100 | + assert b[:title].blank? | |
| 1101 | + | |
| 1102 | + p.copy_blocks_from(template) | |
| 1103 | + | |
| 1104 | + assert_nil p.boxes[0].blocks.first[:title] | |
| 1105 | + end | |
| 1106 | + | |
| 1107 | + should 'copy blocks title when applying template' do | |
| 1108 | + template = Profile.create!(:name => 'test template', :identifier => 'test_template') | |
| 1109 | + template.boxes.destroy_all | |
| 1110 | + template.boxes << Box.new | |
| 1111 | + b = Block.new(:title => 'default title') | |
| 1112 | + template.boxes[0].blocks << b | |
| 1113 | + p = Profile.create!(:name => 'test prof', :identifier => 'test_prof') | |
| 1114 | + assert !b[:title].blank? | |
| 1115 | + | |
| 1116 | + p.copy_blocks_from(template) | |
| 1117 | + | |
| 1118 | + assert_equal 'default title', p.boxes[0].blocks.first[:title] | |
| 1119 | + end | |
| 1120 | + | |
| 1093 | 1121 | TMP_THEMES_DIR = RAILS_ROOT + '/test/tmp/profile_themes' |
| 1094 | 1122 | should 'have themes' do |
| 1095 | 1123 | Theme.stubs(:user_themes_dir).returns(TMP_THEMES_DIR) | ... | ... |