Commit 16601d45d35cad1b1eea9329b2fcd4fb331716de

Authored by AntonioTerceiro
1 parent 5cf17423

ActionItem93: removing models that act as design must imply removing theis desig…

…n boxes and blocks (updated plugin to implement this)



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1046 3f533792-8f58-4932-b0fe-aaf55b0a4547
test/unit/environment_test.rb
... ... @@ -191,4 +191,21 @@ class EnvironmentTest < Test::Unit::TestCase
191 191 assert_equal "?", env.to_s
192 192 end
193 193  
  194 + should 'remove boxes and blocks when removing environment' do
  195 + env = Environment.create!(:name => 'test environment')
  196 +
  197 + env_boxes = env.boxes.size
  198 + env_blocks = env.blocks.size
  199 + assert env_boxes > 0
  200 + assert env_blocks > 0
  201 +
  202 + boxes = Design::Box.count
  203 + blocks = Design::Block.count
  204 +
  205 + env.destroy
  206 +
  207 + assert_equal boxes - env_boxes, Design::Box.count
  208 + assert_equal blocks - env_blocks, Design::Block.count
  209 + end
  210 +
194 211 end
... ...
test/unit/profile_test.rb
... ... @@ -68,12 +68,6 @@ class ProfileTest < Test::Unit::TestCase
68 68 assert !p.errors.invalid?(:name)
69 69 end
70 70  
71   - def test_can_be_tagged
72   - p = Profile.create(:name => 'tagged_profile', :identifier => 'tagged')
73   - p.tags << Tag.create(:name => 'a_tag')
74   - assert Profile.find_tagged_with('a_tag').include?(p)
75   - end
76   -
77 71 def test_can_have_affiliated_people
78 72 pr = Profile.create(:name => 'composite_profile', :identifier => 'composite')
79 73 pe = User.create(:login => 'aff', :email => 'aff@pr.coop', :password => 'blih', :password_confirmation => 'blih').person
... ... @@ -85,13 +79,11 @@ class ProfileTest &lt; Test::Unit::TestCase
85 79 assert pe.memberships.include?(pr)
86 80 end
87 81  
88   - def test_search
  82 + def test_find_by_contents
89 83 p = Profile.create(:name => 'wanted', :identifier => 'wanted')
90   - p.update_attribute(:tag_list, 'bla')
91 84  
92   - assert Profile.search('wanted').include?(p)
93   - assert Profile.search('bla').include?(p)
94   - assert ! Profile.search('not_wanted').include?(p)
  85 + assert Profile.find_by_contents('wanted').include?(p)
  86 + assert ! Profile.find_by_contents('not_wanted').include?(p)
95 87 end
96 88  
97 89 should 'remove pages when removing profile' do
... ... @@ -208,6 +200,23 @@ class ProfileTest &lt; Test::Unit::TestCase
208 200 assert_equal profile, Profile['testprofile']
209 201 end
210 202  
  203 + should 'remove boxes and blocks when removing profile' do
  204 + profile = Profile.create!(:name => 'test environment', :identifier => 'testenv')
  205 +
  206 + profile_boxes = profile.boxes.size
  207 + profile_blocks = profile.blocks.size
  208 + assert profile_boxes > 0
  209 + assert profile_blocks > 0
  210 +
  211 + boxes = Design::Box.count
  212 + blocks = Design::Block.count
  213 +
  214 + profile.destroy
  215 +
  216 + assert_equal boxes - profile_boxes, Design::Box.count
  217 + assert_equal blocks - profile_blocks, Design::Block.count
  218 + end
  219 +
211 220 private
212 221  
213 222 def assert_invalid_identifier(id)
... ...