From d250d0073bf7e67996d513e80c584a1985ff7a98 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Sat, 6 Jun 2009 16:39:53 -0300 Subject: [PATCH] ActionItem1060: when applying template, copy title blocks --- app/models/profile.rb | 2 +- test/unit/profile_test.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index 975c921..1b55620 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -249,7 +249,7 @@ class Profile < ActiveRecord::Base profile.boxes.each do |box| self.boxes << Box.new(:position => box.position) box.blocks.each do |block| - self.boxes[-1].blocks << block.class.new(:title => block.title, :settings => block.settings, :position => block.position) + self.boxes[-1].blocks << block.class.new(:title => block[:title], :settings => block.settings, :position => block.position) end end end diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 2d6c4a1..d2b3b31 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1090,6 +1090,34 @@ class ProfileTest < Test::Unit::TestCase assert_equal 'some xyz article', Profile['test_profile'].home_page.name end + should 'not copy blocks default_title when applying template' do + template = Profile.create!(:name => 'test template', :identifier => 'test_template') + template.boxes.destroy_all + template.boxes << Box.new + b = Block.new() + template.boxes[0].blocks << b + p = Profile.create!(:name => 'test prof', :identifier => 'test_prof') + assert b[:title].blank? + + p.copy_blocks_from(template) + + assert_nil p.boxes[0].blocks.first[:title] + end + + should 'copy blocks title when applying template' do + template = Profile.create!(:name => 'test template', :identifier => 'test_template') + template.boxes.destroy_all + template.boxes << Box.new + b = Block.new(:title => 'default title') + template.boxes[0].blocks << b + p = Profile.create!(:name => 'test prof', :identifier => 'test_prof') + assert !b[:title].blank? + + p.copy_blocks_from(template) + + assert_equal 'default title', p.boxes[0].blocks.first[:title] + end + TMP_THEMES_DIR = RAILS_ROOT + '/test/tmp/profile_themes' should 'have themes' do Theme.stubs(:user_themes_dir).returns(TMP_THEMES_DIR) -- libgit2 0.21.2