From 809bae88883a7dcac9cc1303810929e611efa3dc Mon Sep 17 00:00:00 2001 From: Mauricio Giacomini Girardello <mgg12@inf.ufpr.br> Date: Wed, 8 Jun 2016 11:44:13 -0300 Subject: [PATCH] adding collection controller specs --- .../v1/collections_controller_spec.rb | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/spec/controllers/v1/collections_controller_spec.rb b/spec/controllers/v1/collections_controller_spec.rb index dd2943c4d..fc1eeaedc 100644 --- a/spec/controllers/v1/collections_controller_spec.rb +++ b/spec/controllers/v1/collections_controller_spec.rb @@ -3,17 +3,26 @@ require 'rails_helper' RSpec.describe V1::CollectionsController, type: :controller do fixtures :applications + 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 - it 'will return an array of collections' do - auth_app applications(:test_app), @request - get :index - expect(response).to have_http_status(:ok) - expect(response.content_type).to eq "application/json" + + context 'when application is authenticated' do + before do + auth_app applications(:test_app), @request + get :index + end + + it { expect(response.content_type).to eq('application/json') } + it { expect(response).to have_http_status(:ok) } end - it 'will return not authorized when app is not authenticated' do - get :index - expect(response).to have_http_status(:unauthorized) + context 'when application is not authenticated' do + before { get :index } + + it { expect(response).to have_http_status(:unauthorized) } end end -- GitLab