summaryrefslogtreecommitdiff
path: root/test/unit/asset_test.rb
blob: a1041e4563378f1c00591d53746aa6ca59a3108c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'test_helper'

class AssetTest < ActiveSupport::TestCase
  
  test "related assets get destroyed when assets get destroyed" do
    Asset.delete_all
    RelatedAsset.delete_all
    
    assert asset  = Asset.create
    assert node   = Node.root.children.create( :slug => "asset" )
    assert_equal [], node.draft.assets
    
    draft = node.draft
    draft.assets << asset
    assert_equal 1, draft.assets.length
    
    asset.destroy
    draft.reload
    assert_equal 0, draft.assets.length
    assert_equal 0, RelatedAsset.count
  end
  
end