diff options
| author | hukl <contact@smyck.org> | 2009-09-13 12:58:14 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-09-13 12:58:14 +0200 |
| commit | 34b4e764ab8b00fa24c9ffead40494acd4c9da6b (patch) | |
| tree | 21caf1f7fae0dafccd999c38bff4f8ddff734958 /test | |
| parent | caebe56799887c348ab0da380940c93eb15e8d87 (diff) | |
added :dependent => :destroy to asset model so related assets get deleted as the asset they're referencing is deleted.
Closes #25
Diffstat (limited to 'test')
| -rw-r--r-- | test/unit/asset_test.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/test/unit/asset_test.rb b/test/unit/asset_test.rb index 58aba76..a1041e4 100644 --- a/test/unit/asset_test.rb +++ b/test/unit/asset_test.rb | |||
| @@ -1,8 +1,23 @@ | |||
| 1 | require 'test_helper' | 1 | require 'test_helper' |
| 2 | 2 | ||
| 3 | class AssetTest < ActiveSupport::TestCase | 3 | class AssetTest < ActiveSupport::TestCase |
| 4 | # Replace this with your real tests. | 4 | |
| 5 | test "the truth" do | 5 | test "related assets get destroyed when assets get destroyed" do |
| 6 | assert true | 6 | Asset.delete_all |
| 7 | RelatedAsset.delete_all | ||
| 8 | |||
| 9 | assert asset = Asset.create | ||
| 10 | assert node = Node.root.children.create( :slug => "asset" ) | ||
| 11 | assert_equal [], node.draft.assets | ||
| 12 | |||
| 13 | draft = node.draft | ||
| 14 | draft.assets << asset | ||
| 15 | assert_equal 1, draft.assets.length | ||
| 16 | |||
| 17 | asset.destroy | ||
| 18 | draft.reload | ||
| 19 | assert_equal 0, draft.assets.length | ||
| 20 | assert_equal 0, RelatedAsset.count | ||
| 7 | end | 21 | end |
| 22 | |||
| 8 | end | 23 | end |
