From db1c680ede509f83431048497422ed91ec38c240 Mon Sep 17 00:00:00 2001 From: Oluwatoyosi Oyegoke <34948675+Tooyosi@users.noreply.github.com> Date: Wed, 31 Jan 2024 15:51:13 +0000 Subject: [PATCH] 3298 edit project display name on delete activated state = inactive (#4279) * implement logic to append deleted to inactive project slug * fix test * modifications to code style * modifications to code style --------- Co-authored-by: Zach Wolfenbarger --- app/controllers/api/v1/projects_controller.rb | 7 +++++++ spec/controllers/api/v1/projects_controller_spec.rb | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/app/controllers/api/v1/projects_controller.rb b/app/controllers/api/v1/projects_controller.rb index c28b62435..c1a8b1ccf 100644 --- a/app/controllers/api/v1/projects_controller.rb +++ b/app/controllers/api/v1/projects_controller.rb @@ -63,6 +63,13 @@ def update end end + def destroy + super do |resource| + split_display_name = resource.display_name.split('_') + resource.update(display_name: "#{resource.display_name}_deleted") unless split_display_name[split_display_name.length - 1] == 'deleted' + end + end + def create_classifications_export medium = CreateClassificationsExport.with( api_user: api_user, object: controlled_resource ).run!(params) export_medium_response(medium) diff --git a/spec/controllers/api/v1/projects_controller_spec.rb b/spec/controllers/api/v1/projects_controller_spec.rb index 96f6540e8..0a4dd74cd 100644 --- a/spec/controllers/api/v1/projects_controller_spec.rb +++ b/spec/controllers/api/v1/projects_controller_spec.rb @@ -846,6 +846,12 @@ def tag_request let(:instances_to_disable) { [resource] } it_behaves_like 'is deactivatable' + it "appends 'deleted' to display_name" do + stub_token(scopes: scopes, user_id: authorized_user.id) + set_preconditions + delete :destroy, params: { id: resource.id } + expect(resource.reload.display_name).to end_with('deleted') + end end describe '#copy' do