summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-09-13 12:58:14 +0200
committerhukl <contact@smyck.org>2009-09-13 12:58:14 +0200
commit34b4e764ab8b00fa24c9ffead40494acd4c9da6b (patch)
tree21caf1f7fae0dafccd999c38bff4f8ddff734958 /test
parentcaebe56799887c348ab0da380940c93eb15e8d87 (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.rb21
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 @@
1require 'test_helper' 1require 'test_helper'
2 2
3class AssetTest < ActiveSupport::TestCase 3class 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
8end 23end