Skip to content

Commit

Permalink
refactor(questionnaire): No longer deletes user with questionnaire (#287
Browse files Browse the repository at this point in the history
)

* refactor(questionnaire): No longer deletes user with questionnaire

* Hound whitespace
  • Loading branch information
cbaudouinjr authored Sep 1, 2020
1 parent 5e96a9c commit ac720d9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
2 changes: 0 additions & 2 deletions app/controllers/manage/questionnaires_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/views/manage/questionnaires/edit.html.haml
Original file line number Diff line number Diff line change
@@ -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'
4 changes: 1 addition & 3 deletions test/controllers/manage/questionnaires_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ac720d9

Please sign in to comment.