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

Bump rails 6.0 to to 6.1 #3753

Merged
merged 23 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e25a7c5
Bump rails 6.0 to to 6.1
jsugarman Feb 12, 2021
de1df4f
Fixes after upgrading to Rails 6.1
jrmhaig Feb 15, 2021
711fe80
Allow errors to be ordered differently
jrmhaig Feb 15, 2021
7a08eed
Run `rails app:update`
jrmhaig Mar 5, 2021
584dd55
Do not specify PIDFILE
jrmhaig Mar 5, 2021
480b1fa
Fix for some Rails 6.1 deprecations
jrmhaig Mar 5, 2021
b7b37a5
Small Rubocop fix
jrmhaig Mar 5, 2021
aef0ed8
Refactor to fix Metrics/AbcSize Rubocop offense
jrmhaig Mar 8, 2021
2ab24ac
Small Rubocop fix
jrmhaig Mar 8, 2021
bbd6c6f
Fix test to accommodate ordering of errors
jrmhaig Mar 9, 2021
0df17e3
downgrade mini_mime and bump other
jsugarman Jun 9, 2021
4979351
Remove failing test
jsugarman Jun 10, 2021
8ac3510
Change Rails.root to config.root
jsugarman Jun 10, 2021
7da5b9e
Fix fee presenter spec
jsugarman Jun 11, 2021
2324310
schema changes from running migrations
jsugarman Jun 11, 2021
4c7fa22
Fix Enumerating ActiveModel::Errors deprecation warning
jsugarman Jun 12, 2021
d2bf32d
Fix calling `clear` to an ActiveModel::Errors deprecation
jsugarman Jun 12, 2021
7da4d0a
Prevent run rather than skip inapplicable examples
jsugarman Jun 12, 2021
1d0cd00
Fix ActiveModel::Errors#keys deprecation
jsugarman Jun 12, 2021
17eb18b
Fix deprecated call of `<<` on an ActiveModel::Errors array
jsugarman Jun 13, 2021
c6dea3e
Bump gov_uk_date_fields 3.1.0 --> 3.2+
jsugarman Jun 16, 2021
500959f
Fix a regression relating to error summaries
jsugarman Jun 18, 2021
bfbde94
Refactor error presenter
jsugarman Jun 18, 2021
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
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ Rails/EnvironmentVariableAccess: # (new in 2.10)
Rails/TimeZoneAssignment: # (new in 2.10)
Enabled: true

RSpec/ImplicitSubject:
EnforcedStyle: single_statement_only

RSpec/NestedGroups:
Max: 4

