From 97e0e49c57eab2889b22accc60eb87be30db54c6 Mon Sep 17 00:00:00 2001 From: briri Date: Mon, 27 Sep 2021 08:26:29 -0700 Subject: [PATCH 1/2] added handler for Pundit errors on ApplicationController --- app/controllers/application_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7928da23ad..53dad81fb4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -24,6 +24,8 @@ class ApplicationController < ActionController::Base rescue_from StandardError, with: :handle_server_error + rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized + private def current_org From 0e582c017c9f368ebc906a45c398da46c5d7b032 Mon Sep 17 00:00:00 2001 From: briri Date: Wed, 29 Sep 2021 09:18:44 -0700 Subject: [PATCH 2/2] fixed tests broken by change to redirect when pundit errors --- spec/controllers/super_admin/orgs_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/super_admin/orgs_controller_spec.rb b/spec/controllers/super_admin/orgs_controller_spec.rb index 4d0af37315..764655da06 100644 --- a/spec/controllers/super_admin/orgs_controller_spec.rb +++ b/spec/controllers/super_admin/orgs_controller_spec.rb @@ -42,7 +42,7 @@ sign_in(create(:user)) post :merge_analyze, params: @params expect(response.code).to eql("302") - expect(response).to redirect_to(root_path) + expect(response).to redirect_to(plans_path) expect(flash[:alert].present?).to eql(true) end it "succeeds in analyzing the Orgs" do @@ -64,7 +64,7 @@ sign_in(create(:user)) post :merge_commit, params: @params expect(response.code).to eql("302") - expect(response).to redirect_to(root_path) + expect(response).to redirect_to(plans_path) expect(flash[:alert].present?).to eql(true) end it "fails if :target_org is not found" do