Commit 798c80a29afc96c109a523b84e7a517bd384236a
1 parent
d262a9ed
Exists in
master
and in
29 other branches
ActionItem53: when removing profile, remove also its pages
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@401 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
13 additions
and
0 deletions
Show diff stats
app/models/profile.rb
... | ... | @@ -11,6 +11,11 @@ class Profile < ActiveRecord::Base |
11 | 11 | homepage.save! |
12 | 12 | end |
13 | 13 | |
14 | + after_destroy do |profile| | |
15 | + Comatose::Page.find_by_path(profile.identifier).destroy | |
16 | + end | |
17 | + | |
18 | + | |
14 | 19 | # Valid identifiers must match this format. |
15 | 20 | IDENTIFIER_FORMAT = /^[a-z][a-z0-9_]*[a-z0-9]$/ |
16 | 21 | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -85,4 +85,12 @@ class ProfileTest < Test::Unit::TestCase |
85 | 85 | assert Profile.search('bla').include?(p) |
86 | 86 | assert ! Profile.search('not_wanted').include?(p) |
87 | 87 | end |
88 | + | |
89 | + def test_should_remove_pages_when_removing_profile | |
90 | + profile = Profile.create(:name => 'To bee removed', :identifier => 'to_be_removed') | |
91 | + assert Comatose::Page.find_by_path('to_be_removed') | |
92 | + profile.destroy | |
93 | + assert !Comatose::Page.find_by_path('to_be_removed') | |
94 | + end | |
95 | + | |
88 | 96 | end | ... | ... |