Expand Down
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ gem 'devise', '~> 4.8.0'
gem 'dotenv-rails'
gem 'factory_bot_rails', '~> 6.2.0'
gem 'faker', '~> 2.18.0'
gem 'gov_uk_date_fields', '~> 3.1'
gem 'gov_uk_date_fields', '~> 3.2'
gem 'govuk_design_system_formbuilder', '~> 2.6.0b1'
gem 'govuk_frontend_toolkit', '~> 8.2.0'
gem 'govuk_elements_rails', '~> 3.1.2'
Expand All @@ -37,7 +37,7 @@ gem 'logstasher', '2.1.5'
gem 'logstuff', '0.0.2'
gem 'paper_trail', '~> 12.0.0'
gem 'pg', '~> 1.2.3'
gem 'rails', '~> 6.0.3.7'
gem 'rails', '~> 6.1.3'
gem 'redis', '~> 4.2.5'
gem 'rubyzip'
gem 'config', '~> 3.1' # this gem provides our Settings.xxx mechanism
Expand Down Expand Up @@ -77,7 +77,6 @@ group :development, :devunicorn, :test do
gem 'binding_of_caller'
gem 'byebug'
gem 'guard-cucumber'
gem 'guard-jasmine', '~> 3.1'
gem 'guard-livereload', '>= 2.5.2'
gem 'guard-rspec'
gem 'guard-rubocop'
Expand Down
145 changes: 70 additions & 75 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,40 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.3.7)
actionpack (= 6.0.3.7)
actioncable (6.1.3.2)
actionpack (= 6.1.3.2)
activesupport (= 6.1.3.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.7)
actionpack (= 6.0.3.7)
activejob (= 6.0.3.7)
activerecord (= 6.0.3.7)
activestorage (= 6.0.3.7)
activesupport (= 6.0.3.7)
actionmailbox (6.1.3.2)
actionpack (= 6.1.3.2)
activejob (= 6.1.3.2)
activerecord (= 6.1.3.2)
activestorage (= 6.1.3.2)
activesupport (= 6.1.3.2)
mail (>= 2.7.1)
actionmailer (6.0.3.7)
actionpack (= 6.0.3.7)
actionview (= 6.0.3.7)
activejob (= 6.0.3.7)
actionmailer (6.1.3.2)
actionpack (= 6.1.3.2)
actionview (= 6.1.3.2)
activejob (= 6.1.3.2)
activesupport (= 6.1.3.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3.7)
actionview (= 6.0.3.7)
activesupport (= 6.0.3.7)
rack (~> 2.0, >= 2.0.8)
actionpack (6.1.3.2)
actionview (= 6.1.3.2)
activesupport (= 6.1.3.2)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.7)
actionpack (= 6.0.3.7)
activerecord (= 6.0.3.7)
activestorage (= 6.0.3.7)
activesupport (= 6.0.3.7)
actiontext (6.1.3.2)
actionpack (= 6.1.3.2)
activerecord (= 6.1.3.2)
activestorage (= 6.1.3.2)
activesupport (= 6.1.3.2)
nokogiri (>= 1.8.5)
actionview (6.0.3.7)
activesupport (= 6.0.3.7)
actionview (6.1.3.2)
activesupport (= 6.1.3.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand All @@ -55,25 +57,27 @@ GEM
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
active_storage_validations (0.9.3)
rails (>= 5.2.0)
activejob (6.0.3.7)
activesupport (= 6.0.3.7)
activejob (6.1.3.2)
activesupport (= 6.1.3.2)
globalid (>= 0.3.6)
activemodel (6.0.3.7)
activesupport (= 6.0.3.7)
activerecord (6.0.3.7)
activemodel (= 6.0.3.7)
activesupport (= 6.0.3.7)
activestorage (6.0.3.7)
actionpack (= 6.0.3.7)
activejob (= 6.0.3.7)
activerecord (= 6.0.3.7)
activemodel (6.1.3.2)
activesupport (= 6.1.3.2)
activerecord (6.1.3.2)
activemodel (= 6.1.3.2)
activesupport (= 6.1.3.2)
activestorage (6.1.3.2)
actionpack (= 6.1.3.2)
activejob (= 6.1.3.2)
activerecord (= 6.1.3.2)
activesupport (= 6.1.3.2)
marcel (~> 1.0.0)
activesupport (6.0.3.7)
mini_mime (~> 1.0.2)
activesupport (6.1.3.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
amoeba (3.1.0)
Expand Down Expand Up @@ -292,8 +296,8 @@ GEM
ffi (~> 1.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
gov_uk_date_fields (3.1.0)
rails (>= 5.0)
gov_uk_date_fields (3.2.0)
rails (>= 5.2)
govuk_design_system_formbuilder (2.6.0b1)
actionview (>= 6.0)
activemodel (>= 6.0)
Expand Down Expand Up @@ -339,14 +343,6 @@ GEM
guard-cucumber (3.0.0)
cucumber (>= 3.1)
nenv (>= 0.1)
guard-jasmine (3.1.0)
childprocess (~> 1.0)
guard (~> 2.14)
guard-compat (~> 1.2)
jasmine (~> 3.1)
multi_json (~> 1.12)
thor (~> 0.19)
tilt
guard-livereload (2.5.2)
em-websocket (~> 0.5)
guard (~> 2.8)
Expand Down Expand Up @@ -465,7 +461,7 @@ GEM
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0225)
mini_mime (1.1.0)
mini_mime (1.0.3)
mini_portile2 (2.5.3)
minitest (5.14.4)
msgpack (1.4.2)
Expand Down Expand Up @@ -530,20 +526,20 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3.7)
actioncable (= 6.0.3.7)
actionmailbox (= 6.0.3.7)
actionmailer (= 6.0.3.7)
actionpack (= 6.0.3.7)
actiontext (= 6.0.3.7)
actionview (= 6.0.3.7)
activejob (= 6.0.3.7)
activemodel (= 6.0.3.7)
activerecord (= 6.0.3.7)
activestorage (= 6.0.3.7)
activesupport (= 6.0.3.7)
bundler (>= 1.3.0)
railties (= 6.0.3.7)
rails (6.1.3.2)
actioncable (= 6.1.3.2)
actionmailbox (= 6.1.3.2)
actionmailer (= 6.1.3.2)
actionpack (= 6.1.3.2)
actiontext (= 6.1.3.2)
actionview (= 6.1.3.2)
activejob (= 6.1.3.2)
activemodel (= 6.1.3.2)
activerecord (= 6.1.3.2)
activestorage (= 6.1.3.2)
activesupport (= 6.1.3.2)
bundler (>= 1.15.0)
railties (= 6.1.3.2)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
Expand All @@ -557,12 +553,12 @@ GEM
rails-i18n (6.0.0)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 7)
railties (6.0.3.7)
actionpack (= 6.0.3.7)
activesupport (= 6.0.3.7)
railties (6.1.3.2)
actionpack (= 6.1.3.2)
activesupport (= 6.1.3.2)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
thor (~> 1.0)
rainbow (3.0.0)
raindrops (0.19.1)
rake (12.3.3)
Expand Down Expand Up @@ -699,12 +695,12 @@ GEM
temple (0.8.1)
terminal-table (3.0.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thor (0.20.3)
thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.10)
timecop (0.9.4)
tzinfo (1.2.9)
thread_safe (~> 0.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2021.1)
tzinfo (>= 1.0.0)
uglifier (4.2.0)
Expand Down Expand Up @@ -748,7 +744,7 @@ GEM
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
websocket-driver (0.7.3)
websocket-driver (0.7.4)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
Expand Down Expand Up @@ -795,7 +791,7 @@ DEPENDENCIES
factory_bot_rails (~> 6.2.0)
faker (~> 2.18.0)
geckoboard-ruby
gov_uk_date_fields (~> 3.1)
gov_uk_date_fields (~> 3.2)
govuk_design_system_formbuilder (~> 2.6.0b1)
govuk_elements_rails (~> 3.1.2)
govuk_frontend_toolkit (~> 8.2.0)
Expand All @@ -806,7 +802,6 @@ DEPENDENCIES
grape-swagger (~> 1.4.0)
grape-swagger-rails (~> 0.3.0)
guard-cucumber
guard-jasmine (~> 3.1)
guard-livereload (>= 2.5.2)
guard-rspec
guard-rubocop
Expand Down Expand Up @@ -839,7 +834,7 @@ DEPENDENCIES
pry-rails
puma
rack-livereload (~> 0.3.16)
rails (~> 6.0.3.7)
rails (~> 6.1.3)
rails-controller-testing
redis (~> 4.2.5)
remotipart (~> 1.4)
Expand Down
9 changes: 3 additions & 6 deletions app/form_builders/adp_text_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ def output_buffer
@errors
end

