From 69d278af2b113f322f46f2d2349662822f0c32d2 Mon Sep 17 00:00:00 2001 From: Zee <50284+zspencer@users.noreply.github.com> Date: Mon, 14 Aug 2023 11:15:08 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20`Neighborhood`:=20Handle=20`RecordN?= =?UTF-8?q?otFound`=20exceptions=20(#1756)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐞 `Neighborhood`: Handle ActiveRecord::RecordNotFound - https://github.com/zinc-collective/convene/issues/1754 It appears we do not ... do the baseline NotFound handling... Oops. * Fix failing tests --- app/controllers/application_controller.rb | 2 ++ spec/furniture/marketplace/orders_controller_request_spec.rb | 3 +-- spec/requests/memberships_request_spec.rb | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fbdc06365..6f45284fc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,6 +6,8 @@ class ApplicationController < ActionController::Base before_action :enforce_ssl before_action :ensure_on_byo_domain + rescue_from ActiveRecord::RecordNotFound, with: :render_not_found + include Pundit::Authorization after_action :verify_authorized, except: [:index] # rubocop:disable Rails/LexicallyScopedActionFilter after_action :verify_policy_scoped diff --git a/spec/furniture/marketplace/orders_controller_request_spec.rb b/spec/furniture/marketplace/orders_controller_request_spec.rb index 7f075122f..386d56d40 100644 --- a/spec/furniture/marketplace/orders_controller_request_spec.rb +++ b/spec/furniture/marketplace/orders_controller_request_spec.rb @@ -48,8 +48,7 @@ end context "when the order is not viewable by the current person" do - specify { expect { perform_request }.to raise_error(ActiveRecord::RecordNotFound) } - # it { is_expected.to be_not_found} + it { is_expected.to be_not_found } end end end diff --git a/spec/requests/memberships_request_spec.rb b/spec/requests/memberships_request_spec.rb index 41b65032a..eaad95bd7 100644 --- a/spec/requests/memberships_request_spec.rb +++ b/spec/requests/memberships_request_spec.rb @@ -86,7 +86,9 @@ let(:membership) { create(:membership) } it "does not delete the membership" do - expect { perform_request }.to raise_error(ActiveRecord::RecordNotFound) + perform_request + + expect(response).to be_not_found expect(membership.reload).to be_present expect(membership.reload).not_to be_revoked end