diff --git a/spec/controllers/api/v1/advisories_controller_spec.rb b/spec/controllers/api/v1/advisories_controller_spec.rb index 65ee9dec6..39185bf4a 100644 --- a/spec/controllers/api/v1/advisories_controller_spec.rb +++ b/spec/controllers/api/v1/advisories_controller_spec.rb @@ -14,32 +14,32 @@ end shared_examples_for 'api advisories user with admin rights' do context 'api advisories user with create rights' do - let(:params) { {build_list_id: @build_list.id, advisory: {description: 'test'}} } + let(:params) {{ build_list_id: @build_list.id, advisory: { description: 'test' }, format: :json }} it 'should be able to perform create action' do - post :create, params, format: :json + post :create, params response.should be_success end it 'ensures that advisory has been created' do - lambda { post :create, params, format: :json }.should change{ Advisory.count }.by(1) + lambda { post :create, params }.should change{ Advisory.count }.by(1) end it 'ensures that build_list has been associated with advisory' do - post :create, params, format: :json + post :create, params @build_list.reload @build_list.advisory.should_not be_nil end end context 'api advisories user with update rights' do - let(:params) { {id: @advisory.advisory_id, build_list_id: @build_list.id} } + let(:params) {{ id: @advisory.advisory_id, build_list_id: @build_list.id, format: :json }} it 'should be able to perform update action' do - put :update, params, format: :json + put :update, params response.should be_success end it 'ensures that advisory has not been created' do - lambda { put :update, params, format: :json }.should_not change{ Advisory.count } + lambda { put :update, params }.should_not change{ Advisory.count } end it 'ensures that build_list has been associated with advisory' do - put :update, params, format: :json + put :update, params @build_list.reload @build_list.advisory.should_not be_nil end @@ -48,32 +48,32 @@ end shared_examples_for 'api advisories user without admin rights' do context 'api advisories user without create rights' do - let(:params) { {build_list_id: @build_list.id, advisory: {description: 'test'}} } + let(:params) {{ build_list_id: @build_list.id, advisory: { description: 'test' }, format: :json }} it 'should not be able to perform create action' do - post :create, params, format: :json + post :create, params response.should_not be_success end it 'ensures that advisory has not been created' do - lambda { post :create, params, format: :json }.should_not change{ Advisory.count } + lambda { post :create, params }.should_not change{ Advisory.count } end it 'ensures that build_list has not been associated with advisory' do - post :create, params, format: :json + post :create, params @build_list.reload @build_list.advisory.should be_nil end end context 'api advisories user without update rights' do - let(:params) { {id: @advisory.advisory_id, build_list_id: @build_list.id} } + let(:params) {{ id: @advisory.advisory_id, build_list_id: @build_list.id, format: :json }} it 'should not be able to perform update action' do - put :update, params, format: :json + put :update, params response.should_not be_success end it 'ensures that advisory has not been created' do - lambda { put :update, params, format: :json }.should_not change{ Advisory.count } + lambda { put :update, params }.should_not change{ Advisory.count } end it 'ensures that build_list has not been associated with advisory' do - put :update, params, format: :json + put :update, params @build_list.reload @build_list.advisory.should be_nil end