# @errors can either be an instance of ActiveModel::Errors or ErrorDetail
# @errors can either be an instance of ActiveModel::Errors or ErrorPresenter
def has_errors?
return false if @errors.nil?
if @errors.is_a?(ActiveModel::Errors)
@errors.key?(@error_key.to_sym)
else
@errors.errors_for?(@error_key.to_sym)
end

@errors.key?(@error_key.to_sym)
end

def to_html
Expand Down
9 changes: 5 additions & 4 deletions app/interfaces/api/error_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ def format_field_name(field_name)
end

def fetch_and_translate_error_messages
@model.errors.each do |field_name, error|
field_name = format_field_name(field_name)
emt = ErrorMessageTranslator.new(@translations, field_name, error)
@model.errors.each do |error|
message = error.message
field_name = format_field_name(error.attribute)
emt = ErrorMessageTranslator.new(@translations, field_name, message)
if emt.translation_found?
error_messages.push(error: emt.api_message)
else
error_messages.push(error: fallback_api_message(field_name, error))
error_messages.push(error: fallback_api_message(field_name, message))
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/allocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def claims
def claims_in_correct_state_for?(new_state)
claims.each do |claim|
next if claim.state.in?(VALID_STATES_FOR_TRANSITION[new_state])
errors[:base] << "Claim #{claim.id} cannot be transitioned to #{new_state} from #{claim.state}"
errors.add(:base, "Claim #{claim.id} cannot be transitioned to #{new_state} from #{claim.state}")
end
errors[:base].empty?
end
Expand Down Expand Up @@ -117,7 +117,7 @@ def allocate_or_error_claim!(claim)
end

