From 25a21b17ec67748e3eb8e11ca75afbc51375e6bd Mon Sep 17 00:00:00 2001 From: Thomas Scherz Date: Wed, 10 Jul 2024 09:10:29 -0400 Subject: [PATCH] Adds test for deleting software record with change management. --- .../software_records_controller_spec.rb | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec/controllers/software_records_controller_spec.rb b/spec/controllers/software_records_controller_spec.rb index 40e4417..8d6cf20 100644 --- a/spec/controllers/software_records_controller_spec.rb +++ b/spec/controllers/software_records_controller_spec.rb @@ -54,6 +54,18 @@ ) end + let(:change_attributes) do + { + change_title: 'A Good Software', + change_description: 'A Good description about the software', + software_record_id: 1, + application_pages: 10, + number_roles: 3, + authentication_needed: true, + custom_error_pages: true + } + end + let(:valid_attributes) do { title: 'A Good Software', @@ -505,11 +517,22 @@ def sign_in_user(admin) describe 'DELETE #destroy' do it 'destroys the requested software_record' do software_record = SoftwareRecord.create! valid_attributes + ChangeRequest.create! change_attributes + expect do delete :destroy, params: { id: software_record.to_param }, session: valid_session end.to change(SoftwareRecord, :count).by(-1) end + it 'also destroys the change request associated with the software_record' do + software_record = SoftwareRecord.create! valid_attributes + ChangeRequest.create! change_attributes + expect do + delete :destroy, params: { id: software_record.to_param }, session: valid_session + end.to change(ChangeRequest, :count).by(-1) + expect(response).to redirect_to(session[:previous]) + end + it 'redirects to the software_records list' do session[:previous] = software_records_url software_record = SoftwareRecord.create! valid_attributes