From 16601d45d35cad1b1eea9329b2fcd4fb331716de Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Sun, 2 Dec 2007 02:58:12 +0000 Subject: [PATCH] ActionItem93: removing models that act as design must imply removing theis design boxes and blocks (updated plugin to implement this) --- test/unit/environment_test.rb | 17 +++++++++++++++++ test/unit/profile_test.rb | 31 ++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/test/unit/environment_test.rb b/test/unit/environment_test.rb index 7780323..6ccd0b7 100644 --- a/test/unit/environment_test.rb +++ b/test/unit/environment_test.rb @@ -191,4 +191,21 @@ class EnvironmentTest < Test::Unit::TestCase assert_equal "?", env.to_s end + should 'remove boxes and blocks when removing environment' do + env = Environment.create!(:name => 'test environment') + + env_boxes = env.boxes.size + env_blocks = env.blocks.size + assert env_boxes > 0 + assert env_blocks > 0 + + boxes = Design::Box.count + blocks = Design::Block.count + + env.destroy + + assert_equal boxes - env_boxes, Design::Box.count + assert_equal blocks - env_blocks, Design::Block.count + end + end diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 0a9bcea..d8782fb 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -68,12 +68,6 @@ class ProfileTest < Test::Unit::TestCase assert !p.errors.invalid?(:name) end - def test_can_be_tagged - p = Profile.create(:name => 'tagged_profile', :identifier => 'tagged') - p.tags << Tag.create(:name => 'a_tag') - assert Profile.find_tagged_with('a_tag').include?(p) - end - def test_can_have_affiliated_people pr = Profile.create(:name => 'composite_profile', :identifier => 'composite') pe = User.create(:login => 'aff', :email => 'aff@pr.coop', :password => 'blih', :password_confirmation => 'blih').person @@ -85,13 +79,11 @@ class ProfileTest < Test::Unit::TestCase assert pe.memberships.include?(pr) end - def test_search + def test_find_by_contents p = Profile.create(:name => 'wanted', :identifier => 'wanted') - p.update_attribute(:tag_list, 'bla') - assert Profile.search('wanted').include?(p) - assert Profile.search('bla').include?(p) - assert ! Profile.search('not_wanted').include?(p) + assert Profile.find_by_contents('wanted').include?(p) + assert ! Profile.find_by_contents('not_wanted').include?(p) end should 'remove pages when removing profile' do @@ -208,6 +200,23 @@ class ProfileTest < Test::Unit::TestCase assert_equal profile, Profile['testprofile'] end + should 'remove boxes and blocks when removing profile' do + profile = Profile.create!(:name => 'test environment', :identifier => 'testenv') + + profile_boxes = profile.boxes.size + profile_blocks = profile.blocks.size + assert profile_boxes > 0 + assert profile_blocks > 0 + + boxes = Design::Box.count + blocks = Design::Block.count + + profile.destroy + + assert_equal boxes - profile_boxes, Design::Box.count + assert_equal blocks - profile_blocks, Design::Block.count + end + private def assert_invalid_identifier(id) -- libgit2 0.21.2