diff --git a/Gemfile b/Gemfile index 2dd779838..4295eb57e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'rails', '6.1.7.6' +gem 'rails', '7.0.8' # This needs to be in here for Heroku ruby '3.0.6' diff --git a/Gemfile.lock b/Gemfile.lock index 60ab5b6a7..0d334b672 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,71 +19,77 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) + actioncable (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.6) - actionpack (= 6.1.7.6) - activejob (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionmailbox (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) mail (>= 2.7.1) - actionmailer (6.1.7.6) - actionpack (= 6.1.7.6) - actionview (= 6.1.7.6) - activejob (= 6.1.7.6) - activesupport (= 6.1.7.6) + net-imap + net-pop + net-smtp + actionmailer (7.0.8) + actionpack (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activesupport (= 7.0.8) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7.6) - actionview (= 6.1.7.6) - activesupport (= 6.1.7.6) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.6) - actionpack (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + actiontext (7.0.8) + actionpack (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.6) - activesupport (= 6.1.7.6) + actionview (7.0.8) + activesupport (= 7.0.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.6) - activesupport (= 6.1.7.6) + activejob (7.0.8) + activesupport (= 7.0.8) globalid (>= 0.3.6) - activemodel (6.1.7.6) - activesupport (= 6.1.7.6) + activemodel (7.0.8) + activesupport (= 7.0.8) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (6.1.7.6) - activemodel (= 6.1.7.6) - activesupport (= 6.1.7.6) + activerecord (7.0.8) + activemodel (= 7.0.8) + activesupport (= 7.0.8) activerecord-safer_migrations (3.0.0) activerecord (>= 5.2) - activestorage (6.1.7.6) - actionpack (= 6.1.7.6) - activejob (= 6.1.7.6) - activerecord (= 6.1.7.6) - activesupport (= 6.1.7.6) + activestorage (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activesupport (= 7.0.8) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.6) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) @@ -322,21 +328,20 @@ GEM rack (~> 2.2, >= 2.2.4) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.6) - actioncable (= 6.1.7.6) - actionmailbox (= 6.1.7.6) - actionmailer (= 6.1.7.6) - actionpack (= 6.1.7.6) - actiontext (= 6.1.7.6) - actionview (= 6.1.7.6) - activejob (= 6.1.7.6) - activemodel (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + rails (7.0.8) + actioncable (= 7.0.8) + actionmailbox (= 7.0.8) + actionmailer (= 7.0.8) + actionpack (= 7.0.8) + actiontext (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activemodel (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) bundler (>= 1.15.0) - railties (= 6.1.7.6) - sprockets-rails (>= 2.0.0) + railties (= 7.0.8) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -348,12 +353,13 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.1.0) rb-fsevent (0.11.2) @@ -572,7 +578,7 @@ DEPENDENCIES pvb-instrumentation! rack (>= 2.1.4) rack-canonical-host - rails (= 6.1.7.6) + rails (= 7.0.8) rails-controller-testing rake request_store diff --git a/app/decorators/nomis/contact_decorator.rb b/app/decorators/nomis/contact_decorator.rb index 6ee405377..c29e0a653 100644 --- a/app/decorators/nomis/contact_decorator.rb +++ b/app/decorators/nomis/contact_decorator.rb @@ -4,7 +4,7 @@ class Nomis::ContactDecorator < Draper::Decorator def full_name_and_dob [ "#{given_name} #{surname}", - date_of_birth&.to_s(:short_nomis) + date_of_birth&.to_fs(:short_nomis) ].compact.join(' - ') end diff --git a/app/decorators/rejection_decorator.rb b/app/decorators/rejection_decorator.rb index c6da70c2e..514d3988b 100644 --- a/app/decorators/rejection_decorator.rb +++ b/app/decorators/rejection_decorator.rb @@ -50,7 +50,7 @@ def email_visitor_banned_explanation(visitor) if visitor.banned_until? h.t('visitor_banned_until_html', name: visitor.anonymized_name.titleize, - banned_until: visitor.banned_until.to_s(:short_nomis), + banned_until: visitor.banned_until.to_fs(:short_nomis), scope: %i[visitor_mailer rejected]) else h.t('visitor_banned_html', diff --git a/app/helpers/date_helper.rb b/app/helpers/date_helper.rb index 790b84072..047c18103 100644 --- a/app/helpers/date_helper.rb +++ b/app/helpers/date_helper.rb @@ -1,6 +1,6 @@ module DateHelper def format_date(datetime) - datetime.to_date.to_s(:short_abbrev) + datetime.to_date.to_fs(:short_abbrev) end def format_date_of_birth(datetime) @@ -45,7 +45,7 @@ def format_slot_for_public(slot) def format_slot_for_staff(slot) I18n.t( 'formats.slot.staff', - date: slot.begin_at.to_date.to_s(:full_nomis), + date: slot.begin_at.to_date.to_fs(:full_nomis), begin: format_time_24hr(slot.begin_at), end: format_time_24hr(slot.end_at) ) @@ -53,7 +53,7 @@ def format_slot_for_staff(slot) def format_visit_slot_date_for_staff(visit) slot = visit.slot_granted || visit.slots.first - slot.to_date.to_s(:short_nomis) + slot.to_date.to_fs(:short_nomis) end def format_visit_slot_times_for_staff(visit) diff --git a/app/services/estate_visit_query.rb b/app/services/estate_visit_query.rb index ddfd13cb6..94db7641b 100644 --- a/app/services/estate_visit_query.rb +++ b/app/services/estate_visit_query.rb @@ -8,7 +8,7 @@ def visits_to_print_by_slot(date) visits = Visit.includes(:prisoner, :visitors, :prison) .processed.from_estates(@estates) - .where('slot_granted LIKE ?', "#{date.to_s(:db)}%") + .where('slot_granted LIKE ?', "#{date.to_fs(:db)}%") .order('slot_granted asc').to_a grouped_visits(visits) diff --git a/app/services/nomis/oauth/client.rb b/app/services/nomis/oauth/client.rb index e5a2ffb07..8582ac56f 100644 --- a/app/services/nomis/oauth/client.rb +++ b/app/services/nomis/oauth/client.rb @@ -3,6 +3,11 @@ module Nomis module Oauth class Client + class_attribute :nomis_oauth_client_id, :nomis_oauth_client_secret + + self.nomis_oauth_client_id = Rails.configuration.nomis_oauth_client_id + self.nomis_oauth_client_secret = Rails.configuration.nomis_oauth_client_secret + def initialize(host) @host = host @connection = Faraday.new @@ -34,9 +39,7 @@ def authorisation end def credentials - Base64.strict_encode64( - "#{Rails.configuration.nomis_oauth_client_id}:#{Rails.configuration.nomis_oauth_client_secret}" - ) + Base64.strict_encode64("#{nomis_oauth_client_id}:#{nomis_oauth_client_secret}") end end end diff --git a/app/services/nomis/oauth/jwks_service.rb b/app/services/nomis/oauth/jwks_service.rb index 074844bdf..9f980a751 100644 --- a/app/services/nomis/oauth/jwks_service.rb +++ b/app/services/nomis/oauth/jwks_service.rb @@ -5,12 +5,14 @@ module Oauth class JwksService include Singleton - HOST = Rails.configuration.nomis_oauth_host + class_attribute :host + + self.host = Rails.configuration.nomis_oauth_host attr_reader :oauth_client def initialize(oauth_client: Nomis::Oauth::Client) - @oauth_client = oauth_client.new(HOST) + @oauth_client = oauth_client.new(host) end def fetch_keys diff --git a/app/services/nomis/oauth/token_service.rb b/app/services/nomis/oauth/token_service.rb index 6acf23322..3bfaf0cdb 100644 --- a/app/services/nomis/oauth/token_service.rb +++ b/app/services/nomis/oauth/token_service.rb @@ -5,6 +5,10 @@ module Oauth class TokenService include Singleton + class_attribute :host + + self.host = Rails.configuration.nomis_oauth_host + class << self delegate :valid_token, to: :instance end @@ -25,9 +29,7 @@ def token end def fetch_token - host = Rails.configuration.nomis_oauth_host oauth_client = Nomis::Oauth::Client.new(host) - route = '/auth/oauth/token?grant_type=client_credentials' response = oauth_client.post(route) Token.from_json(response) diff --git a/app/views/prison/dashboards/_cancellations.html.erb b/app/views/prison/dashboards/_cancellations.html.erb index ad650de79..049dce84e 100644 --- a/app/views/prison/dashboards/_cancellations.html.erb +++ b/app/views/prison/dashboards/_cancellations.html.erb @@ -20,10 +20,10 @@ <%= visit.prisoner_number %> <%= visit.prisoner_full_name %> - <%= visit.prisoner_date_of_birth.to_s(:short_nomis) %> + <%= visit.prisoner_date_of_birth.to_fs(:short_nomis) %> <%= format_visit_slot_date_for_staff(visit) %> <%= format_visit_slot_times_for_staff(visit) %> - <%= visit.cancellation.created_at.to_s(:short) %> + <%= visit.cancellation.created_at.to_fs(:short) %> <%= visit.prison_name %> <%= visit.reference_no %> diff --git a/app/views/prison/dashboards/_inbox_results.html.erb b/app/views/prison/dashboards/_inbox_results.html.erb index d5ca9cd23..f51d17566 100644 --- a/app/views/prison/dashboards/_inbox_results.html.erb +++ b/app/views/prison/dashboards/_inbox_results.html.erb @@ -1,10 +1,10 @@ <% @requested_visits.group_by {|v| v.created_at.to_date}.each do |date, booking| %>

