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 `
` element, regardless of whether
+# or not the content is passed as the first argument or as a block.
+# Rails.application.config.action_view.button_to_generates_button_tag = true
+
+# `stylesheet_link_tag` view helper will not render the media attribute by default.
+# Rails.application.config.action_view.apply_stylesheet_media_default = false
+
+# Change the digest class for the key generators to `OpenSSL::Digest::SHA256`.
+# Changing this default means invalidate all encrypted messages generated by
+# your application and, all the encrypted cookies. Only change this after you
+# rotated all the messages using the key rotator.
+#
+# See upgrading guide for more information on how to build a rotator.
+# https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html
+# Rails.application.config.active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
+
+# Change the digest class for ActiveSupport::Digest.
+# Changing this default means that for example Etags change and
+# various cache keys leading to cache invalidation.
+# Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256
+
+# Don't override ActiveSupport::TimeWithZone.name and use the default Ruby
+# implementation.
+# Rails.application.config.active_support.remove_deprecated_time_with_zone_name = true
+
+# Calls `Rails.application.executor.wrap` around test cases.
+# This makes test cases behave closer to an actual request or job.
+# Several features that are normally disabled in test, such as Active Record query cache
+# and asynchronous queries will then be enabled.
+# Rails.application.config.active_support.executor_around_test_case = true
+
+# Set both the `:open_timeout` and `:read_timeout` values for `:smtp` delivery method.
+# Rails.application.config.action_mailer.smtp_timeout = 5
+
+# The ActiveStorage video previewer will now use scene change detection to generate
+# better preview images (rather than the previous default of using the first frame
+# of the video).
+# Rails.application.config.active_storage.video_preview_arguments =
+# "-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"
+
+# Automatically infer `inverse_of` for associations with a scope.
+# Rails.application.config.active_record.automatic_scope_inversing = true
+
+# Raise when running tests if fixtures contained foreign key violations
+# Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
+
+# Disable partial inserts.
+# This default means that all columns will be referenced in INSERT queries
+# regardless of whether they have a default or not.
+# Rails.application.config.active_record.partial_inserts = false
+
+# Protect from open redirect attacks in `redirect_back_or_to` and `redirect_to`.
+# Rails.application.config.action_controller.raise_on_open_redirects = true
+
+# Change the variant processor for Active Storage.
+# Changing this default means updating all places in your code that
+# generate variants to use image processing macros and ruby-vips
+# operations. See the upgrading guide for detail on the changes required.
+# The `:mini_magick` option is not deprecated; it's fine to keep using it.
+# Rails.application.config.active_storage.variant_processor = :vips
+
+# Enable parameter wrapping for JSON.
+# Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it.
+# To disable parameter wrapping entirely, set this config to `false`.
+# Rails.application.config.action_controller.wrap_parameters_by_default = true
+
+# Specifies whether generated namespaced UUIDs follow the RFC 4122 standard for namespace IDs provided as a
+# `String` to `Digest::UUID.uuid_v3` or `Digest::UUID.uuid_v5` method calls.
+#
+# See https://guides.rubyonrails.org/configuring.html#config-active-support-use-rfc4122-namespaced-uuids for
+# more information.
+# Rails.application.config.active_support.use_rfc4122_namespaced_uuids = true
+
+# Change the default headers to disable browsers' flawed legacy XSS protection.
+# Rails.application.config.action_dispatch.default_headers = {
+# "X-Frame-Options" => "SAMEORIGIN",
+# "X-XSS-Protection" => "0",
+# "X-Content-Type-Options" => "nosniff",
+# "X-Download-Options" => "noopen",
+# "X-Permitted-Cross-Domain-Policies" => "none",
+# "Referrer-Policy" => "strict-origin-when-cross-origin"
+# }
+
+# ** Please read carefully, this must be configured in config/application.rb **
+# Change the format of the cache entry.
+# Changing this default means that all new cache entries added to the cache
+# will have a different format that is not supported by Rails 6.1 applications.
+# Only change this value after your application is fully deployed to Rails 7.0
+# and you have no plans to rollback.
+# When you're ready to change format, add this to `config/application.rb` (NOT this file):
+# config.active_support.cache_format_version = 7.0
+
+# Cookie serializer: 2 options
+#
+# If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
+# is `:marshal`. The default for new apps is `:json`.
+#
+# Rails.application.config.action_dispatch.cookies_serializer = :json
+#
+#
+# To migrate an existing application to the `:json` serializer, use the `:hybrid` option.
+#
+# Rails transparently deserializes existing (Marshal-serialized) cookies on read and
+# re-writes them in the JSON format.
+#
+# It is fine to use `:hybrid` long term; you should do that until you're confident *all* your cookies
+# have been converted to JSON. To keep using `:hybrid` long term, move this config to its own
+# initializer or to `config/application.rb`.
+#
+# Rails.application.config.action_dispatch.cookies_serializer = :hybrid
+#
+#
+# If your cookies can't yet be serialized to JSON, keep using `:marshal` for backward-compatibility.
+#
+# If you have configured the serializer elsewhere, you can remove this section of the file.
+#
+# See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.
+
+# Change the return value of `ActionDispatch::Request#content_type` to the Content-Type header without modification.
+# Rails.application.config.action_dispatch.return_only_request_media_type_on_content_type = false
+
+# Active Storage `has_many_attached` relationships will default to replacing the current collection instead of appending to it.
+# Thus, to support submitting an empty collection, the `file_field` helper will render an hidden field `include_hidden` by default when `multiple_file_field_include_hidden` is set to `true`.
+# See https://guides.rubyonrails.org/configuring.html#config-active-storage-multiple-file-field-include-hidden for more information.
+# Rails.application.config.active_storage.multiple_file_field_include_hidden = true
+
+# ** Please read carefully, this must be configured in config/application.rb (NOT this file) **
+# Disables the deprecated #to_s override in some Ruby core classes
+# See https://guides.rubyonrails.org/configuring.html#config-active-support-disable-to-s-conversion for more information.
+# config.active_support.disable_to_s_conversion = true
diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb
new file mode 100644
index 00000000..810aadeb
--- /dev/null
+++ b/config/initializers/permissions_policy.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+# Define an application-wide HTTP permissions policy. For further
+# information see https://developers.google.com/web/updates/2018/06/feature-policy
+#
+# Rails.application.config.permissions_policy do |f|
+# f.camera :none
+# f.gyroscope :none
+# f.microphone :none
+# f.usb :none
+# f.fullscreen :self
+# f.payment :self, "https://secure.example.com"
+# end
diff --git a/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
diff --git a/db/schema.rb b/db/schema.rb
index f28df22c..b089a352 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2019_09_24_154728) do
+ActiveRecord::Schema[6.1].define(version: 2019_09_24_154728) do
create_table "asset_types", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t|
t.string "name", null: false
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..6c99af99 100644
--- a/spec/presenters/asset_index_presenter_spec.rb
+++ b/spec/presenters/asset_index_presenter_spec.rb
@@ -1,8 +1,7 @@
require 'rails_helper'
-require './app/presenters/asset/index'
require './spec/presenters/shared_presenter_behaviour'
-describe Presenter::AssetPresenter::Index do
+describe 'AssetPresenter::Index' do
shared_context 'shared mocks' do
let(:mock_type) do
double('mock_type',
@@ -17,23 +16,23 @@
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) }
+ let(:presenter) { AssetPresenter::Index.new(assets, search, state) }
end
shared_examples 'standard behaviour' do
@@ -45,9 +44,9 @@
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(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
@@ -63,8 +62,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 +77,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 00d1b321..a661b35c 100644
--- a/spec/presenters/asset_presenter_spec.rb
+++ b/spec/presenters/asset_presenter_spec.rb
@@ -1,8 +1,7 @@
require 'rails_helper'
-require './app/presenters/asset/asset'
require 'timecop'
-describe Presenter::AssetPresenter::Asset do
+describe 'AssetPresenter::Asset' do
shared_examples 'shared behaviour' do
let(:mock_type) do
double('mock_type',
@@ -14,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) { 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 aa0ab242..d2163db8 100644
--- a/spec/presenters/asset_type_presenter_spec.rb
+++ b/spec/presenters/asset_type_presenter_spec.rb
@@ -1,15 +1,15 @@
require 'rails_helper'
-describe Presenter::AssetTypePresenter::AssetType do
+describe '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) { 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 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 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 1f060829..a4f25ca4 100644
--- a/spec/presenters/batch_new_presenter_spec.rb
+++ b/spec/presenters/batch_new_presenter_spec.rb
@@ -1,9 +1,7 @@
require 'rails_helper'
-require './app/presenters/batch/new'
-require './spec/presenters/shared_presenter_behaviour'
-describe Presenter::BatchPresenter::New do
- let(:presenter) { Presenter::BatchPresenter::New.new }
+describe 'BatchPresenter::New' do
+ let(:presenter) { 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 3ec550c4..fc8d81ea 100644
--- a/spec/presenters/batch_show_presenter_spec.rb
+++ b/spec/presenters/batch_show_presenter_spec.rb
@@ -1,23 +1,21 @@
require 'rails_helper'
-require './app/presenters/batch/show'
-require './spec/presenters/shared_presenter_behaviour'
-describe Presenter::BatchPresenter::Show do
+describe '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(:presenter) { BatchPresenter::Show.new(test_batch) }
+ 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,12 +27,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(asset1).and_call_original
- expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset2).and_call_original
+ expect(AssetPresenter::Asset).to receive(:new).with(asset_first).and_call_original
+ expect(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(AssetPresenter::Asset, 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 a60e56ab..6858c9b1 100644
--- a/spec/presenters/report_new_presenter_spec.rb
+++ b/spec/presenters/report_new_presenter_spec.rb
@@ -1,9 +1,7 @@
require 'rails_helper'
-require './app/presenters/report/new'
-require './spec/presenters/shared_presenter_behaviour'
-describe Presenter::ReportPresenter::New do
- let(:presenter) { Presenter::ReportPresenter::New.new }
+describe 'ReportPresenter::New' do
+ let(:presenter) { ReportPresenter::New.new }
context 'always' do
include_examples('shared presenter behaviour')
@@ -23,7 +21,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) { ReportPresenter::New.new(report) }
it 'has report data' do
expect(presenter.workflow).to eq 'Workflow'
@@ -38,7 +36,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) { 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 14531c15..6c58d4af 100644
--- a/spec/presenters/report_show_presenter_spec.rb
+++ b/spec/presenters/report_show_presenter_spec.rb
@@ -1,43 +1,46 @@
+# frozen_string_literal: true
+
require 'rails_helper'
-require './app/presenters/report/show'
-require './spec/presenters/shared_presenter_behaviour'
-describe Presenter::ReportPresenter::Show do
+describe '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) }
+ let(:presenter) { ReportPresenter::Show.new(report) }
+
+ before do
+ create(:state, name: 'completed')
+ end
- context 'always' do
+ 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