From b53fad291aebae7e4fdfe0338a372cfa11c4fa02 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Mon, 11 Feb 2008 19:28:40 +0000 Subject: [PATCH] ActionItem154: creating default set of boxes for community --- app/models/community.rb | 14 ++++++++++++++ test/unit/community_test.rb | 13 +++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/app/models/community.rb b/app/models/community.rb index 8865abb..1f09354 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -14,4 +14,18 @@ class Community < Organization self.affiliate(person, Profile::Roles.member) end + after_create :create_default_set_of_blocks_for_community + def create_default_set_of_blocks_for_community + # "main" area + # nothing ... + + # "left" area + self.boxes[1].blocks << ProfileInfoBlock.new + self.boxes[1].blocks << RecentDocumentsBlock.new + + # "right" area + self.boxes[2].blocks << MembersBlock.new + self.boxes[2].blocks << TagsBlock.new + end + end diff --git a/test/unit/community_test.rb b/test/unit/community_test.rb index 0fc0f30..b4095e8 100644 --- a/test/unit/community_test.rb +++ b/test/unit/community_test.rb @@ -27,4 +27,17 @@ class CommunityTest < Test::Unit::TestCase assert c.members.include?(p), "Community should add the new member" end + should 'create default set of blocks' do + c = Community.create!(:name => 'my new community') + + assert c.boxes[0].blocks.map(&:class).include?(MainBlock) + + assert c.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock) + assert c.boxes[1].blocks.map(&:class).include?(RecentDocumentsBlock) + + assert c.boxes[2].blocks.map(&:class).include?(MembersBlock) + assert c.boxes[2].blocks.map(&:class).include?(TagsBlock) + + end + end -- libgit2 0.21.2