From 52cd284b20c4e30db05c936c41c25b6189f8b318 Mon Sep 17 00:00:00 2001 From: jrgriffiniii <1443986+jrgriffiniii@users.noreply.github.com> Date: Fri, 24 May 2024 10:36:40 -0400 Subject: [PATCH] Removing the unnecessary WorksWizardController#rescue_aasm_error --- app/controllers/works_wizard_controller.rb | 13 --------- .../works_wizard_controller_spec.rb | 27 ++----------------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/app/controllers/works_wizard_controller.rb b/app/controllers/works_wizard_controller.rb index 8956cfd8..d1ef6ee7 100644 --- a/app/controllers/works_wizard_controller.rb +++ b/app/controllers/works_wizard_controller.rb @@ -167,19 +167,6 @@ def file_location_url end helper_method :file_location_url - def rescue_aasm_error - yield - rescue AASM::InvalidTransition => error - message = message_from_aasm_error(aasm_error: error, work: @work) - - Honeybadger.notify("Invalid #{@work.current_transition}: #{error.message} errors: #{message}") - transition_error_message = "We apologize, the following errors were encountered: #{message}." - @errors = [transition_error_message] - - # redirect_to root_url, notice: transition_error_message - redirect_aasm_error(transition_error_message) - end - private def edit_helper(view_name, redirect_url) diff --git a/spec/controllers/works_wizard_controller_spec.rb b/spec/controllers/works_wizard_controller_spec.rb index 29b92e26..8c63583e 100644 --- a/spec/controllers/works_wizard_controller_spec.rb +++ b/spec/controllers/works_wizard_controller_spec.rb @@ -354,7 +354,7 @@ expect(response.status).to be 302 expect(work.reload).to be_draft # rubocop:disable Layout/LineLength - expect(assigns[:errors]).to eq(["We apologize, the following errors were encountered: Must provide a description."]) + expect(assigns[:errors]).to eq(["We apologize, the following errors were encountered: Must provide a description. Please contact the PDC Describe administrators for any assistance."]) # rubocop:enable Layout/LineLength end end @@ -369,29 +369,6 @@ end end - context "a work with multiple README files" do - describe "#validate" do - before do - stub_s3(data: [ - FactoryBot.build(:s3_readme), - FactoryBot.build(:s3_readme) - ]) - sign_in(user) - end - - it "renders the error message" do - work.save - post :validate, params: { id: work.id } - expect(response).to redirect_to(edit_work_wizard_path(work)) - expect(response.status).to be 302 - expect(work.reload).to be_draft - # rubocop:disable Layout/LineLength - expect(assigns[:errors]).to eq(["We apologize, the following errors were encountered: You must provide only one README file upload."]) - # rubocop:enable Layout/LineLength - end - end - end - context "a work with one README but no uploaded files" do describe "#validate" do before do @@ -425,7 +402,7 @@ expect(response.status).to be 302 expect(work.reload).to be_draft # rubocop:disable Layout/LineLength - expect(assigns[:errors]).to eq(["We apologize, the following errors were encountered: You must include a README. Please upload one."]) + expect(assigns[:errors]).to eq(["We apologize, the following errors were encountered: You must include a README. Please upload one. Please contact the PDC Describe administrators for any assistance."]) # rubocop:enable Layout/LineLength end end