From ac720d9b2d24c531bade92b0cb91e0182cdd44ab Mon Sep 17 00:00:00 2001 From: "Chris Baudouin, Jr" Date: Tue, 1 Sep 2020 01:26:46 -0400 Subject: [PATCH] refactor(questionnaire): No longer deletes user with questionnaire (#287) * refactor(questionnaire): No longer deletes user with questionnaire * Hound whitespace --- app/controllers/manage/questionnaires_controller.rb | 2 -- app/views/manage/questionnaires/edit.html.haml | 2 +- test/controllers/manage/questionnaires_controller_test.rb | 4 +--- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/manage/questionnaires_controller.rb b/app/controllers/manage/questionnaires_controller.rb index 1db4fffce..ca14c9d85 100644 --- a/app/controllers/manage/questionnaires_controller.rb +++ b/app/controllers/manage/questionnaires_controller.rb @@ -103,9 +103,7 @@ def convert_to_admin end def destroy - user = @questionnaire.user @questionnaire.destroy - user.destroy if user.present? respond_with(:manage, @questionnaire) end diff --git a/app/views/manage/questionnaires/edit.html.haml b/app/views/manage/questionnaires/edit.html.haml index fb3f0973e..9b2faa621 100644 --- a/app/views/manage/questionnaires/edit.html.haml +++ b/app/views/manage/questionnaires/edit.html.haml @@ -1,6 +1,6 @@ = render "layouts/manage/page_title", title: "Edit Questionnaire", subtitle: @questionnaire.user.full_name do .btn-group = link_to 'Cancel', manage_questionnaire_path(@questionnaire), class: 'btn btn-sm btn-outline-secondary' - = link_to 'Delete', manage_questionnaire_path(@questionnaire), method: :delete, data: { confirm: "Are you sure? The questionnaire and account for \"#{@questionnaire.user.full_name}\" will be permanently erased. This action is irreversible." }, class: 'btn btn-sm btn-outline-secondary' + = link_to 'Delete', manage_questionnaire_path(@questionnaire), method: :delete, data: { confirm: "Are you sure? The questionnaire will be permanently deleted. This action is irreversible." }, class: 'btn btn-sm btn-outline-secondary' = render 'form' diff --git a/test/controllers/manage/questionnaires_controller_test.rb b/test/controllers/manage/questionnaires_controller_test.rb index 664b52f81..969937faa 100644 --- a/test/controllers/manage/questionnaires_controller_test.rb +++ b/test/controllers/manage/questionnaires_controller_test.rb @@ -308,9 +308,7 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase should "destroy questionnaire" do assert_difference("Questionnaire.count", -1) do - assert_difference("User.count", -1) do - delete :destroy, params: { id: @questionnaire } - end + delete :destroy, params: { id: @questionnaire } end assert_redirected_to manage_questionnaires_path end