From 97b9a0a18361e9170c7fc719d66f81602695fac1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Apr 2023 16:47:30 +0000 Subject: [PATCH 01/49] Bump nokogiri from 1.14.2 to 1.14.3 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.14.2 to 1.14.3. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.14.2...v1.14.3) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5c0c9760..4e77d314 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -138,7 +138,7 @@ GEM net-smtp (0.3.3) net-protocol nio4r (2.5.9) - nokogiri (1.14.2) + nokogiri (1.14.3) mini_portile2 (~> 2.8.0) racc (~> 1.4) parallel (1.22.1) From f9d9016f8de387d6b680aad796546d341d776a64 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Thu, 3 Aug 2023 19:00:24 +0000 Subject: [PATCH 02/49] Update capybara to version 3.39.2 --- Gemfile.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4e77d314..523040e8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,7 +60,7 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.1) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) autoprefixer-rails (10.4.7.0) @@ -70,7 +70,7 @@ GEM autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) builder (3.2.4) - capybara (3.38.0) + capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) @@ -125,7 +125,7 @@ GEM matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.2) - mini_portile2 (2.8.1) + mini_portile2 (2.8.4) minitest (5.18.0) mysql2 (0.5.5) net-imap (0.3.4) @@ -138,8 +138,8 @@ GEM net-smtp (0.3.3) net-protocol nio4r (2.5.9) - nokogiri (1.14.3) - mini_portile2 (~> 2.8.0) + nokogiri (1.15.3) + mini_portile2 (~> 2.8.2) racc (~> 1.4) parallel (1.22.1) parser (3.2.1.1) @@ -149,14 +149,14 @@ GEM method_source (~> 1.0) psych (4.0.4) stringio - public_suffix (5.0.1) + public_suffix (5.0.3) puma (6.2.2) nio4r (~> 2.0) - racc (1.6.2) - rack (2.2.6.4) + racc (1.7.1) + rack (2.2.8) rack-mini-profiler (3.0.0) rack (>= 1.2.0) - rack-test (2.0.2) + rack-test (2.1.0) rack (>= 1.3) rails (6.1.6) actioncable (= 6.1.6) @@ -188,7 +188,7 @@ GEM rake (13.0.6) rdoc (6.4.0) psych (>= 4.0.0) - regexp_parser (2.7.0) + regexp_parser (2.8.1) rexml (3.2.5) rspec-collection_matchers (1.2.0) rspec-expectations (>= 2.99.0.beta1) From 9aa7e146292579af196f12356dc2ebcef1fd7f8f Mon Sep 17 00:00:00 2001 From: yoldas Date: Wed, 3 Jan 2024 01:42:29 +0000 Subject: [PATCH 03/49] bump tj-actions/changed-files from 23 to 41 in /.github/workflows Bumps tj-actions/changed-files from 23 to 41. --- .github/workflows/check_release_version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_release_version.yml b/.github/workflows/check_release_version.yml index 89019799..bd49a9ec 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 From 2908b0447cc47da27c3a053f1a27d29daea9a676 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:13:11 +0000 Subject: [PATCH 04/49] Update jquery-rails to version 4.6.0 --- Gemfile.lock | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 68fec8ae..0b04d7ba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,7 +83,7 @@ GEM capybara selenium-webdriver coderay (1.1.3) - 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) @@ -104,29 +104,29 @@ GEM ffi (1.15.5) globalid (1.1.0) activesupport (>= 5.0) - i18n (1.12.0) + i18n (1.14.1) concurrent-ruby (~> 1.0) 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) json (2.6.3) launchy (2.5.2) addressable (~> 2.8) - loofah (2.19.1) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) + nokogiri (>= 1.12.0) mail (2.7.1) mini_mime (>= 0.1.1) marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.2) - mini_portile2 (2.8.4) - minitest (5.18.0) + mini_portile2 (2.8.5) + minitest (5.22.2) mysql2 (0.5.5) net-imap (0.3.4) date @@ -138,7 +138,7 @@ GEM net-smtp (0.3.3) net-protocol nio4r (2.5.9) - nokogiri (1.15.3) + nokogiri (1.16.2) mini_portile2 (~> 2.8.2) racc (~> 1.4) parallel (1.23.0) @@ -152,7 +152,7 @@ GEM public_suffix (5.0.3) puma (6.3.0) nio4r (~> 2.0) - racc (1.7.1) + racc (1.7.3) rack (2.2.8) rack-mini-profiler (3.0.0) rack (>= 1.2.0) @@ -173,11 +173,13 @@ GEM bundler (>= 1.15.0) railties (= 6.1.6) sprockets-rails (>= 2.0.0) - 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-html-sanitizer (1.5.0) - loofah (~> 2.19, >= 2.19.1) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) railties (6.1.6) actionpack (= 6.1.6) activesupport (= 6.1.6) @@ -185,7 +187,7 @@ GEM rake (>= 12.2) thor (~> 1.0) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rdoc (6.4.0) psych (>= 4.0.0) regexp_parser (2.8.1) @@ -266,7 +268,7 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) stringio (3.0.2) - thor (1.2.1) + thor (1.3.0) tilt (2.0.11) timecop (0.9.6) timeout (0.3.1) @@ -289,7 +291,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.7) + zeitwerk (2.6.13) PLATFORMS ruby From 28bea618ad9df71dc0490c5eeaa5df4015f0b675 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:17:47 +0000 Subject: [PATCH 05/49] Update puma to version 6.4.2 --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0b04d7ba..bf0c7adf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -137,7 +137,7 @@ GEM timeout net-smtp (0.3.3) net-protocol - nio4r (2.5.9) + nio4r (2.7.0) nokogiri (1.16.2) mini_portile2 (~> 2.8.2) racc (~> 1.4) @@ -150,7 +150,7 @@ GEM psych (4.0.4) stringio public_suffix (5.0.3) - puma (6.3.0) + puma (6.4.2) nio4r (~> 2.0) racc (1.7.3) rack (2.2.8) From ab2842c6b5ca596fd2c4f4e02488aba0a8a1cab5 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:30:19 +0000 Subject: [PATCH 06/49] Update rails to version 6.1.7.6 --- Gemfile.lock | 123 ++++++++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bf0c7adf..314c915e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,60 +1,60 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.6) - actionpack (= 6.1.6) - activesupport (= 6.1.6) + 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.6) - actionpack (= 6.1.6) - activejob (= 6.1.6) - activerecord (= 6.1.6) - activestorage (= 6.1.6) - activesupport (= 6.1.6) + 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.6) - actionpack (= 6.1.6) - actionview (= 6.1.6) - activejob (= 6.1.6) - activesupport (= 6.1.6) + 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.6) - actionview (= 6.1.6) - activesupport (= 6.1.6) + 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.6) - actionpack (= 6.1.6) - activerecord (= 6.1.6) - activestorage (= 6.1.6) - activesupport (= 6.1.6) + 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.6) - activesupport (= 6.1.6) + 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) - activejob (6.1.6) - activesupport (= 6.1.6) + activejob (6.1.7.6) + activesupport (= 6.1.7.6) globalid (>= 0.3.6) - activemodel (6.1.6) - activesupport (= 6.1.6) - activerecord (6.1.6) - activemodel (= 6.1.6) - activesupport (= 6.1.6) - activestorage (6.1.6) - actionpack (= 6.1.6) - activejob (= 6.1.6) - activerecord (= 6.1.6) - activesupport (= 6.1.6) + 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.6) + activesupport (6.1.7.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -102,8 +102,8 @@ GEM factory_bot (6.2.1) activesupport (>= 5.0.0) ffi (1.15.5) - globalid (1.1.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) i18n (1.14.1) concurrent-ruby (~> 1.0) jbuilder (2.11.5) @@ -119,12 +119,15 @@ GEM loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.7.1) + mail (2.8.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) - mini_mime (1.1.2) + mini_mime (1.1.5) mini_portile2 (2.8.5) minitest (5.22.2) mysql2 (0.5.5) @@ -158,20 +161,20 @@ GEM rack (>= 1.2.0) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.6) - actioncable (= 6.1.6) - actionmailbox (= 6.1.6) - actionmailer (= 6.1.6) - actionpack (= 6.1.6) - actiontext (= 6.1.6) - actionview (= 6.1.6) - activejob (= 6.1.6) - activemodel (= 6.1.6) - activerecord (= 6.1.6) - activestorage (= 6.1.6) - activesupport (= 6.1.6) + 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.6) + railties (= 6.1.7.6) sprockets-rails (>= 2.0.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) @@ -180,9 +183,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.6) - actionpack (= 6.1.6) - activesupport (= 6.1.6) + railties (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) method_source rake (>= 12.2) thor (~> 1.0) @@ -260,9 +263,9 @@ GEM simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) spring (4.1.1) - sprockets (3.7.2) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) + rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) @@ -286,7 +289,7 @@ GEM bindex (>= 0.4.0) railties (>= 6.0.0) websocket (1.2.9) - websocket-driver (0.7.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) From 3129db2dc94f21a7153600a094098f1f2eba8bb7 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:32:28 +0000 Subject: [PATCH 07/49] Update rubocop-rails to version 2.23.1 --- Gemfile.lock | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bf0c7adf..44198f51 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -113,7 +113,8 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.6.3) + json (2.7.1) + language_server-protocol (3.17.0.3) launchy (2.5.2) addressable (~> 2.8) loofah (2.22.0) @@ -141,9 +142,10 @@ GEM nokogiri (1.16.2) mini_portile2 (~> 2.8.2) racc (~> 1.4) - parallel (1.23.0) - parser (3.2.2.1) + parallel (1.24.0) + parser (3.3.0.5) ast (~> 2.4.1) + racc pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -190,8 +192,8 @@ GEM rake (13.1.0) rdoc (6.4.0) psych (>= 4.0.0) - regexp_parser (2.8.1) - rexml (3.2.5) + regexp_parser (2.9.0) + rexml (3.2.6) rspec-collection_matchers (1.2.0) rspec-expectations (>= 2.99.0.beta1) rspec-core (3.5.4) @@ -211,27 +213,29 @@ GEM rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) - rubocop (1.51.0) + rubocop (1.60.2) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.0.0) + 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.0, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.28.1) + rubocop-ast (1.30.0) parser (>= 3.2.1.0) rubocop-capybara (2.17.1) rubocop (~> 1.41) rubocop-performance (1.18.0) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.18.0) + rubocop-rails (2.23.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) rubocop-rspec (2.19.0) rubocop (~> 1.33) rubocop-capybara (~> 2.17) @@ -279,7 +283,7 @@ GEM concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.4.2) + unicode-display_width (2.5.0) web-console (4.0.4) actionview (>= 6.0.0) activemodel (>= 6.0.0) From d72940d180673f31c40b4b33735e1ec10bc8a2a2 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:48:00 +0000 Subject: [PATCH 08/49] Fix issues with Rubocop --- .rubocop_todo.yml | 4 ++++ app/models/comment.rb | 2 +- app/presenters/asset/asset.rb | 3 ++- app/presenters/presenter.rb | 12 ++++++------ .../20170306102500_update_states_and_workflows.rb | 2 +- ...20190923134849_update_qc_flow_column_workflows.rb | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 93ce8915..2c568ac2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -611,3 +611,7 @@ Style/ZeroLengthPredicate: Exclude: - 'app/controllers/batches_controller.rb' - 'app/presenters/asset/index.rb' + +Rails/ThreeStateBooleanColumn: + Exclude: + - 'db/migrate/20190923133947_add_qc_flow_column_to_workflows.rb' diff --git a/app/models/comment.rb b/app/models/comment.rb index 2fadf051..d5d0008d 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -4,7 +4,7 @@ class Comment < ApplicationRecord before_destroy :no_assets? def no_assets? - return if assets.empty? || assets.all? { |a| a.destroyed? } + return false if assets.empty? || assets.all? { |a| a.destroyed? } throw(:abort) end diff --git a/app/presenters/asset/asset.rb b/app/presenters/asset/asset.rb index fc38deb3..11d46378 100644 --- a/app/presenters/asset/asset.rb +++ b/app/presenters/asset/asset.rb @@ -57,7 +57,8 @@ def completed_status_label if completed_early? return "Early #{asset.workflow.turn_around_days - asset.time_without_completion} #{'day'.pluralize(overdue_by)}" end - return 'On time' if completed_on_time? + + 'On time' if completed_on_time? end def completed_at_status diff --git a/app/presenters/presenter.rb b/app/presenters/presenter.rb index 6aac5451..d350b44c 100644 --- a/app/presenters/presenter.rb +++ b/app/presenters/presenter.rb @@ -29,7 +29,7 @@ module SharedBehaviour require './app/presenters/asset_type/asset_type' def each_asset_type - AssetType.all.each do |asset_type| + AssetType.find_each do |asset_type| yield(asset_type.name, asset_type.identifier_type, asset_type.has_sample_count, @@ -38,13 +38,13 @@ def each_asset_type end def with_each_asset_type - AssetType.all.each do |asset_type| + AssetType.find_each do |asset_type| yield(Presenter::AssetTypePresenter::AssetType.new(asset_type)) end end def each_workflow - Workflow.all.includes(:initial_state).order(active: :desc).each do |workflow| + Workflow.includes(:initial_state).order(active: :desc).each do |workflow| yield(workflow.name, workflow.has_comment, workflow.id, @@ -57,7 +57,7 @@ def each_workflow end def active_workflows - Workflow.where(active: true).includes(:initial_state).each do |workflow| + Workflow.where(active: true).includes(:initial_state).find_each do |workflow| yield(workflow.name, workflow.has_comment, workflow.id, @@ -70,13 +70,13 @@ def active_workflows end def each_pipeline_destination - PipelineDestination.all.each do |pipeline_destination| + PipelineDestination.find_each do |pipeline_destination| yield pipeline_destination.name, pipeline_destination.id end end def each_cost_code - CostCode.all.each do |cost_code| + CostCode.find_each do |cost_code| yield cost_code.name, cost_code.id end end diff --git a/db/migrate/20170306102500_update_states_and_workflows.rb b/db/migrate/20170306102500_update_states_and_workflows.rb index 958aeba1..32cb1829 100644 --- a/db/migrate/20170306102500_update_states_and_workflows.rb +++ b/db/migrate/20170306102500_update_states_and_workflows.rb @@ -1,7 +1,7 @@ class UpdateStatesAndWorkflows < ActiveRecord::Migration def change ActiveRecord::Base.transaction do - Workflow.where(initial_state: nil).each do |workflow| + Workflow.where(initial_state: nil).find_each do |workflow| workflow.update_attributes!(initial_state_name: 'in_progress') end end diff --git a/db/migrate/20190923134849_update_qc_flow_column_workflows.rb b/db/migrate/20190923134849_update_qc_flow_column_workflows.rb index 2a4ba4f3..194b0c5c 100644 --- a/db/migrate/20190923134849_update_qc_flow_column_workflows.rb +++ b/db/migrate/20190923134849_update_qc_flow_column_workflows.rb @@ -1,6 +1,6 @@ class UpdateQcFlowColumnWorkflows < ActiveRecord::Migration def up - Workflow.includes(:initial_state).each do |workflow| + Workflow.includes(:initial_state).find_each do |workflow| workflow.qc_flow = workflow.initial_state.name != 'in_progress' workflow.save end From 9964ae5907f97a881905b5fb8aba81260f31f1d2 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:52:13 +0000 Subject: [PATCH 09/49] Update capybara to version 3.40.0 --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 44198f51..83501d49 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,7 +60,7 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.5) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) autoprefixer-rails (10.4.7.0) @@ -70,11 +70,11 @@ GEM autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) builder (3.2.4) - 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) @@ -125,7 +125,7 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) - mini_mime (1.1.2) + mini_mime (1.1.5) mini_portile2 (2.8.5) minitest (5.22.2) mysql2 (0.5.5) @@ -151,7 +151,7 @@ GEM method_source (~> 1.0) psych (4.0.4) stringio - public_suffix (5.0.3) + public_suffix (5.0.4) puma (6.4.2) nio4r (~> 2.0) racc (1.7.3) From 485c321d09ece0031c4a09c467576fefd2856cdc Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Tue, 13 Feb 2024 16:54:30 +0000 Subject: [PATCH 10/49] Create LICENSE Update license to MIT --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..f8d7d743 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Wellcome Sanger Institute - PSD + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From c4b518b46d25f03e7f2b742065b55becbd015360 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 19:00:17 +0000 Subject: [PATCH 11/49] Update rspec-collection_matchers to version 1.2.1 --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 83501d49..ad6d075c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -92,7 +92,7 @@ GEM database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) date (3.3.3) - diff-lcs (1.5.0) + diff-lcs (1.5.1) docile (1.4.0) erubi (1.12.0) exception_notification (4.5.0) @@ -194,7 +194,7 @@ GEM psych (>= 4.0.0) regexp_parser (2.9.0) rexml (3.2.6) - rspec-collection_matchers (1.2.0) + rspec-collection_matchers (1.2.1) rspec-expectations (>= 2.99.0.beta1) rspec-core (3.5.4) rspec-support (~> 3.5.0) From 4a3ed99da951e16f5472327ee8fc0efd52c17e6f Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 19:10:55 +0000 Subject: [PATCH 12/49] Update timecop to version 0.9.8 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 83501d49..52b6a2b1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -274,7 +274,7 @@ GEM stringio (3.0.2) thor (1.3.0) tilt (2.0.11) - timecop (0.9.6) + timecop (0.9.8) timeout (0.3.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) From 835060a173e5bb6c13d6bea82abda2918b6d9432 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 19:20:22 +0000 Subject: [PATCH 13/49] Update rubocop-rspec to version 2.26.1 --- Gemfile.lock | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 83501d49..75a7fb07 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -226,7 +226,9 @@ GEM unicode-display_width (>= 2.4.0, < 3.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) @@ -236,9 +238,10 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rspec (2.19.0) - rubocop (~> 1.33) + rubocop-rspec (2.26.1) + rubocop (~> 1.40) rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) rubyzip (2.3.2) sass-rails (6.0.0) From e182d723612f0d7475aac19913dcaa6bc6cd6e41 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 19:25:19 +0000 Subject: [PATCH 14/49] Update rubocop-performance to version 1.20.2 --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 83501d49..7e2c5208 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -228,9 +228,9 @@ GEM parser (>= 3.2.1.0) rubocop-capybara (2.17.1) rubocop (~> 1.41) - rubocop-performance (1.18.0) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) + 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) From b98f21a510c1cc78b0d57ec33b9a46d2d59974fd Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 00:16:24 +0000 Subject: [PATCH 15/49] Update rack-mini-profiler to version 3.3.1 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 83501d49..e68baf74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -156,7 +156,7 @@ GEM nio4r (~> 2.0) racc (1.7.3) rack (2.2.8) - rack-mini-profiler (3.0.0) + rack-mini-profiler (3.3.1) rack (>= 1.2.0) rack-test (2.1.0) rack (>= 1.3) From bed1e21959d07859a06d02a177f1583b9051dc10 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Mon, 19 Feb 2024 13:43:46 +0000 Subject: [PATCH 16/49] added manifest.js --- app/assets/config/manifest.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 app/assets/config/manifest.js diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 00000000..5cc2c089 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css \ No newline at end of file From bd970caf9ef832c0d53e10070da4b730c3330d14 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:00:22 +0000 Subject: [PATCH 17/49] Update spring to version 4.1.3 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 65db7884..8e524094 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -266,7 +266,7 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - spring (4.1.1) + spring (4.1.3) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) From f55875e16481d7b0fa21639f891716b387ac72ca Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:50:14 +0000 Subject: [PATCH 18/49] Update factory_bot to version 6.4.6 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 65db7884..ff06578c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,7 +99,7 @@ GEM actionmailer (>= 5.2, < 8) activesupport (>= 5.2, < 8) execjs (2.8.1) - factory_bot (6.2.1) + factory_bot (6.4.6) activesupport (>= 5.0.0) ffi (1.15.5) globalid (1.2.1) From d55353d7067b54c674e5a276f68e972899e048bd Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 01:55:25 +0000 Subject: [PATCH 19/49] Update selenium-webdriver to version 4.18.1 --- Gemfile.lock | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 65db7884..dff9c92c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,6 +65,7 @@ GEM ast (2.4.2) autoprefixer-rails (10.4.7.0) execjs (~> 2) + base64 (0.2.0) bindex (0.8.1) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) @@ -256,7 +257,8 @@ GEM tilt sdoc (2.4.0) rdoc (>= 5.0) - selenium-webdriver (4.8.1) + selenium-webdriver (4.18.1) + base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -292,7 +294,7 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - websocket (1.2.9) + websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) From 861ba3444d4c4d812dc591fd504bd1359bc0dfac Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:16:31 +0000 Subject: [PATCH 20/49] Update RuboCop configuration and fix rubocop errors --- .rubocop.yml | 1 + report.csv | 2 +- spec/factories/workflow_factories.rb | 6 +- spec/features/create_and_edit_batch_spec.rb | 14 ++--- .../create_and_update_workflow_spec.rb | 6 +- ...ete_and_report_asset_standard_flow_spec.rb | 30 +++++----- ..._and_report_assets_cherrypick_flow_spec.rb | 54 +++++++++--------- ...complete_and_report_assets_qc_flow_spec.rb | 36 ++++++------ .../create_pipeline_destination_spec.rb | 6 +- spec/features/generate_report_spec.rb | 30 +++++----- spec/features/search_batch_and_assets_spec.rb | 20 +++---- spec/models/asset_spec.rb | 32 +++++------ spec/models/batch_creator_spec.rb | 2 +- spec/models/batch_updater_spec.rb | 2 +- spec/models/report_spec.rb | 12 ++-- spec/presenters/asset_index_presenter_spec.rb | 18 +++--- spec/presenters/asset_presenter_spec.rb | 2 +- spec/presenters/asset_type_presenter_spec.rb | 2 +- spec/presenters/batch_new_presenter_spec.rb | 2 +- spec/presenters/batch_show_presenter_spec.rb | 20 +++---- spec/presenters/report_new_presenter_spec.rb | 2 +- spec/presenters/report_show_presenter_spec.rb | 55 ++++++++++--------- spec/presenters/shared_presenter_behaviour.rb | 8 +-- spec/spec_helper.rb | 2 +- 24 files changed, 185 insertions(+), 179 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a3ec06dc..f6c69f84 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,5 +15,6 @@ require: - rubocop-rspec AllCops: NewCops: enable + SuggestExtensions: false Layout/LineLength: Max: 120 diff --git a/report.csv b/report.csv index da71144f..f038ca6a 100644 --- a/report.csv +++ b/report.csv @@ -1,4 +1,4 @@ -Report for 'Workflow1' workflow from 01/03/2017 to 31/03/2017 +Report for 'Workflow_first' workflow from 01/03/2017 to 31/03/2017 Study,Project,Cost code name,Assets count Study1,Project1,Not defined,1 Study1,Project2,A1,1 diff --git a/spec/factories/workflow_factories.rb b/spec/factories/workflow_factories.rb index 199d911e..ca1612a1 100644 --- a/spec/factories/workflow_factories.rb +++ b/spec/factories/workflow_factories.rb @@ -11,16 +11,16 @@ active { true } qc_flow { false } cherrypick_flow { false } - association :initial_state, factory: :state, name: 'in_progress' + initial_state factory: %i[state], name: 'in_progress' factory :qc_workflow do qc_flow { true } - association :initial_state, factory: :state, name: 'volume_check' + initial_state factory: %i[state], name: 'volume_check' end factory :cherrypick_workflow do cherrypick_flow { true } - association :initial_state, factory: :state, name: 'cherrypick' + initial_state factory: %i[state], name: 'cherrypick' factory :cherrypick_qc_workflow do qc_flow { true } diff --git a/spec/features/create_and_edit_batch_spec.rb b/spec/features/create_and_edit_batch_spec.rb index f9dc053f..6ac1615d 100644 --- a/spec/features/create_and_edit_batch_spec.rb +++ b/spec/features/create_and_edit_batch_spec.rb @@ -2,18 +2,18 @@ require 'rails_helper' -describe 'create and edit batch', js: true do +describe 'create and edit batch', :js do let!(:asset_type) { create(:asset_type, name: 'Sample', identifier_type: 'Name') } - let!(:workflow1) { create(:workflow, name: 'Workflow') } - let!(:workflow2) { create(:workflow, name: 'Reportable workflow', reportable: true) } - let!(:workflow3) { create(:qc_workflow, name: 'QC workflow') } - let!(:workflow4) { create(:workflow, name: 'Deactivated workflow', active: false) } + let!(:workflow_first) { create(:workflow, name: 'Workflow') } + let!(:workflow_second) { create(:workflow, name: 'Reportable workflow', reportable: true) } + let!(:workflow_third) { create(:qc_workflow, name: 'QC workflow') } + let!(:workflow_fourth) { create(:workflow, name: 'Deactivated workflow', active: false) } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:volume_check) { create(:state, name: 'volume_check') } it 'can create and edit a batch' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Sample' within('div#sample-template') do fill_in 'identifier', with: 'sample1 sample2' @@ -51,7 +51,7 @@ it 'can create a batch with an Aker barcode' do create(:asset_type, name: 'Plate with Name', identifier_type: 'Name') visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Plate with Name' within('div#plate_with_name-template') do fill_in 'identifier', with: 'AKER-123' diff --git a/spec/features/create_and_update_workflow_spec.rb b/spec/features/create_and_update_workflow_spec.rb index e5461a62..9f4a659e 100644 --- a/spec/features/create_and_update_workflow_spec.rb +++ b/spec/features/create_and_update_workflow_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe 'can create workflow', js: true do +describe 'can create workflow', :js do it 'can create workflow' do create(:state, name: 'in_progress') create(:state, name: 'cherrypick') @@ -16,14 +16,14 @@ find_by_id('hasComment', visible: :all).first(:xpath, './/..').click find_by_id('qcFlow', visible: :all).first(:xpath, './/..').click find_by_id('cherrypickFlow', visible: :all).first(:xpath, './/..').click - click_button(text: 'Create') + click_on(text: 'Create') end expect(page).to have_content('The workflow was created.') expect(Workflow.count).to eq 1 find('a', text: 'Create a new workflow').click within('#add-workflow-modal') do fill_in 'Name', with: 'New workflow' - click_button(text: 'Create') + click_on(text: 'Create') end expect(page).to have_content('Name has already been taken') expect(Workflow.count).to eq 1 diff --git a/spec/features/create_complete_and_report_asset_standard_flow_spec.rb b/spec/features/create_complete_and_report_asset_standard_flow_spec.rb index 449e9673..07728c92 100644 --- a/spec/features/create_complete_and_report_asset_standard_flow_spec.rb +++ b/spec/features/create_complete_and_report_asset_standard_flow_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' -describe 'create complete and report assets within standard flow', js: true do +describe 'create complete and report assets within standard flow', :js do let!(:asset_type) { create(:asset_type, name: 'Tube', identifier_type: 'ID') } - let!(:workflow1) { create(:workflow, name: 'Workflow') } - let!(:workflow2) { create(:workflow, name: 'Reportable workflow', reportable: true) } + let!(:workflow_first) { create(:workflow, name: 'Workflow') } + let!(:workflow_second) { create(:workflow, name: 'Reportable workflow', reportable: true) } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:volume_check) { create(:state, name: 'volume_check') } let!(:quant) { create(:state, name: 'quant') } @@ -15,7 +15,7 @@ it 'can create and complete a non-reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' click_on 'Append to batch' expect(page).to have_content "The entry can't be created as the form contains some errors." @@ -31,22 +31,22 @@ click_on 'Save' expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.first.id}]" click_on 'Completed selected' expect(page).to have_content 'In progress is done for 123' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Volume check' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Quant' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Report Required' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') end it 'can create, complete and report a reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: 123 @@ -67,17 +67,17 @@ click_on 'Save' expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).to have_selector('table tr', count: 4) + expect(page).to have_css('table tr', count: 4) check "assets[#{Asset.second.id}]" click_on 'Completed selected' expect(page).to have_content 'In progress is done for 456' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) click_on 'Volume check' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Quant' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Report Required' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.second.id}]" click_on 'Reported selected' expect(page).to have_content 'Report required is done for 456' diff --git a/spec/features/create_complete_and_report_assets_cherrypick_flow_spec.rb b/spec/features/create_complete_and_report_assets_cherrypick_flow_spec.rb index a7b193a4..30c5fdd1 100644 --- a/spec/features/create_complete_and_report_assets_cherrypick_flow_spec.rb +++ b/spec/features/create_complete_and_report_assets_cherrypick_flow_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe 'create complete and report assets within Cherrypick flow', js: true do +describe 'create complete and report assets within Cherrypick flow', :js do let!(:asset_type) { create(:asset_type, name: 'Tube', identifier_type: 'ID') } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:volume_check) { create(:state, name: 'volume_check') } @@ -10,15 +10,15 @@ let!(:report_required) { create(:state, name: 'report_required') } let!(:completed) { create(:state, name: 'completed') } let!(:reported) { create(:state, name: 'reported') } - let!(:workflow1) { create(:cherrypick_workflow, name: 'Cherrypick workflow') } - let!(:workflow2) { create(:cherrypick_qc_workflow, name: 'Cherrypick QC workflow') } - let!(:workflow3) do + let!(:workflow_first) { create(:cherrypick_workflow, name: 'Cherrypick workflow') } + let!(:workflow_second) { create(:cherrypick_qc_workflow, name: 'Cherrypick QC workflow') } + let!(:workflow_third) do create(:cherrypick_qc_workflow, name: 'Cherrypick Reportable QC workflow', reportable: true) end it 'can create and complete a non-reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: 123 @@ -36,20 +36,20 @@ expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Cherrypick' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.first.id}]" click_on 'Completed selected' expect(page).to have_content 'Cherrypick is done for 123' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) end it 'can create and complete a non-reportable QC asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: '12345' @@ -67,39 +67,39 @@ expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Cherrypick' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.first.id}]" click_on 'Completed selected' expect(page).to have_content 'Cherrypick is done for 12345' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Volume check' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.first.id}]" click_on 'Volume checked selected' expect(page).to have_content 'Volume check is done for 12345' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Quant' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.first.id}]" click_on 'Completed selected' expect(page).to have_content 'Quant is done for 12345' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Report Required' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') end it 'can create, complete and report a reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: 123 @@ -121,40 +121,40 @@ expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Cherrypick' - expect(page).to have_selector('table tr', count: 4) + expect(page).to have_css('table tr', count: 4) check "assets[#{Asset.first.id}]" check "assets[#{Asset.third.id}]" click_on 'Completed selected' expect(page).to have_content 'Cherrypick is done for 123 and 789' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Volume check' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.first.id}]" check "assets[#{Asset.third.id}]" click_on 'Volume checked selected' expect(page).to have_content 'Volume check is done for 123 and 789' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Quant' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.third.id}]" click_on 'Completed selected' expect(page).to have_content 'Quant is done for 789' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Report Required' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.third.id}]" click_on 'Reported selected' expect(page).to have_content 'Report required is done for 789' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') end end diff --git a/spec/features/create_complete_and_report_assets_qc_flow_spec.rb b/spec/features/create_complete_and_report_assets_qc_flow_spec.rb index ce189e82..c9b7ea7a 100644 --- a/spec/features/create_complete_and_report_assets_qc_flow_spec.rb +++ b/spec/features/create_complete_and_report_assets_qc_flow_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe 'create complete and report assets within QC flow', js: true do +describe 'create complete and report assets within QC flow', :js do let!(:asset_type) { create(:asset_type, name: 'Tube', identifier_type: 'ID') } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:volume_check) { create(:state, name: 'volume_check') } @@ -10,12 +10,12 @@ let!(:report_required) { create(:state, name: 'report_required') } let!(:completed) { create(:state, name: 'completed') } let!(:reported) { create(:state, name: 'reported') } - let!(:workflow1) { create(:qc_workflow, name: 'QC workflow') } - let!(:workflow2) { create(:qc_workflow, name: 'Reportable QC workflow', reportable: true) } + let!(:workflow_first) { create(:qc_workflow, name: 'QC workflow') } + let!(:workflow_second) { create(:qc_workflow, name: 'Reportable QC workflow', reportable: true) } it 'can create and complete a non-reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: 123 @@ -31,26 +31,26 @@ click_on 'Save' expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Volume check' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.first.id}]" click_on 'Volume checked selected' expect(page).to have_content 'Volume check is done for 123' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Quant' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.first.id}]" click_on 'Completed selected' expect(page).to have_content 'Quant is done for 123' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Report Required' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') end it 'can create, complete and report a reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: 123 @@ -70,25 +70,25 @@ click_on 'Save' expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Volume check' - expect(page).to have_selector('table tr', count: 4) + expect(page).to have_css('table tr', count: 4) check "assets[#{Asset.first.id}]" check "assets[#{Asset.third.id}]" click_on 'Volume checked selected' expect(page).to have_content 'Volume check is done for 123 and 789' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Quant' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.third.id}]" click_on 'Completed selected' expect(page).to have_content 'Quant is done for 789' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Report Required' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.third.id}]" click_on 'Reported selected' expect(page).to have_content 'Report required is done for 789' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') end end diff --git a/spec/features/create_pipeline_destination_spec.rb b/spec/features/create_pipeline_destination_spec.rb index c356c763..55c07993 100644 --- a/spec/features/create_pipeline_destination_spec.rb +++ b/spec/features/create_pipeline_destination_spec.rb @@ -2,21 +2,21 @@ require 'rails_helper' -describe 'can create pipeline destination', js: true do +describe 'can create pipeline destination', :js do it 'can create pipeline destination' do visit '/' click_on 'Admin' find('a', text: 'Create a new destination').click within('#add-pipeline-destination-modal') do fill_in 'Name', with: 'New pipeline destination' - click_button(text: 'Create') + click_on(text: 'Create') end expect(page).to have_content('The pipeline destination was created.') expect(PipelineDestination.count).to eq 1 find('a', text: 'Create a new destination').click within('#add-pipeline-destination-modal') do fill_in 'Name', with: 'New pipeline destination' - click_button(text: 'Create') + click_on(text: 'Create') end expect(page).to have_content('Name has already been taken') expect(PipelineDestination.count).to eq 1 diff --git a/spec/features/generate_report_spec.rb b/spec/features/generate_report_spec.rb index e5d4220f..11e6a2cd 100644 --- a/spec/features/generate_report_spec.rb +++ b/spec/features/generate_report_spec.rb @@ -2,18 +2,18 @@ require 'rails_helper' -describe 'can generate report', js: true do - let!(:workflow1) { create(:workflow, name: 'Workflow1') } - let!(:workflow2) { create(:workflow, name: 'Workflow2') } +describe 'can generate report', :js do + let!(:workflow_first) { create(:workflow, name: 'Workflow_first') } + let!(:workflow_second) { create(:workflow, name: 'Workflow_second') } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:completed) { create(:state, name: 'completed') } - let!(:asset1) { create(:asset, workflow: workflow1, study: 'Study1', project: 'Project1') } - let!(:asset2) do - create(:asset, workflow: workflow1, study: 'Study1', project: 'Project2', + let!(:asset_first) { create(:asset, workflow: workflow_first, study: 'Study1', project: 'Project1') } + let!(:asset_second) do + create(:asset, workflow: workflow_first, study: 'Study1', project: 'Project2', cost_code: create(:cost_code, name: 'A1')) end - let!(:asset3) { create(:asset, workflow: workflow2, study: 'Study1', project: 'Project2') } - let!(:asset4) { create(:asset, workflow: workflow1) } + let!(:asset_third) { create(:asset, workflow: workflow_second, study: 'Study1', project: 'Project2') } + let!(:asset_fourth) { create(:asset, workflow: workflow_first) } before do Timecop.freeze(Time.local(2017, 3, 7)) @@ -24,22 +24,22 @@ end it 'can generate report' do - asset1.complete - asset2.complete - asset3.complete + asset_first.complete + asset_second.complete + asset_third.complete visit '/' click_on 'Admin' click_on 'Create a new report' - select('Workflow1', from: 'Workflow') + select('Workflow_first', from: 'Workflow') fill_in('start_date', with: '31/03/2017').send_keys(:escape) fill_in('end_date', with: '01/03/2017').send_keys(:escape) - click_button(text: 'Create report') + click_on(text: 'Create report') expect(page).to have_content('Start date should be earlier than the end date.') fill_in('start_date', with: '01/03/2017').send_keys(:escape) fill_in('end_date', with: '31/03/2017').send_keys(:escape) - click_button(text: 'Create report') - expect(page).to have_content("Report for 'Workflow1' workflow from 01/03/2017 to 31/03/2017") + click_on(text: 'Create report') + expect(page).to have_content("Report for 'Workflow_first' workflow from 01/03/2017 to 31/03/2017") within('table#report') do expect(page).to have_xpath('.//tr', count: 3) expect(page).to have_text('Study Project Cost code name Assets count') diff --git a/spec/features/search_batch_and_assets_spec.rb b/spec/features/search_batch_and_assets_spec.rb index 1c559648..7e103c6f 100644 --- a/spec/features/search_batch_and_assets_spec.rb +++ b/spec/features/search_batch_and_assets_spec.rb @@ -2,19 +2,19 @@ require 'rails_helper' -describe 'search assets and batches', js: true do - let!(:batch1) { create(:batch_with_assets) } - let!(:batch2) { create(:batch_with_assets) } - let!(:additional_asset1) { create(:asset, identifier: batch1.id) } - let!(:additional_asset2) { create(:asset, identifier: 'Identifier') } - let!(:search_string) { batch1.id.to_s } +describe 'search assets and batches', :js do + let!(:batch_first) { create(:batch_with_assets) } + let!(:batch_second) { create(:batch_with_assets) } + let!(:additional_asset_first) { create(:asset, identifier: batch_first.id) } + let!(:additional_asset_second) { create(:asset, identifier: 'Identifier') } + let!(:search_string) { batch_first.id.to_s } it 'can create and edit a batch' do visit '/' fill_in 'Search', with: search_string click_on 'search' expect(page).to have_content "Search results where batch id or asset identifier matches '#{search_string}'" - expect(page.all('tbody>tr').count).to eq batch1.assets.count + 1 + expect(page.all('tbody>tr').count).to eq batch_first.assets.count + 1 fill_in 'Search', with: 'Empty' click_on 'search' expect(page).to have_content "Search results where batch id or asset identifier matches 'Empty'" @@ -23,9 +23,9 @@ click_on 'search' expect(page).to have_content "Search results where batch id or asset identifier matches 'Identifier'" expect(page.all('tbody>tr').count).to eq 1 - fill_in 'Search', with: batch2.id + fill_in 'Search', with: batch_second.id click_on 'search' - expect(page).to have_content "Search results where batch id or asset identifier matches '#{batch2.id}'" - expect(page.all('tbody>tr').count).to eq batch2.assets.count + expect(page).to have_content "Search results where batch id or asset identifier matches '#{batch_second.id}'" + expect(page.all('tbody>tr').count).to eq batch_second.assets.count end end diff --git a/spec/models/asset_spec.rb b/spec/models/asset_spec.rb index 71708a80..a8bb63e6 100644 --- a/spec/models/asset_spec.rb +++ b/spec/models/asset_spec.rb @@ -209,9 +209,9 @@ end context 'state machine' do - let!(:state1) { create(:state, name: 'in_progress') } - let!(:state2) { create(:state, name: 'completed') } - let!(:state3) { create(:state, name: 'report_required') } + let!(:state_first) { create(:state, name: 'in_progress') } + let!(:state_second) { create(:state, name: 'completed') } + let!(:state_third) { create(:state, name: 'report_required') } let(:asset) { create(:asset) } let(:reportable_asset) do create(:asset, workflow: create(:workflow, reportable: true)) @@ -243,16 +243,16 @@ end context 'for report' do - let!(:workflow1) { create(:workflow, name: 'Workflow1') } - let!(:workflow2) { create(:workflow, name: 'Workflow2') } + let!(:workflow_first) { create(:workflow, name: 'Workflow_first') } + let!(:workflow_second) { create(:workflow, name: 'Workflow_second') } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:completed) { create(:state, name: 'completed') } let!(:cost_code) { create(:cost_code) } - let!(:asset1) { create(:asset, workflow: workflow1, study: 'Study1', project: 'Project1') } - let!(:asset2) { create(:asset, workflow: workflow1, study: 'Study1', project: 'Project2', cost_code:) } - let!(:asset3) { create(:asset, workflow: workflow2, study: 'Study1', project: 'Project2') } - let!(:asset4) { create(:asset, workflow: workflow2, study: 'Study1', project: 'Project2') } - let!(:asset5) { create(:asset, workflow: workflow1) } + let!(:asset_first) { create(:asset, workflow: workflow_first, study: 'Study1', project: 'Project1') } + let!(:asset_second) { create(:asset, workflow: workflow_first, study: 'Study1', project: 'Project2', cost_code:) } + let!(:asset_third) { create(:asset, workflow: workflow_second, study: 'Study1', project: 'Project2') } + let!(:asset_fourth) { create(:asset, workflow: workflow_second, study: 'Study1', project: 'Project2') } + let!(:asset_fifth) { create(:asset, workflow: workflow_first) } after do Timecop.return @@ -260,17 +260,17 @@ it 'generates the right data for reports' do Timecop.freeze(Time.local(2017, 3, 7)) - asset1.complete - asset2.complete - asset3.complete - asset4.complete + asset_first.complete + asset_second.complete + asset_third.complete + asset_fourth.complete start_date = Date.today - 1 end_date = Date.today + 1 - expect(Asset.generate_report_data(start_date, end_date, workflow1)) + expect(Asset.generate_report_data(start_date, end_date, workflow_first)) .to eq([{ 'study' => 'Study1', 'project' => 'Project1', 'cost_code_name' => nil, 'assets_count' => 1 }, { 'study' => 'Study1', 'project' => 'Project2', 'cost_code_name' => cost_code.name, 'assets_count' => 1 }]) - expect(Asset.generate_report_data(start_date, end_date, workflow2)) + expect(Asset.generate_report_data(start_date, end_date, workflow_second)) .to eq([{ 'study' => 'Study1', 'project' => 'Project2', 'cost_code_name' => nil, 'assets_count' => 2 }]) end diff --git a/spec/models/batch_creator_spec.rb b/spec/models/batch_creator_spec.rb index 172fb14f..a100b32e 100644 --- a/spec/models/batch_creator_spec.rb +++ b/spec/models/batch_creator_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Batch::Creator do +describe 'Batch::Creator' do before do Timecop.freeze(Time.local(2017, 3, 7)) end diff --git a/spec/models/batch_updater_spec.rb b/spec/models/batch_updater_spec.rb index 82f09925..c0b270d2 100644 --- a/spec/models/batch_updater_spec.rb +++ b/spec/models/batch_updater_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Batch::Updater do +describe 'Batch::Updater' do before do Timecop.freeze(Time.local(2017, 3, 7)) end diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb index 88239c12..631262fe 100644 --- a/spec/models/report_spec.rb +++ b/spec/models/report_spec.rb @@ -19,9 +19,9 @@ let!(:workflow) { create(:workflow, name: 'Workflow') } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:completed) { create(:state, name: 'completed') } - let(:asset1) { create(:asset, workflow:, study: 'Study1', project: 'Project1') } - let(:asset2) { create(:asset, workflow:, study: 'Study1', project: 'Project2') } - let(:asset3) { create(:asset, workflow:, study: 'Study1', project: 'Project2') } + let(:asset_first) { create(:asset, workflow:, study: 'Study1', project: 'Project1') } + let(:asset_second) { create(:asset, workflow:, study: 'Study1', project: 'Project2') } + let(:asset_third) { create(:asset, workflow:, study: 'Study1', project: 'Project2') } before do Timecop.freeze(Time.local(2017, 4, 7)) @@ -37,9 +37,9 @@ end it 'creates the right csv' do - asset1.complete - asset2.complete - asset3.complete + asset_first.complete + asset_second.complete + asset_third.complete asset4 = create(:asset, workflow:) report = Report.new(workflow:, start_date: '01/04/2017', end_date: '15/04/2017') expected_report = <<~REPORT diff --git a/spec/presenters/asset_index_presenter_spec.rb b/spec/presenters/asset_index_presenter_spec.rb index c50ff138..912e1841 100644 --- a/spec/presenters/asset_index_presenter_spec.rb +++ b/spec/presenters/asset_index_presenter_spec.rb @@ -2,7 +2,7 @@ require './app/presenters/asset/index' require './spec/presenters/shared_presenter_behaviour' -describe Presenter::AssetPresenter::Index do +describe 'Presenter::AssetPresenter::Index' do shared_context 'shared mocks' do let(:mock_type) do double('mock_type', @@ -17,21 +17,21 @@ variable_samples: true) end let(:mock_workflow) { double('mock_wf', name: 'Work', has_comment: true) } - let(:asset1) do - double('asset_1', - identifier: 'asset_1', + let(:asset_first) do + double('asset_first', + identifier: 'asset_first', asset_type: mock_type, workflow: mock_workflow, study: 'study') end - let(:asset2) do - double('asset_2', - identifier: 'asset_2', + let(:asset_second) do + double('asset_second', + identifier: 'asset_second', asset_type: mock_type2, workflow: mock_workflow, study: 'study') end - let(:assets) { [asset1, asset2] } + let(:assets) { [asset_first, asset_second] } let!(:state) { create(:state, name: 'in_progress') } let(:presenter) { Presenter::AssetPresenter::Index.new(assets, search, state) } end @@ -47,7 +47,7 @@ it 'yields each asset of type x in turn for each_asset(x)' do expect { |b| presenter.each_asset('Type', &b) }.to yield_with_args(Presenter::AssetPresenter::Asset) presenter.each_asset('Type') do |asset| - expect(asset.identifier).to eq('asset_1') + expect(asset.identifier).to eq('asset_first') end end end diff --git a/spec/presenters/asset_presenter_spec.rb b/spec/presenters/asset_presenter_spec.rb index 00d1b321..c6b9281e 100644 --- a/spec/presenters/asset_presenter_spec.rb +++ b/spec/presenters/asset_presenter_spec.rb @@ -2,7 +2,7 @@ require './app/presenters/asset/asset' require 'timecop' -describe Presenter::AssetPresenter::Asset do +describe 'Presenter::AssetPresenter::Asset' do shared_examples 'shared behaviour' do let(:mock_type) do double('mock_type', diff --git a/spec/presenters/asset_type_presenter_spec.rb b/spec/presenters/asset_type_presenter_spec.rb index aa0ab242..b3055bb0 100644 --- a/spec/presenters/asset_type_presenter_spec.rb +++ b/spec/presenters/asset_type_presenter_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Presenter::AssetTypePresenter::AssetType do +describe 'Presenter::AssetTypePresenter::AssetType' do describe '#validates_with' do let(:asset_type) { create(:asset_type, identifier_data_type:) } let(:presenter) { Presenter::AssetTypePresenter::AssetType.new(asset_type) } diff --git a/spec/presenters/batch_new_presenter_spec.rb b/spec/presenters/batch_new_presenter_spec.rb index 1f060829..ecd25e15 100644 --- a/spec/presenters/batch_new_presenter_spec.rb +++ b/spec/presenters/batch_new_presenter_spec.rb @@ -2,7 +2,7 @@ require './app/presenters/batch/new' require './spec/presenters/shared_presenter_behaviour' -describe Presenter::BatchPresenter::New do +describe 'Presenter::BatchPresenter::New' do let(:presenter) { Presenter::BatchPresenter::New.new } context 'always' do diff --git a/spec/presenters/batch_show_presenter_spec.rb b/spec/presenters/batch_show_presenter_spec.rb index 3ec550c4..7d541fb7 100644 --- a/spec/presenters/batch_show_presenter_spec.rb +++ b/spec/presenters/batch_show_presenter_spec.rb @@ -2,22 +2,22 @@ require './app/presenters/batch/show' require './spec/presenters/shared_presenter_behaviour' -describe Presenter::BatchPresenter::Show do +describe 'Presenter::BatchPresenter::Show' do context 'with a batch' do let(:presenter) { Presenter::BatchPresenter::Show.new(test_batch) } - let(:test_batch) { double('batch', assets: [asset1, asset2]) } + let(:test_batch) { double('batch', assets: [asset_first, asset_second]) } let(:comment) { double('comment', comment: 'A comment') } - let(:asset2) do - double('asset_2', - identifier: 'asset_2', + let(:asset_second) do + double('asset_second', + identifier: 'asset_second', asset_type: mock_type, workflow: mock_workflow, study: 'study', comment:) end - let(:asset1) do - double('asset_1', - identifier: 'asset_1', + let(:asset_first) do + double('asset_first', + identifier: 'asset_first', asset_type: mock_type, workflow: mock_workflow, study: 'study', @@ -29,8 +29,8 @@ include_examples('shared presenter behaviour') it 'yields each asset in the batch in turn for each_asset' do - expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset1).and_call_original - expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset2).and_call_original + expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset_first).and_call_original + expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset_second).and_call_original expect do |b| presenter.each_asset(&b) diff --git a/spec/presenters/report_new_presenter_spec.rb b/spec/presenters/report_new_presenter_spec.rb index a60e56ab..ce1a84e4 100644 --- a/spec/presenters/report_new_presenter_spec.rb +++ b/spec/presenters/report_new_presenter_spec.rb @@ -2,7 +2,7 @@ require './app/presenters/report/new' require './spec/presenters/shared_presenter_behaviour' -describe Presenter::ReportPresenter::New do +describe 'Presenter::ReportPresenter::New' do let(:presenter) { Presenter::ReportPresenter::New.new } context 'always' do diff --git a/spec/presenters/report_show_presenter_spec.rb b/spec/presenters/report_show_presenter_spec.rb index 14531c15..6d3fff56 100644 --- a/spec/presenters/report_show_presenter_spec.rb +++ b/spec/presenters/report_show_presenter_spec.rb @@ -1,43 +1,48 @@ +# frozen_string_literal: true + require 'rails_helper' require './app/presenters/report/show' require './spec/presenters/shared_presenter_behaviour' -describe Presenter::ReportPresenter::Show do +describe 'Presenter::ReportPresenter::Show' do let(:workflow) { build(:workflow, name: 'Workflow') } let!(:report) { Report.new(workflow:, start_date: '01/04/2017', end_date: '15/04/2017') } - let!(:completed) { create(:state, name: 'completed') } - let(:asset1) { create(:asset, workflow:, study: 'Study1', project: 'Project1') } - let(:asset2) do + let(:asset_first) { create(:asset, workflow:, study: 'Study1', project: 'Project1') } + let(:asset_second) do create(:asset, workflow:, study: 'Study1', project: 'Project2', cost_code: create(:cost_code, name: 'A1')) end let(:presenter) { Presenter::ReportPresenter::Show.new(report) } - context 'always' do + before do + create(:state, name: 'completed') + end + + context 'when always' do include_examples('shared presenter behaviour') end - it 'genertes correct html for report' do - Timecop.freeze(Time.local(2017, 4, 7)) - asset1.complete - asset2.complete + it 'generates correct html for report' do + Timecop.freeze(Time.zone.local(2017, 4, 7)) + asset_first.complete + asset_second.complete expect(presenter.title).to eq "Report for 'Workflow' workflow from 01/04/2017 to 15/04/2017" - expect(presenter.column_names).to eq "Study" + - "Project" + - "Cost code name" + + expect(presenter.column_names).to eq "Study" \ + "Project" \ + "Cost code name" \ "Assets count" - expect(presenter.rows).to eq '' + - " 1 " + - "Study1" + - "Project1" + - "Not defined" + - "1" + - '' + - '' + - " 2 " + - "Study1" + - "Project2" + - "A1" + - "1" + + expect(presenter.rows).to eq '' \ + " 1 " \ + "Study1" \ + "Project1" \ + "Not defined" \ + "1" \ + '' \ + '' \ + " 2 " \ + "Study1" \ + "Project2" \ + "A1" \ + "1" \ '' expect(presenter.flash).to be_nil expect(presenter.page).to eq :'reports/show' diff --git a/spec/presenters/shared_presenter_behaviour.rb b/spec/presenters/shared_presenter_behaviour.rb index 131e7f8b..4f361f47 100644 --- a/spec/presenters/shared_presenter_behaviour.rb +++ b/spec/presenters/shared_presenter_behaviour.rb @@ -1,17 +1,17 @@ shared_examples 'shared presenter behaviour' do - let!(:asset_type_1) do + let!(:asset_type_first) do create(:asset_type, name: 'type1', identifier_type: 'id1', has_sample_count: true) end - let!(:asset_type_2) do + let!(:asset_type_second) do create(:asset_type, name: 'type2', identifier_type: 'id2', has_sample_count: false) end - let!(:workflow_1) do + let!(:workflow) do create(:qc_workflow, name: 'wf1', has_comment: true, @@ -38,6 +38,6 @@ it 'yields only active workflows (rev)' do expect { |b| presenter.active_workflows(&b) } - .to yield_with_args('wf1', true, workflow_1.id, true, true, workflow_1.cherrypick_flow, 1, true) + .to yield_with_args('wf1', true, workflow.id, true, true, workflow.cherrypick_flow, 1, true) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 87da827f..0dad5843 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -80,7 +80,7 @@ DatabaseCleaner.strategy = :transaction end - config.before(:each, js: true) do + config.before(:each, :js) do DatabaseCleaner.strategy = :truncation end From 920ad80f3ef8ed7bfc053042f105fe3d4701da21 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 19:35:20 +0000 Subject: [PATCH 21/49] Update mysql2 to version 0.5.6 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3c182696..3b3517c7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -131,7 +131,7 @@ GEM mini_mime (1.1.5) mini_portile2 (2.8.5) minitest (5.22.2) - mysql2 (0.5.5) + mysql2 (0.5.6) net-imap (0.3.4) date net-protocol From a11c6f9465b461a4def72068576d1a9ed3ce60e0 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 19:40:32 +0000 Subject: [PATCH 22/49] Update net-smtp to version 0.4.0.1 --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3c182696..9e762b94 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -137,9 +137,9 @@ GEM 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.1) net-protocol nio4r (2.7.0) nokogiri (1.16.2) @@ -278,7 +278,7 @@ GEM thor (1.3.0) tilt (2.0.11) timecop (0.9.8) - timeout (0.3.1) + timeout (0.4.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) From c53bb84e83d2d8ed6e28c83fc6191937b2f18375 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Mon, 26 Feb 2024 13:21:57 +0000 Subject: [PATCH 23/49] Fix method name in Proc class --- .rubocop.yml | 1 + config/initializers/01_proc.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index a3ec06dc..f6c69f84 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,5 +15,6 @@ require: - rubocop-rspec AllCops: NewCops: enable + SuggestExtensions: false Layout/LineLength: Max: 120 diff --git a/config/initializers/01_proc.rb b/config/initializers/01_proc.rb index 5bea7b3f..e9b1cdfe 100644 --- a/config/initializers/01_proc.rb +++ b/config/initializers/01_proc.rb @@ -4,7 +4,7 @@ def callback(callable, *args) self === Class.new do method_name = callable.to_sym define_method(method_name) { |&block| block ? block.call(*args) : true } - define_method("#{method_name}?") { true } + define_method(:"#{method_name}?") { true } def method_missing(*_args) false end From d331b3f4a24f40da53d029980f61c79c2fe95ef2 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 13:55:29 +0000 Subject: [PATCH 24/49] Update rails to version 6.1.7.7 --- Gemfile.lock | 118 +++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5963536d..f64469ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,60 +1,60 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) + actioncable (6.1.7.7) + actionpack (= 6.1.7.7) + activesupport (= 6.1.7.7) 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 (6.1.7.7) + actionpack (= 6.1.7.7) + activejob (= 6.1.7.7) + activerecord (= 6.1.7.7) + activestorage (= 6.1.7.7) + activesupport (= 6.1.7.7) 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) + actionmailer (6.1.7.7) + actionpack (= 6.1.7.7) + actionview (= 6.1.7.7) + activejob (= 6.1.7.7) + activesupport (= 6.1.7.7) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.7.6) - actionview (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionpack (6.1.7.7) + actionview (= 6.1.7.7) + activesupport (= 6.1.7.7) 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.6) - actionpack (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + actiontext (6.1.7.7) + actionpack (= 6.1.7.7) + activerecord (= 6.1.7.7) + activestorage (= 6.1.7.7) + activesupport (= 6.1.7.7) nokogiri (>= 1.8.5) - actionview (6.1.7.6) - activesupport (= 6.1.7.6) + actionview (6.1.7.7) + activesupport (= 6.1.7.7) 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 (6.1.7.7) + activesupport (= 6.1.7.7) globalid (>= 0.3.6) - 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) + activemodel (6.1.7.7) + activesupport (= 6.1.7.7) + activerecord (6.1.7.7) + activemodel (= 6.1.7.7) + activesupport (= 6.1.7.7) + activestorage (6.1.7.7) + actionpack (= 6.1.7.7) + activejob (= 6.1.7.7) + activerecord (= 6.1.7.7) + activesupport (= 6.1.7.7) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.6) + activesupport (6.1.7.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -92,7 +92,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.1) docile (1.4.0) erubi (1.12.0) @@ -133,14 +133,14 @@ GEM mini_portile2 (2.8.5) minitest (5.22.2) mysql2 (0.5.6) - net-imap (0.3.4) + net-imap (0.4.10) 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.1) net-protocol nio4r (2.7.0) nokogiri (1.16.2) @@ -159,25 +159,25 @@ GEM puma (6.4.2) nio4r (~> 2.0) racc (1.7.3) - rack (2.2.8) + rack (2.2.8.1) rack-mini-profiler (3.3.1) rack (>= 1.2.0) 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 (6.1.7.7) + actioncable (= 6.1.7.7) + actionmailbox (= 6.1.7.7) + actionmailer (= 6.1.7.7) + actionpack (= 6.1.7.7) + actiontext (= 6.1.7.7) + actionview (= 6.1.7.7) + activejob (= 6.1.7.7) + activemodel (= 6.1.7.7) + activerecord (= 6.1.7.7) + activestorage (= 6.1.7.7) + activesupport (= 6.1.7.7) bundler (>= 1.15.0) - railties (= 6.1.7.6) + railties (= 6.1.7.7) sprockets-rails (>= 2.0.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) @@ -186,9 +186,9 @@ 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 (6.1.7.7) + actionpack (= 6.1.7.7) + activesupport (= 6.1.7.7) method_source rake (>= 12.2) thor (~> 1.0) @@ -283,7 +283,7 @@ GEM thor (1.3.0) tilt (2.0.11) timecop (0.9.8) - timeout (0.3.1) + timeout (0.4.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) From 2762bcb7416dc8ee371628389e0064574d51e97f Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 04:15:37 +0000 Subject: [PATCH 25/49] Update launchy to version 3.0.0 --- Gemfile.lock | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index f64469ee..47e8886c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,6 +83,7 @@ GEM capybara-selenium (0.0.6) capybara selenium-webdriver + childprocess (5.0.0) coderay (1.1.3) concurrent-ruby (1.2.3) crass (1.0.6) @@ -116,8 +117,9 @@ GEM thor (>= 0.14, < 2.0) json (2.7.1) language_server-protocol (3.17.0.3) - launchy (2.5.2) + launchy (3.0.0) addressable (~> 2.8) + childprocess (~> 5.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) From 4f490225de6305c92ecd52801f616cba35f6773d Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:25:25 +0000 Subject: [PATCH 26/49] Update rubocop to version 1.62.1 --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f64469ee..89279d16 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -217,7 +217,7 @@ GEM rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) - rubocop (1.60.2) + rubocop (1.62.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -225,11 +225,11 @@ GEM rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) + rubocop-ast (1.31.2) + parser (>= 3.3.0.4) rubocop-capybara (2.20.0) rubocop (~> 1.41) rubocop-factory_bot (2.25.1) From 3134fb7176fac8cb12ef3a2307f771498016351a Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 21:15:54 +0000 Subject: [PATCH 27/49] Update rubocop-rspec to version 2.27.1 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 97d38a08..d5ece230 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -244,7 +244,7 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rspec (2.26.1) + rubocop-rspec (2.27.1) rubocop (~> 1.40) rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) From f4fba7b3065b651751b8d79077832c76703582f8 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 21:30:32 +0000 Subject: [PATCH 28/49] Update rubocop-rails to version 2.24.0 --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d5ece230..64884c1a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -106,7 +106,7 @@ GEM ffi (1.15.5) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.1) + i18n (1.14.4) concurrent-ruby (~> 1.0) jbuilder (2.11.5) actionview (>= 5.0.0) @@ -239,11 +239,11 @@ GEM rubocop-performance (1.20.2) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rails (2.23.1) + rubocop-rails (2.24.0) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) rubocop-rspec (2.27.1) rubocop (~> 1.40) rubocop-capybara (~> 2.17) From 6b160a7358277bff6a8fdcfccb2a41ee88e0a7e9 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 26 Mar 2024 05:10:21 +0000 Subject: [PATCH 29/49] Update rubocop-rails to version 2.24.1 --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 64884c1a..8931f57c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -133,7 +133,7 @@ GEM method_source (1.0.0) mini_mime (1.1.5) mini_portile2 (2.8.5) - minitest (5.22.2) + minitest (5.22.3) mysql2 (0.5.6) net-imap (0.4.10) date @@ -161,7 +161,7 @@ GEM puma (6.4.2) nio4r (~> 2.0) racc (1.7.3) - rack (2.2.8.1) + rack (2.2.9) rack-mini-profiler (3.3.1) rack (>= 1.2.0) rack-test (2.1.0) @@ -239,7 +239,7 @@ GEM rubocop-performance (1.20.2) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rails (2.24.0) + rubocop-rails (2.24.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) From b868148997c50ff3b2209cc61fb98492b471e4f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 16:15:27 +0000 Subject: [PATCH 30/49] Bump rdoc from 6.4.0 to 6.6.3.1 Bumps [rdoc](https://github.com/ruby/rdoc) from 6.4.0 to 6.6.3.1. - [Release notes](https://github.com/ruby/rdoc/releases) - [Changelog](https://github.com/ruby/rdoc/blob/master/History.rdoc) - [Commits](https://github.com/ruby/rdoc/compare/v6.4.0...v6.6.3.1) --- updated-dependencies: - dependency-name: rdoc dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8931f57c..06d1018a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -155,7 +155,7 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - psych (4.0.4) + psych (5.1.2) stringio public_suffix (5.0.4) puma (6.4.2) @@ -196,7 +196,7 @@ GEM thor (~> 1.0) rainbow (3.1.1) rake (13.1.0) - rdoc (6.4.0) + rdoc (6.6.3.1) psych (>= 4.0.0) regexp_parser (2.9.0) rexml (3.2.6) @@ -281,7 +281,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - stringio (3.0.2) + stringio (3.1.0) thor (1.3.0) tilt (2.0.11) timecop (0.9.8) From c85f8290461a8eb72d5b22d7edbac13877909d70 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 19:05:29 +0000 Subject: [PATCH 31/49] Update net-smtp to version 0.5.0 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 06d1018a..cdfbdfb7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -142,7 +142,7 @@ GEM net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.0) net-protocol nio4r (2.7.0) nokogiri (1.16.2) From 842953df66986d651618b744f04abfa14430117b Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 19:50:32 +0000 Subject: [PATCH 32/49] Update spring to version 4.2.1 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 06d1018a..f577836b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -273,7 +273,7 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - spring (4.1.3) + spring (4.2.1) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) From eff5dc8db9c1da8762271dcdf86b78bace61a7ac Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:20:37 +0000 Subject: [PATCH 33/49] Update rubocop to version 1.63.4 --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 06d1018a..6e612aad 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -115,7 +115,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.7.1) + json (2.7.2) language_server-protocol (3.17.0.3) launchy (3.0.0) addressable (~> 2.8) @@ -149,7 +149,7 @@ GEM mini_portile2 (~> 2.8.2) racc (~> 1.4) parallel (1.24.0) - parser (3.3.0.5) + parser (3.3.1.0) ast (~> 2.4.1) racc pry (0.14.2) @@ -219,7 +219,7 @@ GEM rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) - rubocop (1.62.1) + rubocop (1.63.4) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -230,8 +230,8 @@ GEM rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.2) - parser (>= 3.3.0.4) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) rubocop-capybara (2.20.0) rubocop (~> 1.41) rubocop-factory_bot (2.25.1) From 9e66a5439630f5b47a93ce72b750cd6fc01a759e Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 19:25:26 +0000 Subject: [PATCH 34/49] Update jbuilder to version 2.12.0 --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6e612aad..7327f081 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,7 +108,7 @@ GEM activesupport (>= 6.1) i18n (1.14.4) concurrent-ruby (~> 1.0) - jbuilder (2.11.5) + jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) jquery-rails (4.6.0) @@ -132,7 +132,7 @@ GEM matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.5) - mini_portile2 (2.8.5) + mini_portile2 (2.8.6) minitest (5.22.3) mysql2 (0.5.6) net-imap (0.4.10) @@ -145,7 +145,7 @@ GEM net-smtp (0.4.0.1) net-protocol nio4r (2.7.0) - nokogiri (1.16.2) + nokogiri (1.16.4) mini_portile2 (~> 2.8.2) racc (~> 1.4) parallel (1.24.0) From b01c2a810e0efdc83d5f3e95d562cc630734ea20 Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Thu, 30 May 2024 11:47:30 +0100 Subject: [PATCH 35/49] Create assign_issue_number.yml --- .github/workflows/assign_issue_number.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/assign_issue_number.yml diff --git a/.github/workflows/assign_issue_number.yml b/.github/workflows/assign_issue_number.yml new file mode 100644 index 00000000..ef05cbc5 --- /dev/null +++ b/.github/workflows/assign_issue_number.yml @@ -0,0 +1,12 @@ +name: Assign Issue Number + +on: + issues: + types: [opened] + +jobs: + call-add-to-project: + uses: sanger/.github/.github/workflows/generate-issue-number.yml@master + secrets: + app_id: ${{ secrets.ISSUE_GEN_APP_ID }} + app_key: ${{ secrets.ISSUE_GEN_APP_KEY }} From 996ed74032f7ad42ff0351e40d659d627d2d6f8b Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Thu, 30 May 2024 11:56:12 +0100 Subject: [PATCH 36/49] Update assign_issue_number.yml --- .github/workflows/assign_issue_number.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/assign_issue_number.yml b/.github/workflows/assign_issue_number.yml index ef05cbc5..90630b1e 100644 --- a/.github/workflows/assign_issue_number.yml +++ b/.github/workflows/assign_issue_number.yml @@ -6,7 +6,7 @@ on: jobs: call-add-to-project: - uses: sanger/.github/.github/workflows/generate-issue-number.yml@master + uses: sanger/.github/.github/workflows/generate_issue_number.yml@master secrets: app_id: ${{ secrets.ISSUE_GEN_APP_ID }} app_key: ${{ secrets.ISSUE_GEN_APP_KEY }} From 3b4f5bd6cf6dc694a1f9019458241f257db2f835 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 6 Jun 2024 14:28:42 +0100 Subject: [PATCH 37/49] reate add_prs_to_tech_debt_project.yml to add dependency updates to the technical debt project --- .../add_prs_to_tech_debt_project.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/add_prs_to_tech_debt_project.yml diff --git a/.github/workflows/add_prs_to_tech_debt_project.yml b/.github/workflows/add_prs_to_tech_debt_project.yml new file mode 100644 index 00000000..07d1e53d --- /dev/null +++ b/.github/workflows/add_prs_to_tech_debt_project.yml @@ -0,0 +1,19 @@ +# Calls a reusable workflow in the .github repo, +# which adds the PR that triggered this to the Technical Debt project board, if it is a depfu one. +# Passes the 'PSD-AddToProject' GitHub App key and App Id as secrets to the reusable workflow. + +name: Add dependencies to technical debt project + +on: + # Triggered on creation of pull requests with any label, + # or when a label is added to an existing pull request. + pull_request: + types: + - labeled + +jobs: + call-workflow-add_to_technical_debt_project: + uses: sanger/.github/.github/workflows/add_to_tech_debt_project_reusable.yml@master + secrets: + app_id: ${{ secrets.ADD_TO_PROJECT_APP_ID_PSD }} + app_key: ${{ secrets.ADD_TO_PROJECT_APP_KEY_PSD }} \ No newline at end of file From e06144165d88c3c6558585b6f510a48ee2072b69 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:33:52 +0100 Subject: [PATCH 38/49] New line added at end of file --- .github/workflows/add_prs_to_tech_debt_project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add_prs_to_tech_debt_project.yml b/.github/workflows/add_prs_to_tech_debt_project.yml index 07d1e53d..221de81e 100644 --- a/.github/workflows/add_prs_to_tech_debt_project.yml +++ b/.github/workflows/add_prs_to_tech_debt_project.yml @@ -16,4 +16,4 @@ jobs: uses: sanger/.github/.github/workflows/add_to_tech_debt_project_reusable.yml@master secrets: app_id: ${{ secrets.ADD_TO_PROJECT_APP_ID_PSD }} - app_key: ${{ secrets.ADD_TO_PROJECT_APP_KEY_PSD }} \ No newline at end of file + app_key: ${{ secrets.ADD_TO_PROJECT_APP_KEY_PSD }} From 44bc0114fbe120a2f46a400ed49bb97ffd1ac3d8 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sat, 8 Jun 2024 19:11:38 +0000 Subject: [PATCH 39/49] Update rubocop-rspec to version 2.31.0 --- Gemfile.lock | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6e612aad..6b6bd083 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -148,8 +148,8 @@ GEM nokogiri (1.16.2) mini_portile2 (~> 2.8.2) racc (~> 1.4) - parallel (1.24.0) - parser (3.3.1.0) + parallel (1.25.1) + parser (3.3.2.0) ast (~> 2.4.1) racc pry (0.14.2) @@ -160,7 +160,7 @@ GEM public_suffix (5.0.4) puma (6.4.2) nio4r (~> 2.0) - racc (1.7.3) + racc (1.8.0) rack (2.2.9) rack-mini-profiler (3.3.1) rack (>= 1.2.0) @@ -198,8 +198,9 @@ GEM rake (13.1.0) rdoc (6.6.3.1) psych (>= 4.0.0) - regexp_parser (2.9.0) - rexml (3.2.6) + regexp_parser (2.9.2) + rexml (3.2.8) + strscan (>= 3.0.9) rspec-collection_matchers (1.2.1) rspec-expectations (>= 2.99.0.beta1) rspec-core (3.5.4) @@ -219,7 +220,7 @@ GEM rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) - rubocop (1.63.4) + rubocop (1.64.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -232,9 +233,9 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.31.3) parser (>= 3.3.1.0) - rubocop-capybara (2.20.0) + rubocop-capybara (2.21.0) rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) + rubocop-factory_bot (2.26.0) rubocop (~> 1.41) rubocop-performance (1.20.2) rubocop (>= 1.48.1, < 2.0) @@ -244,10 +245,13 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (2.27.1) + rubocop-rspec (2.31.0) rubocop (~> 1.40) rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) + rubocop-rspec_rails (~> 2.28) + rubocop-rspec_rails (2.29.0) + rubocop (~> 1.40) ruby-progressbar (1.13.0) rubyzip (2.3.2) sass-rails (6.0.0) @@ -282,6 +286,7 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) stringio (3.1.0) + strscan (3.1.0) thor (1.3.0) tilt (2.0.11) timecop (0.9.8) From bde6f4e1c625a58533ad9c8dc1f520e4e42f8dae Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:10:50 +0000 Subject: [PATCH 40/49] Update rails to version 7.0.8.1 --- Gemfile | 2 +- Gemfile.lock | 154 ++++++++++++++++++++++++++------------------------- 2 files changed, 81 insertions(+), 75 deletions(-) diff --git a/Gemfile b/Gemfile index 00f80e61..5d724ccd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 6.1.6' +gem 'rails', '~> 7.0.8' # Use mysql2 as the database for Active Record gem 'mysql2' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index cbf05d40..77726f91 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,65 +1,71 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.7) - actionpack (= 6.1.7.7) - activesupport (= 6.1.7.7) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.7) - actionpack (= 6.1.7.7) - activejob (= 6.1.7.7) - activerecord (= 6.1.7.7) - activestorage (= 6.1.7.7) - activesupport (= 6.1.7.7) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (>= 2.7.1) - actionmailer (6.1.7.7) - actionpack (= 6.1.7.7) - actionview (= 6.1.7.7) - activejob (= 6.1.7.7) - activesupport (= 6.1.7.7) + net-imap + net-pop + net-smtp + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7.7) - actionview (= 6.1.7.7) - activesupport (= 6.1.7.7) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) + 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.7) - actionpack (= 6.1.7.7) - activerecord (= 6.1.7.7) - activestorage (= 6.1.7.7) - activesupport (= 6.1.7.7) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.7) - activesupport (= 6.1.7.7) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.7) - activesupport (= 6.1.7.7) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.3.6) - activemodel (6.1.7.7) - activesupport (= 6.1.7.7) - activerecord (6.1.7.7) - activemodel (= 6.1.7.7) - activesupport (= 6.1.7.7) - activestorage (6.1.7.7) - actionpack (= 6.1.7.7) - activejob (= 6.1.7.7) - activerecord (= 6.1.7.7) - activesupport (= 6.1.7.7) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.7) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) @@ -70,7 +76,7 @@ GEM bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) - builder (3.2.4) + builder (3.3.0) capybara (3.40.0) addressable matrix @@ -85,7 +91,7 @@ GEM selenium-webdriver childprocess (5.0.0) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.3) crass (1.0.6) database_cleaner (2.0.2) database_cleaner-active_record (>= 2, < 3) @@ -96,7 +102,7 @@ GEM date (3.3.4) diff-lcs (1.5.1) docile (1.4.0) - erubi (1.12.0) + erubi (1.13.0) exception_notification (4.5.0) actionmailer (>= 5.2, < 8) activesupport (>= 5.2, < 8) @@ -106,7 +112,7 @@ GEM ffi (1.15.5) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.4) + i18n (1.14.5) concurrent-ruby (~> 1.0) jbuilder (2.12.0) actionview (>= 5.0.0) @@ -128,14 +134,14 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) - method_source (1.0.0) + method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.6) - minitest (5.22.3) + mini_portile2 (2.8.7) + minitest (5.24.1) mysql2 (0.5.6) - net-imap (0.4.10) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) @@ -144,8 +150,8 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.0) - nokogiri (1.16.4) + nio4r (2.7.3) + nokogiri (1.16.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) parallel (1.25.1) @@ -166,21 +172,20 @@ GEM rack (>= 1.2.0) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.7) - actioncable (= 6.1.7.7) - actionmailbox (= 6.1.7.7) - actionmailer (= 6.1.7.7) - actionpack (= 6.1.7.7) - actiontext (= 6.1.7.7) - actionview (= 6.1.7.7) - activejob (= 6.1.7.7) - activemodel (= 6.1.7.7) - activerecord (= 6.1.7.7) - activestorage (= 6.1.7.7) - activesupport (= 6.1.7.7) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) bundler (>= 1.15.0) - railties (= 6.1.7.7) - sprockets-rails (>= 2.0.0) + railties (= 7.0.8.1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -188,14 +193,15 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.7.7) - actionpack (= 6.1.7.7) - activesupport (= 6.1.7.7) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rdoc (6.6.3.1) psych (>= 4.0.0) regexp_parser (2.9.2) @@ -281,13 +287,13 @@ GEM sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + sprockets-rails (3.5.1) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) stringio (3.1.0) strscan (3.1.0) - thor (1.3.0) + thor (1.3.1) tilt (2.0.11) timecop (0.9.8) timeout (0.4.1) @@ -310,7 +316,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.13) + zeitwerk (2.6.16) PLATFORMS ruby @@ -332,7 +338,7 @@ DEPENDENCIES pry puma rack-mini-profiler - rails (~> 6.1.6) + rails (~> 7.0.8) rspec-collection_matchers rspec-rails (~> 3.5.0) rubocop From 9d3d337966c8e4fe4157966355ca597f79124a92 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Wed, 3 Jul 2024 14:12:05 +0100 Subject: [PATCH 41/49] chore: Update to Rails 7. Rubocopped. --- .rubocop_todo.yml | 50 ++++++------------- app/controllers/assets_controller.rb | 2 +- app/controllers/batches_controller.rb | 4 +- app/controllers/reports_controller.rb | 4 +- app/controllers/workflows_controller.rb | 2 +- app/presenters/admin/index.rb | 4 +- .../{asset => asset_presenter}/asset.rb | 11 ++-- .../{asset => asset_presenter}/index.rb | 13 +++-- .../asset_type.rb | 5 +- .../{batch => batch_presenter}/new.rb | 3 ++ .../{batch => batch_presenter}/show.rb | 17 ++++--- app/presenters/presenter.rb | 7 ++- .../{report => report_presenter}/new.rb | 3 ++ .../{report => report_presenter}/show.rb | 11 ++-- .../{workflow => workflow_presenter}/show.rb | 3 ++ app/views/assets/_asset_group.html.erb | 4 +- app/views/assets/index.html.erb | 6 +-- config/application.rb | 2 + config/initializers/asset_types.rb | 1 + spec/presenters/asset_index_presenter_spec.rb | 10 ++-- spec/presenters/asset_presenter_spec.rb | 1 - spec/presenters/batch_new_presenter_spec.rb | 2 +- spec/presenters/batch_show_presenter_spec.rb | 2 +- spec/presenters/report_new_presenter_spec.rb | 2 +- spec/presenters/report_show_presenter_spec.rb | 2 +- 25 files changed, 91 insertions(+), 80 deletions(-) rename app/presenters/{asset => asset_presenter}/asset.rb (90%) rename app/presenters/{asset => asset_presenter}/index.rb (87%) rename app/presenters/{asset_type => asset_type_presenter}/asset_type.rb (89%) rename app/presenters/{batch => batch_presenter}/new.rb (89%) rename app/presenters/{batch => batch_presenter}/show.rb (79%) rename app/presenters/{report => report_presenter}/new.rb (90%) rename app/presenters/{report => report_presenter}/show.rb (75%) rename app/presenters/{workflow => workflow_presenter}/show.rb (86%) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2c568ac2..d4ac98fd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -15,13 +15,13 @@ Lint/DuplicateMethods: # Offense count: 7 Lint/MissingSuper: Exclude: - - 'app/presenters/asset/asset.rb' - - 'app/presenters/asset/index.rb' - - 'app/presenters/asset_type/asset_type.rb' - - 'app/presenters/batch/show.rb' - - 'app/presenters/report/new.rb' - - 'app/presenters/report/show.rb' - - 'app/presenters/workflow/show.rb' + - 'app/presenters/asset_presenter/asset.rb' + - 'app/presenters/asset_presenter/index.rb' + - 'app/presenters/asset_type_presenter/asset_type.rb' + - 'app/presenters/batch_presenter/show.rb' + - 'app/presenters/report_presenter/new.rb' + - 'app/presenters/report_presenter/show.rb' + - 'app/presenters/workflow_presenter/show.rb' # Offense count: 6 Lint/UselessAssignment: @@ -329,14 +329,14 @@ Style/CaseEquality: Style/ClassAndModuleChildren: Exclude: - 'app/presenters/admin/index.rb' - - 'app/presenters/asset/asset.rb' - - 'app/presenters/asset/index.rb' - - 'app/presenters/asset_type/asset_type.rb' - - 'app/presenters/batch/new.rb' - - 'app/presenters/batch/show.rb' - - 'app/presenters/report/new.rb' - - 'app/presenters/report/show.rb' - - 'app/presenters/workflow/show.rb' + - 'app/presenters/asset_presenter/asset.rb' + - 'app/presenters/asset_presenter/index.rb' + - 'app/presenters/asset_type_presenter/asset_type.rb' + - 'app/presenters/batch_presenter/new.rb' + - 'app/presenters/batch_presenter/show.rb' + - 'app/presenters/report_presenter/new.rb' + - 'app/presenters/report_presenter/show.rb' + - 'app/presenters/workflow_presenter/show.rb' # Offense count: 69 Style/Documentation: @@ -359,15 +359,6 @@ Style/Documentation: - 'app/models/event.rb' - 'app/models/report.rb' - 'app/models/workflow.rb' - - 'app/presenters/asset/asset.rb' - - 'app/presenters/asset/index.rb' - - 'app/presenters/asset_type/asset_type.rb' - - 'app/presenters/batch/new.rb' - - 'app/presenters/batch/show.rb' - - 'app/presenters/presenter.rb' - - 'app/presenters/report/new.rb' - - 'app/presenters/report/show.rb' - - 'app/presenters/workflow/show.rb' - 'config/application.rb' - 'config/data/asset_types.rb' - 'config/data/pipeline_destinations.rb' @@ -436,16 +427,7 @@ Style/FrozenStringLiteralComment: - 'app/models/report.rb' - 'app/models/state.rb' - 'app/models/workflow.rb' - - 'app/presenters/admin/index.rb' - - 'app/presenters/asset/asset.rb' - - 'app/presenters/asset/index.rb' - - 'app/presenters/asset_type/asset_type.rb' - - 'app/presenters/batch/new.rb' - - 'app/presenters/batch/show.rb' - - 'app/presenters/presenter.rb' - - 'app/presenters/report/new.rb' - - 'app/presenters/report/show.rb' - - 'app/presenters/workflow/show.rb' + - 'app/presenters/report_presenter/show.rb' - 'config.ru' - 'config/application.rb' - 'config/boot.rb' diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index dc39b81c..14fb47ec 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -1,4 +1,4 @@ -require './app/presenters/asset/index' +require './app/presenters/asset_presenter/index' class AssetsController < ApplicationController def index diff --git a/app/controllers/batches_controller.rb b/app/controllers/batches_controller.rb index e46b7c6f..c29219ee 100644 --- a/app/controllers/batches_controller.rb +++ b/app/controllers/batches_controller.rb @@ -1,5 +1,5 @@ -require './app/presenters/batch/new' -require './app/presenters/batch/show' +require './app/presenters/batch_presenter/new' +require './app/presenters/batch_presenter/show' class BatchesController < ApplicationController before_action :batch, only: %i[show update remove] diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 6c777c69..eab9e104 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,5 +1,5 @@ -require './app/presenters/report/new' -require './app/presenters/report/show' +require './app/presenters/report_presenter/new' +require './app/presenters/report_presenter/show' class ReportsController < ApplicationController def show; end diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb index bb165efa..f3ba63c4 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -1,4 +1,4 @@ -require './app/presenters/workflow/show' +require './app/presenters/workflow_presenter/show' class WorkflowsController < ApplicationController include InitialState diff --git a/app/presenters/admin/index.rb b/app/presenters/admin/index.rb index ec4ad98e..0b5f57ab 100644 --- a/app/presenters/admin/index.rb +++ b/app/presenters/admin/index.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + require './app/presenters/presenter' -require './app/presenters/asset/asset' +require './app/presenters/asset_presenter/asset' module Presenter::AdminPresenter class Index < Presenter diff --git a/app/presenters/asset/asset.rb b/app/presenters/asset_presenter/asset.rb similarity index 90% rename from app/presenters/asset/asset.rb rename to app/presenters/asset_presenter/asset.rb index 11d46378..b10f2dae 100644 --- a/app/presenters/asset/asset.rb +++ b/app/presenters/asset_presenter/asset.rb @@ -1,6 +1,9 @@ +# frozen_string_literal: true + require './app/presenters/presenter' module Presenter::AssetPresenter + # Presenter for showing an asset class Asset < Presenter attr_reader :asset @@ -62,7 +65,7 @@ def completed_status_label end def completed_at_status - "#{asset.completed_at.strftime('%d/%m/%Y')} #{'(' + completed_status_label + ')' if completed_status_label}" + "#{asset.completed_at.strftime('%d/%m/%Y')} #{"(#{completed_status_label})" if completed_status_label}" end def completed_at @@ -70,7 +73,7 @@ def completed_at return 'Due today' if due_today? return "Overdue (#{overdue_by} #{'day'.pluralize(overdue_by)})" if overdue? - 'In progress' + in_progress_status + "In progress#{in_progress_status}" end def days_left @@ -86,7 +89,7 @@ def in_progress_status def due_today? return false if asset.workflow.turn_around_days.nil? - (0..1).include?(time_from_due_date) + (0..1).cover?(time_from_due_date) end def time_from_due_date @@ -118,7 +121,7 @@ def overdue_by end def overdue? - asset.completed_at.nil? && overdue_by > 0 + asset.completed_at.nil? && overdue_by.positive? end def completed? diff --git a/app/presenters/asset/index.rb b/app/presenters/asset_presenter/index.rb similarity index 87% rename from app/presenters/asset/index.rb rename to app/presenters/asset_presenter/index.rb index 01d57873..a3296277 100644 --- a/app/presenters/asset/index.rb +++ b/app/presenters/asset_presenter/index.rb @@ -1,7 +1,10 @@ +# frozen_string_literal: true + require './app/presenters/presenter' -require './app/presenters/asset/asset' +require './app/presenters/asset_presenter/asset' module Presenter::AssetPresenter + # Presenter for showing a list of assets class Index < Presenter attr_reader :search, :assets, :total @@ -16,8 +19,8 @@ def asset_identifiers assets.values.flatten.map(&:identifier) end - def has_assets?(type) - assets[type].length > 0 + def assets?(type) + assets[type].length.positive? end def num_assets(type) @@ -37,10 +40,10 @@ def each_asset(type) end def search_parameters - yield search if is_search? + yield search if search? end - def is_search? + def search? search.present? end diff --git a/app/presenters/asset_type/asset_type.rb b/app/presenters/asset_type_presenter/asset_type.rb similarity index 89% rename from app/presenters/asset_type/asset_type.rb rename to app/presenters/asset_type_presenter/asset_type.rb index ae66cb2b..b7512a1b 100644 --- a/app/presenters/asset_type/asset_type.rb +++ b/app/presenters/asset_type_presenter/asset_type.rb @@ -1,6 +1,9 @@ +# frozen_string_literal: true + require './app/presenters/presenter' module Presenter::AssetTypePresenter + # Presenter for showing an asset type class AssetType < Presenter attr_reader :asset_type @@ -44,7 +47,7 @@ def asset_fields :created_at, :completed_at].compact end - def is_field_value_shared_inside_batch?(asset_field) + def field_value_shared_inside_batch?(asset_field) %i[batch_id workflow cost_code study project].include?(asset_field) end end diff --git a/app/presenters/batch/new.rb b/app/presenters/batch_presenter/new.rb similarity index 89% rename from app/presenters/batch/new.rb rename to app/presenters/batch_presenter/new.rb index 2ef7278e..31d83cba 100644 --- a/app/presenters/batch/new.rb +++ b/app/presenters/batch_presenter/new.rb @@ -1,6 +1,9 @@ +# frozen_string_literal: true + require './app/presenters/presenter' module Presenter::BatchPresenter + # Presenter for creating a new batch class New < Presenter def each_asset; end diff --git a/app/presenters/batch/show.rb b/app/presenters/batch_presenter/show.rb similarity index 79% rename from app/presenters/batch/show.rb rename to app/presenters/batch_presenter/show.rb index cd371ca5..4cb47e0d 100644 --- a/app/presenters/batch/show.rb +++ b/app/presenters/batch_presenter/show.rb @@ -1,7 +1,10 @@ +# frozen_string_literal: true + require './app/presenters/presenter' -require './app/presenters/asset/asset' +require './app/presenters/asset_presenter/asset' module Presenter::BatchPresenter + # Presenter for showing a batch class Show < Presenter attr_reader :batch @@ -38,11 +41,11 @@ def workflow end def prohibited_workflow(reportable, qc_flow, cherrypick_flow) - if workflow.present? - (workflow.reportable != reportable) || - (workflow.qc_flow != qc_flow) || - (workflow.cherrypick_flow != cherrypick_flow) - end + return if workflow.blank? + + (workflow.reportable != reportable) || + (workflow.qc_flow != qc_flow) || + (workflow.cherrypick_flow != cherrypick_flow) end def workflow_name @@ -62,7 +65,7 @@ def cost_code end def comment - return first_asset.comment.comment if first_asset && first_asset.comment + return first_asset.comment.comment if first_asset&.comment '' end diff --git a/app/presenters/presenter.rb b/app/presenters/presenter.rb index d350b44c..68344670 100644 --- a/app/presenters/presenter.rb +++ b/app/presenters/presenter.rb @@ -1,4 +1,8 @@ +# frozen_string_literal: true + +# This file contains the Presenter module, which is included in all presenters. class Presenter + # Provides information about the deployed version module DeploymentInfo require './lib/deployed_version' @@ -25,8 +29,9 @@ def release_name end include DeploymentInfo + # Presenter::SharedBehaviour module SharedBehaviour - require './app/presenters/asset_type/asset_type' + require './app/presenters/asset_type_presenter/asset_type' def each_asset_type AssetType.find_each do |asset_type| diff --git a/app/presenters/report/new.rb b/app/presenters/report_presenter/new.rb similarity index 90% rename from app/presenters/report/new.rb rename to app/presenters/report_presenter/new.rb index 5a3992b4..5c5149de 100644 --- a/app/presenters/report/new.rb +++ b/app/presenters/report_presenter/new.rb @@ -1,6 +1,9 @@ +# frozen_string_literal: true + require './app/presenters/presenter' module Presenter::ReportPresenter + # Presenter for creating a new report class New < Presenter attr_reader :report diff --git a/app/presenters/report/show.rb b/app/presenters/report_presenter/show.rb similarity index 75% rename from app/presenters/report/show.rb rename to app/presenters/report_presenter/show.rb index 02f7b1c2..39a9994a 100644 --- a/app/presenters/report/show.rb +++ b/app/presenters/report_presenter/show.rb @@ -1,6 +1,7 @@ require './app/presenters/presenter' module Presenter::ReportPresenter + # Presenter for showing a report class Show < Presenter attr_reader :report @@ -17,19 +18,17 @@ def flash; end delegate :title, to: :report def column_names - "" + - report.column_names.map(&:humanize).join("") + - '' + "#{report.column_names.map(&:humanize).join("")}" end def rows ''.tap do |html| report.rows.each_with_index do |row, index| - html_for_row = '' + - " #{index + 1} " + + html_for_row = '' \ + " #{index + 1} " \ "" + row.data_for(report.column_names).join("") + - '' + + '' \ '' html << html_for_row end diff --git a/app/presenters/workflow/show.rb b/app/presenters/workflow_presenter/show.rb similarity index 86% rename from app/presenters/workflow/show.rb rename to app/presenters/workflow_presenter/show.rb index 6dfcdb3b..61ad3447 100644 --- a/app/presenters/workflow/show.rb +++ b/app/presenters/workflow_presenter/show.rb @@ -1,6 +1,9 @@ +# frozen_string_literal: true + require './app/presenters/presenter' module Presenter::WorkflowPresenter + # Presenter for showing a workflow class Show < Presenter attr_reader :workflow diff --git a/app/views/assets/_asset_group.html.erb b/app/views/assets/_asset_group.html.erb index d9022886..e74e4b99 100644 --- a/app/views/assets/_asset_group.html.erb +++ b/app/views/assets/_asset_group.html.erb @@ -10,7 +10,7 @@ <% if new_batch != previous_batch %> class="batch-box" style="text-align: center;"> - <% if !presenter.is_search? %> + <% if !presenter.search? %>
@@ -21,7 +21,7 @@ <% end %> <% else %> - <% if ((asset_field == :identifier) && (!presenter.is_search?)) %> + <% if ((asset_field == :identifier) && (!presenter.search?)) %>
diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb index 7b4ded26..ae7d2e6c 100644 --- a/app/views/assets/index.html.erb +++ b/app/views/assets/index.html.erb @@ -1,5 +1,5 @@
-<% if (@presenter.is_search?) %> +<% if (@presenter.search?) %> <% @presenter.search_parameters do |param| %>
Search results where <%= param %>
<% end %> @@ -35,8 +35,8 @@