<%= t('requested_on', scope: :shared) %> - <%= date.to_s(:short) %> + <%= date.to_fs(:short) %>

- + diff --git a/app/views/prison/dashboards/_inbox_search_results.html.erb b/app/views/prison/dashboards/_inbox_search_results.html.erb index cba09af3c..597a93275 100644 --- a/app/views/prison/dashboards/_inbox_search_results.html.erb +++ b/app/views/prison/dashboards/_inbox_search_results.html.erb @@ -14,9 +14,9 @@ <% visits.each do |visit| %> - + - + - + - + <% end %> diff --git a/app/views/prison/dashboards/_print_slot.html.erb b/app/views/prison/dashboards/_print_slot.html.erb index 8fd96e7dc..394f4a5f9 100644 --- a/app/views/prison/dashboards/_print_slot.html.erb +++ b/app/views/prison/dashboards/_print_slot.html.erb @@ -20,7 +20,7 @@ - + - + - +
<%= t('title', scope: [:prison, :dashboards, :inbox]).capitalize %> - <%= t('requested_on', scope: :shared).downcase %><%= date.to_s(:short) %><%= t('title', scope: [:prison, :dashboards, :inbox]).capitalize %> - <%= t('requested_on', scope: :shared).downcase %><%= date.to_fs(:short) %>
<%= t('prisoner_name', scope: :shared) %>
<%= visit.prisoner_full_name %><%= visit.slots.first.to_date.to_s(:short_nomis) %><%= visit.slots.first.to_date.to_fs(:short_nomis) %> <%= visit.principal_visitor.full_name %><%= visit.created_at.to_s(:short) %><%= visit.created_at.to_fs(:short) %> <%= visit.prison_name %> <%= link_to prison_visit_path(visit), title: t('view', scope: :shared) do %> diff --git a/app/views/prison/dashboards/_print_cancelled_slot.html.erb b/app/views/prison/dashboards/_print_cancelled_slot.html.erb index 0272e6ae4..be8642b9f 100644 --- a/app/views/prison/dashboards/_print_cancelled_slot.html.erb +++ b/app/views/prison/dashboards/_print_cancelled_slot.html.erb @@ -16,17 +16,17 @@
<%= visit.prisoner_full_name %> <%= visit.prisoner_number %><%= visit.principal_visitor.full_name %>
(<%= visit.principal_visitor.date_of_birth.to_s(:short_nomis) %>)
<%= visit.principal_visitor.full_name %>
(<%= visit.principal_visitor.date_of_birth.to_fs(:short_nomis) %>)
<%= visit.contact_phone_no %>
<% visit.visitors[1..-1].each do |visitor| %> - <%= visitor.full_name %> (<%= visitor.date_of_birth.to_s(:short_nomis) %>)
+ <%= visitor.full_name %> (<%= visitor.date_of_birth.to_fs(:short_nomis) %>)
<% end %>
<%= visit.prison_name %><%= visit.updated_at.to_s(:short) %><%= visit.updated_at.to_fs(:short) %>
<%= visit.prisoner_full_name %> <%= visit.prisoner_number %><%= visit.principal_visitor.full_name %>
(<%= visit.principal_visitor.date_of_birth.to_s(:short_nomis) %>)
<%= visit.principal_visitor.full_name %>
(<%= visit.principal_visitor.date_of_birth.to_fs(:short_nomis) %>)
<%= visit.contact_phone_no %>
diff --git a/app/views/prison/dashboards/_request_summary_row.html.erb b/app/views/prison/dashboards/_request_summary_row.html.erb index 7bdf64035..424c63ff7 100644 --- a/app/views/prison/dashboards/_request_summary_row.html.erb +++ b/app/views/prison/dashboards/_request_summary_row.html.erb @@ -1,8 +1,8 @@
<%= visit.prisoner_full_name %><%= visit.slots.first.to_date.to_s(:short_nomis) %><%= visit.slots.first.to_date.to_fs(:short_nomis) %> <%= visit.principal_visitor.full_name %><%= visit.created_at.to_s(:time) %><%= visit.created_at.to_fs(:time) %> <%= visit.prison_name %> <%= link_to prison_visit_path(visit), {:title => t('view', scope: :shared)} do %> diff --git a/app/views/prison/print_visits/show.html.erb b/app/views/prison/print_visits/show.html.erb index dc98309da..d704e076c 100644 --- a/app/views/prison/print_visits/show.html.erb +++ b/app/views/prison/print_visits/show.html.erb @@ -19,7 +19,7 @@ <% end -%> <% if !@submitted_date.nil? && !@data.any? %> -