def rollback_all_allocations!
errors[:base].unshift('NO claims allocated because: ')
errors.add(:base, 'NO claims were allocated')
@successful_claims = []
raise ActiveRecord::Rollback
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/roles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def strip_empty_role

def roles_valid
if roles.empty?
errors[:roles] << 'Choose at least one role'
errors.add(:roles, 'Choose at least one role')
elsif (roles - self.class::ROLES).any?
errors[:roles] << "Must be one or more of: #{roles_string}"
errors.add(:roles, "Must be one or more of: #{roles_string}")
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/models/determination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ def to_s
private

def fees_valid
errors[:base] << 'Assessed fees must be greater than or equal to zero' if negative_or_nil?(fees)
errors.add(:base, 'Assessed fees must be greater than or equal to zero') if negative_or_nil?(fees)
end

def expenses_valid
errors[:base] << 'Assessed expenses must be greater than or equal to zero' if negative_or_nil?(expenses)
errors.add(:base, 'Assessed expenses must be greater than or equal to zero') if negative_or_nil?(expenses)
end

def disbursements_valid
errors[:base] << 'Assessed disbursements must be greater than or equal to zero' if negative_or_nil?(disbursements)
errors.add(:base, 'Assessed disbursements must be greater than or equal to zero') if negative_or_nil?(disbursements)
end

def zero_or_nil?(value)
Expand Down
2 changes: 1 addition & 1 deletion app/models/offence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def offence_class_description

def offence_class_xor_offence_band
return if offence_class.present? ^ offence_band.present?
errors[:base] << I18n.t('external_users.claims.offence_details.scheme_xor.one_not_both')
errors.add(:base, I18n.t('external_users.claims.offence_details.scheme_xor.one_not_both'))
end

def scheme_nine?
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/error_message_translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(translations, fieldname, error)
def translate!
get_messages(@translations, @key, @error)
return unless translation_found?
@long_message = substitute_submodel_numbers_and_names(@long_message)
@long_message = substitute_submodel_numbers_and_names(@long_message)
@short_message = substitute_submodel_numbers_and_names(@short_message)
@api_message = substitute_submodel_numbers_and_names(@api_message)
end
Expand Down Expand Up @@ -58,9 +58,9 @@ def get_messages(translations, key, error)
translation_subset, submodel_key = extract_submodel_attribute(translations, key)
get_messages(translation_subset, submodel_key, error)
elsif translation_exists?(translations, key, error)
@long_message = translations[key][error]['long']
@long_message = translations[key][error]['long']
@short_message = translations[key][error]['short']
@api_message = translations[key][error]['api']
@api_message = translations[key][error]['api']
end
end

Expand Down
Loading