diff --git a/spec/controllers/v1/collections_controller_spec.rb b/spec/controllers/v1/collections_controller_spec.rb index dd2943c4db1bb886b396041a270f294b5e53599e..fc1eeaedc20f4ca214620bf4bd7a176c7a624a2f 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