Skip to content

Commit

Permalink
Neighborhood: Handle RecordNotFound exceptions (#1756)
Browse files Browse the repository at this point in the history
* 🐞 `Neighborhood`: Handle ActiveRecord::RecordNotFound

- #1754

It appears we do not ... do the baseline NotFound handling... Oops.

* Fix failing tests
  • Loading branch information
zspencer authored Aug 14, 2023
1 parent 381bd44 commit 69d278a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions spec/furniture/marketplace/orders_controller_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion spec/requests/memberships_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 69d278a

Please sign in to comment.