Commit b53fad291aebae7e4fdfe0338a372cfa11c4fa02
1 parent
43e1c725
Exists in
master
and in
29 other branches
ActionItem154: creating default set of boxes for community
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1356 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
27 additions
and
0 deletions
Show diff stats
app/models/community.rb
... | ... | @@ -14,4 +14,18 @@ class Community < Organization |
14 | 14 | self.affiliate(person, Profile::Roles.member) |
15 | 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 | + | |
17 | 31 | end | ... | ... |
test/unit/community_test.rb
... | ... | @@ -27,4 +27,17 @@ class CommunityTest < Test::Unit::TestCase |
27 | 27 | assert c.members.include?(p), "Community should add the new member" |
28 | 28 | end |
29 | 29 | |
30 | + should 'create default set of blocks' do | |
31 | + c = Community.create!(:name => 'my new community') | |
32 | + | |
33 | + assert c.boxes[0].blocks.map(&:class).include?(MainBlock) | |
34 | + | |
35 | + assert c.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock) | |
36 | + assert c.boxes[1].blocks.map(&:class).include?(RecentDocumentsBlock) | |
37 | + | |
38 | + assert c.boxes[2].blocks.map(&:class).include?(MembersBlock) | |
39 | + assert c.boxes[2].blocks.map(&:class).include?(TagsBlock) | |
40 | + | |
41 | + end | |
42 | + | |
30 | 43 | end | ... | ... |