diff options
Diffstat (limited to 'test/models/asset_destroy_test.rb')
| -rw-r--r-- | test/models/asset_destroy_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/models/asset_destroy_test.rb b/test/models/asset_destroy_test.rb index 5583f685..2f38d692 100644 --- a/test/models/asset_destroy_test.rb +++ b/test/models/asset_destroy_test.rb | |||
| @@ -48,4 +48,17 @@ class AssetDestroyTest < ActiveSupport::TestCase | |||
| 48 | assert_equal "Doomed asset", action.metadata["asset_name"] | 48 | assert_equal "Doomed asset", action.metadata["asset_name"] |
| 49 | assert_nil action.action_participants.first.subject | 49 | assert_nil action.action_participants.first.subject |
| 50 | end | 50 | end |
| 51 | |||
| 52 | test "destroying an asset attached to a restricted node needs the redaktion role" do | ||
| 53 | editor = User.create!(:login => "asset_gate", :email => "ag@example.com", | ||
| 54 | :password => "secret", :password_confirmation => "secret") | ||
| 55 | updates = Node.root.children.create!(:slug => "updates") | ||
| 56 | node = updates.children.create!(:slug => "gated-attachment") | ||
| 57 | node.reload.attach_asset!(@asset, :user => nil) | ||
| 58 | |||
| 59 | error = assert_raises(ActiveRecord::RecordInvalid) { @asset.destroy_witnessed!(:user => editor) } | ||
| 60 | assert_includes error.message, | ||
| 61 | I18n.t("activerecord.errors.models.asset.attributes.base.not_permitted") | ||
| 62 | assert Asset.exists?(@asset.id) | ||
| 63 | end | ||
| 51 | end | 64 | end |
