From 0c1fbf2a53e32a591a7fcf1652ea5d5b36afc27f Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 14 Feb 2008 19:28:54 +0000 Subject: [PATCH] ActionItem154: fixing up person for the creation of default blocks --- app/models/person.rb | 3 ++- test/unit/person_test.rb | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 5c5e55e..88919e8 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -70,15 +70,16 @@ class Person < Profile # "left" area self.boxes[1].blocks << ProfileInfoBlock.new + self.boxes[1].blocks << RecentDocumentsBlock.new # right area self.boxes[2].blocks << TagsBlock.new - self.boxes[2].blocks << RecentDocumentsBlock.new true end # FIXME this is *weird*, because this class is not inheriting the callbacks before_create :set_default_environment + after_create :insert_default_homepage_and_feed end diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index 5870619..7f1a266 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -120,13 +120,6 @@ class PersonTest < Test::Unit::TestCase assert person.is_admin? end - should 'have boxes and blocks created when person is created' do - person = create_user('testboxes').person - - assert person.boxes.size > 0, 'Person should have boxes upon creation' - assert person.blocks.size > 0, 'Person should have blocks upon creation' - end - should 'get a default home page and a RSS feed' do person = create_user('mytestuser').person @@ -134,4 +127,18 @@ class PersonTest < Test::Unit::TestCase assert_kind_of RssFeed, person.articles.find_by_path('feed') end + should 'create default set of blocks' do + p = create_user('testingblocks').person + + assert p.boxes[0].blocks.map(&:class).include?(MainBlock), 'person must have a MainBlock upon creation' + + assert p.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock), 'person must have a ProfileInfoBlock upon creation' + assert p.boxes[1].blocks.map(&:class).include?(RecentDocumentsBlock), 'person must have a RecentDocumentsBlock upon creation' + + assert p.boxes[2].blocks.map(&:class).include?(TagsBlock), 'person must have a Tags Block upon creation' + # TODO check also for a "friends" block + + assert_equal 4, p.blocks.size + end + end -- libgit2 0.21.2