<%= t('.no_visits', date: @submitted_date.to_s(:short_nomis)) %>

+

<%= t('.no_visits', date: @submitted_date.to_fs(:short_nomis)) %>

<% end -%> <% if @submitted_date.nil? %> diff --git a/app/views/prison/visits/_prisoner_details.html.erb b/app/views/prison/visits/_prisoner_details.html.erb index 906d32a17..df0da9c9a 100644 --- a/app/views/prison/visits/_prisoner_details.html.erb +++ b/app/views/prison/visits/_prisoner_details.html.erb @@ -32,7 +32,7 @@
<%= t('.prisoner_dob') %> -
<%= @visit.prisoner_date_of_birth.to_s(:short_nomis) %>
+
<%= @visit.prisoner_date_of_birth.to_fs(:short_nomis) %>
<% case @visit.prisoner_existance_status %> <% when PrisonerDetailsPresenter::VALID, PrisonerLocationValidation::INVALID %>
<%= t('.verified') %>
diff --git a/app/views/prison/visits/_processed.html.erb b/app/views/prison/visits/_processed.html.erb index 041d0fd68..6351995b4 100644 --- a/app/views/prison/visits/_processed.html.erb +++ b/app/views/prison/visits/_processed.html.erb @@ -6,10 +6,10 @@
-
<%= t('requested', scope: 'shared') %>:
<%= @visit.created_at.to_date.to_s(:short_nomis) %> - <%= @visit.created_at.to_s(:time) %>
+
<%= t('requested', scope: 'shared') %>:
<%= @visit.created_at.to_date.to_fs(:short_nomis) %> - <%= @visit.created_at.to_fs(:time) %>
-
<%= @visit.processing_state.capitalize %>:
<%= @visit.processed_at.to_date.to_s(:short_nomis) %> - <%= @visit.processed_at.to_s(:time) %>
+
<%= @visit.processing_state.capitalize %>:
<%= @visit.processed_at.to_date.to_fs(:short_nomis) %> - <%= @visit.processed_at.to_fs(:time) %>
ID: <%= @visit.human_id %>
diff --git a/app/views/prison/visits/_processed_prisoner_details.html.erb b/app/views/prison/visits/_processed_prisoner_details.html.erb index 4e342df7a..3254723e0 100644 --- a/app/views/prison/visits/_processed_prisoner_details.html.erb +++ b/app/views/prison/visits/_processed_prisoner_details.html.erb @@ -9,7 +9,7 @@
<%= t('prisoner_dob', scope: %i[prison visits prisoner_details]) %> -
<%= @visit.prisoner_date_of_birth.to_s(:short_nomis) %>
+
<%= @visit.prisoner_date_of_birth.to_fs(:short_nomis) %>
diff --git a/app/views/prison/visits/_requested.html.erb b/app/views/prison/visits/_requested.html.erb index 8889ac68f..368917042 100644 --- a/app/views/prison/visits/_requested.html.erb +++ b/app/views/prison/visits/_requested.html.erb @@ -23,7 +23,7 @@
-
<%= t('requested', scope: 'shared') %>:
<%= @visit.created_at.to_date.to_s(:short_nomis) %> - <%= @visit.created_at.to_s(:time) %>
+
<%= t('requested', scope: 'shared') %>:
<%= @visit.created_at.to_date.to_fs(:short_nomis) %> - <%= @visit.created_at.to_fs(:time) %>
diff --git a/app/views/prison/visits/_timeline.html.erb b/app/views/prison/visits/_timeline.html.erb index 1ce165dc4..2bf6032cb 100644 --- a/app/views/prison/visits/_timeline.html.erb +++ b/app/views/prison/visits/_timeline.html.erb @@ -2,7 +2,7 @@
    <% VisitTimeline.new(@visit).events.each do |event| %> <%= content_tag :li, class: timeline_event_html_class(event) do -%> -
    <%= event.created_at.to_s(:timeline_date) %><%= event.created_at.to_s(:timeline_time) %>
    +
    <%= event.created_at.to_fs(:timeline_date) %><%= event.created_at.to_fs(:timeline_time) %>
    <%= t(".#{event.state}") %><%= t('.by', name: event.user_name || t('.anonymous')) %>
    <% end -%> <% end -%> diff --git a/app/views/prison/visits/_visitor_contact.html.erb b/app/views/prison/visits/_visitor_contact.html.erb index d086a4532..1e9ccc932 100644 --- a/app/views/prison/visits/_visitor_contact.html.erb +++ b/app/views/prison/visits/_visitor_contact.html.erb @@ -11,7 +11,7 @@
    <%= vf.hidden_field :id %> - <%= v.full_name %> - <%= v.date_of_birth.to_s(:short_nomis) %> + <%= v.full_name %> - <%= v.date_of_birth.to_fs(:short_nomis) %> (<%= v.age %>)
    <% if @visit.principal_visitor == v %> diff --git a/app/views/prison/visits/_visitor_detail.html.erb b/app/views/prison/visits/_visitor_detail.html.erb index 1e97ec10d..a58b56e3d 100644 --- a/app/views/prison/visits/_visitor_detail.html.erb +++ b/app/views/prison/visits/_visitor_detail.html.erb @@ -11,7 +11,7 @@ <%= t('.rejected_banned') %> <% if @visit.principal_visitor.banned_until? %> - <%= t('.until') %> <%= @visit.principal_visitor.banned_until.to_date.to_s(:short_nomis) %> + <%= t('.until') %> <%= @visit.principal_visitor.banned_until.to_date.to_fs(:short_nomis) %> <% end %> <% elsif @visit.principal_visitor.not_on_list %> @@ -39,7 +39,7 @@
    <%= t('.dob') %>
    -
    <%= @visit.principal_visitor.date_of_birth.to_s(:short_nomis) %> (<%= @visit.principal_visitor.age %>)
    +
    <%= @visit.principal_visitor.date_of_birth.to_fs(:short_nomis) %> (<%= @visit.principal_visitor.age %>)
    diff --git a/app/views/visitor_mailer/booked.html.erb b/app/views/visitor_mailer/booked.html.erb index f434c6836..30671eaa1 100644 --- a/app/views/visitor_mailer/booked.html.erb +++ b/app/views/visitor_mailer/booked.html.erb @@ -41,7 +41,7 @@ <% @visit.banned_visitors.each do |v| %>

    <% if v.banned_until? %> - <%= t('.visitor_banned_until_html', name: v.anonymized_name, banned_until: v.banned_until.to_s(:short_nomis)) %> + <%= t('.visitor_banned_until_html', name: v.anonymized_name, banned_until: v.banned_until.to_fs(:short_nomis)) %> <% else %> <%= t('.visitor_banned_html', name: v.anonymized_name) %> <% end %> diff --git a/bin/rake b/bin/rake index 7327f471e..4fbf10b96 100755 --- a/bin/rake +++ b/bin/rake @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -load File.expand_path("spring", __dir__) require_relative "../config/boot" require "rake" Rake.application.run diff --git a/bin/setup b/bin/setup index 90700ac4f..8f0cfddbc 100755 --- a/bin/setup +++ b/bin/setup @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -require "fileutils" +require 'fileutils' # path to your application root. APP_ROOT = File.expand_path('..', __dir__) @@ -20,17 +20,17 @@ FileUtils.chdir APP_ROOT do # Install JavaScript dependencies system! 'bin/yarn' - # puts "\n== Copying sample files ==" + # puts '\n== Copying sample files ==' # unless File.exist?('config/database.yml') # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' # end - puts "\n== Preparing database ==" + puts '\n== Preparing database ==' system! 'bin/rails db:prepare' - puts "\n== Removing old logs and tempfiles ==" + puts '\n== Removing old logs and tempfiles ==' system! 'bin/rails log:clear tmp:clear' - puts "\n== Restarting application server ==" + puts '\n== Restarting application server ==' system! 'bin/rails restart' end diff --git a/config/application.rb b/config/application.rb index 0cfd67375..5e81d06ef 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,6 +15,7 @@ require 'sprockets/railtie' require 'rails/test_unit/railtie' require_relative '../app/middleware/http_method_not_allowed' +require_relative '../app/middleware/robots_tag' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -24,6 +25,7 @@ module PrisonVisits class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 6.1 + config.autoload_paths += %w[app/metrics/support] config.eager_load_paths += %w[app/metrics/support] @@ -53,6 +55,7 @@ class Application < Rails::Application config.sentry_dsn = ENV['SENTRY_DSN'] config.sentry_js_dsn = ENV['SENTRY_JS_DSN'] + config.middleware.use RobotsTag config.middleware.insert_before Rack::Head, HttpMethodNotAllowed config.sendgrid_api_user = ENV['SMTP_USERNAME'] diff --git a/config/boot.rb b/config/boot.rb index b9e460cef..30f5120df 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,3 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. -require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb new file mode 100644 index 000000000..b2fc1683c --- /dev/null +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -0,0 +1,141 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.0 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `7.0`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +# `button_to` view helper will render `