From 835060a173e5bb6c13d6bea82abda2918b6d9432 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 19:20:22 +0000 Subject: [PATCH 1/8] Update rubocop-rspec to version 2.26.1 --- Gemfile.lock | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 83501d49..75a7fb07 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -226,7 +226,9 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.30.0) parser (>= 3.2.1.0) - rubocop-capybara (2.17.1) + rubocop-capybara (2.20.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.25.1) rubocop (~> 1.41) rubocop-performance (1.18.0) rubocop (>= 1.7.0, < 2.0) @@ -236,9 +238,10 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rspec (2.19.0) - rubocop (~> 1.33) + rubocop-rspec (2.26.1) + rubocop (~> 1.40) rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) rubyzip (2.3.2) sass-rails (6.0.0) From e182d723612f0d7475aac19913dcaa6bc6cd6e41 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 19:25:19 +0000 Subject: [PATCH 2/8] Update rubocop-performance to version 1.20.2 --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 83501d49..7e2c5208 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -228,9 +228,9 @@ GEM parser (>= 3.2.1.0) rubocop-capybara (2.17.1) rubocop (~> 1.41) - rubocop-performance (1.18.0) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) + rubocop-performance (1.20.2) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) rubocop-rails (2.23.1) activesupport (>= 4.2.0) rack (>= 1.1) From b98f21a510c1cc78b0d57ec33b9a46d2d59974fd Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 00:16:24 +0000 Subject: [PATCH 3/8] Update rack-mini-profiler to version 3.3.1 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 83501d49..e68baf74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -156,7 +156,7 @@ GEM nio4r (~> 2.0) racc (1.7.3) rack (2.2.8) - rack-mini-profiler (3.0.0) + rack-mini-profiler (3.3.1) rack (>= 1.2.0) rack-test (2.1.0) rack (>= 1.3) From f55875e16481d7b0fa21639f891716b387ac72ca Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:50:14 +0000 Subject: [PATCH 4/8] Update factory_bot to version 6.4.6 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 65db7884..ff06578c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,7 +99,7 @@ GEM actionmailer (>= 5.2, < 8) activesupport (>= 5.2, < 8) execjs (2.8.1) - factory_bot (6.2.1) + factory_bot (6.4.6) activesupport (>= 5.0.0) ffi (1.15.5) globalid (1.2.1) From d55353d7067b54c674e5a276f68e972899e048bd Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 01:55:25 +0000 Subject: [PATCH 5/8] Update selenium-webdriver to version 4.18.1 --- Gemfile.lock | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 65db7884..dff9c92c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,6 +65,7 @@ GEM ast (2.4.2) autoprefixer-rails (10.4.7.0) execjs (~> 2) + base64 (0.2.0) bindex (0.8.1) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) @@ -256,7 +257,8 @@ GEM tilt sdoc (2.4.0) rdoc (>= 5.0) - selenium-webdriver (4.8.1) + selenium-webdriver (4.18.1) + base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -292,7 +294,7 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - websocket (1.2.9) + websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) From 861ba3444d4c4d812dc591fd504bd1359bc0dfac Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:16:31 +0000 Subject: [PATCH 6/8] Update RuboCop configuration and fix rubocop errors --- .rubocop.yml | 1 + report.csv | 2 +- spec/factories/workflow_factories.rb | 6 +- spec/features/create_and_edit_batch_spec.rb | 14 ++--- .../create_and_update_workflow_spec.rb | 6 +- ...ete_and_report_asset_standard_flow_spec.rb | 30 +++++----- ..._and_report_assets_cherrypick_flow_spec.rb | 54 +++++++++--------- ...complete_and_report_assets_qc_flow_spec.rb | 36 ++++++------ .../create_pipeline_destination_spec.rb | 6 +- spec/features/generate_report_spec.rb | 30 +++++----- spec/features/search_batch_and_assets_spec.rb | 20 +++---- spec/models/asset_spec.rb | 32 +++++------ spec/models/batch_creator_spec.rb | 2 +- spec/models/batch_updater_spec.rb | 2 +- spec/models/report_spec.rb | 12 ++-- spec/presenters/asset_index_presenter_spec.rb | 18 +++--- spec/presenters/asset_presenter_spec.rb | 2 +- spec/presenters/asset_type_presenter_spec.rb | 2 +- spec/presenters/batch_new_presenter_spec.rb | 2 +- spec/presenters/batch_show_presenter_spec.rb | 20 +++---- spec/presenters/report_new_presenter_spec.rb | 2 +- spec/presenters/report_show_presenter_spec.rb | 55 ++++++++++--------- spec/presenters/shared_presenter_behaviour.rb | 8 +-- spec/spec_helper.rb | 2 +- 24 files changed, 185 insertions(+), 179 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a3ec06dc..f6c69f84 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,5 +15,6 @@ require: - rubocop-rspec AllCops: NewCops: enable + SuggestExtensions: false Layout/LineLength: Max: 120 diff --git a/report.csv b/report.csv index da71144f..f038ca6a 100644 --- a/report.csv +++ b/report.csv @@ -1,4 +1,4 @@ -Report for 'Workflow1' workflow from 01/03/2017 to 31/03/2017 +Report for 'Workflow_first' workflow from 01/03/2017 to 31/03/2017 Study,Project,Cost code name,Assets count Study1,Project1,Not defined,1 Study1,Project2,A1,1 diff --git a/spec/factories/workflow_factories.rb b/spec/factories/workflow_factories.rb index 199d911e..ca1612a1 100644 --- a/spec/factories/workflow_factories.rb +++ b/spec/factories/workflow_factories.rb @@ -11,16 +11,16 @@ active { true } qc_flow { false } cherrypick_flow { false } - association :initial_state, factory: :state, name: 'in_progress' + initial_state factory: %i[state], name: 'in_progress' factory :qc_workflow do qc_flow { true } - association :initial_state, factory: :state, name: 'volume_check' + initial_state factory: %i[state], name: 'volume_check' end factory :cherrypick_workflow do cherrypick_flow { true } - association :initial_state, factory: :state, name: 'cherrypick' + initial_state factory: %i[state], name: 'cherrypick' factory :cherrypick_qc_workflow do qc_flow { true } diff --git a/spec/features/create_and_edit_batch_spec.rb b/spec/features/create_and_edit_batch_spec.rb index f9dc053f..6ac1615d 100644 --- a/spec/features/create_and_edit_batch_spec.rb +++ b/spec/features/create_and_edit_batch_spec.rb @@ -2,18 +2,18 @@ require 'rails_helper' -describe 'create and edit batch', js: true do +describe 'create and edit batch', :js do let!(:asset_type) { create(:asset_type, name: 'Sample', identifier_type: 'Name') } - let!(:workflow1) { create(:workflow, name: 'Workflow') } - let!(:workflow2) { create(:workflow, name: 'Reportable workflow', reportable: true) } - let!(:workflow3) { create(:qc_workflow, name: 'QC workflow') } - let!(:workflow4) { create(:workflow, name: 'Deactivated workflow', active: false) } + let!(:workflow_first) { create(:workflow, name: 'Workflow') } + let!(:workflow_second) { create(:workflow, name: 'Reportable workflow', reportable: true) } + let!(:workflow_third) { create(:qc_workflow, name: 'QC workflow') } + let!(:workflow_fourth) { create(:workflow, name: 'Deactivated workflow', active: false) } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:volume_check) { create(:state, name: 'volume_check') } it 'can create and edit a batch' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Sample' within('div#sample-template') do fill_in 'identifier', with: 'sample1 sample2' @@ -51,7 +51,7 @@ it 'can create a batch with an Aker barcode' do create(:asset_type, name: 'Plate with Name', identifier_type: 'Name') visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Plate with Name' within('div#plate_with_name-template') do fill_in 'identifier', with: 'AKER-123' diff --git a/spec/features/create_and_update_workflow_spec.rb b/spec/features/create_and_update_workflow_spec.rb index e5461a62..9f4a659e 100644 --- a/spec/features/create_and_update_workflow_spec.rb +++ b/spec/features/create_and_update_workflow_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe 'can create workflow', js: true do +describe 'can create workflow', :js do it 'can create workflow' do create(:state, name: 'in_progress') create(:state, name: 'cherrypick') @@ -16,14 +16,14 @@ find_by_id('hasComment', visible: :all).first(:xpath, './/..').click find_by_id('qcFlow', visible: :all).first(:xpath, './/..').click find_by_id('cherrypickFlow', visible: :all).first(:xpath, './/..').click - click_button(text: 'Create') + click_on(text: 'Create') end expect(page).to have_content('The workflow was created.') expect(Workflow.count).to eq 1 find('a', text: 'Create a new workflow').click within('#add-workflow-modal') do fill_in 'Name', with: 'New workflow' - click_button(text: 'Create') + click_on(text: 'Create') end expect(page).to have_content('Name has already been taken') expect(Workflow.count).to eq 1 diff --git a/spec/features/create_complete_and_report_asset_standard_flow_spec.rb b/spec/features/create_complete_and_report_asset_standard_flow_spec.rb index 449e9673..07728c92 100644 --- a/spec/features/create_complete_and_report_asset_standard_flow_spec.rb +++ b/spec/features/create_complete_and_report_asset_standard_flow_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' -describe 'create complete and report assets within standard flow', js: true do +describe 'create complete and report assets within standard flow', :js do let!(:asset_type) { create(:asset_type, name: 'Tube', identifier_type: 'ID') } - let!(:workflow1) { create(:workflow, name: 'Workflow') } - let!(:workflow2) { create(:workflow, name: 'Reportable workflow', reportable: true) } + let!(:workflow_first) { create(:workflow, name: 'Workflow') } + let!(:workflow_second) { create(:workflow, name: 'Reportable workflow', reportable: true) } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:volume_check) { create(:state, name: 'volume_check') } let!(:quant) { create(:state, name: 'quant') } @@ -15,7 +15,7 @@ it 'can create and complete a non-reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' click_on 'Append to batch' expect(page).to have_content "The entry can't be created as the form contains some errors." @@ -31,22 +31,22 @@ click_on 'Save' expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.first.id}]" click_on 'Completed selected' expect(page).to have_content 'In progress is done for 123' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Volume check' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Quant' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Report Required' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') end it 'can create, complete and report a reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: 123 @@ -67,17 +67,17 @@ click_on 'Save' expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).to have_selector('table tr', count: 4) + expect(page).to have_css('table tr', count: 4) check "assets[#{Asset.second.id}]" click_on 'Completed selected' expect(page).to have_content 'In progress is done for 456' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) click_on 'Volume check' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Quant' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Report Required' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.second.id}]" click_on 'Reported selected' expect(page).to have_content 'Report required is done for 456' diff --git a/spec/features/create_complete_and_report_assets_cherrypick_flow_spec.rb b/spec/features/create_complete_and_report_assets_cherrypick_flow_spec.rb index a7b193a4..30c5fdd1 100644 --- a/spec/features/create_complete_and_report_assets_cherrypick_flow_spec.rb +++ b/spec/features/create_complete_and_report_assets_cherrypick_flow_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe 'create complete and report assets within Cherrypick flow', js: true do +describe 'create complete and report assets within Cherrypick flow', :js do let!(:asset_type) { create(:asset_type, name: 'Tube', identifier_type: 'ID') } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:volume_check) { create(:state, name: 'volume_check') } @@ -10,15 +10,15 @@ let!(:report_required) { create(:state, name: 'report_required') } let!(:completed) { create(:state, name: 'completed') } let!(:reported) { create(:state, name: 'reported') } - let!(:workflow1) { create(:cherrypick_workflow, name: 'Cherrypick workflow') } - let!(:workflow2) { create(:cherrypick_qc_workflow, name: 'Cherrypick QC workflow') } - let!(:workflow3) do + let!(:workflow_first) { create(:cherrypick_workflow, name: 'Cherrypick workflow') } + let!(:workflow_second) { create(:cherrypick_qc_workflow, name: 'Cherrypick QC workflow') } + let!(:workflow_third) do create(:cherrypick_qc_workflow, name: 'Cherrypick Reportable QC workflow', reportable: true) end it 'can create and complete a non-reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: 123 @@ -36,20 +36,20 @@ expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Cherrypick' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.first.id}]" click_on 'Completed selected' expect(page).to have_content 'Cherrypick is done for 123' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) end it 'can create and complete a non-reportable QC asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: '12345' @@ -67,39 +67,39 @@ expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Cherrypick' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.first.id}]" click_on 'Completed selected' expect(page).to have_content 'Cherrypick is done for 12345' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Volume check' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.first.id}]" click_on 'Volume checked selected' expect(page).to have_content 'Volume check is done for 12345' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Quant' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.first.id}]" click_on 'Completed selected' expect(page).to have_content 'Quant is done for 12345' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Report Required' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') end it 'can create, complete and report a reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: 123 @@ -121,40 +121,40 @@ expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Cherrypick' - expect(page).to have_selector('table tr', count: 4) + expect(page).to have_css('table tr', count: 4) check "assets[#{Asset.first.id}]" check "assets[#{Asset.third.id}]" click_on 'Completed selected' expect(page).to have_content 'Cherrypick is done for 123 and 789' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Volume check' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.first.id}]" check "assets[#{Asset.third.id}]" click_on 'Volume checked selected' expect(page).to have_content 'Volume check is done for 123 and 789' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Quant' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.third.id}]" click_on 'Completed selected' expect(page).to have_content 'Quant is done for 789' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Report Required' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.third.id}]" click_on 'Reported selected' expect(page).to have_content 'Report required is done for 789' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') end end diff --git a/spec/features/create_complete_and_report_assets_qc_flow_spec.rb b/spec/features/create_complete_and_report_assets_qc_flow_spec.rb index ce189e82..c9b7ea7a 100644 --- a/spec/features/create_complete_and_report_assets_qc_flow_spec.rb +++ b/spec/features/create_complete_and_report_assets_qc_flow_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe 'create complete and report assets within QC flow', js: true do +describe 'create complete and report assets within QC flow', :js do let!(:asset_type) { create(:asset_type, name: 'Tube', identifier_type: 'ID') } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:volume_check) { create(:state, name: 'volume_check') } @@ -10,12 +10,12 @@ let!(:report_required) { create(:state, name: 'report_required') } let!(:completed) { create(:state, name: 'completed') } let!(:reported) { create(:state, name: 'reported') } - let!(:workflow1) { create(:qc_workflow, name: 'QC workflow') } - let!(:workflow2) { create(:qc_workflow, name: 'Reportable QC workflow', reportable: true) } + let!(:workflow_first) { create(:qc_workflow, name: 'QC workflow') } + let!(:workflow_second) { create(:qc_workflow, name: 'Reportable QC workflow', reportable: true) } it 'can create and complete a non-reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: 123 @@ -31,26 +31,26 @@ click_on 'Save' expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Volume check' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.first.id}]" click_on 'Volume checked selected' expect(page).to have_content 'Volume check is done for 123' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Quant' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.first.id}]" click_on 'Completed selected' expect(page).to have_content 'Quant is done for 123' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Report Required' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') end it 'can create, complete and report a reportable asset' do visit '/' - click_link 'New Batch' + click_on 'New Batch' click_on 'Tube' within('div#tube-template') do fill_in 'identifier', with: 123 @@ -70,25 +70,25 @@ click_on 'Save' expect(page).to have_content 'The batch was created.' click_on 'In Progress' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') click_on 'Volume check' - expect(page).to have_selector('table tr', count: 4) + expect(page).to have_css('table tr', count: 4) check "assets[#{Asset.first.id}]" check "assets[#{Asset.third.id}]" click_on 'Volume checked selected' expect(page).to have_content 'Volume check is done for 123 and 789' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Quant' - expect(page).to have_selector('table tr', count: 3) + expect(page).to have_css('table tr', count: 3) check "assets[#{Asset.third.id}]" click_on 'Completed selected' expect(page).to have_content 'Quant is done for 789' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) click_on 'Report Required' - expect(page).to have_selector('table tr', count: 2) + expect(page).to have_css('table tr', count: 2) check "assets[#{Asset.third.id}]" click_on 'Reported selected' expect(page).to have_content 'Report required is done for 789' - expect(page).not_to have_selector('table tr') + expect(page).to have_no_css('table tr') end end diff --git a/spec/features/create_pipeline_destination_spec.rb b/spec/features/create_pipeline_destination_spec.rb index c356c763..55c07993 100644 --- a/spec/features/create_pipeline_destination_spec.rb +++ b/spec/features/create_pipeline_destination_spec.rb @@ -2,21 +2,21 @@ require 'rails_helper' -describe 'can create pipeline destination', js: true do +describe 'can create pipeline destination', :js do it 'can create pipeline destination' do visit '/' click_on 'Admin' find('a', text: 'Create a new destination').click within('#add-pipeline-destination-modal') do fill_in 'Name', with: 'New pipeline destination' - click_button(text: 'Create') + click_on(text: 'Create') end expect(page).to have_content('The pipeline destination was created.') expect(PipelineDestination.count).to eq 1 find('a', text: 'Create a new destination').click within('#add-pipeline-destination-modal') do fill_in 'Name', with: 'New pipeline destination' - click_button(text: 'Create') + click_on(text: 'Create') end expect(page).to have_content('Name has already been taken') expect(PipelineDestination.count).to eq 1 diff --git a/spec/features/generate_report_spec.rb b/spec/features/generate_report_spec.rb index e5d4220f..11e6a2cd 100644 --- a/spec/features/generate_report_spec.rb +++ b/spec/features/generate_report_spec.rb @@ -2,18 +2,18 @@ require 'rails_helper' -describe 'can generate report', js: true do - let!(:workflow1) { create(:workflow, name: 'Workflow1') } - let!(:workflow2) { create(:workflow, name: 'Workflow2') } +describe 'can generate report', :js do + let!(:workflow_first) { create(:workflow, name: 'Workflow_first') } + let!(:workflow_second) { create(:workflow, name: 'Workflow_second') } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:completed) { create(:state, name: 'completed') } - let!(:asset1) { create(:asset, workflow: workflow1, study: 'Study1', project: 'Project1') } - let!(:asset2) do - create(:asset, workflow: workflow1, study: 'Study1', project: 'Project2', + let!(:asset_first) { create(:asset, workflow: workflow_first, study: 'Study1', project: 'Project1') } + let!(:asset_second) do + create(:asset, workflow: workflow_first, study: 'Study1', project: 'Project2', cost_code: create(:cost_code, name: 'A1')) end - let!(:asset3) { create(:asset, workflow: workflow2, study: 'Study1', project: 'Project2') } - let!(:asset4) { create(:asset, workflow: workflow1) } + let!(:asset_third) { create(:asset, workflow: workflow_second, study: 'Study1', project: 'Project2') } + let!(:asset_fourth) { create(:asset, workflow: workflow_first) } before do Timecop.freeze(Time.local(2017, 3, 7)) @@ -24,22 +24,22 @@ end it 'can generate report' do - asset1.complete - asset2.complete - asset3.complete + asset_first.complete + asset_second.complete + asset_third.complete visit '/' click_on 'Admin' click_on 'Create a new report' - select('Workflow1', from: 'Workflow') + select('Workflow_first', from: 'Workflow') fill_in('start_date', with: '31/03/2017').send_keys(:escape) fill_in('end_date', with: '01/03/2017').send_keys(:escape) - click_button(text: 'Create report') + click_on(text: 'Create report') expect(page).to have_content('Start date should be earlier than the end date.') fill_in('start_date', with: '01/03/2017').send_keys(:escape) fill_in('end_date', with: '31/03/2017').send_keys(:escape) - click_button(text: 'Create report') - expect(page).to have_content("Report for 'Workflow1' workflow from 01/03/2017 to 31/03/2017") + click_on(text: 'Create report') + expect(page).to have_content("Report for 'Workflow_first' workflow from 01/03/2017 to 31/03/2017") within('table#report') do expect(page).to have_xpath('.//tr', count: 3) expect(page).to have_text('Study Project Cost code name Assets count') diff --git a/spec/features/search_batch_and_assets_spec.rb b/spec/features/search_batch_and_assets_spec.rb index 1c559648..7e103c6f 100644 --- a/spec/features/search_batch_and_assets_spec.rb +++ b/spec/features/search_batch_and_assets_spec.rb @@ -2,19 +2,19 @@ require 'rails_helper' -describe 'search assets and batches', js: true do - let!(:batch1) { create(:batch_with_assets) } - let!(:batch2) { create(:batch_with_assets) } - let!(:additional_asset1) { create(:asset, identifier: batch1.id) } - let!(:additional_asset2) { create(:asset, identifier: 'Identifier') } - let!(:search_string) { batch1.id.to_s } +describe 'search assets and batches', :js do + let!(:batch_first) { create(:batch_with_assets) } + let!(:batch_second) { create(:batch_with_assets) } + let!(:additional_asset_first) { create(:asset, identifier: batch_first.id) } + let!(:additional_asset_second) { create(:asset, identifier: 'Identifier') } + let!(:search_string) { batch_first.id.to_s } it 'can create and edit a batch' do visit '/' fill_in 'Search', with: search_string click_on 'search' expect(page).to have_content "Search results where batch id or asset identifier matches '#{search_string}'" - expect(page.all('tbody>tr').count).to eq batch1.assets.count + 1 + expect(page.all('tbody>tr').count).to eq batch_first.assets.count + 1 fill_in 'Search', with: 'Empty' click_on 'search' expect(page).to have_content "Search results where batch id or asset identifier matches 'Empty'" @@ -23,9 +23,9 @@ click_on 'search' expect(page).to have_content "Search results where batch id or asset identifier matches 'Identifier'" expect(page.all('tbody>tr').count).to eq 1 - fill_in 'Search', with: batch2.id + fill_in 'Search', with: batch_second.id click_on 'search' - expect(page).to have_content "Search results where batch id or asset identifier matches '#{batch2.id}'" - expect(page.all('tbody>tr').count).to eq batch2.assets.count + expect(page).to have_content "Search results where batch id or asset identifier matches '#{batch_second.id}'" + expect(page.all('tbody>tr').count).to eq batch_second.assets.count end end diff --git a/spec/models/asset_spec.rb b/spec/models/asset_spec.rb index 71708a80..a8bb63e6 100644 --- a/spec/models/asset_spec.rb +++ b/spec/models/asset_spec.rb @@ -209,9 +209,9 @@ end context 'state machine' do - let!(:state1) { create(:state, name: 'in_progress') } - let!(:state2) { create(:state, name: 'completed') } - let!(:state3) { create(:state, name: 'report_required') } + let!(:state_first) { create(:state, name: 'in_progress') } + let!(:state_second) { create(:state, name: 'completed') } + let!(:state_third) { create(:state, name: 'report_required') } let(:asset) { create(:asset) } let(:reportable_asset) do create(:asset, workflow: create(:workflow, reportable: true)) @@ -243,16 +243,16 @@ end context 'for report' do - let!(:workflow1) { create(:workflow, name: 'Workflow1') } - let!(:workflow2) { create(:workflow, name: 'Workflow2') } + let!(:workflow_first) { create(:workflow, name: 'Workflow_first') } + let!(:workflow_second) { create(:workflow, name: 'Workflow_second') } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:completed) { create(:state, name: 'completed') } let!(:cost_code) { create(:cost_code) } - let!(:asset1) { create(:asset, workflow: workflow1, study: 'Study1', project: 'Project1') } - let!(:asset2) { create(:asset, workflow: workflow1, study: 'Study1', project: 'Project2', cost_code:) } - let!(:asset3) { create(:asset, workflow: workflow2, study: 'Study1', project: 'Project2') } - let!(:asset4) { create(:asset, workflow: workflow2, study: 'Study1', project: 'Project2') } - let!(:asset5) { create(:asset, workflow: workflow1) } + let!(:asset_first) { create(:asset, workflow: workflow_first, study: 'Study1', project: 'Project1') } + let!(:asset_second) { create(:asset, workflow: workflow_first, study: 'Study1', project: 'Project2', cost_code:) } + let!(:asset_third) { create(:asset, workflow: workflow_second, study: 'Study1', project: 'Project2') } + let!(:asset_fourth) { create(:asset, workflow: workflow_second, study: 'Study1', project: 'Project2') } + let!(:asset_fifth) { create(:asset, workflow: workflow_first) } after do Timecop.return @@ -260,17 +260,17 @@ it 'generates the right data for reports' do Timecop.freeze(Time.local(2017, 3, 7)) - asset1.complete - asset2.complete - asset3.complete - asset4.complete + asset_first.complete + asset_second.complete + asset_third.complete + asset_fourth.complete start_date = Date.today - 1 end_date = Date.today + 1 - expect(Asset.generate_report_data(start_date, end_date, workflow1)) + expect(Asset.generate_report_data(start_date, end_date, workflow_first)) .to eq([{ 'study' => 'Study1', 'project' => 'Project1', 'cost_code_name' => nil, 'assets_count' => 1 }, { 'study' => 'Study1', 'project' => 'Project2', 'cost_code_name' => cost_code.name, 'assets_count' => 1 }]) - expect(Asset.generate_report_data(start_date, end_date, workflow2)) + expect(Asset.generate_report_data(start_date, end_date, workflow_second)) .to eq([{ 'study' => 'Study1', 'project' => 'Project2', 'cost_code_name' => nil, 'assets_count' => 2 }]) end diff --git a/spec/models/batch_creator_spec.rb b/spec/models/batch_creator_spec.rb index 172fb14f..a100b32e 100644 --- a/spec/models/batch_creator_spec.rb +++ b/spec/models/batch_creator_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Batch::Creator do +describe 'Batch::Creator' do before do Timecop.freeze(Time.local(2017, 3, 7)) end diff --git a/spec/models/batch_updater_spec.rb b/spec/models/batch_updater_spec.rb index 82f09925..c0b270d2 100644 --- a/spec/models/batch_updater_spec.rb +++ b/spec/models/batch_updater_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Batch::Updater do +describe 'Batch::Updater' do before do Timecop.freeze(Time.local(2017, 3, 7)) end diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb index 88239c12..631262fe 100644 --- a/spec/models/report_spec.rb +++ b/spec/models/report_spec.rb @@ -19,9 +19,9 @@ let!(:workflow) { create(:workflow, name: 'Workflow') } let!(:in_progress) { create(:state, name: 'in_progress') } let!(:completed) { create(:state, name: 'completed') } - let(:asset1) { create(:asset, workflow:, study: 'Study1', project: 'Project1') } - let(:asset2) { create(:asset, workflow:, study: 'Study1', project: 'Project2') } - let(:asset3) { create(:asset, workflow:, study: 'Study1', project: 'Project2') } + let(:asset_first) { create(:asset, workflow:, study: 'Study1', project: 'Project1') } + let(:asset_second) { create(:asset, workflow:, study: 'Study1', project: 'Project2') } + let(:asset_third) { create(:asset, workflow:, study: 'Study1', project: 'Project2') } before do Timecop.freeze(Time.local(2017, 4, 7)) @@ -37,9 +37,9 @@ end it 'creates the right csv' do - asset1.complete - asset2.complete - asset3.complete + asset_first.complete + asset_second.complete + asset_third.complete asset4 = create(:asset, workflow:) report = Report.new(workflow:, start_date: '01/04/2017', end_date: '15/04/2017') expected_report = <<~REPORT diff --git a/spec/presenters/asset_index_presenter_spec.rb b/spec/presenters/asset_index_presenter_spec.rb index c50ff138..912e1841 100644 --- a/spec/presenters/asset_index_presenter_spec.rb +++ b/spec/presenters/asset_index_presenter_spec.rb @@ -2,7 +2,7 @@ require './app/presenters/asset/index' require './spec/presenters/shared_presenter_behaviour' -describe Presenter::AssetPresenter::Index do +describe 'Presenter::AssetPresenter::Index' do shared_context 'shared mocks' do let(:mock_type) do double('mock_type', @@ -17,21 +17,21 @@ variable_samples: true) end let(:mock_workflow) { double('mock_wf', name: 'Work', has_comment: true) } - let(:asset1) do - double('asset_1', - identifier: 'asset_1', + let(:asset_first) do + double('asset_first', + identifier: 'asset_first', asset_type: mock_type, workflow: mock_workflow, study: 'study') end - let(:asset2) do - double('asset_2', - identifier: 'asset_2', + let(:asset_second) do + double('asset_second', + identifier: 'asset_second', asset_type: mock_type2, workflow: mock_workflow, study: 'study') end - let(:assets) { [asset1, asset2] } + let(:assets) { [asset_first, asset_second] } let!(:state) { create(:state, name: 'in_progress') } let(:presenter) { Presenter::AssetPresenter::Index.new(assets, search, state) } end @@ -47,7 +47,7 @@ it 'yields each asset of type x in turn for each_asset(x)' do expect { |b| presenter.each_asset('Type', &b) }.to yield_with_args(Presenter::AssetPresenter::Asset) presenter.each_asset('Type') do |asset| - expect(asset.identifier).to eq('asset_1') + expect(asset.identifier).to eq('asset_first') end end end diff --git a/spec/presenters/asset_presenter_spec.rb b/spec/presenters/asset_presenter_spec.rb index 00d1b321..c6b9281e 100644 --- a/spec/presenters/asset_presenter_spec.rb +++ b/spec/presenters/asset_presenter_spec.rb @@ -2,7 +2,7 @@ require './app/presenters/asset/asset' require 'timecop' -describe Presenter::AssetPresenter::Asset do +describe 'Presenter::AssetPresenter::Asset' do shared_examples 'shared behaviour' do let(:mock_type) do double('mock_type', diff --git a/spec/presenters/asset_type_presenter_spec.rb b/spec/presenters/asset_type_presenter_spec.rb index aa0ab242..b3055bb0 100644 --- a/spec/presenters/asset_type_presenter_spec.rb +++ b/spec/presenters/asset_type_presenter_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe Presenter::AssetTypePresenter::AssetType do +describe 'Presenter::AssetTypePresenter::AssetType' do describe '#validates_with' do let(:asset_type) { create(:asset_type, identifier_data_type:) } let(:presenter) { Presenter::AssetTypePresenter::AssetType.new(asset_type) } diff --git a/spec/presenters/batch_new_presenter_spec.rb b/spec/presenters/batch_new_presenter_spec.rb index 1f060829..ecd25e15 100644 --- a/spec/presenters/batch_new_presenter_spec.rb +++ b/spec/presenters/batch_new_presenter_spec.rb @@ -2,7 +2,7 @@ require './app/presenters/batch/new' require './spec/presenters/shared_presenter_behaviour' -describe Presenter::BatchPresenter::New do +describe 'Presenter::BatchPresenter::New' do let(:presenter) { Presenter::BatchPresenter::New.new } context 'always' do diff --git a/spec/presenters/batch_show_presenter_spec.rb b/spec/presenters/batch_show_presenter_spec.rb index 3ec550c4..7d541fb7 100644 --- a/spec/presenters/batch_show_presenter_spec.rb +++ b/spec/presenters/batch_show_presenter_spec.rb @@ -2,22 +2,22 @@ require './app/presenters/batch/show' require './spec/presenters/shared_presenter_behaviour' -describe Presenter::BatchPresenter::Show do +describe 'Presenter::BatchPresenter::Show' do context 'with a batch' do let(:presenter) { Presenter::BatchPresenter::Show.new(test_batch) } - let(:test_batch) { double('batch', assets: [asset1, asset2]) } + let(:test_batch) { double('batch', assets: [asset_first, asset_second]) } let(:comment) { double('comment', comment: 'A comment') } - let(:asset2) do - double('asset_2', - identifier: 'asset_2', + let(:asset_second) do + double('asset_second', + identifier: 'asset_second', asset_type: mock_type, workflow: mock_workflow, study: 'study', comment:) end - let(:asset1) do - double('asset_1', - identifier: 'asset_1', + let(:asset_first) do + double('asset_first', + identifier: 'asset_first', asset_type: mock_type, workflow: mock_workflow, study: 'study', @@ -29,8 +29,8 @@ include_examples('shared presenter behaviour') it 'yields each asset in the batch in turn for each_asset' do - expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset1).and_call_original - expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset2).and_call_original + expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset_first).and_call_original + expect(Presenter::AssetPresenter::Asset).to receive(:new).with(asset_second).and_call_original expect do |b| presenter.each_asset(&b) diff --git a/spec/presenters/report_new_presenter_spec.rb b/spec/presenters/report_new_presenter_spec.rb index a60e56ab..ce1a84e4 100644 --- a/spec/presenters/report_new_presenter_spec.rb +++ b/spec/presenters/report_new_presenter_spec.rb @@ -2,7 +2,7 @@ require './app/presenters/report/new' require './spec/presenters/shared_presenter_behaviour' -describe Presenter::ReportPresenter::New do +describe 'Presenter::ReportPresenter::New' do let(:presenter) { Presenter::ReportPresenter::New.new } context 'always' do diff --git a/spec/presenters/report_show_presenter_spec.rb b/spec/presenters/report_show_presenter_spec.rb index 14531c15..6d3fff56 100644 --- a/spec/presenters/report_show_presenter_spec.rb +++ b/spec/presenters/report_show_presenter_spec.rb @@ -1,43 +1,48 @@ +# frozen_string_literal: true + require 'rails_helper' require './app/presenters/report/show' require './spec/presenters/shared_presenter_behaviour' -describe Presenter::ReportPresenter::Show do +describe 'Presenter::ReportPresenter::Show' do let(:workflow) { build(:workflow, name: 'Workflow') } let!(:report) { Report.new(workflow:, start_date: '01/04/2017', end_date: '15/04/2017') } - let!(:completed) { create(:state, name: 'completed') } - let(:asset1) { create(:asset, workflow:, study: 'Study1', project: 'Project1') } - let(:asset2) do + let(:asset_first) { create(:asset, workflow:, study: 'Study1', project: 'Project1') } + let(:asset_second) do create(:asset, workflow:, study: 'Study1', project: 'Project2', cost_code: create(:cost_code, name: 'A1')) end let(:presenter) { Presenter::ReportPresenter::Show.new(report) } - context 'always' do + before do + create(:state, name: 'completed') + end + + context 'when always' do include_examples('shared presenter behaviour') end - it 'genertes correct html for report' do - Timecop.freeze(Time.local(2017, 4, 7)) - asset1.complete - asset2.complete + it 'generates correct html for report' do + Timecop.freeze(Time.zone.local(2017, 4, 7)) + asset_first.complete + asset_second.complete expect(presenter.title).to eq "Report for 'Workflow' workflow from 01/04/2017 to 15/04/2017" - expect(presenter.column_names).to eq "Study" + - "Project" + - "Cost code name" + + expect(presenter.column_names).to eq "Study" \ + "Project" \ + "Cost code name" \ "Assets count" - expect(presenter.rows).to eq '' + - " 1 " + - "Study1" + - "Project1" + - "Not defined" + - "1" + - '' + - '' + - " 2 " + - "Study1" + - "Project2" + - "A1" + - "1" + + expect(presenter.rows).to eq '' \ + " 1 " \ + "Study1" \ + "Project1" \ + "Not defined" \ + "1" \ + '' \ + '' \ + " 2 " \ + "Study1" \ + "Project2" \ + "A1" \ + "1" \ '' expect(presenter.flash).to be_nil expect(presenter.page).to eq :'reports/show' diff --git a/spec/presenters/shared_presenter_behaviour.rb b/spec/presenters/shared_presenter_behaviour.rb index 131e7f8b..4f361f47 100644 --- a/spec/presenters/shared_presenter_behaviour.rb +++ b/spec/presenters/shared_presenter_behaviour.rb @@ -1,17 +1,17 @@ shared_examples 'shared presenter behaviour' do - let!(:asset_type_1) do + let!(:asset_type_first) do create(:asset_type, name: 'type1', identifier_type: 'id1', has_sample_count: true) end - let!(:asset_type_2) do + let!(:asset_type_second) do create(:asset_type, name: 'type2', identifier_type: 'id2', has_sample_count: false) end - let!(:workflow_1) do + let!(:workflow) do create(:qc_workflow, name: 'wf1', has_comment: true, @@ -38,6 +38,6 @@ it 'yields only active workflows (rev)' do expect { |b| presenter.active_workflows(&b) } - .to yield_with_args('wf1', true, workflow_1.id, true, true, workflow_1.cherrypick_flow, 1, true) + .to yield_with_args('wf1', true, workflow.id, true, true, workflow.cherrypick_flow, 1, true) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 87da827f..0dad5843 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -80,7 +80,7 @@ DatabaseCleaner.strategy = :transaction end - config.before(:each, js: true) do + config.before(:each, :js) do DatabaseCleaner.strategy = :truncation end From 920ad80f3ef8ed7bfc053042f105fe3d4701da21 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 19:35:20 +0000 Subject: [PATCH 7/8] Update mysql2 to version 0.5.6 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3c182696..3b3517c7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -131,7 +131,7 @@ GEM mini_mime (1.1.5) mini_portile2 (2.8.5) minitest (5.22.2) - mysql2 (0.5.5) + mysql2 (0.5.6) net-imap (0.3.4) date net-protocol From c53bb84e83d2d8ed6e28c83fc6191937b2f18375 Mon Sep 17 00:00:00 2001 From: Stephen <519327+stevieing@users.noreply.github.com> Date: Mon, 26 Feb 2024 13:21:57 +0000 Subject: [PATCH 8/8] Fix method name in Proc class --- .rubocop.yml | 1 + config/initializers/01_proc.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index a3ec06dc..f6c69f84 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,5 +15,6 @@ require: - rubocop-rspec AllCops: NewCops: enable + SuggestExtensions: false Layout/LineLength: Max: 120 diff --git a/config/initializers/01_proc.rb b/config/initializers/01_proc.rb index 5bea7b3f..e9b1cdfe 100644 --- a/config/initializers/01_proc.rb +++ b/config/initializers/01_proc.rb @@ -4,7 +4,7 @@ def callback(callable, *args) self === Class.new do method_name = callable.to_sym define_method(method_name) { |&block| block ? block.call(*args) : true } - define_method("#{method_name}?") { true } + define_method(:"#{method_name}?") { true } def method_missing(*_args) false end