Commit fa8ef8f771f419abfdebcb4e231ea4e9c6705f5a
1 parent
77649157
Exists in
master
and in
29 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,4 +53,16 @@ class Person < Profile | ||
53 | end | 53 | end |
54 | end | 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 | end | 68 | end |
test/unit/person_test.rb
@@ -110,4 +110,12 @@ class PersonTest < Test::Unit::TestCase | @@ -110,4 +110,12 @@ class PersonTest < Test::Unit::TestCase | ||
110 | person.reload | 110 | person.reload |
111 | assert person.is_admin? | 111 | assert person.is_admin? |
112 | end | 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 | end | 121 | end |