Commit 0c1fbf2a53e32a591a7fcf1652ea5d5b36afc27f
1 parent
ae109991
Exists in
master
and in
29 other branches
ActionItem154: fixing up person for the creation of default blocks
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1371 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
16 additions
and
8 deletions
Show diff stats
app/models/person.rb
| ... | ... | @@ -70,15 +70,16 @@ class Person < Profile |
| 70 | 70 | |
| 71 | 71 | # "left" area |
| 72 | 72 | self.boxes[1].blocks << ProfileInfoBlock.new |
| 73 | + self.boxes[1].blocks << RecentDocumentsBlock.new | |
| 73 | 74 | |
| 74 | 75 | # right area |
| 75 | 76 | self.boxes[2].blocks << TagsBlock.new |
| 76 | - self.boxes[2].blocks << RecentDocumentsBlock.new | |
| 77 | 77 | |
| 78 | 78 | true |
| 79 | 79 | end |
| 80 | 80 | |
| 81 | 81 | # FIXME this is *weird*, because this class is not inheriting the callbacks |
| 82 | 82 | before_create :set_default_environment |
| 83 | + after_create :insert_default_homepage_and_feed | |
| 83 | 84 | |
| 84 | 85 | end | ... | ... |
test/unit/person_test.rb
| ... | ... | @@ -120,13 +120,6 @@ class PersonTest < Test::Unit::TestCase |
| 120 | 120 | assert person.is_admin? |
| 121 | 121 | end |
| 122 | 122 | |
| 123 | - should 'have boxes and blocks created when person is created' do | |
| 124 | - person = create_user('testboxes').person | |
| 125 | - | |
| 126 | - assert person.boxes.size > 0, 'Person should have boxes upon creation' | |
| 127 | - assert person.blocks.size > 0, 'Person should have blocks upon creation' | |
| 128 | - end | |
| 129 | - | |
| 130 | 123 | should 'get a default home page and a RSS feed' do |
| 131 | 124 | person = create_user('mytestuser').person |
| 132 | 125 | |
| ... | ... | @@ -134,4 +127,18 @@ class PersonTest < Test::Unit::TestCase |
| 134 | 127 | assert_kind_of RssFeed, person.articles.find_by_path('feed') |
| 135 | 128 | end |
| 136 | 129 | |
| 130 | + should 'create default set of blocks' do | |
| 131 | + p = create_user('testingblocks').person | |
| 132 | + | |
| 133 | + assert p.boxes[0].blocks.map(&:class).include?(MainBlock), 'person must have a MainBlock upon creation' | |
| 134 | + | |
| 135 | + assert p.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock), 'person must have a ProfileInfoBlock upon creation' | |
| 136 | + assert p.boxes[1].blocks.map(&:class).include?(RecentDocumentsBlock), 'person must have a RecentDocumentsBlock upon creation' | |
| 137 | + | |
| 138 | + assert p.boxes[2].blocks.map(&:class).include?(TagsBlock), 'person must have a Tags Block upon creation' | |
| 139 | + # TODO check also for a "friends" block | |
| 140 | + | |
| 141 | + assert_equal 4, p.blocks.size | |
| 142 | + end | |
| 143 | + | |
| 137 | 144 | end | ... | ... |