From 9c1c673f39c69e418041a26eb66d87b46483c6a5 Mon Sep 17 00:00:00 2001
From: Mauricio Giacomini Girardello <mgg12@inf.ufpr.br>
Date: Fri, 10 Jun 2016 11:00:13 -0300
Subject: [PATCH] adding more specs

---
 .../v1/collections_controller_spec.rb         | 36 +++++++++++++------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/spec/controllers/v1/collections_controller_spec.rb b/spec/controllers/v1/collections_controller_spec.rb
index fc1eeaedc..d5621cd6e 100644
--- a/spec/controllers/v1/collections_controller_spec.rb
+++ b/spec/controllers/v1/collections_controller_spec.rb
@@ -1,29 +1,45 @@
 require 'rails_helper'
 
 RSpec.describe V1::CollectionsController, type: :controller do
-  fixtures :applications
+  fixtures :all
 
   it { should use_before_action(:authenticate_user!) }
   it { should use_before_action(:set_collection) }
   it { should route(:get, '/v1/collections').to(action: :index) }
 
-  describe 'GET #index' do
+  describe 'sociable actions' do
+    it { should use_before_action(:authorize_sociable!) }
+    it { should use_before_action(:view_object!) }
+    it { should route(:post, '/v1/collections/1/like').to(action: :like, id: 1) }
+    it { should route(:delete, '/v1/collections/1/like').to(action: :unlike, id: 1) }
 
-    context 'when application is authenticated' do
+    describe 'POST #like' do
       before do
         auth_app applications(:test_app), @request
-        get :index
+        post :like, id: collections(:ufpr).id
       end
 
-      it { expect(response.content_type).to eq('application/json') }
-      it { expect(response).to have_http_status(:ok) }
+      context 'when user is authenticated' do
+        it do
+          #user = applications(:test_app).user
+          expect(response).to have_http_status(:created)
+        end
+      end
+
+      context 'when user is not authenticated' do
+        it { expect(response).to have_http_status(:unauthorized) }
+      end
     end
+  end
 
-    context 'when application is not authenticated' do
-      before { get :index }
+  describe 'GET #index' do
+      before do
+        auth_app applications(:test_app), @request
+        get :index
+      end
 
-      it { expect(response).to have_http_status(:unauthorized) }
-    end
+      it { expect(response.content_type).to eq('application/json') }
+      it { expect(response).to have_http_status(:ok) }
   end
 
 end
\ No newline at end of file
-- 
GitLab