From ae10999133cfb9aa46c40cabaec0a941ee5e7644 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 14 Feb 2008 19:28:30 +0000 Subject: [PATCH] ActionItem154: adding default blocks for enterprise --- app/models/community.rb | 14 -------------- app/models/organization.rb | 14 ++++++++++++++ test/unit/enterprise_test.rb | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/app/models/community.rb b/app/models/community.rb index 1f09354..8865abb 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -14,18 +14,4 @@ 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/app/models/organization.rb b/app/models/organization.rb index be9aa4e..b3c36f7 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -53,4 +53,18 @@ class Organization < Profile true end + after_create :create_default_set_of_blocks_for_organization + def create_default_set_of_blocks_for_organization + # "main" area + # nothing ..., MainBlock is already there + + # "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/enterprise_test.rb b/test/unit/enterprise_test.rb index d099365..de6dd7a 100644 --- a/test/unit/enterprise_test.rb +++ b/test/unit/enterprise_test.rb @@ -62,4 +62,18 @@ class EnterpriseTest < Test::Unit::TestCase assert_kind_of RssFeed, enterprise.articles.find_by_path('feed') end + should 'create default set of blocks' do + e = Enterprise.create!(:name => 'my new community', :identifier => 'mynewcommunity') + + assert e.boxes[0].blocks.map(&:class).include?(MainBlock), 'enterprise must have a MainBlock upon creation' + + assert e.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock), 'enterprise must have a ProfileInfoBlock upon creation' + assert e.boxes[1].blocks.map(&:class).include?(RecentDocumentsBlock), 'enterprise must have a RecentDocumentsBlock upon creation' + + assert e.boxes[2].blocks.map(&:class).include?(MembersBlock), 'enterprise must have a MembersBlock upon creation' + assert e.boxes[2].blocks.map(&:class).include?(TagsBlock), 'enterprise must have a TagsBlock upon creation' + + assert_equal 5, e.blocks.size + end + end -- libgit2 0.21.2