From b9e8b2248b70d1f61d29ffca290c7d34e4feff50 Mon Sep 17 00:00:00 2001
From: Clarissa <cdp13@inf.ufpr.br>
Date: Tue, 6 Feb 2018 11:28:51 -0200
Subject: [PATCH] SCRUM#294: delete CollectionItems only activate
 really_destroy

---
 app/controllers/v1/collections_controller.rb | 2 +-
 app/models/collection.rb                     | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/app/controllers/v1/collections_controller.rb b/app/controllers/v1/collections_controller.rb
index 06ada88cb..451b56066 100644
--- a/app/controllers/v1/collections_controller.rb
+++ b/app/controllers/v1/collections_controller.rb
@@ -95,7 +95,7 @@ class V1::CollectionsController < ApplicationController
   # DELETE /v1/collections/1/items
   def delete_object
     return render nothing: true, status: :unprocessable_entity if extra_params.blank? || extra_params[:items].blank?
-    @collection.delete_items(extra_params[:items])
+    @collection.really_delete_items(extra_params[:items])
     render json: @collection, status: :ok
   end
 
diff --git a/app/models/collection.rb b/app/models/collection.rb
index 00620bfc3..e01839592 100644
--- a/app/models/collection.rb
+++ b/app/models/collection.rb
@@ -131,6 +131,12 @@ class Collection < ApplicationRecord
     end
   end
 
+  def really_delete_items(items)
+    items.each do |item|
+      CollectionItem.find(item[:id]).really_destroy!
+    end
+  end
+
   ## score methods
   def user_category
     owner.try('user_category')
-- 
GitLab