<%= asset_type.name %> <%= @presenter.num_assets(asset_type.name) %>

- <% if @presenter.has_assets?(asset_type.name) %> - <% if (!@presenter.is_search?) %> + <% if @presenter.assets?(asset_type.name) %> + <% if (!@presenter.search?) %> Select all | Unselect <% end %> diff --git a/config/application.rb b/config/application.rb index 4544c151..398d1287 100644 --- a/config/application.rb +++ b/config/application.rb @@ -27,5 +27,7 @@ class Application < Rails::Application # Enabling the behaviour where 'belongs_to' associations are required by default. # (https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#active-record-belongs-to-required-by-default-option) config.active_record.belongs_to_required_by_default = true + + config.active_record.legacy_connection_handling = false end end diff --git a/config/initializers/asset_types.rb b/config/initializers/asset_types.rb index cff45e54..0a1adec7 100644 --- a/config/initializers/asset_types.rb +++ b/config/initializers/asset_types.rb @@ -1,4 +1,5 @@ require './config/data/asset_types' +require './lib/utils/dependent_loader' DependentLoader.start(:asset_types) do |on| on.success do diff --git a/spec/presenters/asset_index_presenter_spec.rb b/spec/presenters/asset_index_presenter_spec.rb index 912e1841..6713fe59 100644 --- a/spec/presenters/asset_index_presenter_spec.rb +++ b/spec/presenters/asset_index_presenter_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -require './app/presenters/asset/index' +require './app/presenters/asset_presenter/index' require './spec/presenters/shared_presenter_behaviour' describe 'Presenter::AssetPresenter::Index' do @@ -63,8 +63,8 @@ # Eg. presenter.search_parameters {|sp| puts sp } # -> identifier matches 'my plate' - it 'returns true for is_search?' do - expect(presenter.is_search?).to be_truthy + it 'returns true for search?' do + expect(presenter.search?).to be_truthy end end @@ -78,8 +78,8 @@ end # Eg. presenter.search_parameters {|sp| puts "Never called" } - it 'returns false for is_search?' do - expect(presenter.is_search?).to be_falsey + it 'returns false for search?' do + expect(presenter.search?).to be_falsey end end diff --git a/spec/presenters/asset_presenter_spec.rb b/spec/presenters/asset_presenter_spec.rb index c6b9281e..bb1b774e 100644 --- a/spec/presenters/asset_presenter_spec.rb +++ b/spec/presenters/asset_presenter_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' -require './app/presenters/asset/asset' require 'timecop' describe 'Presenter::AssetPresenter::Asset' do diff --git a/spec/presenters/batch_new_presenter_spec.rb b/spec/presenters/batch_new_presenter_spec.rb index ecd25e15..9eb15726 100644 --- a/spec/presenters/batch_new_presenter_spec.rb +++ b/spec/presenters/batch_new_presenter_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -require './app/presenters/batch/new' +require './app/presenters/batch_presenter/new' require './spec/presenters/shared_presenter_behaviour' describe 'Presenter::BatchPresenter::New' do diff --git a/spec/presenters/batch_show_presenter_spec.rb b/spec/presenters/batch_show_presenter_spec.rb index 7d541fb7..c586effb 100644 --- a/spec/presenters/batch_show_presenter_spec.rb +++ b/spec/presenters/batch_show_presenter_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -require './app/presenters/batch/show' +require './app/presenters/batch_presenter/show' require './spec/presenters/shared_presenter_behaviour' describe 'Presenter::BatchPresenter::Show' do diff --git a/spec/presenters/report_new_presenter_spec.rb b/spec/presenters/report_new_presenter_spec.rb index ce1a84e4..a23633d3 100644 --- a/spec/presenters/report_new_presenter_spec.rb +++ b/spec/presenters/report_new_presenter_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -require './app/presenters/report/new' +require './app/presenters/report_presenter/new' require './spec/presenters/shared_presenter_behaviour' describe 'Presenter::ReportPresenter::New' do diff --git a/spec/presenters/report_show_presenter_spec.rb b/spec/presenters/report_show_presenter_spec.rb index 6d3fff56..b5edcf1d 100644 --- a/spec/presenters/report_show_presenter_spec.rb +++ b/spec/presenters/report_show_presenter_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -require './app/presenters/report/show' +require './app/presenters/report_presenter/show' require './spec/presenters/shared_presenter_behaviour' describe 'Presenter::ReportPresenter::Show' do From 7a8d0b5fcd48af3bd7e9edfff6fd3373f9552050 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:44:13 +0100 Subject: [PATCH 42/49] chore: Update require statement for admin presenter in admin controller --- .rubocop_todo.yml | 2 +- app/controllers/admin_controller.rb | 2 +- app/presenters/{admin => admin_presenter}/index.rb | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename app/presenters/{admin => admin_presenter}/index.rb (100%) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d4ac98fd..9862a889 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -328,7 +328,7 @@ Style/CaseEquality: # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Exclude: - - 'app/presenters/admin/index.rb' + - 'app/presenters/admin_presenter/index.rb' - 'app/presenters/asset_presenter/asset.rb' - 'app/presenters/asset_presenter/index.rb' - 'app/presenters/asset_type_presenter/asset_type.rb' diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7a0ea906..6bc6b8bd 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,4 +1,4 @@ -require './app/presenters/admin/index' +require './app/presenters/admin_presenter/index' class AdminController < ApplicationController def index diff --git a/app/presenters/admin/index.rb b/app/presenters/admin_presenter/index.rb similarity index 100% rename from app/presenters/admin/index.rb rename to app/presenters/admin_presenter/index.rb From 5d1e5cb1aa89d4e909152e2009fe74b418ce4385 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:22:39 +0100 Subject: [PATCH 43/49] Update presenter require statements to use the new namespace in controller files --- app/controllers/admin_controller.rb | 2 +- app/controllers/assets_controller.rb | 4 +- app/controllers/batches_controller.rb | 8 +- app/controllers/reports_controller.rb | 9 +- app/controllers/workflows_controller.rb | 2 +- app/presenters/admin_presenter/index.rb | 9 +- app/presenters/asset_presenter/asset.rb | 204 +++++++++--------- app/presenters/asset_presenter/index.rb | 111 +++++----- .../asset_type_presenter/asset_type.rb | 98 ++++----- app/presenters/batch_presenter/new.rb | 74 +++---- app/presenters/batch_presenter/show.rb | 119 +++++----- app/presenters/presenter.rb | 2 +- app/presenters/report_presenter/new.rb | 66 +++--- app/presenters/report_presenter/show.rb | 54 ++--- app/presenters/workflow_presenter/show.rb | 30 +-- config/application.rb | 5 + spec/presenters/asset_index_presenter_spec.rb | 4 +- spec/presenters/asset_presenter_spec.rb | 4 +- spec/presenters/asset_type_presenter_spec.rb | 6 +- spec/presenters/batch_new_presenter_spec.rb | 6 +- spec/presenters/batch_show_presenter_spec.rb | 8 +- spec/presenters/report_new_presenter_spec.rb | 8 +- spec/presenters/report_show_presenter_spec.rb | 4 +- 23 files changed, 419 insertions(+), 418 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 6bc6b8bd..03757c57 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -2,6 +2,6 @@ class AdminController < ApplicationController def index - @presenter = Presenter::AdminPresenter::Index.new + @presenter = Presenters::AdminPresenter::Index.new end end diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index 14fb47ec..f5d13b1b 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -1,5 +1,3 @@ -require './app/presenters/asset_presenter/index' - class AssetsController < ApplicationController def index if params[:state].nil? && params[:identifier].nil? @@ -7,7 +5,7 @@ def index else assets = Asset.in_state(state) .with_identifier(params[:identifier]) - @presenter = Presenter::AssetPresenter::Index.new(assets, search, state) + @presenter = Presenters::AssetPresenter::Index.new(assets, search, state) end end diff --git a/app/controllers/batches_controller.rb b/app/controllers/batches_controller.rb index c29219ee..0ed50dc4 100644 --- a/app/controllers/batches_controller.rb +++ b/app/controllers/batches_controller.rb @@ -5,11 +5,11 @@ class BatchesController < ApplicationController before_action :batch, only: %i[show update remove] def show - @presenter = Presenter::BatchPresenter::Show.new(batch) + @presenter = Presenters::BatchPresenter::Show.new(batch) end def new - @presenter = Presenter::BatchPresenter::New.new + @presenter = Presenters::BatchPresenter::New.new end def create @@ -26,7 +26,7 @@ def create ) if batch_creator.valid? batch = batch_creator.create! - @presenter = Presenter::BatchPresenter::Show.new(batch) + @presenter = Presenters::BatchPresenter::Show.new(batch) flash[:notice] = I18n.t('batches.success.created') redirect_to("/batches/#{@presenter.id}") else @@ -48,7 +48,7 @@ def update ) if batch_updater.valid? batch = batch_updater.update! - @presenter = Presenter::BatchPresenter::Show.new(batch) + @presenter = Presenters::BatchPresenter::Show.new(batch) flash[:notice] = I18n.t('batches.success.updated') redirect_to("/batches/#{params[:id]}") else diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index eab9e104..50a23fd3 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,20 +1,17 @@ -require './app/presenters/report_presenter/new' -require './app/presenters/report_presenter/show' - class ReportsController < ApplicationController def show; end def new - @presenter = Presenter::ReportPresenter::New.new + @presenter = Presenters::ReportPresenter::New.new end def create report = Report.new(params.permit(:workflow_id, :start_date, :end_date)) if report.valid? - @presenter = Presenter::ReportPresenter::Show.new(report) + @presenter = Presenters::ReportPresenter::Show.new(report) render :show else - @presenter = Presenter::ReportPresenter::New.new(report) + @presenter = Presenters::ReportPresenter::New.new(report) flash[:error] = @presenter.flash render :new end diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb index f3ba63c4..ac7c1b76 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -4,7 +4,7 @@ class WorkflowsController < ApplicationController include InitialState def show - @presenter = Presenter::WorkflowPresenter::Show.new(workflow) + @presenter = Presenters::WorkflowPresenter::Show.new(workflow) end def create diff --git a/app/presenters/admin_presenter/index.rb b/app/presenters/admin_presenter/index.rb index 0b5f57ab..b64a3299 100644 --- a/app/presenters/admin_presenter/index.rb +++ b/app/presenters/admin_presenter/index.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true -require './app/presenters/presenter' -require './app/presenters/asset_presenter/asset' - -module Presenter::AdminPresenter - class Index < Presenter +module Presenters + module AdminPresenter + class Index < Presenter + end end end diff --git a/app/presenters/asset_presenter/asset.rb b/app/presenters/asset_presenter/asset.rb index b10f2dae..eb58a922 100644 --- a/app/presenters/asset_presenter/asset.rb +++ b/app/presenters/asset_presenter/asset.rb @@ -1,143 +1,145 @@ # frozen_string_literal: true -require './app/presenters/presenter' - -module Presenter::AssetPresenter - # Presenter for showing an asset - class Asset < Presenter - attr_reader :asset - - def initialize(asset) - @asset = asset - end +module Presenters + module AssetPresenter + # Presenter for showing an asset + class Asset < Presenter + attr_reader :asset + + def initialize(asset) + @asset = asset + end - def identifier_type - asset.asset_type.identifier_type - end + def identifier_type + asset.asset_type.identifier_type + end - delegate :id, to: :asset + delegate :id, to: :asset - delegate :identifier, to: :asset + delegate :identifier, to: :asset - delegate :sample_count, to: :asset + delegate :sample_count, to: :asset - delegate :study, to: :asset + delegate :study, to: :asset - def project - asset.project.nil? ? 'Not defined' : asset.project - end - - def workflow - asset.workflow.name - end + def project + asset.project.nil? ? 'Not defined' : asset.project + end - def pipeline_destination - asset.pipeline_destination.nil? ? 'None' : asset.pipeline_destination.name - end + def workflow + asset.workflow.name + end - def cost_code - asset.cost_code.nil? ? 'Not defined' : asset.cost_code.name - end + def pipeline_destination + asset.pipeline_destination.nil? ? 'None' : asset.pipeline_destination.name + end - def created_at - asset.begun_at.strftime('%d/%m/%Y') - end + def cost_code + asset.cost_code.nil? ? 'Not defined' : asset.cost_code.name + end - def updated_at - asset.updated_at.strftime('%d/%m/%Y') - end + def created_at + asset.begun_at.strftime('%d/%m/%Y') + end - def comments - return asset.comment.comment if asset.comment + def updated_at + asset.updated_at.strftime('%d/%m/%Y') + end - '' - end + def comments + return asset.comment.comment if asset.comment - def completed_status_label - if completed_late? - return "Late #{asset.time_without_completion - asset.workflow.turn_around_days} #{'day'.pluralize(overdue_by)}" - end - if completed_early? - return "Early #{asset.workflow.turn_around_days - asset.time_without_completion} #{'day'.pluralize(overdue_by)}" + '' end - 'On time' if completed_on_time? - end + def completed_status_label + if completed_late? + return "Late #{asset.time_without_completion - asset.workflow.turn_around_days} " \ + "#{'day'.pluralize(overdue_by)}" + end + if completed_early? + return "Early #{asset.workflow.turn_around_days - asset.time_without_completion} " \ + "#{'day'.pluralize(overdue_by)}" + end + + 'On time' if completed_on_time? + end - def completed_at_status - "#{asset.completed_at.strftime('%d/%m/%Y')} #{"(#{completed_status_label})" if completed_status_label}" - end + def completed_at_status + "#{asset.completed_at.strftime('%d/%m/%Y')} #{"(#{completed_status_label})" if completed_status_label}" + end - def completed_at - return completed_at_status if asset.completed_at - return 'Due today' if due_today? - return "Overdue (#{overdue_by} #{'day'.pluralize(overdue_by)})" if overdue? + def completed_at + return completed_at_status if asset.completed_at + return 'Due today' if due_today? + return "Overdue (#{overdue_by} #{'day'.pluralize(overdue_by)})" if overdue? - "In progress#{in_progress_status}" - end + "In progress#{in_progress_status}" + end - def days_left - [asset.workflow.turn_around_days - asset.age, 0].max.to_i - end + def days_left + [asset.workflow.turn_around_days - asset.age, 0].max.to_i + end - def in_progress_status - return " (#{days_left} days left)" if asset.workflow.turn_around_days + def in_progress_status + return " (#{days_left} days left)" if asset.workflow.turn_around_days - '' - end + '' + end - def due_today? - return false if asset.workflow.turn_around_days.nil? + def due_today? + return false if asset.workflow.turn_around_days.nil? - (0..1).cover?(time_from_due_date) - end + (0..1).cover?(time_from_due_date) + end - def time_from_due_date - asset.age - asset.workflow.turn_around_days - end + def time_from_due_date + asset.age - asset.workflow.turn_around_days + end - def completed_early? - return asset.time_without_completion < asset.workflow.turn_around_days if asset.workflow.turn_around_days + def completed_early? + return asset.time_without_completion < asset.workflow.turn_around_days if asset.workflow.turn_around_days - false - end + false + end - def completed_late? - return asset.time_without_completion > asset.workflow.turn_around_days if asset.workflow.turn_around_days + def completed_late? + return asset.time_without_completion > asset.workflow.turn_around_days if asset.workflow.turn_around_days - false - end + false + end - def completed_on_time? - return asset.time_without_completion == asset.workflow.turn_around_days if asset.workflow.turn_around_days + def completed_on_time? + return asset.time_without_completion == asset.workflow.turn_around_days if asset.workflow.turn_around_days - false - end + false + end - def overdue_by - return 0 if asset.workflow.turn_around_days.nil? + def overdue_by + return 0 if asset.workflow.turn_around_days.nil? - [time_from_due_date.floor, 0].max - end + [time_from_due_date.floor, 0].max + end - def overdue? - asset.completed_at.nil? && overdue_by.positive? - end + def overdue? + asset.completed_at.nil? && overdue_by.positive? + end - def completed? - asset.completed_at.present? - end + def completed? + asset.completed_at.present? + end - def batch_id - asset.batch.id - end + def batch_id + asset.batch.id + end - def status_code - return 'success' if completed_early? - return 'warning' if due_today? || completed_on_time? - return 'danger' if overdue? || completed_late? + def status_code + return 'success' if completed_early? + return 'warning' if due_today? || completed_on_time? + return 'danger' if overdue? || completed_late? - 'default' + 'default' + end end end end diff --git a/app/presenters/asset_presenter/index.rb b/app/presenters/asset_presenter/index.rb index a3296277..3b678c88 100644 --- a/app/presenters/asset_presenter/index.rb +++ b/app/presenters/asset_presenter/index.rb @@ -1,75 +1,74 @@ # frozen_string_literal: true -require './app/presenters/presenter' -require './app/presenters/asset_presenter/asset' +module Presenters + module AssetPresenter + # Presenter for showing a list of assets + class Index < Presenter + attr_reader :search, :assets, :total -module Presenter::AssetPresenter - # Presenter for showing a list of assets - class Index < Presenter - attr_reader :search, :assets, :total - - def initialize(found_assets, search = nil, state = nil) - @assets = found_assets.group_by { |a| a.asset_type.name }.tap { |h| h.default = [] } - @total = found_assets.length - @search = search - @state = state.name if state - end + def initialize(found_assets, search = nil, state = nil) + @assets = found_assets.group_by { |a| a.asset_type.name }.tap { |h| h.default = [] } + @total = found_assets.length + @search = search + @state = state.name if state + end - def asset_identifiers - assets.values.flatten.map(&:identifier) - end + def asset_identifiers + assets.values.flatten.map(&:identifier) + end - def assets?(type) - assets[type].length.positive? - end + def assets?(type) + assets[type].length.positive? + end - def num_assets(type) - assets[type].length - end + def num_assets(type) + assets[type].length + end - def assets_from_batch(type, batch_id) - @assets[type].select { |a| a.batch.id == batch_id } - end + def assets_from_batch(type, batch_id) + @assets[type].select { |a| a.batch.id == batch_id } + end - def each_asset(type) - return if assets[type].nil? + def each_asset(type) + return if assets[type].nil? - assets[type].each do |asset| - yield Presenter::AssetPresenter::Asset.new(asset) + assets[type].each do |asset| + yield Presenters::AssetPresenter::Asset.new(asset) + end end - end - def search_parameters - yield search if search? - end + def search_parameters + yield search if search? + end - def search? - search.present? - end + def search? + search.present? + end - def workflow - 'None' - end + def workflow + 'None' + end - def state - @state.humanize - end + def state + @state.humanize + end - def action - { 'in_progress' => 'complete', - 'cherrypick' => 'cherrypicking', - 'volume_check' => 'check_volume', - 'quant' => 'complete', - 'report_required' => 'report' }[@state] - end + def action + { 'in_progress' => 'complete', + 'cherrypick' => 'cherrypicking', + 'volume_check' => 'check_volume', + 'quant' => 'complete', + 'report_required' => 'report' }[@state] + end - def action_button - { 'in_progress' => 'Completed selected', - 'cherrypick' => 'Completed selected', - 'volume_check' => 'Volume checked selected', - 'quant' => 'Completed selected', - 'report_required' => 'Reported selected' }[@state].tap do |button| - yield button if button.present? + def action_button + { 'in_progress' => 'Completed selected', + 'cherrypick' => 'Completed selected', + 'volume_check' => 'Volume checked selected', + 'quant' => 'Completed selected', + 'report_required' => 'Reported selected' }[@state].tap do |button| + yield button if button.present? + end end end end diff --git a/app/presenters/asset_type_presenter/asset_type.rb b/app/presenters/asset_type_presenter/asset_type.rb index b7512a1b..18d5e4e8 100644 --- a/app/presenters/asset_type_presenter/asset_type.rb +++ b/app/presenters/asset_type_presenter/asset_type.rb @@ -1,54 +1,54 @@ # frozen_string_literal: true -require './app/presenters/presenter' - -module Presenter::AssetTypePresenter - # Presenter for showing an asset type - class AssetType < Presenter - attr_reader :asset_type - - ALPHANUMERIC_REGEX = '^[\w-]+$' - NUMERIC_REGEX = '^\d+$' - - def initialize(asset_type) - @asset_type = asset_type - end - - delegate :name, to: :asset_type - - def identifier - asset_type.identifier_type - end - - def sample_count? - yield if asset_type.has_sample_count - end - - delegate :id, to: :asset_type - - def type - asset_type.labware_type - end - - def template_name - asset_type.name.downcase.tr(' ', '_') - end - - def validates_with - { - 'alphanumeric' => ALPHANUMERIC_REGEX, - 'numeric' => NUMERIC_REGEX - }[asset_type.identifier_data_type] - end - - def asset_fields - sample_count = asset_type.has_sample_count ? :sample_count : nil - [:batch_id, :identifier, :study, :project, sample_count, :workflow, :pipeline_destination, :cost_code, - :created_at, :completed_at].compact - end - - def field_value_shared_inside_batch?(asset_field) - %i[batch_id workflow cost_code study project].include?(asset_field) +module Presenters + module AssetTypePresenter + # Presenter for showing an asset type + class AssetType < Presenter + attr_reader :asset_type + + ALPHANUMERIC_REGEX = '^[\w-]+$' + NUMERIC_REGEX = '^\d+$' + + def initialize(asset_type) + @asset_type = asset_type + end + + delegate :name, to: :asset_type + + def identifier + asset_type.identifier_type + end + + def sample_count? + yield if asset_type.has_sample_count + end + + delegate :id, to: :asset_type + + def type + asset_type.labware_type + end + + def template_name + asset_type.name.downcase.tr(' ', '_') + end + + def validates_with + { + 'alphanumeric' => ALPHANUMERIC_REGEX, + 'numeric' => NUMERIC_REGEX + }[asset_type.identifier_data_type] + end + + def asset_fields + sample_count = asset_type.has_sample_count ? :sample_count : nil + [:batch_id, :identifier, :study, :project, sample_count, :workflow, :pipeline_destination, :cost_code, + :created_at, :completed_at].compact + end + + def field_value_shared_inside_batch?(asset_field) + %i[batch_id workflow cost_code study project].include?(asset_field) + end end end end diff --git a/app/presenters/batch_presenter/new.rb b/app/presenters/batch_presenter/new.rb index 31d83cba..b92c76ee 100644 --- a/app/presenters/batch_presenter/new.rb +++ b/app/presenters/batch_presenter/new.rb @@ -1,54 +1,54 @@ # frozen_string_literal: true -require './app/presenters/presenter' +module Presenters + module BatchPresenter + # Presenter for creating a new batch + class New < Presenter + def each_asset; end -module Presenter::BatchPresenter - # Presenter for creating a new batch - class New < Presenter - def each_asset; end + def study + '' + end - def study - '' - end + def project + '' + end - def project - '' - end + def workflow; end - def workflow; end + def pipeline_destination + 'None' + end - def pipeline_destination - 'None' - end - - def cost_code - '' - end + def cost_code + '' + end - def action - '/batches' - end + def action + '/batches' + end - def comment - '' - end + def comment + '' + end - def show_completed? - false - end + def show_completed? + false + end - def num_assets - 1 - end + def num_assets + 1 + end - def placeholder_date - 'Today' - end + def placeholder_date + 'Today' + end - def prohibited_workflow(_reportable, _qc_flow, _cherrypick_flow); end + def prohibited_workflow(_reportable, _qc_flow, _cherrypick_flow); end - def workflow_name - '' + def workflow_name + '' + end end end end diff --git a/app/presenters/batch_presenter/show.rb b/app/presenters/batch_presenter/show.rb index 4cb47e0d..888185da 100644 --- a/app/presenters/batch_presenter/show.rb +++ b/app/presenters/batch_presenter/show.rb @@ -1,89 +1,90 @@ # frozen_string_literal: true -require './app/presenters/presenter' require './app/presenters/asset_presenter/asset' -module Presenter::BatchPresenter - # Presenter for showing a batch - class Show < Presenter - attr_reader :batch +module Presenters + module BatchPresenter + # Presenter for showing a batch + class Show < Presenter + attr_reader :batch - def initialize(batch) - @batch = batch - end + def initialize(batch) + @batch = batch + end - delegate :id, to: :batch + delegate :id, to: :batch - def action - "/batches/#{id}" - end + def action + "/batches/#{id}" + end - def each_asset - batch.assets.each do |asset| - yield Presenter::AssetPresenter::Asset.new(asset) + def each_asset + batch.assets.each do |asset| + yield Presenters::AssetPresenter::Asset.new(asset) + end end - end - def study - return first_asset.study if first_asset + def study + return first_asset.study if first_asset - 'Not Applicable' - end + 'Not Applicable' + end - def project - return first_asset.project if first_asset + def project + return first_asset.project if first_asset - 'Not Applicable' - end + 'Not Applicable' + end - def workflow - @workflow ||= (first_asset.workflow if first_asset.present?) || '' - end + def workflow + @workflow ||= (first_asset.workflow if first_asset.present?) || '' + end - def prohibited_workflow(reportable, qc_flow, cherrypick_flow) - return if workflow.blank? + def prohibited_workflow(reportable, qc_flow, cherrypick_flow) + return if workflow.blank? - (workflow.reportable != reportable) || - (workflow.qc_flow != qc_flow) || - (workflow.cherrypick_flow != cherrypick_flow) - end + (workflow.reportable != reportable) || + (workflow.qc_flow != qc_flow) || + (workflow.cherrypick_flow != cherrypick_flow) + end - def workflow_name - workflow.name if workflow.present? - end + def workflow_name + workflow.name if workflow.present? + end - def pipeline_destination - return first_asset.pipeline_destination.name if first_asset && !first_asset.pipeline_destination.nil? + def pipeline_destination + return first_asset.pipeline_destination.name if first_asset && !first_asset.pipeline_destination.nil? - 'None' - end + 'None' + end - def cost_code - return first_asset.cost_code.name if first_asset && !first_asset.cost_code.nil? + def cost_code + return first_asset.cost_code.name if first_asset && !first_asset.cost_code.nil? - '' - end + '' + end - def comment - return first_asset.comment.comment if first_asset&.comment + def comment + return first_asset.comment.comment if first_asset&.comment - '' - end + '' + end - def show_completed? - true - end + def show_completed? + true + end - def first_asset - batch.assets.first - end + def first_asset + batch.assets.first + end - def num_assets - batch.assets.count - end + def num_assets + batch.assets.count + end - def placeholder_date - first_asset.begun_at.strftime('%d/%m/%Y') + def placeholder_date + first_asset.begun_at.strftime('%d/%m/%Y') + end end end end diff --git a/app/presenters/presenter.rb b/app/presenters/presenter.rb index 68344670..87a37d8c 100644 --- a/app/presenters/presenter.rb +++ b/app/presenters/presenter.rb @@ -44,7 +44,7 @@ def each_asset_type def with_each_asset_type AssetType.find_each do |asset_type| - yield(Presenter::AssetTypePresenter::AssetType.new(asset_type)) + yield(Presenters::AssetTypePresenter::AssetType.new(asset_type)) end end diff --git a/app/presenters/report_presenter/new.rb b/app/presenters/report_presenter/new.rb index 5c5149de..351ee8b6 100644 --- a/app/presenters/report_presenter/new.rb +++ b/app/presenters/report_presenter/new.rb @@ -1,38 +1,38 @@ # frozen_string_literal: true -require './app/presenters/presenter' - -module Presenter::ReportPresenter - # Presenter for creating a new report - class New < Presenter - attr_reader :report - - def initialize(report = Report.new({})) - @report = report - end - - def action - '/reports' - end - - def page - :'reports/new' - end - - def flash - report.errors.full_messages.join(', ') if report.errors.present? - end - - def workflow - report.workflow.name if report.workflow.present? - end - - def start_date - report.start_date.strftime(report.date_format) if report.start_date.present? - end - - def end_date - report.end_date.strftime(report.date_format) if report.end_date.present? +module Presenters + module ReportPresenter + # Presenter for creating a new report + class New < Presenter + attr_reader :report + + def initialize(report = Report.new({})) + @report = report + end + + def action + '/reports' + end + + def page + :'reports/new' + end + + def flash + report.errors.full_messages.join(', ') if report.errors.present? + end + + def workflow + report.workflow.name if report.workflow.present? + end + + def start_date + report.start_date.strftime(report.date_format) if report.start_date.present? + end + + def end_date + report.end_date.strftime(report.date_format) if report.end_date.present? + end end end end diff --git a/app/presenters/report_presenter/show.rb b/app/presenters/report_presenter/show.rb index 39a9994a..4e545d46 100644 --- a/app/presenters/report_presenter/show.rb +++ b/app/presenters/report_presenter/show.rb @@ -1,36 +1,36 @@ -require './app/presenters/presenter' +module Presenters + module ReportPresenter + # Presenter for showing a report + class Show < Presenter + attr_reader :report -module Presenter::ReportPresenter - # Presenter for showing a report - class Show < Presenter - attr_reader :report - - def initialize(report) - @report = report - end + def initialize(report) + @report = report + end - def page - :'reports/show' - end + def page + :'reports/show' + end - def flash; end + def flash; end - delegate :title, to: :report + delegate :title, to: :report - def column_names - "#{report.column_names.map(&:humanize).join("")}" - end + def column_names + "#{report.column_names.map(&:humanize).join("")}" + end - def rows - ''.tap do |html| - report.rows.each_with_index do |row, index| - html_for_row = '' \ - " #{index + 1} " \ - "" + - row.data_for(report.column_names).join("") + - '' \ - '' - html << html_for_row + def rows + ''.tap do |html| + report.rows.each_with_index do |row, index| + html_for_row = '' \ + " #{index + 1} " \ + "" + + row.data_for(report.column_names).join("") + + '' \ + '' + html << html_for_row + end end end end diff --git a/app/presenters/workflow_presenter/show.rb b/app/presenters/workflow_presenter/show.rb index 61ad3447..ca749fb9 100644 --- a/app/presenters/workflow_presenter/show.rb +++ b/app/presenters/workflow_presenter/show.rb @@ -1,24 +1,24 @@ # frozen_string_literal: true -require './app/presenters/presenter' +module Presenters + module WorkflowPresenter + # Presenter for showing a workflow + class Show < Presenter + attr_reader :workflow -module Presenter::WorkflowPresenter - # Presenter for showing a workflow - class Show < Presenter - attr_reader :workflow + def initialize(workflow) + @workflow = workflow + end - def initialize(workflow) - @workflow = workflow - end - - delegate :name, :has_comment, :reportable, :qc_flow, :cherrypick_flow, :active, to: :workflow + delegate :name, :has_comment, :reportable, :qc_flow, :cherrypick_flow, :active, to: :workflow - def turn_around - workflow.turn_around_days - end + def turn_around + workflow.turn_around_days + end - def action - "/admin/workflows/#{workflow.id}" + def action + "/admin/workflows/#{workflow.id}" + end end end end diff --git a/config/application.rb b/config/application.rb index 398d1287..974bb5bb 100644 --- a/config/application.rb +++ b/config/application.rb @@ -24,6 +24,11 @@ class Application < Rails::Application config.autoload_paths += %W[#{config.root}/lib/utils] config.disable_animations = false + config.autoload_paths += %W[#{Rails.root}/app] + config.eager_load_paths += %W[#{Rails.root}/app] + config.autoload_paths += %W[#{Rails.root}/app/presenters] + config.eager_load_paths += %W[#{Rails.root}/app/presenters] + # Enabling the behaviour where 'belongs_to' associations are required by default. # (https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#active-record-belongs-to-required-by-default-option) config.active_record.belongs_to_required_by_default = true diff --git a/spec/presenters/asset_index_presenter_spec.rb b/spec/presenters/asset_index_presenter_spec.rb index 6713fe59..dc860f8f 100644 --- a/spec/presenters/asset_index_presenter_spec.rb +++ b/spec/presenters/asset_index_presenter_spec.rb @@ -33,7 +33,7 @@ end let(:assets) { [asset_first, asset_second] } let!(:state) { create(:state, name: 'in_progress') } - let(:presenter) { Presenter::AssetPresenter::Index.new(assets, search, state) } + let(:presenter) { Presenters::AssetPresenter::Index.new(assets, search, state) } end shared_examples 'standard behaviour' do @@ -45,7 +45,7 @@ end it 'yields each asset of type x in turn for each_asset(x)' do - expect { |b| presenter.each_asset('Type', &b) }.to yield_with_args(Presenter::AssetPresenter::Asset) + expect { |b| presenter.each_asset('Type', &b) }.to yield_with_args(Presenters::AssetPresenter::Asset) presenter.each_asset('Type') do |asset| expect(asset.identifier).to eq('asset_first') end diff --git a/spec/presenters/asset_presenter_spec.rb b/spec/presenters/asset_presenter_spec.rb index bb1b774e..6bf60b07 100644 --- a/spec/presenters/asset_presenter_spec.rb +++ b/spec/presenters/asset_presenter_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'timecop' -describe 'Presenter::AssetPresenter::Asset' do +describe 'Presenters::AssetPresenter::Asset' do shared_examples 'shared behaviour' do let(:mock_type) do double('mock_type', @@ -13,7 +13,7 @@ let(:date) { DateTime.parse('01-02-2012 13:15') } let(:comment) { double('comment', comment: 'A comment') } - let(:presenter) { Presenter::AssetPresenter::Asset.new(asset) } + let(:presenter) { Presenters::AssetPresenter::Asset.new(asset) } it 'returns the identifier type for identifier_type' do expect(presenter.identifier_type).to eq('id') diff --git a/spec/presenters/asset_type_presenter_spec.rb b/spec/presenters/asset_type_presenter_spec.rb index b3055bb0..d63d9ff1 100644 --- a/spec/presenters/asset_type_presenter_spec.rb +++ b/spec/presenters/asset_type_presenter_spec.rb @@ -3,13 +3,13 @@ describe 'Presenter::AssetTypePresenter::AssetType' do describe '#validates_with' do let(:asset_type) { create(:asset_type, identifier_data_type:) } - let(:presenter) { Presenter::AssetTypePresenter::AssetType.new(asset_type) } + let(:presenter) { Presenters::AssetTypePresenter::AssetType.new(asset_type) } context 'when identifier_data_type is alphanumeric' do let(:identifier_data_type) { 'alphanumeric' } it 'returns the correct validation for the identifier data type' do - expect(presenter.validates_with).to eq Presenter::AssetTypePresenter::AssetType::ALPHANUMERIC_REGEX + expect(presenter.validates_with).to eq Presenters::AssetTypePresenter::AssetType::ALPHANUMERIC_REGEX end end @@ -17,7 +17,7 @@ let(:identifier_data_type) { 'numeric' } it 'returns the correct validation for the identifier data type' do - expect(presenter.validates_with).to eq Presenter::AssetTypePresenter::AssetType::NUMERIC_REGEX + expect(presenter.validates_with).to eq Presenters::AssetTypePresenter::AssetType::NUMERIC_REGEX end end end diff --git a/spec/presenters/batch_new_presenter_spec.rb b/spec/presenters/batch_new_presenter_spec.rb index 9eb15726..5bafd95a 100644 --- a/spec/presenters/batch_new_presenter_spec.rb +++ b/spec/presenters/batch_new_presenter_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -require './app/presenters/batch_presenter/new' -require './spec/presenters/shared_presenter_behaviour' +# require './app/presenters/batch_presenter/new' +# require './spec/presenters/shared_presenter_behaviour' describe 'Presenter::BatchPresenter::New' do - let(:presenter) { Presenter::BatchPresenter::New.new } + let(:presenter) { Presenters::BatchPresenter::New.new } context 'always' do include_examples('shared presenter behaviour') diff --git a/spec/presenters/batch_show_presenter_spec.rb b/spec/presenters/batch_show_presenter_spec.rb index c586effb..c62e0b37 100644 --- a/spec/presenters/batch_show_presenter_spec.rb +++ b/spec/presenters/batch_show_presenter_spec.rb @@ -4,7 +4,7 @@ describe 'Presenter::BatchPresenter::Show' do context 'with a batch' do - let(:presenter) { Presenter::BatchPresenter::Show.new(test_batch) } + let(:presenter) { Presenters::BatchPresenter::Show.new(test_batch) } let(:test_batch) { double('batch', assets: [asset_first, asset_second]) } let(:comment) { double('comment', comment: 'A comment') } let(:asset_second) do @@ -29,12 +29,12 @@ include_examples('shared presenter behaviour') it 'yields each asset in the batch in turn for each_asset' do - expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset_first).and_call_original - expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset_second).and_call_original + expect(Presenters::AssetPresenter::Asset).to receive(:new).with(asset_first).and_call_original + expect(Presenters::AssetPresenter::Asset).to receive(:new).with(asset_second).and_call_original expect do |b| presenter.each_asset(&b) - end.to yield_successive_args(Presenter::AssetPresenter::Asset, Presenter::AssetPresenter::Asset) + end.to yield_successive_args(Presenters::AssetPresenter::Asset, Presenters::AssetPresenter::Asset) end it 'returns the study_name (of the first asset) for study' do diff --git a/spec/presenters/report_new_presenter_spec.rb b/spec/presenters/report_new_presenter_spec.rb index a23633d3..4f1471b7 100644 --- a/spec/presenters/report_new_presenter_spec.rb +++ b/spec/presenters/report_new_presenter_spec.rb @@ -2,8 +2,8 @@ require './app/presenters/report_presenter/new' require './spec/presenters/shared_presenter_behaviour' -describe 'Presenter::ReportPresenter::New' do - let(:presenter) { Presenter::ReportPresenter::New.new } +describe 'Presenters::ReportPresenter::New' do + let(:presenter) { Presenters::ReportPresenter::New.new } context 'always' do include_examples('shared presenter behaviour') @@ -23,7 +23,7 @@ context 'with valid report' do let!(:workflow) { create(:workflow, name: 'Workflow') } let!(:report) { Report.new(workflow:, start_date: '01/04/2017', end_date: '15/04/2017') } - let(:presenter) { Presenter::ReportPresenter::New.new(report) } + let(:presenter) { Presenters::ReportPresenter::New.new(report) } it 'has report data' do expect(presenter.workflow).to eq 'Workflow' @@ -38,7 +38,7 @@ context 'with invalid report' do let!(:workflow) { create(:workflow, name: 'Workflow') } let!(:report) { Report.new(workflow:, start_date: '01/04/2017') } - let(:presenter) { Presenter::ReportPresenter::New.new(report) } + let(:presenter) { Presenters::ReportPresenter::New.new(report) } it 'has flash' do expect(presenter.report.valid?).to be false diff --git a/spec/presenters/report_show_presenter_spec.rb b/spec/presenters/report_show_presenter_spec.rb index b5edcf1d..eeac6056 100644 --- a/spec/presenters/report_show_presenter_spec.rb +++ b/spec/presenters/report_show_presenter_spec.rb @@ -4,14 +4,14 @@ require './app/presenters/report_presenter/show' require './spec/presenters/shared_presenter_behaviour' -describe 'Presenter::ReportPresenter::Show' do +describe 'Presenters::ReportPresenter::Show' do let(:workflow) { build(:workflow, name: 'Workflow') } let!(:report) { Report.new(workflow:, start_date: '01/04/2017', end_date: '15/04/2017') } let(:asset_first) { create(:asset, workflow:, study: 'Study1', project: 'Project1') } let(:asset_second) do create(:asset, workflow:, study: 'Study1', project: 'Project2', cost_code: create(:cost_code, name: 'A1')) end - let(:presenter) { Presenter::ReportPresenter::Show.new(report) } + let(:presenter) { Presenters::ReportPresenter::Show.new(report) } before do create(:state, name: 'completed') From 43fd4e90e6fa42ac4e310fc48d0340efb6fc1613 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:19:21 +0100 Subject: [PATCH 44/49] Fixed Zeitwerk issues. --- app/controllers/admin_controller.rb | 4 +- app/controllers/assets_controller.rb | 2 +- app/controllers/batches_controller.rb | 11 +- app/controllers/reports_controller.rb | 6 +- app/controllers/workflows_controller.rb | 4 +- app/presenters/admin_presenter/index.rb | 8 +- app/presenters/asset_presenter/asset.rb | 206 +++++++++--------- app/presenters/asset_presenter/index.rb | 110 +++++----- .../asset_type_presenter/asset_type.rb | 8 +- app/presenters/batch_presenter/new.rb | 76 +++---- app/presenters/batch_presenter/show.rb | 124 ++++++----- app/presenters/deployment_info.rb | 27 +++ app/presenters/report_presenter/new.rb | 66 +++--- app/presenters/report_presenter/show.rb | 54 ++--- .../{presenter.rb => shared_behaviour.rb} | 39 +--- app/presenters/workflow_presenter/show.rb | 30 +-- bin/rails | 11 +- bin/rake | 9 +- bin/setup | 28 ++- config/application.rb | 3 + config/boot.rb | 4 +- config/cable.yml | 10 + config/environment.rb | 2 +- config/environments/development.rb | 65 ++++-- config/environments/production.rb | 68 +++--- config/environments/test.rb | 50 +++-- config/initializers/assets.rb | 9 +- .../initializers/content_security_policy.rb | 25 +++ .../initializers/filter_parameter_logging.rb | 8 +- config/initializers/inflections.rb | 8 +- .../new_framework_defaults_7_0.rb | 143 ++++++++++++ config/initializers/permissions_policy.rb | 11 + db/schema.rb | 2 +- .../create_and_update_workflow_spec.rb | 3 + spec/presenters/asset_index_presenter_spec.rb | 7 +- spec/presenters/asset_presenter_spec.rb | 4 +- spec/presenters/asset_type_presenter_spec.rb | 8 +- spec/presenters/batch_new_presenter_spec.rb | 6 +- spec/presenters/batch_show_presenter_spec.rb | 12 +- spec/presenters/report_new_presenter_spec.rb | 10 +- spec/presenters/report_show_presenter_spec.rb | 6 +- 41 files changed, 758 insertions(+), 529 deletions(-) create mode 100644 app/presenters/deployment_info.rb rename app/presenters/{presenter.rb => shared_behaviour.rb} (63%) create mode 100644 config/cable.yml create mode 100644 config/initializers/content_security_policy.rb create mode 100644 config/initializers/new_framework_defaults_7_0.rb create mode 100644 config/initializers/permissions_policy.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 03757c57..126ee9e8 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,7 +1,5 @@ -require './app/presenters/admin_presenter/index' - class AdminController < ApplicationController def index - @presenter = Presenters::AdminPresenter::Index.new + @presenter = AdminPresenter::Index.new end end diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index f5d13b1b..c946f114 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -5,7 +5,7 @@ def index else assets = Asset.in_state(state) .with_identifier(params[:identifier]) - @presenter = Presenters::AssetPresenter::Index.new(assets, search, state) + @presenter = AssetPresenter::Index.new(assets, search, state) end end diff --git a/app/controllers/batches_controller.rb b/app/controllers/batches_controller.rb index 0ed50dc4..a667f094 100644 --- a/app/controllers/batches_controller.rb +++ b/app/controllers/batches_controller.rb @@ -1,15 +1,12 @@ -require './app/presenters/batch_presenter/new' -require './app/presenters/batch_presenter/show' - class BatchesController < ApplicationController before_action :batch, only: %i[show update remove] def show - @presenter = Presenters::BatchPresenter::Show.new(batch) + @presenter = BatchPresenter::Show.new(batch) end def new - @presenter = Presenters::BatchPresenter::New.new + @presenter = BatchPresenter::New.new end def create @@ -26,7 +23,7 @@ def create ) if batch_creator.valid? batch = batch_creator.create! - @presenter = Presenters::BatchPresenter::Show.new(batch) + @presenter = BatchPresenter::Show.new(batch) flash[:notice] = I18n.t('batches.success.created') redirect_to("/batches/#{@presenter.id}") else @@ -48,7 +45,7 @@ def update ) if batch_updater.valid? batch = batch_updater.update! - @presenter = Presenters::BatchPresenter::Show.new(batch) + @presenter = BatchPresenter::Show.new(batch) flash[:notice] = I18n.t('batches.success.updated') redirect_to("/batches/#{params[:id]}") else diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 50a23fd3..4bbdc33c 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -2,16 +2,16 @@ class ReportsController < ApplicationController def show; end def new - @presenter = Presenters::ReportPresenter::New.new + @presenter = ReportPresenter::New.new end def create report = Report.new(params.permit(:workflow_id, :start_date, :end_date)) if report.valid? - @presenter = Presenters::ReportPresenter::Show.new(report) + @presenter = ReportPresenter::Show.new(report) render :show else - @presenter = Presenters::ReportPresenter::New.new(report) + @presenter = ReportPresenter::New.new(report) flash[:error] = @presenter.flash render :new end diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb index ac7c1b76..ef9684bc 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -1,10 +1,8 @@ -require './app/presenters/workflow_presenter/show' - class WorkflowsController < ApplicationController include InitialState def show - @presenter = Presenters::WorkflowPresenter::Show.new(workflow) + @presenter = WorkflowPresenter::Show.new(workflow) end def create diff --git a/app/presenters/admin_presenter/index.rb b/app/presenters/admin_presenter/index.rb index b64a3299..36b4b9d9 100644 --- a/app/presenters/admin_presenter/index.rb +++ b/app/presenters/admin_presenter/index.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -module Presenters - module AdminPresenter - class Index < Presenter - end +module AdminPresenter + class Index + include SharedBehaviour + include DeploymentInfo end end diff --git a/app/presenters/asset_presenter/asset.rb b/app/presenters/asset_presenter/asset.rb index eb58a922..cc1f83d6 100644 --- a/app/presenters/asset_presenter/asset.rb +++ b/app/presenters/asset_presenter/asset.rb @@ -1,145 +1,145 @@ # frozen_string_literal: true -module Presenters - module AssetPresenter - # Presenter for showing an asset - class Asset < Presenter - attr_reader :asset - - def initialize(asset) - @asset = asset - end +module AssetPresenter + # Presenter for showing an asset + class Asset + include SharedBehaviour + include DeploymentInfo + attr_reader :asset + + def initialize(asset) + @asset = asset + end - def identifier_type - asset.asset_type.identifier_type - end + def identifier_type + asset.asset_type.identifier_type + end - delegate :id, to: :asset + delegate :id, to: :asset - delegate :identifier, to: :asset + delegate :identifier, to: :asset - delegate :sample_count, to: :asset + delegate :sample_count, to: :asset - delegate :study, to: :asset + delegate :study, to: :asset - def project - asset.project.nil? ? 'Not defined' : asset.project - end + def project + asset.project.nil? ? 'Not defined' : asset.project + end - def workflow - asset.workflow.name - end + def workflow + asset.workflow.name + end - def pipeline_destination - asset.pipeline_destination.nil? ? 'None' : asset.pipeline_destination.name - end + def pipeline_destination + asset.pipeline_destination.nil? ? 'None' : asset.pipeline_destination.name + end - def cost_code - asset.cost_code.nil? ? 'Not defined' : asset.cost_code.name - end + def cost_code + asset.cost_code.nil? ? 'Not defined' : asset.cost_code.name + end - def created_at - asset.begun_at.strftime('%d/%m/%Y') - end + def created_at + asset.begun_at.strftime('%d/%m/%Y') + end - def updated_at - asset.updated_at.strftime('%d/%m/%Y') - end + def updated_at + asset.updated_at.strftime('%d/%m/%Y') + end - def comments - return asset.comment.comment if asset.comment + def comments + return asset.comment.comment if asset.comment - '' - end + '' + end - def completed_status_label - if completed_late? - return "Late #{asset.time_without_completion - asset.workflow.turn_around_days} " \ - "#{'day'.pluralize(overdue_by)}" - end - if completed_early? - return "Early #{asset.workflow.turn_around_days - asset.time_without_completion} " \ - "#{'day'.pluralize(overdue_by)}" - end - - 'On time' if completed_on_time? + def completed_status_label + if completed_late? + return "Late #{asset.time_without_completion - asset.workflow.turn_around_days} " \ + "#{'day'.pluralize(overdue_by)}" end - - def completed_at_status - "#{asset.completed_at.strftime('%d/%m/%Y')} #{"(#{completed_status_label})" if completed_status_label}" + if completed_early? + return "Early #{asset.workflow.turn_around_days - asset.time_without_completion} " \ + "#{'day'.pluralize(overdue_by)}" end - def completed_at - return completed_at_status if asset.completed_at - return 'Due today' if due_today? - return "Overdue (#{overdue_by} #{'day'.pluralize(overdue_by)})" if overdue? + 'On time' if completed_on_time? + end - "In progress#{in_progress_status}" - end + def completed_at_status + "#{asset.completed_at.strftime('%d/%m/%Y')} #{"(#{completed_status_label})" if completed_status_label}" + end - def days_left - [asset.workflow.turn_around_days - asset.age, 0].max.to_i - end + def completed_at + return completed_at_status if asset.completed_at + return 'Due today' if due_today? + return "Overdue (#{overdue_by} #{'day'.pluralize(overdue_by)})" if overdue? + + "In progress#{in_progress_status}" + end - def in_progress_status - return " (#{days_left} days left)" if asset.workflow.turn_around_days + def days_left + [asset.workflow.turn_around_days - asset.age, 0].max.to_i + end - '' - end + def in_progress_status + return " (#{days_left} days left)" if asset.workflow.turn_around_days - def due_today? - return false if asset.workflow.turn_around_days.nil? + '' + end - (0..1).cover?(time_from_due_date) - end + def due_today? + return false if asset.workflow.turn_around_days.nil? - def time_from_due_date - asset.age - asset.workflow.turn_around_days - end + (0..1).cover?(time_from_due_date) + end - def completed_early? - return asset.time_without_completion < asset.workflow.turn_around_days if asset.workflow.turn_around_days + def time_from_due_date + asset.age - asset.workflow.turn_around_days + end - false - end + def completed_early? + return asset.time_without_completion < asset.workflow.turn_around_days if asset.workflow.turn_around_days - def completed_late? - return asset.time_without_completion > asset.workflow.turn_around_days if asset.workflow.turn_around_days + false + end - false - end + def completed_late? + return asset.time_without_completion > asset.workflow.turn_around_days if asset.workflow.turn_around_days + + false + end - def completed_on_time? - return asset.time_without_completion == asset.workflow.turn_around_days if asset.workflow.turn_around_days + def completed_on_time? + return asset.time_without_completion == asset.workflow.turn_around_days if asset.workflow.turn_around_days - false - end + false + end - def overdue_by - return 0 if asset.workflow.turn_around_days.nil? + def overdue_by + return 0 if asset.workflow.turn_around_days.nil? - [time_from_due_date.floor, 0].max - end + [time_from_due_date.floor, 0].max + end - def overdue? - asset.completed_at.nil? && overdue_by.positive? - end + def overdue? + asset.completed_at.nil? && overdue_by.positive? + end - def completed? - asset.completed_at.present? - end + def completed? + asset.completed_at.present? + end - def batch_id - asset.batch.id - end + def batch_id + asset.batch.id + end - def status_code - return 'success' if completed_early? - return 'warning' if due_today? || completed_on_time? - return 'danger' if overdue? || completed_late? + def status_code + return 'success' if completed_early? + return 'warning' if due_today? || completed_on_time? + return 'danger' if overdue? || completed_late? - 'default' - end + 'default' end end end diff --git a/app/presenters/asset_presenter/index.rb b/app/presenters/asset_presenter/index.rb index 3b678c88..32cafa6f 100644 --- a/app/presenters/asset_presenter/index.rb +++ b/app/presenters/asset_presenter/index.rb @@ -1,74 +1,74 @@ # frozen_string_literal: true -module Presenters - module AssetPresenter - # Presenter for showing a list of assets - class Index < Presenter - attr_reader :search, :assets, :total +module AssetPresenter + # Presenter for showing a list of assets + class Index + include SharedBehaviour + include DeploymentInfo + attr_reader :search, :assets, :total - def initialize(found_assets, search = nil, state = nil) - @assets = found_assets.group_by { |a| a.asset_type.name }.tap { |h| h.default = [] } - @total = found_assets.length - @search = search - @state = state.name if state - end + def initialize(found_assets, search = nil, state = nil) + @assets = found_assets.group_by { |a| a.asset_type.name }.tap { |h| h.default = [] } + @total = found_assets.length + @search = search + @state = state.name if state + end - def asset_identifiers - assets.values.flatten.map(&:identifier) - end + def asset_identifiers + assets.values.flatten.map(&:identifier) + end - def assets?(type) - assets[type].length.positive? - end + def assets?(type) + assets[type].length.positive? + end - def num_assets(type) - assets[type].length - end + def num_assets(type) + assets[type].length + end - def assets_from_batch(type, batch_id) - @assets[type].select { |a| a.batch.id == batch_id } - end + def assets_from_batch(type, batch_id) + @assets[type].select { |a| a.batch.id == batch_id } + end - def each_asset(type) - return if assets[type].nil? + def each_asset(type) + return if assets[type].nil? - assets[type].each do |asset| - yield Presenters::AssetPresenter::Asset.new(asset) - end + assets[type].each do |asset| + yield AssetPresenter::Asset.new(asset) end + end - def search_parameters - yield search if search? - end + def search_parameters + yield search if search? + end - def search? - search.present? - end + def search? + search.present? + end - def workflow - 'None' - end + def workflow + 'None' + end - def state - @state.humanize - end + def state + @state.humanize + end - def action - { 'in_progress' => 'complete', - 'cherrypick' => 'cherrypicking', - 'volume_check' => 'check_volume', - 'quant' => 'complete', - 'report_required' => 'report' }[@state] - end + def action + { 'in_progress' => 'complete', + 'cherrypick' => 'cherrypicking', + 'volume_check' => 'check_volume', + 'quant' => 'complete', + 'report_required' => 'report' }[@state] + end - def action_button - { 'in_progress' => 'Completed selected', - 'cherrypick' => 'Completed selected', - 'volume_check' => 'Volume checked selected', - 'quant' => 'Completed selected', - 'report_required' => 'Reported selected' }[@state].tap do |button| - yield button if button.present? - end + def action_button + { 'in_progress' => 'Completed selected', + 'cherrypick' => 'Completed selected', + 'volume_check' => 'Volume checked selected', + 'quant' => 'Completed selected', + 'report_required' => 'Reported selected' }[@state].tap do |button| + yield button if button.present? end end end diff --git a/app/presenters/asset_type_presenter/asset_type.rb b/app/presenters/asset_type_presenter/asset_type.rb index 18d5e4e8..5e4bceb8 100644 --- a/app/presenters/asset_type_presenter/asset_type.rb +++ b/app/presenters/asset_type_presenter/asset_type.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true -module Presenters - module AssetTypePresenter +module AssetTypePresenter # Presenter for showing an asset type - class AssetType < Presenter + class AssetType + include SharedBehaviour + include DeploymentInfo attr_reader :asset_type ALPHANUMERIC_REGEX = '^[\w-]+$' @@ -50,5 +51,4 @@ def field_value_shared_inside_batch?(asset_field) %i[batch_id workflow cost_code study project].include?(asset_field) end end - end end diff --git a/app/presenters/batch_presenter/new.rb b/app/presenters/batch_presenter/new.rb index b92c76ee..5e1777b5 100644 --- a/app/presenters/batch_presenter/new.rb +++ b/app/presenters/batch_presenter/new.rb @@ -1,54 +1,54 @@ # frozen_string_literal: true -module Presenters - module BatchPresenter - # Presenter for creating a new batch - class New < Presenter - def each_asset; end - - def study - '' - end +module BatchPresenter + # Presenter for creating a new batch + class New + include SharedBehaviour + include DeploymentInfo + def each_asset; end + + def study + '' + end - def project - '' - end + def project + '' + end - def workflow; end + def workflow; end - def pipeline_destination - 'None' - end + def pipeline_destination + 'None' + end - def cost_code - '' - end + def cost_code + '' + end - def action - '/batches' - end + def action + '/batches' + end - def comment - '' - end + def comment + '' + end - def show_completed? - false - end + def show_completed? + false + end - def num_assets - 1 - end + def num_assets + 1 + end - def placeholder_date - 'Today' - end + def placeholder_date + 'Today' + end - def prohibited_workflow(_reportable, _qc_flow, _cherrypick_flow); end + def prohibited_workflow(_reportable, _qc_flow, _cherrypick_flow); end - def workflow_name - '' - end + def workflow_name + '' end end end diff --git a/app/presenters/batch_presenter/show.rb b/app/presenters/batch_presenter/show.rb index 888185da..84659965 100644 --- a/app/presenters/batch_presenter/show.rb +++ b/app/presenters/batch_presenter/show.rb @@ -1,90 +1,88 @@ # frozen_string_literal: true -require './app/presenters/asset_presenter/asset' - -module Presenters - module BatchPresenter - # Presenter for showing a batch - class Show < Presenter - attr_reader :batch - - def initialize(batch) - @batch = batch - end +module BatchPresenter + # Presenter for showing a batch + class Show + include SharedBehaviour + include DeploymentInfo + attr_reader :batch + + def initialize(batch) + @batch = batch + end - delegate :id, to: :batch + delegate :id, to: :batch - def action - "/batches/#{id}" - end + def action + "/batches/#{id}" + end - def each_asset - batch.assets.each do |asset| - yield Presenters::AssetPresenter::Asset.new(asset) - end + def each_asset + batch.assets.each do |asset| + yield AssetPresenter::Asset.new(asset) end + end - def study - return first_asset.study if first_asset + def study + return first_asset.study if first_asset - 'Not Applicable' - end + 'Not Applicable' + end - def project - return first_asset.project if first_asset + def project + return first_asset.project if first_asset - 'Not Applicable' - end + 'Not Applicable' + end - def workflow - @workflow ||= (first_asset.workflow if first_asset.present?) || '' - end + def workflow + @workflow ||= (first_asset.workflow if first_asset.present?) || '' + end - def prohibited_workflow(reportable, qc_flow, cherrypick_flow) - return if workflow.blank? + def prohibited_workflow(reportable, qc_flow, cherrypick_flow) + return if workflow.blank? - (workflow.reportable != reportable) || - (workflow.qc_flow != qc_flow) || - (workflow.cherrypick_flow != cherrypick_flow) - end + (workflow.reportable != reportable) || + (workflow.qc_flow != qc_flow) || + (workflow.cherrypick_flow != cherrypick_flow) + end - def workflow_name - workflow.name if workflow.present? - end + def workflow_name + workflow.name if workflow.present? + end - def pipeline_destination - return first_asset.pipeline_destination.name if first_asset && !first_asset.pipeline_destination.nil? + def pipeline_destination + return first_asset.pipeline_destination.name if first_asset && !first_asset.pipeline_destination.nil? - 'None' - end + 'None' + end - def cost_code - return first_asset.cost_code.name if first_asset && !first_asset.cost_code.nil? + def cost_code + return first_asset.cost_code.name if first_asset && !first_asset.cost_code.nil? - '' - end + '' + end - def comment - return first_asset.comment.comment if first_asset&.comment + def comment + return first_asset.comment.comment if first_asset&.comment - '' - end + '' + end - def show_completed? - true - end + def show_completed? + true + end - def first_asset - batch.assets.first - end + def first_asset + batch.assets.first + end - def num_assets - batch.assets.count - end + def num_assets + batch.assets.count + end - def placeholder_date - first_asset.begun_at.strftime('%d/%m/%Y') - end + def placeholder_date + first_asset.begun_at.strftime('%d/%m/%Y') end end end diff --git a/app/presenters/deployment_info.rb b/app/presenters/deployment_info.rb new file mode 100644 index 00000000..cb93c224 --- /dev/null +++ b/app/presenters/deployment_info.rb @@ -0,0 +1,27 @@ +require './lib/deployed_version' + +# module Presenters + module DeploymentInfo + + def version_information + # Provides a quick means of checking the deployed version + Deployed::VERSION_STRING + end + + def commit_information + Deployed::VERSION_COMMIT + end + + def repo_url + Deployed::REPO_URL + end + + def host_name + Deployed::HOSTNAME + end + + def release_name + Deployed::RELEASE_NAME + end + end +# end \ No newline at end of file diff --git a/app/presenters/report_presenter/new.rb b/app/presenters/report_presenter/new.rb index 351ee8b6..4023108a 100644 --- a/app/presenters/report_presenter/new.rb +++ b/app/presenters/report_presenter/new.rb @@ -1,38 +1,38 @@ # frozen_string_literal: true -module Presenters - module ReportPresenter - # Presenter for creating a new report - class New < Presenter - attr_reader :report - - def initialize(report = Report.new({})) - @report = report - end - - def action - '/reports' - end - - def page - :'reports/new' - end - - def flash - report.errors.full_messages.join(', ') if report.errors.present? - end - - def workflow - report.workflow.name if report.workflow.present? - end - - def start_date - report.start_date.strftime(report.date_format) if report.start_date.present? - end - - def end_date - report.end_date.strftime(report.date_format) if report.end_date.present? - end +module ReportPresenter + # Presenter for creating a new report + class New + include SharedBehaviour + include DeploymentInfo + attr_reader :report + + def initialize(report = Report.new({})) + @report = report + end + + def action + '/reports' + end + + def page + :'reports/new' + end + + def flash + report.errors.full_messages.join(', ') if report.errors.present? + end + + def workflow + report.workflow.name if report.workflow.present? + end + + def start_date + report.start_date.strftime(report.date_format) if report.start_date.present? + end + + def end_date + report.end_date.strftime(report.date_format) if report.end_date.present? end end end diff --git a/app/presenters/report_presenter/show.rb b/app/presenters/report_presenter/show.rb index 4e545d46..bc3dc352 100644 --- a/app/presenters/report_presenter/show.rb +++ b/app/presenters/report_presenter/show.rb @@ -1,36 +1,36 @@ -module Presenters - module ReportPresenter - # Presenter for showing a report - class Show < Presenter - attr_reader :report +module ReportPresenter + # Presenter for showing a report + class Show + include SharedBehaviour + include DeploymentInfo + attr_reader :report - def initialize(report) - @report = report - end + def initialize(report) + @report = report + end - def page - :'reports/show' - end + def page + :'reports/show' + end - def flash; end + def flash; end - delegate :title, to: :report + delegate :title, to: :report - def column_names - "#{report.column_names.map(&:humanize).join("")}" - end + def column_names + "#{report.column_names.map(&:humanize).join("")}" + end - def rows - ''.tap do |html| - report.rows.each_with_index do |row, index| - html_for_row = '' \ - " #{index + 1} " \ - "" + - row.data_for(report.column_names).join("") + - '' \ - '' - html << html_for_row - end + def rows + ''.tap do |html| + report.rows.each_with_index do |row, index| + html_for_row = '' \ + " #{index + 1} " \ + "" + + row.data_for(report.column_names).join("") + + '' \ + '' + html << html_for_row end end end diff --git a/app/presenters/presenter.rb b/app/presenters/shared_behaviour.rb similarity index 63% rename from app/presenters/presenter.rb rename to app/presenters/shared_behaviour.rb index 87a37d8c..771a0571 100644 --- a/app/presenters/presenter.rb +++ b/app/presenters/shared_behaviour.rb @@ -1,37 +1,5 @@ -# frozen_string_literal: true - -# This file contains the Presenter module, which is included in all presenters. -class Presenter - # Provides information about the deployed version - module DeploymentInfo - require './lib/deployed_version' - - def version_information - # Provides a quick means of checking the deployed version - Deployed::VERSION_STRING - end - - def commit_information - Deployed::VERSION_COMMIT - end - - def repo_url - Deployed::REPO_URL - end - - def host_name - Deployed::HOSTNAME - end - - def release_name - Deployed::RELEASE_NAME - end - end - include DeploymentInfo - - # Presenter::SharedBehaviour +# module Presenters module SharedBehaviour - require './app/presenters/asset_type_presenter/asset_type' def each_asset_type AssetType.find_each do |asset_type| @@ -44,7 +12,7 @@ def each_asset_type def with_each_asset_type AssetType.find_each do |asset_type| - yield(Presenters::AssetTypePresenter::AssetType.new(asset_type)) + yield(AssetTypePresenter::AssetType.new(asset_type)) end end @@ -86,5 +54,4 @@ def each_cost_code end end end - include SharedBehaviour -end +# end diff --git a/app/presenters/workflow_presenter/show.rb b/app/presenters/workflow_presenter/show.rb index ca749fb9..5f63a2d7 100644 --- a/app/presenters/workflow_presenter/show.rb +++ b/app/presenters/workflow_presenter/show.rb @@ -1,24 +1,24 @@ # frozen_string_literal: true -module Presenters - module WorkflowPresenter - # Presenter for showing a workflow - class Show < Presenter - attr_reader :workflow +module WorkflowPresenter + # Presenter for showing a workflow + class Show + include SharedBehaviour + include DeploymentInfo + attr_reader :workflow - def initialize(workflow) - @workflow = workflow - end + def initialize(workflow) + @workflow = workflow + end - delegate :name, :has_comment, :reportable, :qc_flow, :cherrypick_flow, :active, to: :workflow + delegate :name, :has_comment, :reportable, :qc_flow, :cherrypick_flow, :active, to: :workflow - def turn_around - workflow.turn_around_days - end + def turn_around + workflow.turn_around_days + end - def action - "/admin/workflows/#{workflow.id}" - end + def action + "/admin/workflows/#{workflow.id}" end end end diff --git a/bin/rails b/bin/rails index 0138d79b..efc03774 100755 --- a/bin/rails +++ b/bin/rails @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end -APP_PATH = File.expand_path('../../config/application', __FILE__) -require_relative '../config/boot' -require 'rails/commands' +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake index d87d5f57..4fbf10b9 100755 --- a/bin/rake +++ b/bin/rake @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end -require_relative '../config/boot' -require 'rake' +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/bin/setup b/bin/setup index acdb2c13..ec47b79b 100755 --- a/bin/setup +++ b/bin/setup @@ -1,29 +1,33 @@ #!/usr/bin/env ruby -require 'pathname' +require "fileutils" # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = File.expand_path("..", __dir__) -Dir.chdir APP_ROOT do - # This script is a starting point to setup your application. - # Add necessary setup steps to this file: +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. + # Add necessary setup steps to this file. puts "== Installing dependencies ==" - system "gem install bundler --conservative" - system "bundle check || bundle install" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" # unless File.exist?("config/database.yml") - # system "cp config/database.yml.sample config/database.yml" + # FileUtils.cp "config/database.yml.sample", "config/database.yml" # end puts "\n== Preparing database ==" - system "bin/rake db:setup" + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system "rm -f log/*" - system "rm -rf tmp/cache" + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system "touch tmp/restart.txt" + system! "bin/rails restart" end diff --git a/config/application.rb b/config/application.rb index 974bb5bb..6c46a0ec 100644 --- a/config/application.rb +++ b/config/application.rb @@ -20,12 +20,15 @@ class Application < Rails::Application # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de + config.load_defaults 7.0 + config.mailer = YAML.load_file("#{Rails.root}/config/mailer.yml")[Rails.env] config.autoload_paths += %W[#{config.root}/lib/utils] config.disable_animations = false config.autoload_paths += %W[#{Rails.root}/app] config.eager_load_paths += %W[#{Rails.root}/app] + config.autoload_paths += %W[#{Rails.root}/app/presenters] config.eager_load_paths += %W[#{Rails.root}/app/presenters] diff --git a/config/boot.rb b/config/boot.rb index 30f5120d..28201161 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -require 'bundler/setup' # Set up gems listed in the Gemfile. +require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 00000000..affbda04 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: test + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: sm_workflow_lims_production diff --git a/config/environment.rb b/config/environment.rb index 0b8bdd82..cac53157 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('application', __dir__) +require_relative "application" # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index b55e2144..8500f459 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,41 +1,70 @@ +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + + # Enable server timing + config.server_timing = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join("tmp/caching-dev.txt").exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + config.action_mailer.perform_caching = false + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - config.assets.debug = true + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Suppress logger output for asset requests. + config.assets.quiet = true - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true - # Adds additional error checking when serving assets at runtime. - # Checks for improperly declared sprockets dependencies. - # Raises helpful error messages. - config.assets.raise_runtime_errors = true + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 9ae9dd2d..6dd5f0a4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -14,51 +16,53 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier + # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache + # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain. + # config.action_cable.mount_path = nil + # config.action_cable.url = "wss://example.com/cable" + # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "sm_workflow_lims_production" + + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. @@ -68,11 +72,21 @@ # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify + # Don't log any deprecations. + config.active_support.report_deprecations = false # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = Logger::Formatter.new + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require "syslog/logger" + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false diff --git a/config/environments/test.rb b/config/environments/test.rb index bd09bd25..6ea4d1e7 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,24 +1,31 @@ +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! + # Turn false under Spring and add config.action_view.cache_template_loading = true. config.cache_classes = true - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. - config.eager_load = false + # Eager loading loads your whole application. When running a single test locally, + # this probably isn't necessary. It's a good idea to do in a continuous integration + # system, or in some way before deploying your code. + config.eager_load = ENV["CI"].present? - # Configure static file server for tests with Cache-Control for performance. - config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{1.hour.to_i}" + } # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false + config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false @@ -26,19 +33,28 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Randomize the order test cases are executed. - config.active_support.test_order = :random - # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true - config.disable_animations = true + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 6ef752c0..2eeef966 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,11 +1,12 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.version = "1.0" -# Add additional assets to the asset load path +# Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path # Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -Rails.application.config.assets.precompile += %w[disable_animations.css] +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 00000000..54f47cf1 --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header + +# Rails.application.configure do +# 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 +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap and inline scripts +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1e..adc6568c 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +# Configure parameters to be filtered from the log file. Use this to limit dissemination of +# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported +# notations and behaviors. +Rails.application.config.filter_parameters += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index ac033bf9..3860f659 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,13 @@ # 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.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' +# inflect.acronym "RESTful" # end 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 00000000..b13ef5ed --- /dev/null +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -0,0 +1,143 @@ +# 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 `