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..221de81e --- /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 }} diff --git a/.github/workflows/assign_issue_number.yml b/.github/workflows/assign_issue_number.yml new file mode 100644 index 00000000..90630b1e --- /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 }} 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 diff --git a/.release-version b/.release-version index 7c69a55d..19811903 100644 --- a/.release-version +++ b/.release-version @@ -1 +1 @@ -3.7.0 +3.8.0 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/.rubocop_todo.yml b/.rubocop_todo.yml index 93ce8915..4236bab3 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: @@ -328,15 +328,15 @@ Style/CaseEquality: # SupportedStyles: nested, compact 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/admin_presenter/index.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' @@ -611,3 +593,11 @@ 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' + +Layout/LineLength: + Exclude: + - 'config/initializers/new_framework_defaults_7_0.rb' 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 f4a94e01..77726f91 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,80 +1,87 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.6) - actionpack (= 6.1.6) - activesupport (= 6.1.6) + 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.6) - actionpack (= 6.1.6) - activejob (= 6.1.6) - activerecord (= 6.1.6) - activestorage (= 6.1.6) - activesupport (= 6.1.6) + 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.6) - actionpack (= 6.1.6) - actionview (= 6.1.6) - activejob (= 6.1.6) - activesupport (= 6.1.6) + 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.6) - actionview (= 6.1.6) - activesupport (= 6.1.6) - 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.6) - actionpack (= 6.1.6) - activerecord (= 6.1.6) - activestorage (= 6.1.6) - activesupport (= 6.1.6) + 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.6) - activesupport (= 6.1.6) + 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.6) - activesupport (= 6.1.6) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) 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 (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.6) + 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.1) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) 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) sassc (>= 2.0.0) - builder (3.2.4) - capybara (3.38.0) + builder (3.3.0) + 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) @@ -82,8 +89,9 @@ GEM capybara-selenium (0.0.6) capybara selenium-webdriver + childprocess (5.0.0) coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.3.3) crass (1.0.6) database_cleaner (2.0.2) database_cleaner-active_record (>= 2, < 3) @@ -91,106 +99,115 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.3) - diff-lcs (1.5.0) + 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) execjs (2.8.1) - factory_bot (6.2.1) + factory_bot (6.4.6) activesupport (>= 5.0.0) ffi (1.15.5) - globalid (1.1.0) - activesupport (>= 5.0) - i18n (1.12.0) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) - jbuilder (2.11.5) + jbuilder (2.12.0) 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) + json (2.7.2) + language_server-protocol (3.17.0.3) + launchy (3.0.0) addressable (~> 2.8) - loofah (2.19.1) + childprocess (~> 5.0) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (1.0.2) + net-imap + net-pop + net-smtp + marcel (1.0.4) matrix (0.4.2) - method_source (1.0.0) - mini_mime (1.1.2) - mini_portile2 (2.8.1) - minitest (5.18.0) - mysql2 (0.5.5) - net-imap (0.3.4) + method_source (1.1.0) + mini_mime (1.1.5) + mini_portile2 (2.8.7) + minitest (5.24.1) + mysql2 (0.5.6) + net-imap (0.4.14) 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.5.0) net-protocol - nio4r (2.5.9) - nokogiri (1.14.3) - mini_portile2 (~> 2.8.0) + nio4r (2.7.3) + nokogiri (1.16.6) + mini_portile2 (~> 2.8.2) racc (~> 1.4) - parallel (1.23.0) - parser (3.2.2.1) + parallel (1.25.1) + parser (3.3.2.0) ast (~> 2.4.1) + racc pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - psych (4.0.4) + psych (5.1.2) stringio - public_suffix (5.0.1) - puma (6.3.0) + public_suffix (5.0.4) + puma (6.4.2) nio4r (~> 2.0) - racc (1.6.2) - rack (2.2.6.4) - rack-mini-profiler (3.0.0) + racc (1.8.0) + rack (2.2.9) + rack-mini-profiler (3.3.1) 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) - 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 (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.6) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + railties (= 7.0.8.1) + 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) - railties (6.1.6) - actionpack (= 6.1.6) - activesupport (= 6.1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + 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.0.6) - rdoc (6.4.0) + rake (13.2.1) + rdoc (6.6.3.1) psych (>= 4.0.0) - regexp_parser (2.8.0) - rexml (3.2.5) - rspec-collection_matchers (1.2.0) + 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) rspec-support (~> 3.5.0) @@ -209,30 +226,38 @@ GEM rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) - rubocop (1.51.0) + rubocop (1.64.1) 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.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.28.1) - parser (>= 3.2.1.0) - rubocop-capybara (2.17.1) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.26.0) 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-performance (1.20.2) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) + rubocop-rails (2.24.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) - rubocop-rspec (2.19.0) - rubocop (~> 1.33) + rubocop-ast (>= 1.31.1, < 2.0) + 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) @@ -247,7 +272,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) @@ -257,19 +283,20 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - spring (4.1.1) - sprockets (3.7.2) + spring (4.2.1) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.1) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) - stringio (3.0.2) - thor (1.2.1) + stringio (3.1.0) + strscan (3.1.0) + thor (1.3.1) tilt (2.0.11) - timecop (0.9.6) - timeout (0.3.1) + timecop (0.9.8) + timeout (0.4.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) @@ -277,19 +304,19 @@ 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) bindex (>= 0.4.0) railties (>= 6.0.0) - websocket (1.2.9) - websocket-driver (0.7.5) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.7) + zeitwerk (2.6.16) PLATFORMS ruby @@ -311,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 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. 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 diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7a0ea906..126ee9e8 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,7 +1,5 @@ -require './app/presenters/admin/index' - class AdminController < ApplicationController def index - @presenter = Presenter::AdminPresenter::Index.new + @presenter = AdminPresenter::Index.new end end diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index dc39b81c..c946f114 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -1,5 +1,3 @@ -require './app/presenters/asset/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 = AssetPresenter::Index.new(assets, search, state) end end diff --git a/app/controllers/batches_controller.rb b/app/controllers/batches_controller.rb index e46b7c6f..a667f094 100644 --- a/app/controllers/batches_controller.rb +++ b/app/controllers/batches_controller.rb @@ -1,15 +1,12 @@ -require './app/presenters/batch/new' -require './app/presenters/batch/show' - class BatchesController < ApplicationController before_action :batch, only: %i[show update remove] def show - @presenter = Presenter::BatchPresenter::Show.new(batch) + @presenter = BatchPresenter::Show.new(batch) end def new - @presenter = Presenter::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 = Presenter::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 = Presenter::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 6c777c69..4bbdc33c 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,20 +1,17 @@ -require './app/presenters/report/new' -require './app/presenters/report/show' - class ReportsController < ApplicationController def show; end def new - @presenter = Presenter::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 = Presenter::ReportPresenter::Show.new(report) + @presenter = ReportPresenter::Show.new(report) render :show else - @presenter = Presenter::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 bb165efa..ef9684bc 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -1,10 +1,8 @@ -require './app/presenters/workflow/show' - class WorkflowsController < ApplicationController include InitialState def show - @presenter = Presenter::WorkflowPresenter::Show.new(workflow) + @presenter = WorkflowPresenter::Show.new(workflow) end def create 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/admin/index.rb b/app/presenters/admin/index.rb deleted file mode 100644 index ec4ad98e..00000000 --- a/app/presenters/admin/index.rb +++ /dev/null @@ -1,7 +0,0 @@ -require './app/presenters/presenter' -require './app/presenters/asset/asset' - -module Presenter::AdminPresenter - class Index < Presenter - end -end diff --git a/app/presenters/admin_presenter/index.rb b/app/presenters/admin_presenter/index.rb new file mode 100644 index 00000000..36b4b9d9 --- /dev/null +++ b/app/presenters/admin_presenter/index.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module AdminPresenter + class Index + include SharedBehaviour + include DeploymentInfo + end +end diff --git a/app/presenters/asset/asset.rb b/app/presenters/asset_presenter/asset.rb similarity index 81% rename from app/presenters/asset/asset.rb rename to app/presenters/asset_presenter/asset.rb index fc38deb3..f2c37b26 100644 --- a/app/presenters/asset/asset.rb +++ b/app/presenters/asset_presenter/asset.rb @@ -1,7 +1,10 @@ -require './app/presenters/presenter' +# frozen_string_literal: true -module Presenter::AssetPresenter - class Asset < Presenter +module AssetPresenter + # Presenter for showing an asset + class Asset + include SharedBehaviour + include DeploymentInfo attr_reader :asset def initialize(asset) @@ -52,16 +55,19 @@ def comments def completed_status_label if completed_late? - return "Late #{asset.time_without_completion - asset.workflow.turn_around_days} #{'day'.pluralize(overdue_by)}" + 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)}" + 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 - "#{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 @@ -69,7 +75,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 @@ -85,7 +91,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 @@ -117,7 +123,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 81% rename from app/presenters/asset/index.rb rename to app/presenters/asset_presenter/index.rb index 01d57873..32cafa6f 100644 --- a/app/presenters/asset/index.rb +++ b/app/presenters/asset_presenter/index.rb @@ -1,8 +1,10 @@ -require './app/presenters/presenter' -require './app/presenters/asset/asset' +# frozen_string_literal: true -module Presenter::AssetPresenter - class Index < Presenter +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) @@ -16,8 +18,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) @@ -32,15 +34,15 @@ def each_asset(type) return if assets[type].nil? assets[type].each do |asset| - yield Presenter::AssetPresenter::Asset.new(asset) + yield AssetPresenter::Asset.new(asset) end 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 81% rename from app/presenters/asset_type/asset_type.rb rename to app/presenters/asset_type_presenter/asset_type.rb index ae66cb2b..27f8383b 100644 --- a/app/presenters/asset_type/asset_type.rb +++ b/app/presenters/asset_type_presenter/asset_type.rb @@ -1,7 +1,10 @@ -require './app/presenters/presenter' +# frozen_string_literal: true -module Presenter::AssetTypePresenter - class AssetType < Presenter +module AssetTypePresenter + # Presenter for showing an asset type + class AssetType + include SharedBehaviour + include DeploymentInfo attr_reader :asset_type ALPHANUMERIC_REGEX = '^[\w-]+$' @@ -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 77% rename from app/presenters/batch/new.rb rename to app/presenters/batch_presenter/new.rb index 2ef7278e..5e1777b5 100644 --- a/app/presenters/batch/new.rb +++ b/app/presenters/batch_presenter/new.rb @@ -1,7 +1,10 @@ -require './app/presenters/presenter' +# frozen_string_literal: true -module Presenter::BatchPresenter - class New < Presenter +module BatchPresenter + # Presenter for creating a new batch + class New + include SharedBehaviour + include DeploymentInfo def each_asset; end def study diff --git a/app/presenters/batch/show.rb b/app/presenters/batch_presenter/show.rb similarity index 72% rename from app/presenters/batch/show.rb rename to app/presenters/batch_presenter/show.rb index cd371ca5..84659965 100644 --- a/app/presenters/batch/show.rb +++ b/app/presenters/batch_presenter/show.rb @@ -1,8 +1,10 @@ -require './app/presenters/presenter' -require './app/presenters/asset/asset' +# frozen_string_literal: true -module Presenter::BatchPresenter - class Show < Presenter +module BatchPresenter + # Presenter for showing a batch + class Show + include SharedBehaviour + include DeploymentInfo attr_reader :batch def initialize(batch) @@ -17,7 +19,7 @@ def action def each_asset batch.assets.each do |asset| - yield Presenter::AssetPresenter::Asset.new(asset) + yield AssetPresenter::Asset.new(asset) end end @@ -38,11 +40,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 +64,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/deployment_info.rb b/app/presenters/deployment_info.rb new file mode 100644 index 00000000..f0bc7ad0 --- /dev/null +++ b/app/presenters/deployment_info.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +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 diff --git a/app/presenters/presenter.rb b/app/presenters/presenter.rb deleted file mode 100644 index 6aac5451..00000000 --- a/app/presenters/presenter.rb +++ /dev/null @@ -1,85 +0,0 @@ -class Presenter - 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 - - module SharedBehaviour - require './app/presenters/asset_type/asset_type' - - def each_asset_type - AssetType.all.each do |asset_type| - yield(asset_type.name, - asset_type.identifier_type, - asset_type.has_sample_count, - asset_type.id) - end - end - - def with_each_asset_type - AssetType.all.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| - yield(workflow.name, - workflow.has_comment, - workflow.id, - workflow.reportable, - workflow.qc_flow, - workflow.turn_around_days, - workflow.active, - workflow.cherrypick_flow) - end - end - - def active_workflows - Workflow.where(active: true).includes(:initial_state).each do |workflow| - yield(workflow.name, - workflow.has_comment, - workflow.id, - workflow.reportable, - workflow.qc_flow, - workflow.cherrypick_flow, - workflow.turn_around_days, - workflow.active) - end - end - - def each_pipeline_destination - PipelineDestination.all.each do |pipeline_destination| - yield pipeline_destination.name, pipeline_destination.id - end - end - - def each_cost_code - CostCode.all.each do |cost_code| - yield cost_code.name, cost_code.id - end - end - end - include SharedBehaviour -end diff --git a/app/presenters/report/new.rb b/app/presenters/report_presenter/new.rb similarity index 78% rename from app/presenters/report/new.rb rename to app/presenters/report_presenter/new.rb index 5a3992b4..4023108a 100644 --- a/app/presenters/report/new.rb +++ b/app/presenters/report_presenter/new.rb @@ -1,7 +1,10 @@ -require './app/presenters/presenter' +# frozen_string_literal: true -module Presenter::ReportPresenter - class New < Presenter +module ReportPresenter + # Presenter for creating a new report + class New + include SharedBehaviour + include DeploymentInfo attr_reader :report def initialize(report = Report.new({})) diff --git a/app/presenters/report/show.rb b/app/presenters/report_presenter/show.rb similarity index 66% rename from app/presenters/report/show.rb rename to app/presenters/report_presenter/show.rb index 02f7b1c2..2dd8328e 100644 --- a/app/presenters/report/show.rb +++ b/app/presenters/report_presenter/show.rb @@ -1,7 +1,8 @@ -require './app/presenters/presenter' - -module Presenter::ReportPresenter - class Show < Presenter +module ReportPresenter + # Presenter for showing a report + class Show + include SharedBehaviour + include DeploymentInfo attr_reader :report def initialize(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/shared_behaviour.rb b/app/presenters/shared_behaviour.rb new file mode 100644 index 00000000..677dc474 --- /dev/null +++ b/app/presenters/shared_behaviour.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +# module Presenters +module SharedBehaviour + def each_asset_type + AssetType.find_each do |asset_type| + yield(asset_type.name, + asset_type.identifier_type, + asset_type.has_sample_count, + asset_type.id) + end + end + + def with_each_asset_type + AssetType.find_each do |asset_type| + yield(AssetTypePresenter::AssetType.new(asset_type)) + end + end + + def each_workflow + Workflow.includes(:initial_state).order(active: :desc).each do |workflow| + yield(workflow.name, + workflow.has_comment, + workflow.id, + workflow.reportable, + workflow.qc_flow, + workflow.turn_around_days, + workflow.active, + workflow.cherrypick_flow) + end + end + + def active_workflows + Workflow.where(active: true).includes(:initial_state).find_each do |workflow| + yield(workflow.name, + workflow.has_comment, + workflow.id, + workflow.reportable, + workflow.qc_flow, + workflow.cherrypick_flow, + workflow.turn_around_days, + workflow.active) + end + end + + def each_pipeline_destination + PipelineDestination.find_each do |pipeline_destination| + yield pipeline_destination.name, pipeline_destination.id + end + end + + def each_cost_code + CostCode.find_each do |cost_code| + yield cost_code.name, cost_code.id + end + end +end +# end diff --git a/app/presenters/workflow/show.rb b/app/presenters/workflow_presenter/show.rb similarity index 67% rename from app/presenters/workflow/show.rb rename to app/presenters/workflow_presenter/show.rb index 6dfcdb3b..5f63a2d7 100644 --- a/app/presenters/workflow/show.rb +++ b/app/presenters/workflow_presenter/show.rb @@ -1,7 +1,10 @@ -require './app/presenters/presenter' +# frozen_string_literal: true -module Presenter::WorkflowPresenter - class Show < Presenter +module WorkflowPresenter + # Presenter for showing a workflow + class Show + include SharedBehaviour + include DeploymentInfo attr_reader :workflow def initialize(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/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 4544c151..d1407928 100644 --- a/config/application.rb +++ b/config/application.rb @@ -20,12 +20,21 @@ 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/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 + + config.active_record.legacy_connection_handling = false + + config.action_controller.default_protect_from_forgery = false end end diff --git a/config/environment.rb b/config/environment.rb index 0b8bdd82..426333bb 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..e522e6ec 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..9d97b418 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,12 +72,22 @@ # 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 + # 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 end diff --git a/config/environments/test.rb b/config/environments/test.rb index bd09bd25..5f6cef4d 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/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 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/config/initializers/assets.rb b/config/initializers/assets.rb index 6ef752c0..b4475b51 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,9 +3,11 @@ # Version of your assets, change this if you want to expire all your assets. 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. +# 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 ) Rails.application.config.assets.precompile += %w[disable_animations.css] diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 00000000..53538c14 --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# 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..166997c5 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 += %i[ + 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..a91b0142 --- /dev/null +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -0,0 +1,143 @@ +# frozen_string_literal: true + +# 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 `