Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combined fixes 280624 #1338

Merged
merged 7 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class ApplicationController < ActionController::Base

helper LinksHelper

def not_found
render status: :not_found, plain: 'Not found'
end

private

def http_referrer
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/visits_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class VisitsController < ApplicationController
def show
@visit = PrisonVisits::Api.instance.get_visit(params[:id])
raise PrisonVisits::APINotFound unless @visit

@request_completed = !request.referer.nil?
render @visit.processing_state.to_s
rescue PrisonVisits::APINotFound
Expand Down
5 changes: 4 additions & 1 deletion app/services/prison_visits/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ def get_visit(id)
response = pool.with { |client| client.get("visits/#{id}") }
Visit.new(response.fetch('visit'))
else
visit_decorator(Staff::Visit.where(human_id: id).first)
visit = Staff::Visit.where(human_id: id).first
if visit
visit_decorator(Staff::Visit.where(human_id: id).first)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/vsip/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Vsip

# This client is **NOT** thread safe. To be used with a connection pool. See below.
class Client
TIMEOUT = 5 # seconds
TIMEOUT = 10 # seconds
EXCON_INSTRUMENT_NAME = 'vsip_api'.freeze
JSON_MIME_TYPE = 'application/json'.freeze

Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@
post '/validations/visitors', to: 'validations#visitors'
end
end

match '*path', to: 'application#not_found', via: :all
end
8 changes: 8 additions & 0 deletions spec/features/not_found_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'rails_helper'

RSpec.feature 'not_found', js: true do
scenario 'catch all pages' do
visit '/unknown'
expect(page).to have_text('Not found')
end
end