Commit fa8ef8f771f419abfdebcb4e231ea4e9c6705f5a
1 parent
77649157
Exists in
master
and in
28 other branches
ActionItem152: creating boxes for Person
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1217 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
20 additions
and
0 deletions
Show diff stats
app/models/person.rb
| ... | ... | @@ -53,4 +53,16 @@ class Person < Profile |
| 53 | 53 | end |
| 54 | 54 | end |
| 55 | 55 | |
| 56 | + # FIXME this is *weird*, because this class is not inheriting the callback | |
| 57 | + # from Profile !!! | |
| 58 | + after_create :create_default_set_of_boxes_for_person | |
| 59 | + def create_default_set_of_boxes_for_person | |
| 60 | + 3.times do | |
| 61 | + self.boxes << Box.new | |
| 62 | + end | |
| 63 | + self.boxes.first.blocks << MainBlock.new | |
| 64 | + | |
| 65 | + true | |
| 66 | + end | |
| 67 | + | |
| 56 | 68 | end | ... | ... |
test/unit/person_test.rb
| ... | ... | @@ -110,4 +110,12 @@ class PersonTest < Test::Unit::TestCase |
| 110 | 110 | person.reload |
| 111 | 111 | assert person.is_admin? |
| 112 | 112 | end |
| 113 | + | |
| 114 | + should 'have boxes and blocks created when person is created' do | |
| 115 | + person = create_user('testboxes').person | |
| 116 | + | |
| 117 | + assert person.boxes.size > 0, 'Person should have boxes upon creation' | |
| 118 | + assert person.blocks.size > 0, 'Person should have blocks upon creation' | |
| 119 | + end | |
| 120 | + | |
| 113 | 121 | end | ... | ... |