Skip to content

Commit

Permalink
Adds test for deleting software record with change management.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Scherz committed Jul 12, 2024
1 parent 067ee7d commit 25a21b1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/controllers/software_records_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 25a21b1

Please sign in to comment.