File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed
Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ jobs:
121121 - run :
122122 name : " Bundle"
123123 command : |
124- gem install bundler
124+ gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
125125 bundle check --path vendor/bundle || bundle install --deployment
126126 - run :
127127 name : " Yarn"
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33class ResourcesController < ApplicationController
4+ rescue_from ActiveRecord ::RecordNotFound , with : :resource_not_found
5+
46 def show
57 @resource = ResourceDecorator . decorate ( find_resource ( params [ :id ] ) )
68 authorize @resource
@@ -49,4 +51,13 @@ def alternate_format_request_params
4951 :title
5052 )
5153 end
54+
55+ def resource_not_found ( exception )
56+ if request . get? && request . path . match? ( %r{^/resources/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$} )
57+ Bugsnag . notify ( exception , &:ignore! )
58+ head :not_found
59+ else
60+ raise exception
61+ end
62+ end
5263end
Original file line number Diff line number Diff line change 7777
7878 context 'when requesting an unknown uuid' do
7979 it do
80+ allow ( Bugsnag ) . to receive ( :notify )
8081 expect {
8182 get :show , params : { id : 'not-a-valid-uuid' }
8283 } . to raise_error ( ActiveRecord ::RecordNotFound )
8384 end
8485 end
8586
87+ context 'when requesting an unknown uuid that follows uuid pattern' do
88+ it do
89+ allow ( Bugsnag ) . to receive ( :notify )
90+ expect {
91+ get :show , params : { id : '123e4567-e89b-12d3-a456-426614174000' }
92+ } . not_to raise_error ( ActiveRecord ::RecordNotFound )
93+ expect ( Bugsnag ) . to have_received ( :notify ) . with ( ActiveRecord ::RecordNotFound , &:ignore! )
94+ expect ( response ) . to have_http_status :not_found
95+ end
96+ end
97+
8698 context 'when the resource is valid with no access' do
8799 let ( :work ) { create ( :work , :with_no_access ) }
88100
You can’t perform that action at this time.
0 commit comments