diff --git a/.github/workflows/check_release_version.yml b/.github/workflows/check_release_version.yml index e5db52d7..3f441c5f 100644 --- a/.github/workflows/check_release_version.yml +++ b/.github/workflows/check_release_version.yml @@ -14,7 +14,7 @@ jobs: - name: Get specific changed files id: changed-files-specific - uses: tj-actions/changed-files@v23 + uses: tj-actions/changed-files@v41 with: files: | .release-version diff --git a/.release-version b/.release-version index 53cc1a6f..f9e8384b 100644 --- a/.release-version +++ b/.release-version @@ -1 +1 @@ -1.24.0 +1.24.1 diff --git a/Gemfile.lock b/Gemfile.lock index 72151458..dd22ead0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,71 +8,71 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.4) - actionpack (= 6.1.7.4) - activesupport (= 6.1.7.4) + actioncable (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.4) - actionpack (= 6.1.7.4) - activejob (= 6.1.7.4) - activerecord (= 6.1.7.4) - activestorage (= 6.1.7.4) - activesupport (= 6.1.7.4) + 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) mail (>= 2.7.1) - actionmailer (6.1.7.4) - actionpack (= 6.1.7.4) - actionview (= 6.1.7.4) - activejob (= 6.1.7.4) - activesupport (= 6.1.7.4) + 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) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.7.4) - actionview (= 6.1.7.4) - activesupport (= 6.1.7.4) + actionpack (6.1.7.6) + actionview (= 6.1.7.6) + activesupport (= 6.1.7.6) 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.1.7.4) - actionpack (= 6.1.7.4) - activerecord (= 6.1.7.4) - activestorage (= 6.1.7.4) - activesupport (= 6.1.7.4) + 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) nokogiri (>= 1.8.5) - actionview (6.1.7.4) - activesupport (= 6.1.7.4) + actionview (6.1.7.6) + activesupport (= 6.1.7.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - active_model_serializers (0.10.13) - actionpack (>= 4.1, < 7.1) - activemodel (>= 4.1, < 7.1) + active_model_serializers (0.10.14) + actionpack (>= 4.1) + activemodel (>= 4.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (6.1.7.4) - activesupport (= 6.1.7.4) + activejob (6.1.7.6) + activesupport (= 6.1.7.6) globalid (>= 0.3.6) - activemodel (6.1.7.4) - activesupport (= 6.1.7.4) - activerecord (6.1.7.4) - activemodel (= 6.1.7.4) - activesupport (= 6.1.7.4) - activestorage (6.1.7.4) - actionpack (= 6.1.7.4) - activejob (= 6.1.7.4) - activerecord (= 6.1.7.4) - activesupport (= 6.1.7.4) + activemodel (6.1.7.6) + activesupport (= 6.1.7.6) + activerecord (6.1.7.6) + activemodel (= 6.1.7.6) + activesupport (= 6.1.7.6) + 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) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.4) + activesupport (6.1.7.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.4) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) amq-protocol (2.3.2) ancestry (4.3.3) @@ -85,19 +85,20 @@ GEM rest-client (~> 2.0) thor (~> 1.1.0) ast (2.4.2) + base64 (0.2.0) bindex (0.8.1) - bootsnap (1.16.0) + bootsnap (1.18.3) msgpack (~> 1.2) builder (3.2.4) - bunny (2.20.3) + bunny (2.22.0) amq-protocol (~> 2.3, >= 2.3.1) sorted_set (~> 1, >= 1.0.2) byebug (11.1.3) - capybara (3.39.2) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) @@ -116,7 +117,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) crass (1.0.6) database_cleaner (2.0.2) database_cleaner-active_record (>= 2, < 3) @@ -124,7 +125,7 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.3) + date (3.3.4) diff-lcs (1.5.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) @@ -133,10 +134,10 @@ GEM actionmailer (>= 5.2, < 8) activesupport (>= 5.2, < 8) execjs (2.8.1) - factory_bot (6.2.1) + factory_bot (6.4.5) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.3) + factory_bot (~> 6.4) railties (>= 5.0.0) faraday (1.10.3) faraday-em_http (~> 1.0) @@ -164,8 +165,8 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) ffi (1.15.5) - globalid (1.1.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) http-accept (1.7.0) http-cookie (1.0.5) domain_name (~> 0.5) @@ -174,7 +175,7 @@ GEM jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - jquery-rails (4.5.1) + jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) @@ -183,7 +184,7 @@ GEM turbolinks jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (2.6.3) + json (2.7.1) json_api_client (1.21.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) @@ -198,7 +199,7 @@ GEM listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.21.3) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -212,30 +213,32 @@ GEM mime-types (3.4.1) mime-types-data (~> 3.2015) mime-types-data (3.2023.0218.1) - mini_mime (1.1.2) - minitest (5.19.0) - mocha (2.0.2) + mini_mime (1.1.5) + minitest (5.21.2) + mocha (2.1.0) ruby2_keywords (>= 0.0.5) - msgpack (1.6.0) + msgpack (1.7.2) multipart-post (2.3.0) mysql2 (0.5.5) - net-imap (0.3.6) + net-imap (0.4.7) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol netrc (0.11.0) - nio4r (2.5.9) - nokogiri (1.15.3-x86_64-darwin) + nio4r (2.7.0) + nokogiri (1.16.0-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.0-x86_64-darwin) racc (~> 1.4) - nokogiri (1.15.3-x86_64-linux) + nokogiri (1.16.0-x86_64-linux) racc (~> 1.4) - parallel (1.23.0) - parser (3.2.2.3) + parallel (1.24.0) + parser (3.3.0.5) ast (~> 2.4.1) racc pry (0.14.2) @@ -243,36 +246,37 @@ GEM method_source (~> 1.0) psych (5.1.0) stringio - public_suffix (5.0.3) - puma (6.2.2) + public_suffix (5.0.4) + puma (6.4.2) nio4r (~> 2.0) - racc (1.7.1) + racc (1.7.3) rack (2.2.8) rack-cors (2.0.1) rack (>= 2.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.4) - actioncable (= 6.1.7.4) - actionmailbox (= 6.1.7.4) - actionmailer (= 6.1.7.4) - actionpack (= 6.1.7.4) - actiontext (= 6.1.7.4) - actionview (= 6.1.7.4) - activejob (= 6.1.7.4) - activemodel (= 6.1.7.4) - activerecord (= 6.1.7.4) - activestorage (= 6.1.7.4) - activesupport (= 6.1.7.4) + 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) bundler (>= 1.15.0) - railties (= 6.1.7.4) + railties (= 6.1.7.6) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) rails-erd (1.7.2) activerecord (>= 4.2) @@ -282,14 +286,14 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.7.4) - actionpack (= 6.1.7.4) - activesupport (= 6.1.7.4) + railties (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) method_source rake (>= 12.2) thor (~> 1.0) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) @@ -297,55 +301,59 @@ GEM rbtree (0.4.6) rdoc (6.5.0) psych (>= 4.0.0) - regexp_parser (2.8.1) + regexp_parser (2.9.0) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) rexml (3.2.6) - rspec-core (3.12.1) + rspec-core (3.12.2) rspec-support (~> 3.12.0) - rspec-expectations (3.12.2) + rspec-expectations (3.12.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-mocks (3.12.3) + rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-rails (6.0.1) + rspec-rails (6.1.1) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.11) - rspec-expectations (~> 3.11) - rspec-mocks (~> 3.11) - rspec-support (~> 3.11) - rspec-support (3.12.0) - rubocop (1.55.1) + rspec-core (~> 3.12) + rspec-expectations (~> 3.12) + rspec-mocks (~> 3.12) + rspec-support (~> 3.12) + rspec-support (3.12.1) + rubocop (1.60.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.3) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) + rubocop-ast (1.30.0) parser (>= 3.2.1.0) - rubocop-capybara (2.17.1) + rubocop-capybara (2.20.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.25.1) rubocop (~> 1.41) - rubocop-performance (1.18.0) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.20.2) + rubocop-performance (1.20.2) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) + rubocop-rails (2.23.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) - rubocop-rspec (2.19.0) - rubocop (~> 1.33) + rubocop-ast (>= 1.30.0, < 2.0) + rubocop-rspec (2.26.1) + rubocop (~> 1.40) rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) ruby-graphviz (1.2.5) rexml ruby-progressbar (1.13.0) @@ -364,7 +372,8 @@ GEM sdoc (2.6.1) rdoc (>= 5.0) select2-rails (4.0.13) - selenium-webdriver (4.9.0) + selenium-webdriver (4.17.0) + base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -372,8 +381,8 @@ GEM sorted_set (1.0.3) rbtree set (~> 1.0) - spring (4.1.1) - sprockets (4.2.0) + spring (4.1.3) + sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) @@ -387,7 +396,7 @@ GEM teaspoon (>= 1.0.0) thor (1.1.0) tilt (2.1.0) - timeout (0.4.0) + timeout (0.4.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) @@ -398,23 +407,24 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.8.2) - unicode-display_width (2.4.2) - web-console (4.2.0) + unicode-display_width (2.5.0) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - websocket (1.2.9) - websocket-driver (0.7.5) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - with_model (2.1.6) - activerecord (>= 5.2) + with_model (2.1.7) + activerecord (>= 6.0) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.10) + zeitwerk (2.6.12) PLATFORMS + arm64-darwin-22 x86_64-darwin-21 x86_64-darwin-22 x86_64-linux diff --git a/app/forms/location_form.rb b/app/forms/location_form.rb index bfd6b183..53b9e175 100644 --- a/app/forms/location_form.rb +++ b/app/forms/location_form.rb @@ -94,7 +94,7 @@ def reserve end def coordinateable - @coordinateable ||= (coordinateable? || @location.is_a?(OrderedLocation)) + @coordinateable ||= coordinateable? || @location.is_a?(OrderedLocation) end def persisted? diff --git a/app/lib/validators/existence_validator.rb b/app/lib/validators/existence_validator.rb index 8f75194d..69cd7368 100644 --- a/app/lib/validators/existence_validator.rb +++ b/app/lib/validators/existence_validator.rb @@ -8,7 +8,7 @@ class ExistenceValidator < ActiveModel::EachValidator # If the object is blank or the field with _id is blank add # an error to the attribute def validate_each(record, attribute, value) - return unless value.blank? && record.send("#{attribute}_id".to_sym).blank? + return unless value.blank? && record.send(:"#{attribute}_id").blank? record.errors.add(attribute, I18n.t('errors.messages.existence')) end diff --git a/app/models/broker.rb b/app/models/broker.rb index 784bafe5..b857dd6f 100644 --- a/app/models/broker.rb +++ b/app/models/broker.rb @@ -1,5 +1,16 @@ # frozen_string_literal: true -# Broker for handling messages +# Broker setup module Broker + if Rails.configuration.bunny['enabled'] + Handle = Messages::Broker.new(Rails.configuration.bunny) + Handle.create_connection + else + # Create an "empty" class definition when bunny is disabled + Handle = Messages::Broker.new(Rails.configuration.bunny).tap do |obj| + obj.instance_eval do + # empty block + end + end + end end diff --git a/app/models/labware_collection/base.rb b/app/models/labware_collection/labware_collection/base.rb similarity index 97% rename from app/models/labware_collection/base.rb rename to app/models/labware_collection/labware_collection/base.rb index 045f47b5..7d570b23 100644 --- a/app/models/labware_collection/base.rb +++ b/app/models/labware_collection/labware_collection/base.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +# module LabwareCollection module LabwareCollection # Base for LabwareCollection class Base diff --git a/app/models/labware_collection/ordered_location.rb b/app/models/labware_collection/labware_collection/ordered_location.rb similarity index 100% rename from app/models/labware_collection/ordered_location.rb rename to app/models/labware_collection/labware_collection/ordered_location.rb diff --git a/app/models/labware_collection/unordered_location.rb b/app/models/labware_collection/labware_collection/unordered_location.rb similarity index 100% rename from app/models/labware_collection/unordered_location.rb rename to app/models/labware_collection/labware_collection/unordered_location.rb diff --git a/app/models/locations/location.rb b/app/models/locations/location.rb index d21e09a7..293ed53a 100644 --- a/app/models/locations/location.rb +++ b/app/models/locations/location.rb @@ -216,7 +216,7 @@ def been_used? end def only_one_unknown - return unless type == 'UnknownLocation' && (new_record? || type_changed?) && UnknownLocation.all.count >= 1 + return unless type == 'UnknownLocation' && (new_record? || type_changed?) && UnknownLocation.count >= 1 errors.add(:base, UNKNOWN_LIMIT_ERROR) end diff --git a/app/models/restriction_creator.rb b/app/models/restriction_creator.rb index 3d117527..02aeaaea 100644 --- a/app/models/restriction_creator.rb +++ b/app/models/restriction_creator.rb @@ -15,7 +15,7 @@ def run! private def generate! - restrictions.each do |_k, restriction| + restrictions.each_value do |restriction| create_restriction(restriction) end end diff --git a/config/application.rb b/config/application.rb index bbe66d82..db5bfa86 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,7 @@ module Labwhere class Application < Rails::Application - config.load_defaults 5.2 + config.load_defaults 6.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers @@ -45,6 +45,11 @@ class Application < Rails::Application config.label_templates = Rails.application.config_for(:label_templates) + config.eager_load_paths += %W[#{config.root}/app/lib/utils #{config.root}/app/lib/validators + #{config.root}/app/models/users #{config.root}/app/models/locations + #{config.root}/app/models/restrictions #{config.root}/app/lib/label_printing + #{config.root}/app/models/labware_collection] + # replace fixtures with factory bot config.generators do |g| g.test_framework :rspec, @@ -62,5 +67,12 @@ class Application < Rails::Application # RabbitMQ config config.bunny = config_for(:bunny) + + Rails.application.config.middleware.insert_before 0, Rack::Cors do + allow do + origins '*' + resource '*', headers: :any, methods: [:get] + end + end end end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb deleted file mode 100644 index f4556db3..00000000 --- a/config/initializers/application_controller_renderer.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true -# Be sure to restart your server when you modify this file. - -# ActiveSupport::Reloader.to_prepare do -# ApplicationController.renderer.defaults.merge!( -# http_host: 'example.org', -# https: false -# ) -# end diff --git a/config/initializers/broker_handle_rabbitmq.rb b/config/initializers/broker_handle_rabbitmq.rb deleted file mode 100644 index 066964b5..00000000 --- a/config/initializers/broker_handle_rabbitmq.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -# Broker setup -Broker::Handle = Messages::Broker.new(Rails.configuration.bunny) diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb deleted file mode 100644 index f3bcce54..00000000 --- a/config/initializers/content_security_policy.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true -# Be sure to restart your server when you modify this file. - -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy - -# Rails.application.config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # If you are using webpack-dev-server then specify webpack-dev-server host -# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? - -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" -# end - -# If you are using UJS then enable automatic nonce generation -# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } - -# Set the nonce only to specific directives -# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) - -# Report CSP violations to a specified URI -# For further information see the following documentation: -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only -# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb deleted file mode 100644 index 69dc2306..00000000 --- a/config/initializers/cors.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -# Be sure to restart your server when you modify this file. - -# Avoid CORS issues when API is called from the frontend app. -# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. - -# Read more: https://github.com/cyu/rack-cors - -Rails.application.config.middleware.insert_before 0, Rack::Cors do - allow do - origins '*' - resource '*', headers: :any, methods: [:get] - end -end diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb deleted file mode 100644 index aa7435fb..00000000 --- a/config/initializers/inflections.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format. Inflections -# are locale specific, and you may define rules for as many different -# locales as you wish. All of these examples are active by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) -# end - -# These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' -# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb deleted file mode 100644 index 6e1d16f0..00000000 --- a/config/initializers/mime_types.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true -# Be sure to restart your server when you modify this file. - -# Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb deleted file mode 100644 index 16d85189..00000000 --- a/config/initializers/new_framework_defaults.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 5.0 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Rails.application.config.action_controller.raise_on_unfiltered_parameters = true - -# Enable per-form CSRF tokens. Previous versions had false. -# Rails.application.config.action_controller.per_form_csrf_tokens = true - -# Enable origin-checking CSRF mitigation. Previous versions had false. -# Rails.application.config.action_controller.forgery_protection_origin_check = true - -# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. -# Previous versions had false. -ActiveSupport.to_time_preserves_timezone = true - -# Require `belongs_to` associations by default. Previous versions had false. -Rails.application.config.active_record.belongs_to_required_by_default = true diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb deleted file mode 100644 index b33ee806..00000000 --- a/config/initializers/new_framework_defaults_5_1.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 5.1 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Make `form_with` generate non-remote forms. -Rails.application.config.action_view.form_with_generates_remote_forms = false - -# Unknown asset fallback will return the path passed in when the given -# asset is not present in the asset pipeline. -# Rails.application.config.assets.unknown_asset_fallback = false diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb deleted file mode 100644 index 3d84e42b..00000000 --- a/config/initializers/new_framework_defaults_5_2.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 5.2 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Make Active Record use stable #cache_key alongside new #cache_version method. -# This is needed for recyclable cache keys. -Rails.application.config.active_record.cache_versioning = true - -# Use AES-256-GCM authenticated encryption for encrypted cookies. -# Also, embed cookie expiry in signed or encrypted cookies for increased security. -# -# This option is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 5.2. -# -# Existing cookies will be converted on read then written with the new scheme. -Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true - -# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages -# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true. -Rails.application.config.active_support.use_authenticated_message_encryption = true - -# Add default protection from forgery to ActionController::Base instead of in -# ApplicationController. -Rails.application.config.action_controller.default_protect_from_forgery = true - -# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and -# 'f' after migrating old data. -# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true - -# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header. -Rails.application.config.active_support.hash_digest_class = Digest::SHA1 - -# Make `form_with` generate id attributes for any generated HTML tags. -Rails.application.config.action_view.form_with_generates_ids = true diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb deleted file mode 100644 index 0b4ce023..00000000 --- a/config/initializers/new_framework_defaults_6_1.rb +++ /dev/null @@ -1,68 +0,0 @@ -# frozen_string_literal: true -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 6.1 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Support for inversing belongs_to -> has_many Active Record associations. -# Rails.application.config.active_record.has_many_inversing = true - -# Track Active Storage variants in the database. -# Rails.application.config.active_storage.track_variants = true - -# Apply random variation to the delay when retrying failed jobs. -# Rails.application.config.active_job.retry_jitter = 0.15 - -# Stop executing `after_enqueue`/`after_perform` callbacks if -# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. -# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true - -# Specify cookies SameSite protection level: either :none, :lax, or :strict. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax - -# Generate CSRF tokens that are encoded in URL-safe Base64. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_controller.urlsafe_csrf_tokens = true - -# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an -# UTC offset or a UTC time. -# ActiveSupport.utc_to_local_returns_utc_offset_times = true - -# Change the default HTTP status code to `308` when redirecting non-GET/HEAD -# requests to HTTPS in `ActionDispatch::SSL` middleware. -# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 - -# Use new connection handling API. For most applications this won't have any -# effect. For applications using multiple databases, this new API provides -# support for granular connection swapping. -# Rails.application.config.active_record.legacy_connection_handling = false - -# Make `form_with` generate non-remote forms by default. -# Rails.application.config.action_view.form_with_generates_remote_forms = false - -# Set the default queue name for the analysis job to the queue adapter default. -# Rails.application.config.active_storage.queues.analysis = nil - -# Set the default queue name for the purge job to the queue adapter default. -# Rails.application.config.active_storage.queues.purge = nil - -# Set the default queue name for the incineration job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.incineration = nil - -# Set the default queue name for the routing job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.routing = nil - -# Set the default queue name for the mail deliver job to the queue adapter default. -# Rails.application.config.action_mailer.deliver_later_queue_name = nil - -# Generate a `Link` header that gives a hint to modern browsers about -# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. -# Rails.application.config.action_view.preload_links_header = true diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb deleted file mode 100644 index 50bcf4ea..00000000 --- a/config/initializers/permissions_policy.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true -# Define an application-wide HTTP permissions policy. For further -# information see https://developers.google.com/web/updates/2018/06/feature-policy -# -# Rails.application.config.permissions_policy do |f| -# f.camera :none -# f.gyroscope :none -# f.microphone :none -# f.usb :none -# f.fullscreen :self -# f.payment :self, "https://secure.example.com" -# end diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 1e6563c9..338cb843 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -14,7 +14,7 @@ namespace :db do # create some location types location_types = YAML.load_file(Rails.root.join('config/location_types.yml')) - location_types.each do |_k, v| + location_types.each_value do |v| LocationType.create(v) end diff --git a/lib/tasks/duplicate_labware_data_fix.rake b/lib/tasks/duplicate_labware_data_fix.rake index 60b6351a..324bd8ae 100644 --- a/lib/tasks/duplicate_labware_data_fix.rake +++ b/lib/tasks/duplicate_labware_data_fix.rake @@ -19,7 +19,7 @@ namespace :duplicates do barcode_to_labs = labs.group_by(&:barcode) puts 'Deleting duplicates...' - barcode_to_labs.each do |_barcode, labwares| + barcode_to_labs.each_value do |labwares| # save one of them labwares.pop diff --git a/lib/tasks/hash_user_swipe_cards.rake b/lib/tasks/hash_user_swipe_cards.rake index f8444484..5a3c2458 100644 --- a/lib/tasks/hash_user_swipe_cards.rake +++ b/lib/tasks/hash_user_swipe_cards.rake @@ -7,7 +7,7 @@ require 'digest/sha1' namespace :user do desc "to hash all existing users swipe_card_id's" task hash_swipe_card_ids: :environment do - User.all.each do |user| + User.find_each do |user| next if user.swipe_card_id.blank? user.swipe_card_id = Digest::SHA1.hexdigest(user.swipe_card_id) diff --git a/lib/tasks/invalid_locations.rake b/lib/tasks/invalid_locations.rake index bea9af60..ec524f3f 100644 --- a/lib/tasks/invalid_locations.rake +++ b/lib/tasks/invalid_locations.rake @@ -5,7 +5,7 @@ task invalid_locations: :environment do has_failures = false format = "%-20s\t%-20s\t%-20s\t%-20s\n" - Location.all.each do |location| + Location.find_each do |location| next if location.valid? # Print out some nicely formatted headers diff --git a/lib/tasks/protected_locations.rake b/lib/tasks/protected_locations.rake index 378fa927..52b24291 100644 --- a/lib/tasks/protected_locations.rake +++ b/lib/tasks/protected_locations.rake @@ -4,7 +4,7 @@ namespace :protected_locations do desc 'Sets the protected flag to true for locations with certain location types' task set_default_protected_flag: :environment do protected_locations = ['Building', 'Room', 'Site', 'Car Park', 'Reefer', 'Bin', 'DELIVERED'] - Location.all.each do |location| + Location.find_each do |location| if location.location_type_id.present? location.protected = true if protected_locations.include?(location.location_type.name) location.save diff --git a/lib/tasks/uuid_migration.rake b/lib/tasks/uuid_migration.rake index 5f2be23a..551078bf 100644 --- a/lib/tasks/uuid_migration.rake +++ b/lib/tasks/uuid_migration.rake @@ -5,7 +5,7 @@ namespace :migration do task create_uuids: :environment do |_t| puts 'Updating labwares...' labware_updated = 0 - Labware.where(uuid: '').each do |lab| + Labware.where(uuid: '').find_each do |lab| lab.uuid = SecureRandom.uuid result = lab.save(validate: false) labware_updated += 1 if result @@ -14,7 +14,7 @@ namespace :migration do puts 'Updating locations...' locations_updated = 0 - Location.where(uuid: '').each do |loc| + Location.where(uuid: '').find_each do |loc| loc.uuid = SecureRandom.uuid result = loc.save(validate: false) locations_updated += 1 if result @@ -23,7 +23,7 @@ namespace :migration do puts 'Updating audits...' audits_updated = 0 - Audit.where(uuid: '').each do |aud| + Audit.where(uuid: '').find_each do |aud| aud.uuid = SecureRandom.uuid result = aud.save(validate: false) audits_updated += 1 if result diff --git a/spec/forms/scan_form_spec.rb b/spec/forms/scan_form_spec.rb index e3e8273b..998da9a4 100644 --- a/spec/forms/scan_form_spec.rb +++ b/spec/forms/scan_form_spec.rb @@ -73,7 +73,7 @@ create_scan.submit(params.merge(scan: { 'location_barcode' => location.barcode, 'labware_barcodes' => new_labware.join_barcodes, user_code: sci_swipe_card_id })) - expect(Audit.all.count).to eq(4) + expect(Audit.count).to eq(4) expect(location.labwares.first.audits.first.user).to eq(scientist) expect(location.labwares.first.audits.first.action).to eq('create') end diff --git a/spec/models/labware_spec.rb b/spec/models/labware_spec.rb index c2acf39e..1e11314e 100644 --- a/spec/models/labware_spec.rb +++ b/spec/models/labware_spec.rb @@ -66,7 +66,7 @@ labwares += create_list(:labware_with_location, 2) labwares += create_list(:labware_with_ordered_location, 2) labwares += [create(:labware, location: UnknownLocation.get)] - location_barcodes = labwares.map(&:location).map(&:barcode) + location_barcodes = labwares.map { |labware| labware.location.barcode } expect(Labware.by_location_barcode(location_barcodes).count).to eq(5) end @@ -78,6 +78,7 @@ labware2 = create(:labware, coordinate: coordinate) expect(labware2.location).to eq(coordinate.location) labware3 = create(:labware) + expect(labware3.location).to be_empty end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b36384bf..7c44f837 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -53,22 +53,22 @@ describe 'User Types' do it 'should be able to create an Administrator' do create(:user, type: 'Administrator') - expect(Administrator.all.count).to eq(1) + expect(Administrator.count).to eq(1) end it 'should be able to create a Technician' do create(:user, type: 'Technician') - expect(Technician.all.count).to eq(1) + expect(Technician.count).to eq(1) end it 'should be able to create a Guest' do create(:user, type: 'Guest') - expect(Guest.all.count).to eq(1) + expect(Guest.count).to eq(1) end it 'should be able to create a Scientist' do create(:user, type: 'Scientist') - expect(Scientist.all.count).to eq(1) + expect(Scientist.count).to eq(1) end end