assert_operator c.delete_at, :>=, time_before_trashing + Rails.configuration.default_trash_lifetime
end
end
+
+ test 'untrash a trashed collection' do
+ authorize_with :active
+ post :untrash, {
+ id: collections(:expired_collection).uuid,
+ }
+ assert_response 200
+ assert_equal false, json_response['is_trashed']
+ assert_nil json_response['trash_at']
+ end
+
+ test 'untrash error on not trashed collection' do
+ authorize_with :active
+ post :untrash, {
+ id: collections(:collection_owned_by_active).uuid,
+ }
+ assert_response 422
+ end
+
+ [:active, :admin].each do |user|
+ test "get trashed collections as #{user}" do
+ authorize_with :active
+ get :index, {
+ filters: [["is_trashed", "=", true]],
+ include_trash: true,
+ }
+ assert_response :success
+
+ items = []
+ json_response["items"].each do |coll|
+ items << coll['uuid']
+ end
+
+ assert_includes(items, collections('unique_expired_collection')['uuid'])
+ if user == :admin
+ assert_includes(items, collections('unique_expired_collection2')['uuid'])
+ else
+ assert_not_includes(items, collections('unique_expired_collection2')['uuid'])
+ end
+ end
+ end
end