Commit ae10999133cfb9aa46c40cabaec0a941ee5e7644
1 parent
3d57165a
Exists in
master
and in
28 other branches
ActionItem154: adding default blocks for enterprise
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1370 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
28 additions
and
14 deletions
Show diff stats
app/models/community.rb
@@ -14,18 +14,4 @@ class Community < Organization | @@ -14,18 +14,4 @@ class Community < Organization | ||
14 | self.affiliate(person, Profile::Roles.member) | 14 | self.affiliate(person, Profile::Roles.member) |
15 | end | 15 | end |
16 | 16 | ||
17 | - after_create :create_default_set_of_blocks_for_community | ||
18 | - def create_default_set_of_blocks_for_community | ||
19 | - # "main" area | ||
20 | - # nothing ... | ||
21 | - | ||
22 | - # "left" area | ||
23 | - self.boxes[1].blocks << ProfileInfoBlock.new | ||
24 | - self.boxes[1].blocks << RecentDocumentsBlock.new | ||
25 | - | ||
26 | - # "right" area | ||
27 | - self.boxes[2].blocks << MembersBlock.new | ||
28 | - self.boxes[2].blocks << TagsBlock.new | ||
29 | - end | ||
30 | - | ||
31 | end | 17 | end |
app/models/organization.rb
@@ -53,4 +53,18 @@ class Organization < Profile | @@ -53,4 +53,18 @@ class Organization < Profile | ||
53 | true | 53 | true |
54 | end | 54 | end |
55 | 55 | ||
56 | + after_create :create_default_set_of_blocks_for_organization | ||
57 | + def create_default_set_of_blocks_for_organization | ||
58 | + # "main" area | ||
59 | + # nothing ..., MainBlock is already there | ||
60 | + | ||
61 | + # "left" area | ||
62 | + self.boxes[1].blocks << ProfileInfoBlock.new | ||
63 | + self.boxes[1].blocks << RecentDocumentsBlock.new | ||
64 | + | ||
65 | + # "right" area | ||
66 | + self.boxes[2].blocks << MembersBlock.new | ||
67 | + self.boxes[2].blocks << TagsBlock.new | ||
68 | + end | ||
69 | + | ||
56 | end | 70 | end |
test/unit/enterprise_test.rb
@@ -62,4 +62,18 @@ class EnterpriseTest < Test::Unit::TestCase | @@ -62,4 +62,18 @@ class EnterpriseTest < Test::Unit::TestCase | ||
62 | assert_kind_of RssFeed, enterprise.articles.find_by_path('feed') | 62 | assert_kind_of RssFeed, enterprise.articles.find_by_path('feed') |
63 | end | 63 | end |
64 | 64 | ||
65 | + should 'create default set of blocks' do | ||
66 | + e = Enterprise.create!(:name => 'my new community', :identifier => 'mynewcommunity') | ||
67 | + | ||
68 | + assert e.boxes[0].blocks.map(&:class).include?(MainBlock), 'enterprise must have a MainBlock upon creation' | ||
69 | + | ||
70 | + assert e.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock), 'enterprise must have a ProfileInfoBlock upon creation' | ||
71 | + assert e.boxes[1].blocks.map(&:class).include?(RecentDocumentsBlock), 'enterprise must have a RecentDocumentsBlock upon creation' | ||
72 | + | ||
73 | + assert e.boxes[2].blocks.map(&:class).include?(MembersBlock), 'enterprise must have a MembersBlock upon creation' | ||
74 | + assert e.boxes[2].blocks.map(&:class).include?(TagsBlock), 'enterprise must have a TagsBlock upon creation' | ||
75 | + | ||
76 | + assert_equal 5, e.blocks.size | ||
77 | + end | ||
78 | + | ||
65 | end | 79 | end |