From 1e74e418cc2a0bf2205c9e549afa1f01ea1bb049 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sun, 28 Jul 2024 07:16:11 +0000 Subject: [PATCH 001/158] Update Ruby to version 3.2.5 --- .ruby-version | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.ruby-version b/.ruby-version index 351227fca3..5ae69bd5f0 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.4 +3.2.5 diff --git a/Dockerfile b/Dockerfile index d42b9dae40..f4f75b7182 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG CHIPSET=default # Use the correct base image depending on the architecture # For Apple M1 Chip, run: docker build --build-arg CHIPSET=m1 . -FROM ruby:3.2.4-slim AS base_default +FROM ruby:3.2.5-slim AS base_default FROM --platform=linux/amd64 ruby:3.2.4-slim AS base_m1 FROM base_${CHIPSET} AS base From 8acb857adb1b17bdef68f0cc9f4501bca2cc82c5 Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:11:05 +0100 Subject: [PATCH 002/158] Added plate purposes for LCM Triomics EMSeq steps --- .../013_lcm_triomics_plate_purposes.wip.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml diff --git a/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml b/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml new file mode 100644 index 0000000000..6783947808 --- /dev/null +++ b/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml @@ -0,0 +1,11 @@ +# Plate purposes for LCM Triomics DNA WGS and EMSeq +--- +LCMT Lysate: + type: PlatePurpose::Input + stock_plate: true + cherrypickable_target: false + +LCMT DNA Adp Lig: + type: PlatePurpose + stock_plate: false + cherrypickable_target: false From 7806f054e456e75da1a6e21f3ec88749114e21eb Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:12:03 +0100 Subject: [PATCH 003/158] Added request types for LCM Triomics DNA Library Prep --- ..._limber_lcm_triomics_request_types.wip.yml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml diff --git a/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml b/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml new file mode 100644 index 0000000000..a0380589a2 --- /dev/null +++ b/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml @@ -0,0 +1,38 @@ +# Request types for LCM Triomics DNA WGS and EMSeq +--- +limber_lcm_triomics_dna_prep: + name: LCM Triomics DNA Prep + asset_type: Well + order: 1 + request_class_name: CustomerRequest + for_multiplexing: false + billable: true + product_line_name: Short Read + acceptable_purposes: + - LCMT Lysate + +limber_lcm_triomics_dna_wgs_library_prep: + name: LCM Triomics DNA WGS Library Prep + asset_type: Well + order: 1 + request_class_name: IlluminaHtp::Requests::StdLibraryRequest + for_multiplexing: false + billable: true + product_line_name: Short Read + acceptable_purposes: + - LCMT DNA Adp Lig + library_types: + - LCM Triomics DNA WGS + +limber_lcm_triomics_dna_emseq_library_prep: + name: LCM Triomics DNA EMSeq Library Prep + asset_type: Well + order: 1 + request_class_name: IlluminaHtp::Requests::StdLibraryRequest + for_multiplexing: false + billable: true + product_line_name: Short Read + acceptable_purposes: + - LCMT DNA Adp Lig + library_types: + - LCM Triomics DNA EMSeq From d08514737fee63ece06c55df1788ab3dc277994b Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:12:16 +0100 Subject: [PATCH 004/158] Added LCMT to product catalogue --- .../product_catalogues/013_lcm_triomics_catalogue.wip.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml diff --git a/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml b/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml new file mode 100644 index 0000000000..6a36dcf6e5 --- /dev/null +++ b/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml @@ -0,0 +1,3 @@ +--- +LCM Triomics: + selection_behaviour: SingleProduct From 3bf1c7bbdfdb87069190454f39c8945c83354945 Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:31:14 +0100 Subject: [PATCH 005/158] Added submission template for LCMT pipeline entry --- .../014_lcm_triomics_submission_templates.wip.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml diff --git a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml new file mode 100644 index 0000000000..4ca2657ffa --- /dev/null +++ b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml @@ -0,0 +1,9 @@ +# Submission template for LCM Triomics DNA WGS and EMSeq +--- +# LCM Triomics DNA Prep submission template +Limber-Htp - LCM Triomics DNA Prep: + submission_class_name: "LinearSubmission" + related_records: + request_type_keys: ["limber_lcm_triomics_dna_prep"] + product_line_name: LCM Triomics + product_catalogue_name: LCM Triomics From 7232edd389a4a5decabdf8f7d7df043fbe692a47 Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:33:36 +0100 Subject: [PATCH 006/158] Removed adp lig from plate purposes --- .../plate_purposes/013_lcm_triomics_plate_purposes.wip.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml b/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml index 6783947808..36089ca6cd 100644 --- a/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml +++ b/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml @@ -4,8 +4,3 @@ LCMT Lysate: type: PlatePurpose::Input stock_plate: true cherrypickable_target: false - -LCMT DNA Adp Lig: - type: PlatePurpose - stock_plate: false - cherrypickable_target: false From a95b1e7707a5791d995f3963f05b23d0c7d79d2e Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:44:53 +0100 Subject: [PATCH 007/158] Removed redundant request types --- ..._limber_lcm_triomics_request_types.wip.yml | 29 ++----------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml b/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml index a0380589a2..f0ff0db3cb 100644 --- a/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml +++ b/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml @@ -1,7 +1,7 @@ # Request types for LCM Triomics DNA WGS and EMSeq --- -limber_lcm_triomics_dna_prep: - name: LCM Triomics DNA Prep +limber_lcm_triomics: + name: LCM Triomics asset_type: Well order: 1 request_class_name: CustomerRequest @@ -11,28 +11,3 @@ limber_lcm_triomics_dna_prep: acceptable_purposes: - LCMT Lysate -limber_lcm_triomics_dna_wgs_library_prep: - name: LCM Triomics DNA WGS Library Prep - asset_type: Well - order: 1 - request_class_name: IlluminaHtp::Requests::StdLibraryRequest - for_multiplexing: false - billable: true - product_line_name: Short Read - acceptable_purposes: - - LCMT DNA Adp Lig - library_types: - - LCM Triomics DNA WGS - -limber_lcm_triomics_dna_emseq_library_prep: - name: LCM Triomics DNA EMSeq Library Prep - asset_type: Well - order: 1 - request_class_name: IlluminaHtp::Requests::StdLibraryRequest - for_multiplexing: false - billable: true - product_line_name: Short Read - acceptable_purposes: - - LCMT DNA Adp Lig - library_types: - - LCM Triomics DNA EMSeq From ba36d98053ac660c8089bc51c1fc1ed3fa799729 Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:45:06 +0100 Subject: [PATCH 008/158] Modified submission template --- .../014_lcm_triomics_submission_templates.wip.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml index 4ca2657ffa..d620c89c4c 100644 --- a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml +++ b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml @@ -1,9 +1,9 @@ # Submission template for LCM Triomics DNA WGS and EMSeq --- # LCM Triomics DNA Prep submission template -Limber-Htp - LCM Triomics DNA Prep: +Limber-Htp - LCM Triomics: submission_class_name: "LinearSubmission" related_records: - request_type_keys: ["limber_lcm_triomics_dna_prep"] + request_type_keys: ["limber_lcm_triomics"] product_line_name: LCM Triomics product_catalogue_name: LCM Triomics From c75c8f3ae6a16b30f9eb8ed48011a56e0f094619 Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Wed, 28 Aug 2024 12:52:54 +0100 Subject: [PATCH 009/158] Prettier --- .../request_types/018_limber_lcm_triomics_request_types.wip.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml b/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml index f0ff0db3cb..2b4e149396 100644 --- a/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml +++ b/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml @@ -10,4 +10,3 @@ limber_lcm_triomics: product_line_name: Short Read acceptable_purposes: - LCMT Lysate - From 51527e1844022502b3a85fa1536a4538c9cb15b3 Mon Sep 17 00:00:00 2001 From: yoldas Date: Wed, 28 Aug 2024 23:40:04 +0100 Subject: [PATCH 010/158] Convert the initial LCM Triomics DNA WGS and EMSeq request to library request --- .../018_limber_lcm_triomics_request_types.wip.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml b/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml index 2b4e149396..4763365cf0 100644 --- a/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml +++ b/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml @@ -4,9 +4,11 @@ limber_lcm_triomics: name: LCM Triomics asset_type: Well order: 1 - request_class_name: CustomerRequest + request_class_name: IlluminaHtp::Requests::StdLibraryRequest for_multiplexing: false billable: true product_line_name: Short Read + library_types: + - LCM Triomics EMSeq acceptable_purposes: - LCMT Lysate From 04badd9444814bc36896c167e94597f0c1bb7036 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Tue, 3 Sep 2024 14:46:27 +0100 Subject: [PATCH 011/158] Refactor model for BaitLibraryLayout --- app/models/bait_library_layout.rb | 67 ++++++++++++++++--------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/app/models/bait_library_layout.rb b/app/models/bait_library_layout.rb index 9c435856e8..8d0fa21943 100644 --- a/app/models/bait_library_layout.rb +++ b/app/models/bait_library_layout.rb @@ -12,29 +12,41 @@ class BaitLibraryLayout < ApplicationRecord validates :plate, presence: true validates :plate_id, uniqueness: true - # The layout of the bait libraries is recorded so that we can see what happened. It is serialized in a compact + # The layout of the bait libraries is recorded so that we can see what happened. It is serialized in a compact # form that maps the bait library to the wells it was put into, but can be accessed in the reverse. serialize :layout, Hash validates_unassigned :layout + # Before creation the layout of the bait libraries on the plate must be performed, based on the information + # specified as part of the submissions that lead to this plate. + before_create :layout_bait_libraries_on_plate + def well_layout {}.tap { |well_to_name| layout.map { |name, locations| locations.map { |l| well_to_name[l] = name } } } end + # This method can be used to get a preview of what will happen when the bait libraries are laid out on a plate. + def self.preview!(attributes = {}, &block) + new(attributes, &block).tap do |layout| + raise ActiveRecord::RecordInvalid, layout unless layout.valid? + + layout.unsaved_uuid! + layout.send(:generate_for_preview) + end + end + + private + # Records the assignment of the bait library to a particular well def record_bait_library_assignment(well, bait_library) # NOTE: The serialization of the hash prevents the use of a block # to set default values etc. (layout[bait_library.name] ||= []).push(well.map.description) end - private :record_bait_library_assignment - # Before creation the layout of the bait libraries on the plate must be performed, based on the information - # specified as part of the submissions that lead to this plate. - before_create :layout_bait_libraries_on_plate def layout_bait_libraries_on_plate # To improve the performance we store the aliquot IDs that need each of the individual bait libraries - # attached to them in a hash. Then we'll be able to bulk update them later. + # attached to them in a hash. Then we'll be able to bulk update them later. bait_libraries_to_aliquot_ids = Hash.new { |h, k| h[k] = [] } each_bait_library_assignment do |well, bait_library| bait_libraries_to_aliquot_ids[bait_library.id].concat(well.aliquot_ids) @@ -46,46 +58,35 @@ def layout_bait_libraries_on_plate Aliquot.where(id: aliquot_ids).update_all(bait_library_id: bait_library_id) # rubocop:disable Rails/SkipsModelValidations end end - private :layout_bait_libraries_on_plate - # rubocop:todo Metrics/MethodLength - def each_bait_library_assignment # rubocop:todo Metrics/AbcSize + def first_bait_library(well) + bait_library = + well.aliquot_requests.for_submission_id(well.pool_id).map(&:request_metadata).map(&:bait_library).uniq + + if bait_library.size > 1 + raise StandardError, + "Multiple bait libraries found for #{well.map.description} on plate #{well.plate.human_barcode}" + end + + bait_library.first + end + + def each_bait_library_assignment # We only accept the wells which have been pooled plate .wells .with_pool_id .filter(&:pool_id) .each do |well| - bait_library = - well.aliquot_requests.for_submission_id(well.pool_id).map(&:request_metadata).map(&:bait_library).uniq - if bait_library.size > 1 - raise StandardError, - "Multiple bait libraries found for #{well.map.description} on plate #{well.plate.human_barcode}" - end - - yield(well, bait_library.first) + yield well, first_bait_library(well) end end - # rubocop:enable Metrics/MethodLength - private :each_bait_library_assignment - - # Generates the layout of bait libraries for preview. In other words, none of the actually assignment is - # done, just the recording, which would fail validation if an attempt was then made to save it. So this is + # Generates the layout of bait libraries for preview. In other words, none of the actual assignment is + # done, just the recording, which would fail validation if an attempt was then made to save it. So this is # safe to do. def generate_for_preview each_bait_library_assignment { |well, bait_library| record_bait_library_assignment(well, bait_library) } end private :generate_for_preview - - # This method can be used to view a previous of what will happen when the bait libraries are laid out - # on a plate. - def self.preview!(attributes = {}, &block) - new(attributes, &block).tap do |layout| - raise ActiveRecord::RecordInvalid, layout unless layout.valid? - - layout.unsaved_uuid! - layout.send(:generate_for_preview) - end - end end From 533ac04a3d5443da14933696909be19bf65fee98 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Tue, 3 Sep 2024 14:46:47 +0100 Subject: [PATCH 012/158] Add deprecation documentation to UUID attributes on StateChangeResource --- app/resources/api/v2/state_change_resource.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/resources/api/v2/state_change_resource.rb b/app/resources/api/v2/state_change_resource.rb index 16810e08db..53f8388aad 100644 --- a/app/resources/api/v2/state_change_resource.rb +++ b/app/resources/api/v2/state_change_resource.rb @@ -45,6 +45,7 @@ class StateChangeResource < BaseResource # @!attribute [w] target_uuid # This is declared for convenience where the target is not available to set as a relationship. # Setting this attribute alongside the `target` relationship will prefer the relationship value. + # @deprecated Use the `target` relationship instead. # @param value [String] The UUID of the target labware this state change applies to. # @return [Void] # @see #target @@ -57,6 +58,7 @@ def target_uuid=(value) # @!attribute [w] user_uuid # This is declared for convenience where the user is not available to set as a relationship. # Setting this attribute alongside the `user` relationship will prefer the relationship value. + # @deprecated Use the `user` relationship instead. # @param value [String] The UUID of the user who initiated this state change. # @return [Void] # @see #user From 72018ddc4fece8ec51c166d09f0e4db8d97bd7dd Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Tue, 3 Sep 2024 14:47:13 +0100 Subject: [PATCH 013/158] Create JSONAPI::Resource for BaitLibraryLayout model --- .../api/v2/bait_library_layouts_controller.rb | 12 +++ .../api/v2/bait_library_layout_resource.rb | 80 +++++++++++++++++++ config/routes.rb | 1 + 3 files changed, 93 insertions(+) create mode 100644 app/controllers/api/v2/bait_library_layouts_controller.rb create mode 100644 app/resources/api/v2/bait_library_layout_resource.rb diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb new file mode 100644 index 0000000000..c8973ddd96 --- /dev/null +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Api + module V2 + # Provides a JSON API controller for BaitLibraryLayouts + # See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation + class BaitLibraryLayoutsController < JSONAPI::ResourceController + # By default JSONAPI::ResourceController provides most the standard + # behaviour, and in many cases this file may be left empty. + end + end +end diff --git a/app/resources/api/v2/bait_library_layout_resource.rb b/app/resources/api/v2/bait_library_layout_resource.rb new file mode 100644 index 0000000000..6b99434dfd --- /dev/null +++ b/app/resources/api/v2/bait_library_layout_resource.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +module Api + module V2 + # @todo This documentation does not yet include a detailed description of what this resource represents. + # @todo This documentation does not yet include detailed descriptions for relationships, attributes and filters. + # @todo This documentation does not yet include any example usage of the API via cURL or similar. + # + # @note This resource cannot be modified after creation: its endpoint will not accept `PATCH` requests. + # @note Access this resource via the `/api/v2/bait_library_layouts/` endpoint. + # + # Provides a JSON:API representation of {BaitLibraryLayout}. + # + # For more information about JSON:API see the [JSON:API Specifications](https://jsonapi.org/format/) + # or look at the [JSONAPI::Resources](http://jsonapi-resources.com/) package for Sequencescape's implementation + # of the JSON:API standard. + class BaitLibraryLayoutResource < BaseResource + # @!attribute [w] plate_uuid + # This is declared for convenience where the plate is not available to set as a relationship. + # Setting this attribute alongside the `plate` relationship will prefer the relationship value. + # @deprecated Use the `plate` relationship instead. + # @param value [String] The UUID of the plate for this bait library layout. + # @return [Void] + # @see #plate + attribute :plate_uuid + + def plate_uuid=(value) + @model.plate = Plate.with_uuid(value).first + end + + # @!attribute [w] user_uuid + # This is declared for convenience where the user is not available to set as a relationship. + # Setting this attribute alongside the `user` relationship will prefer the relationship value. + # @deprecated Use the `user` relationship instead. + # @param value [String] The UUID of the user who created this bait library layout. + # @return [Void] + # @see #user + attribute :user_uuid + + def user_uuid=(value) + @model.user = User.with_uuid(value).first + end + + # @!attribute [r] layout + # @return [Hash] The layout of the bait libraries on the plate. + attribute :layout, readonly: true + + # # @!attribute [r] uuid + # # @return [String] The UUID of the state change. + attribute :uuid, readonly: true + + ### + # Relationships + ### + + # @!attribute [rw] user + # Setting this relationship alongside the `user_uuid` attribute will override the attribute value. + # @return [UserResource] The user who created this bait library layout. + # @note This relationship is required. + has_one :user + + # @!attribute [rw] plate + # Setting this relationship alongside the `plate_uuid` attribute will override the attribute value. + # @return [PlateResource] The plate for this bait library layout. + # @note This relationship is required. + has_one :plate + + def self.creatable_fields(context) + # The layout is generated by the system. + # The UUID is set by the system. + super - %i[layout uuid] + end + + def fetchable_fields + # UUIDs for relationships are not fetchable. They should be accessed via the relationship itself. + super - %i[plate_uuid user_uuid] + end + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 72810314eb..5cfae4b157 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,6 +21,7 @@ jsonapi_resources :aliquots jsonapi_resources :assets jsonapi_resources :asset_audits + jsonapi_resources :bait_library_layouts, except: %i[update] jsonapi_resources :barcode_printers jsonapi_resources :comments jsonapi_resources :custom_metadatum_collections From 85ae9bde352549c35cb913762ccec1d2972e09c0 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Wed, 4 Sep 2024 11:25:46 +0100 Subject: [PATCH 014/158] Add a preview custom method with a stub response --- .../api/v2/bait_library_layouts_controller.rb | 30 +++++++++++++++++-- config/routes.rb | 8 ++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index c8973ddd96..f0e2759a6b 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -5,8 +5,34 @@ module V2 # Provides a JSON API controller for BaitLibraryLayouts # See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation class BaitLibraryLayoutsController < JSONAPI::ResourceController - # By default JSONAPI::ResourceController provides most the standard - # behaviour, and in many cases this file may be left empty. + # By default JSONAPI::ResourceController provides most the standard behaviour, and in many cases this file may be + # left empty. + # However, to remain consistent with functionality of API v1, we have included a custom preview method here. + + # Preview the layout of the bait libraries on a plate. + # This method is not part of the JSONAPI::ResourceController standard actions. + # @example Preview a {BaitLibraryLayout} with the given User and Plate identified by UUIDs + # POST /api/v2/bait_library_layouts/preview + # { + # "user_uuid": "11111111-2222-3333-4444-555555666666", + # "plate_uuid": "22222222-3333-4444-5555-666666777777" + # } + # @return [JSON] The JSON representation of a {BaitLibraryLayout}. + def preview + temp_response = { + "data": { + "id": 0, + "type": "bait_library_layouts", + "attributes": { + "layout": { + "Human all exon 50MB": [ "A1", "A2" ] + } + } + } + } + + render json: temp_response, status: :ok + end end end end diff --git a/config/routes.rb b/config/routes.rb index 5cfae4b157..5a25790c5a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,7 +21,13 @@ jsonapi_resources :aliquots jsonapi_resources :assets jsonapi_resources :asset_audits - jsonapi_resources :bait_library_layouts, except: %i[update] + + jsonapi_resources :bait_library_layouts, except: %i[update] do + collection do + post :preview + end + end + jsonapi_resources :barcode_printers jsonapi_resources :comments jsonapi_resources :custom_metadatum_collections From 9f4a76f6c25db96c45b7c67732fb5742c0c0ca03 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Wed, 4 Sep 2024 11:27:03 +0100 Subject: [PATCH 015/158] Apply prettier --- .../api/v2/bait_library_layouts_controller.rb | 12 ++++++------ app/models/bait_library_layout.rb | 8 +------- config/routes.rb | 4 +--- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index f0e2759a6b..912650096d 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -20,12 +20,12 @@ class BaitLibraryLayoutsController < JSONAPI::ResourceController # @return [JSON] The JSON representation of a {BaitLibraryLayout}. def preview temp_response = { - "data": { - "id": 0, - "type": "bait_library_layouts", - "attributes": { - "layout": { - "Human all exon 50MB": [ "A1", "A2" ] + data: { + id: 0, + type: 'bait_library_layouts', + attributes: { + layout: { + 'Human all exon 50MB': %w[A1 A2] } } } diff --git a/app/models/bait_library_layout.rb b/app/models/bait_library_layout.rb index 8d0fa21943..3c65fc4c42 100644 --- a/app/models/bait_library_layout.rb +++ b/app/models/bait_library_layout.rb @@ -73,13 +73,7 @@ def first_bait_library(well) def each_bait_library_assignment # We only accept the wells which have been pooled - plate - .wells - .with_pool_id - .filter(&:pool_id) - .each do |well| - yield well, first_bait_library(well) - end + plate.wells.with_pool_id.filter(&:pool_id).each { |well| yield well, first_bait_library(well) } end # Generates the layout of bait libraries for preview. In other words, none of the actual assignment is diff --git a/config/routes.rb b/config/routes.rb index 5a25790c5a..340fe8dcd6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,9 +23,7 @@ jsonapi_resources :asset_audits jsonapi_resources :bait_library_layouts, except: %i[update] do - collection do - post :preview - end + collection { post :preview } end jsonapi_resources :barcode_printers From a21cc37c22ccc9fcb4d485c825fbd0f8e3f41987 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Wed, 4 Sep 2024 12:35:55 +0100 Subject: [PATCH 016/158] Provide implementation for bait_library_layout preview method --- .../api/v2/bait_library_layouts_controller.rb | 56 ++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index 912650096d..2bdfbb0346 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -11,27 +11,55 @@ class BaitLibraryLayoutsController < JSONAPI::ResourceController # Preview the layout of the bait libraries on a plate. # This method is not part of the JSONAPI::ResourceController standard actions. + # # @example Preview a {BaitLibraryLayout} with the given User and Plate identified by UUIDs # POST /api/v2/bait_library_layouts/preview # { # "user_uuid": "11111111-2222-3333-4444-555555666666", # "plate_uuid": "22222222-3333-4444-5555-666666777777" # } - # @return [JSON] The JSON representation of a {BaitLibraryLayout}. + # + # @return [JSON] The JSON representation of a sparsely populated {BaitLibraryLayoutResource}. + # Only the `layout` attribute is included. + # The returned `id` is always `0` and cannot be used to reference the resource. def preview - temp_response = { - data: { - id: 0, - type: 'bait_library_layouts', - attributes: { - layout: { - 'Human all exon 50MB': %w[A1 A2] - } - } - } - } - - render json: temp_response, status: :ok + records = preview_records + return if records.nil? + + # Catch the layout preview failing validation. + begin + preview = BaitLibraryLayout.preview!(user: records[:user], plate: records[:plate]) + rescue ActiveRecord::RecordInvalid => e + render json: { errors: e.record.errors.full_messages }, status: :unprocessable_entity and return + end + + json = { data: { id: 0, type: 'bait_library_layouts', attributes: { layout: preview.layout } } } + render json: json, status: :ok + end + + private + + def preview_params + params.permit(:user_uuid, :plate_uuid) + end + + def preview_records + # Catch missing required parameters. + begin + missing_records_errors = [] + + user = User.with_uuid(preview_params.require(:user_uuid)).first + missing_records_errors.append('User not found') if user.nil? + + plate = Plate.with_uuid(preview_params.require(:plate_uuid)).first + missing_records_errors.append('Plate not found') if plate.nil? + rescue ActionController::ParameterMissing => e + render json: { errors: [e.message] }, status: :bad_request and return + end + + render json: { errors: missing_records_errors }, status: :bad_request and return if missing_records_errors.any? + + { user: user, plate: plate } end end end From 303a21f67359ff0d90fa682d88502efade774a34 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Wed, 4 Sep 2024 13:53:03 +0100 Subject: [PATCH 017/158] Use correct JSON:API error responses when errors occur --- .../api/v2/bait_library_layouts_controller.rb | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index 2bdfbb0346..0beefedff5 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -30,7 +30,7 @@ def preview begin preview = BaitLibraryLayout.preview!(user: records[:user], plate: records[:plate]) rescue ActiveRecord::RecordInvalid => e - render json: { errors: e.record.errors.full_messages }, status: :unprocessable_entity and return + render_errors('Validation failed', e.record.errors.full_messages, :unprocessable_entity) and return end json = { data: { id: 0, type: 'bait_library_layouts', attributes: { layout: preview.layout } } } @@ -39,25 +39,44 @@ def preview private + def render_errors(title, details, status) + status_code = Rack::Utils::SYMBOL_TO_STATUS_CODE[status] + + errors = details.map { |detail| { title: title, detail: detail, code: status_code, status: status_code } } + + render json: { errors: errors }, status: status + end + def preview_params params.permit(:user_uuid, :plate_uuid) end - def preview_records - # Catch missing required parameters. - begin - missing_records_errors = [] + def preview_user(record_errors) + user_uuid = preview_params.require(:user_uuid) + user = User.with_uuid(user_uuid).first + record_errors.append("The User record identified by UUID '#{user_uuid}' cannot be found") if user.nil? - user = User.with_uuid(preview_params.require(:user_uuid)).first - missing_records_errors.append('User not found') if user.nil? + user + end + + def preview_plate(record_errors) + plate_uuid = preview_params.require(:plate_uuid) + plate = Plate.with_uuid(plate_uuid).first + record_errors.append("The Plate record identified by UUID '#{plate_uuid}' cannot be found") if plate.nil? + + plate + end - plate = Plate.with_uuid(preview_params.require(:plate_uuid)).first - missing_records_errors.append('Plate not found') if plate.nil? + def preview_records + begin + record_errors = [] + user = preview_user(record_errors) + plate = preview_plate(record_errors) rescue ActionController::ParameterMissing => e - render json: { errors: [e.message] }, status: :bad_request and return + render_errors('Missing parameter', [e.message], :bad_request) and return end - render json: { errors: missing_records_errors }, status: :bad_request and return if missing_records_errors.any? + render_errors('Record not found', record_errors, :bad_request) and return if record_errors.any? { user: user, plate: plate } end From 302e3e131527e643d0c36f7751f78deb12326a77 Mon Sep 17 00:00:00 2001 From: yoldas Date: Thu, 5 Sep 2024 00:44:33 +0100 Subject: [PATCH 018/158] Drop the word DNA from the pipeline name; WGS and EMSeq are sufficient --- .../plate_purposes/013_lcm_triomics_plate_purposes.wip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml b/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml index 36089ca6cd..d39b9b44d8 100644 --- a/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml +++ b/config/default_records/plate_purposes/013_lcm_triomics_plate_purposes.wip.yml @@ -1,4 +1,4 @@ -# Plate purposes for LCM Triomics DNA WGS and EMSeq +# Plate purposes for LCM Triomics WGS and EMSeq --- LCMT Lysate: type: PlatePurpose::Input From e336b5c4c1a609d59c185d4f213c679a1b9a40a1 Mon Sep 17 00:00:00 2001 From: yoldas Date: Thu, 5 Sep 2024 00:45:27 +0100 Subject: [PATCH 019/158] Update catalogue name for the pipeline --- .../product_catalogues/013_lcm_triomics_catalogue.wip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml b/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml index 6a36dcf6e5..38a49bb2b6 100644 --- a/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml +++ b/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml @@ -1,3 +1,3 @@ --- -LCM Triomics: +M Triomics WGS and EMSeq: selection_behaviour: SingleProduct From 8e5ab6d45066da0c732a5ce5fa3cd21c850ea5c8 Mon Sep 17 00:00:00 2001 From: yoldas Date: Thu, 5 Sep 2024 00:48:41 +0100 Subject: [PATCH 020/158] Match the request type key and the name --- .../018_limber_lcm_triomics_request_types.wip.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml b/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml index 4763365cf0..66ce9a5260 100644 --- a/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml +++ b/config/default_records/request_types/018_limber_lcm_triomics_request_types.wip.yml @@ -1,14 +1,14 @@ -# Request types for LCM Triomics DNA WGS and EMSeq +# Request types for LCM Triomics WGS and EMSeq --- -limber_lcm_triomics: - name: LCM Triomics +limber_lcm_triomics_emseq: + name: LCM Triomics EMSeq asset_type: Well order: 1 request_class_name: IlluminaHtp::Requests::StdLibraryRequest for_multiplexing: false billable: true product_line_name: Short Read - library_types: - - LCM Triomics EMSeq acceptable_purposes: - LCMT Lysate + library_types: + - LCM Triomics EMSeq From b7fa6c89bc4f74dd462929c10e50e6260ad4619b Mon Sep 17 00:00:00 2001 From: yoldas Date: Thu, 5 Sep 2024 00:50:27 +0100 Subject: [PATCH 021/158] Update the request type key of the submission --- .../014_lcm_triomics_submission_templates.wip.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml index d620c89c4c..969c6d6a51 100644 --- a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml +++ b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml @@ -1,9 +1,9 @@ -# Submission template for LCM Triomics DNA WGS and EMSeq +# Submission templates for LCM Triomics WGS and EMSeq --- -# LCM Triomics DNA Prep submission template +# LCM Triomics EMSeq submission template Limber-Htp - LCM Triomics: submission_class_name: "LinearSubmission" related_records: - request_type_keys: ["limber_lcm_triomics"] - product_line_name: LCM Triomics - product_catalogue_name: LCM Triomics + request_type_keys: ["limber_lcm_triomics_emseq"] + product_line_name: LCM Triomics WGS and EMSeq + product_catalogue_name: LCM Triomics WGS and EMSeq From 1197771dfb6d6ee94e93ad4634d91ad09ff0a225 Mon Sep 17 00:00:00 2001 From: yoldas Date: Thu, 5 Sep 2024 01:35:09 +0100 Subject: [PATCH 022/158] Fix typo in lcm triomics catalogue record --- .../product_catalogues/013_lcm_triomics_catalogue.wip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml b/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml index 38a49bb2b6..4bf791e027 100644 --- a/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml +++ b/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml @@ -1,3 +1,3 @@ --- -M Triomics WGS and EMSeq: +LCM Triomics WGS and EMSeq: selection_behaviour: SingleProduct From 44ec8a8d920533249f89bd242edb2af365597fd8 Mon Sep 17 00:00:00 2001 From: yoldas Date: Thu, 5 Sep 2024 08:51:18 +0100 Subject: [PATCH 023/158] Rename to Limber-Htp - LCM Triomics EMSeq --- .../014_lcm_triomics_submission_templates.wip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml index 969c6d6a51..a10355f5ef 100644 --- a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml +++ b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml @@ -1,7 +1,7 @@ # Submission templates for LCM Triomics WGS and EMSeq --- # LCM Triomics EMSeq submission template -Limber-Htp - LCM Triomics: +Limber-Htp - LCM Triomics EMSeq: submission_class_name: "LinearSubmission" related_records: request_type_keys: ["limber_lcm_triomics_emseq"] From a31e9f1021776aa9cead44e33e0ddb85a2165724 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 5 Sep 2024 15:18:45 +0100 Subject: [PATCH 024/158] Create resource specifications for bait library layout Also make a custom matcher for having readonly attributes. There will be more for the other resources I've been creating. --- .../factories/bait_library_layout_factories.rb | 11 +++++++++++ spec/rails_helper.rb | 1 + .../v2/bait_library_layout_resource_spec.rb | 18 ++++++++++++++++++ spec/support/api_v2_resource_matchers.rb | 17 +++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 spec/factories/bait_library_layout_factories.rb create mode 100644 spec/resources/api/v2/bait_library_layout_resource_spec.rb create mode 100644 spec/support/api_v2_resource_matchers.rb diff --git a/spec/factories/bait_library_layout_factories.rb b/spec/factories/bait_library_layout_factories.rb new file mode 100644 index 0000000000..efd105ece7 --- /dev/null +++ b/spec/factories/bait_library_layout_factories.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :bait_library_layout do + user + plate + layout { { + 'Human all exon 50MB' => %w[A1 A2 B1 B2 C1 C2 D1 D2 E1 F1 G1 H1] + } } + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4c85f7ed6a..cf90c377a2 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -84,6 +84,7 @@ config.include Rails.application.routes.url_helpers config.include ApiV2Helper, with: :api_v2 + config.include ApiV2Matchers config.include RSpec::Longrun::DSL Capybara.add_selector(:data_behavior) { xpath { |name| XPath.css("[data-behavior='#{name}']") } } diff --git a/spec/resources/api/v2/bait_library_layout_resource_spec.rb b/spec/resources/api/v2/bait_library_layout_resource_spec.rb new file mode 100644 index 0000000000..cf7a349492 --- /dev/null +++ b/spec/resources/api/v2/bait_library_layout_resource_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'rails_helper' +require './app/resources/api/v2/bait_library_layout_resource' + +RSpec.describe Api::V2::BaitLibraryLayoutResource, type: :resource do + subject(:resource) { described_class.new(resource_model, {}) } + + let(:resource_model) { build_stubbed :bait_library_layout } + + # Attributes + it { is_expected.to have_readonly_attribute :uuid } + it { is_expected.to have_readonly_attribute :layout } + + # Relationships + it { is_expected.to have_one(:plate).with_class_name('Plate') } + it { is_expected.to have_one(:user).with_class_name('User') } +end diff --git a/spec/support/api_v2_resource_matchers.rb b/spec/support/api_v2_resource_matchers.rb new file mode 100644 index 0000000000..4a2d6a375a --- /dev/null +++ b/spec/support/api_v2_resource_matchers.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module ApiV2Matchers + RSpec::Matchers.define :have_readonly_attribute do |attribute| + description { "have readonly attribute `#{attribute.to_s}`" } + + failure_message { "expected #{resource.class.name.demodulize} to #{description}" } + failure_message_when_negated do + "expected #{resource.class.name.demodulize} not to #{description}" + end + + match do |resource| + expect(resource).to have_attribute attribute + expect(resource).not_to have_updatable_field attribute + end + end +end From 43a822d39cf8a0e7f8d4b104e8727b1c44582678 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 5 Sep 2024 15:38:24 +0100 Subject: [PATCH 025/158] Use new resource spec matchers across new resources --- .../api/v2/barcode_printer_resource_spec.rb | 30 ++------------ ...stom_metadatum_collection_resource_spec.rb | 30 ++------------ .../api/v2/state_change_resource_spec.rb | 41 +++++-------------- .../v2/tag_layout_template_resource_spec.rb | 22 +++------- .../api/v2/transfer_template_resource_spec.rb | 24 ++--------- spec/support/api_v2_resource_matchers.rb | 30 +++++++++++++- 6 files changed, 56 insertions(+), 121 deletions(-) diff --git a/spec/resources/api/v2/barcode_printer_resource_spec.rb b/spec/resources/api/v2/barcode_printer_resource_spec.rb index 8c445b38fc..5dbed2cbb1 100644 --- a/spec/resources/api/v2/barcode_printer_resource_spec.rb +++ b/spec/resources/api/v2/barcode_printer_resource_spec.rb @@ -9,31 +9,9 @@ let(:resource_model) { build_stubbed :barcode_printer } # Test attributes - it 'has the expected attributes', :aggregate_failures do - expect(resource).not_to have_attribute :id - expect(resource).to have_attribute :uuid - expect(resource).to have_attribute :name - expect(resource).to have_attribute :print_service - expect(resource).to have_attribute :barcode_type - end + it { is_expected.to have_readonly_attribute :uuid } + it { is_expected.to have_readonly_attribute :print_service } + it { is_expected.to have_readonly_attribute :barcode_type } - # Updatable fields - it 'allows updating of read-write fields', :aggregate_failures do - expect(resource).to have_updatable_field :name - end - - it 'disallows updating of read only fields', :aggregate_failures do - expect(resource).not_to have_updatable_field :uuid - expect(resource).not_to have_updatable_field :print_service - expect(resource).not_to have_updatable_field :barcode_type - end - - # Filters - # eg. it { is_expected.to filter(:order_type) } - - # Associations - # eg. it { is_expected.to have_many(:samples).with_class_name('Sample') } - - # Custom method tests - # Add tests for any custom methods you've added. + it { is_expected.to have_readwrite_attribute :name } end diff --git a/spec/resources/api/v2/custom_metadatum_collection_resource_spec.rb b/spec/resources/api/v2/custom_metadatum_collection_resource_spec.rb index 63aec31f3f..9d42fd1187 100644 --- a/spec/resources/api/v2/custom_metadatum_collection_resource_spec.rb +++ b/spec/resources/api/v2/custom_metadatum_collection_resource_spec.rb @@ -9,31 +9,9 @@ let(:resource_model) { build_stubbed :custom_metadatum_collection } # Test attributes - it 'has the expected attributes', :aggregate_failures do - expect(resource).to have_attribute :uuid - expect(resource).to have_attribute :user_id - expect(resource).to have_attribute :asset_id - expect(resource).to have_attribute :metadata - end + it { is_expected.to have_readonly_attribute :uuid } + it { is_expected.to have_readonly_attribute :user_id } + it { is_expected.to have_readonly_attribute :asset_id } - # Updatable fields - it 'allows updating of read-write fields', :aggregate_failures do - expect(resource).to have_updatable_field :metadata - end - - it 'disallows updating of read-only fields', :aggregate_failures do - expect(resource).not_to have_updatable_field :id - expect(resource).not_to have_updatable_field :uuid - expect(resource).not_to have_updatable_field :user_id - expect(resource).not_to have_updatable_field :asset_id - end - - # Filters - # eg. it { is_expected.to filter(:order_type) } - - # Associations - # eg. it { is_expected.to have_many(:samples).with_class_name('Sample') } - - # Custom method tests - # Add tests for any custom methods you've added. + it { is_expected.to have_readwrite_attribute :metadata } end diff --git a/spec/resources/api/v2/state_change_resource_spec.rb b/spec/resources/api/v2/state_change_resource_spec.rb index d985610dc6..d9dbc8c676 100644 --- a/spec/resources/api/v2/state_change_resource_spec.rb +++ b/spec/resources/api/v2/state_change_resource_spec.rb @@ -9,39 +9,18 @@ let(:resource_model) { build_stubbed :state_change } # Attributes - it 'has the expected read-only attributes', :aggregate_failures do - expect(resource).to have_attribute :uuid - expect(resource).not_to have_updatable_field :uuid + it { is_expected.to have_readonly_attribute :uuid } + it { is_expected.to have_readonly_attribute :previous_state } - expect(resource).to have_attribute :previous_state - expect(resource).not_to have_updatable_field :previous_state - end + it { is_expected.to have_readwrite_attribute :contents } + it { is_expected.to have_readwrite_attribute :reason } + it { is_expected.to have_readwrite_attribute :target_state } - it 'has the expected read-write attributes', :aggregate_failures do - expect(resource).to have_attribute :contents - expect(resource).to have_updatable_field :contents - - expect(resource).to have_attribute :reason - expect(resource).to have_updatable_field :reason - - expect(resource).to have_attribute :target_state - expect(resource).to have_updatable_field :target_state - end - - it 'has the expected write-only attributes', :aggregate_failures do - expect(resource).not_to have_attribute :user_uuid - expect(resource).to have_updatable_field :user_uuid - - expect(resource).not_to have_attribute :target_uuid - expect(resource).to have_updatable_field :target_uuid - - expect(resource).not_to have_attribute :customer_accepts_responsibility - expect(resource).to have_updatable_field :customer_accepts_responsibility - end + it { is_expected.to have_writeonly_attribute :user_uuid } + it { is_expected.to have_writeonly_attribute :target_uuid } + it { is_expected.to have_writeonly_attribute :customer_accepts_responsibility } # Relationships - it 'has the expected relationships', :aggregate_failures do - expect(resource).to have_one(:target).with_class_name('Labware') - expect(resource).to have_one(:user).with_class_name('User') - end + it { is_expected.to have_one(:target).with_class_name('Labware') } + it { is_expected.to have_one(:user).with_class_name('User') } end diff --git a/spec/resources/api/v2/tag_layout_template_resource_spec.rb b/spec/resources/api/v2/tag_layout_template_resource_spec.rb index c01091e1f3..2794d64c8f 100644 --- a/spec/resources/api/v2/tag_layout_template_resource_spec.rb +++ b/spec/resources/api/v2/tag_layout_template_resource_spec.rb @@ -8,26 +8,16 @@ let(:resource_model) { build_stubbed :tag_layout_template } - # Expected attributes - it { is_expected.not_to have_attribute :id } - it { is_expected.to have_attribute :uuid } - it { is_expected.to have_attribute :name } - it { is_expected.to have_attribute :direction } - it { is_expected.to have_attribute :walking_by } - - # Read-only fields - it { is_expected.not_to have_updatable_field :uuid } - it { is_expected.not_to have_updatable_field :name } - it { is_expected.not_to have_updatable_field :direction } - it { is_expected.not_to have_updatable_field :walking_by } + # Attributes + it { is_expected.to have_readonly_attribute :uuid } + it { is_expected.to have_readonly_attribute :name } + it { is_expected.to have_readonly_attribute :direction } + it { is_expected.to have_readonly_attribute :walking_by } # Filters it { is_expected.to filter(:enabled) } - # Associations + # Relationships it { is_expected.to have_one(:tag_group).with_class_name('TagGroup') } it { is_expected.to have_one(:tag2_group).with_class_name('TagGroup') } - - # Custom method tests - # Add tests for any custom methods you've added. end diff --git a/spec/resources/api/v2/transfer_template_resource_spec.rb b/spec/resources/api/v2/transfer_template_resource_spec.rb index adb61a50c7..30c3fd1f9a 100644 --- a/spec/resources/api/v2/transfer_template_resource_spec.rb +++ b/spec/resources/api/v2/transfer_template_resource_spec.rb @@ -8,28 +8,10 @@ let(:resource_model) { build_stubbed :transfer_template } - # Test attributes - it 'has the expected attributes', :aggregate_failures do - expect(resource).not_to have_attribute :id - expect(resource).to have_attribute :uuid - expect(resource).to have_attribute :name - end - - # Updatable fields - it 'allows updating of read-write fields', :aggregate_failures do - expect(resource).to have_updatable_field :name - end - - it 'disallows updating of read-only fields', :aggregate_failures do - expect(resource).not_to have_updatable_field :uuid - end + # Attributes + it { is_expected.to have_readonly_attribute :uuid } + it { is_expected.to have_readwrite_attribute :name } # Filters it { is_expected.to filter(:uuid) } - - # Associations - # eg. it { is_expected.to have_many(:samples).with_class_name('Sample') } - - # Custom method tests - # Add tests for any custom methods you've added. end diff --git a/spec/support/api_v2_resource_matchers.rb b/spec/support/api_v2_resource_matchers.rb index 4a2d6a375a..2b30b4325a 100644 --- a/spec/support/api_v2_resource_matchers.rb +++ b/spec/support/api_v2_resource_matchers.rb @@ -2,7 +2,7 @@ module ApiV2Matchers RSpec::Matchers.define :have_readonly_attribute do |attribute| - description { "have readonly attribute `#{attribute.to_s}`" } + description { "have read-only attribute `#{attribute.to_s}`" } failure_message { "expected #{resource.class.name.demodulize} to #{description}" } failure_message_when_negated do @@ -14,4 +14,32 @@ module ApiV2Matchers expect(resource).not_to have_updatable_field attribute end end + + RSpec::Matchers.define :have_readwrite_attribute do |attribute| + description { "have read-write attribute `#{attribute.to_s}`" } + + failure_message { "expected #{resource.class.name.demodulize} to #{description}" } + failure_message_when_negated do + "expected #{resource.class.name.demodulize} not to #{description}" + end + + match do |resource| + expect(resource).to have_attribute attribute + expect(resource).to have_updatable_field attribute + end + end + + RSpec::Matchers.define :have_writeonly_attribute do |attribute| + description { "have write-only attribute `#{attribute.to_s}`" } + + failure_message { "expected #{resource.class.name.demodulize} to #{description}" } + failure_message_when_negated do + "expected #{resource.class.name.demodulize} not to #{description}" + end + + match do |resource| + expect(resource).not_to have_attribute attribute + expect(resource).to have_updatable_field attribute + end + end end From 0dd6cee1669c1ecdbab43042d6ae24fceb276d62 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 5 Sep 2024 17:28:10 +0100 Subject: [PATCH 026/158] Tidy up shared examples for POST requests on StateChanges --- ...alid_post_requests.rb => post_requests.rb} | 18 ++- spec/requests/api/v2/state_changes_spec.rb | 119 +++++++++--------- .../api/v2/transfers/transfers_spec.rb | 2 +- 3 files changed, 77 insertions(+), 62 deletions(-) rename spec/requests/api/v2/shared_examples/{invalid_post_requests.rb => post_requests.rb} (68%) diff --git a/spec/requests/api/v2/shared_examples/invalid_post_requests.rb b/spec/requests/api/v2/shared_examples/post_requests.rb similarity index 68% rename from spec/requests/api/v2/shared_examples/invalid_post_requests.rb rename to spec/requests/api/v2/shared_examples/post_requests.rb index fa0308aa0f..acb9a5e5df 100644 --- a/spec/requests/api/v2/shared_examples/invalid_post_requests.rb +++ b/spec/requests/api/v2/shared_examples/post_requests.rb @@ -30,7 +30,7 @@ end it 'specifies which attribute cannot be blank' do - expect(json.dig('errors', 0, 'detail')).to eq("#{missing_attribute} - can't be blank") + expect(json.dig('errors', 0, 'detail')).to eq(error_detail_message) end end @@ -46,6 +46,20 @@ end it 'specifies which relationship must exist' do - expect(json.dig('errors', 0, 'detail')).to eq("#{missing_relationship} - must exist") + expect(json.dig('errors', 0, 'detail')).to eq(error_detail_message) + end +end + +shared_examples 'a POST request including a has_one relationship' do + before { api_get "#{base_endpoint}/#{resource.id}?include=#{related_name}" } + + it 'responds with a success http code' do + expect(response).to have_http_status(:success) + end + + it 'returns the expected relationship' do + related = json['included'].find { |i| i['type'] == related_type } + expect(related['id']).to eq(resource.send(related_name).id.to_s) + expect(related['type']).to eq(related_type) end end diff --git a/spec/requests/api/v2/state_changes_spec.rb b/spec/requests/api/v2/state_changes_spec.rb index 585747c8cd..f6bac10e1a 100644 --- a/spec/requests/api/v2/state_changes_spec.rb +++ b/spec/requests/api/v2/state_changes_spec.rb @@ -2,50 +2,55 @@ require 'rails_helper' require './spec/requests/api/v2/shared_examples/api_key_authenticatable' -require './spec/requests/api/v2/shared_examples/invalid_post_requests' +require './spec/requests/api/v2/shared_examples/post_requests' describe 'State Changes API', with: :api_v2 do - let(:base_endpoint) { '/api/v2/state_changes' } let(:model_class) { StateChange } + let(:base_endpoint) { "/api/v2/#{resource_type}" } + let(:resource_type) { model_class.name.demodulize.pluralize.underscore } it_behaves_like 'ApiKeyAuthenticatable' - context 'with a list of StateChanges' do - let!(:state_changes) { create_list(:state_change, 5) } + context 'with a list of resource' do + let(:resource_count) { 5 } - describe '#GET all StateChanges' do + before { create_list(:state_change, resource_count) } + + describe '#GET all resources' do before { api_get base_endpoint } it 'responds with a success http code' do expect(response).to have_http_status(:success) end - it 'returns the full list of StateChanges' do - expect(json['data'].length).to eq(5) + it 'returns all the resources' do + expect(json['data'].length).to eq(resource_count) end end + end - describe '#GET StateChange by ID' do - let(:state_change) { state_changes.first } + context 'with a single resource' do + describe '#GET resource by ID' do + let(:resource) { create :state_change } context 'without included relationships' do - before { api_get "#{base_endpoint}/#{state_change.id}" } + before { api_get "#{base_endpoint}/#{resource.id}" } it 'responds with a success http code' do expect(response).to have_http_status(:success) end - it 'returns the correct StateChange' do - expect(json.dig('data', 'id')).to eq(state_change.id.to_s) - expect(json.dig('data', 'type')).to eq('state_changes') + it 'returns the correct resource' do + expect(json.dig('data', 'id')).to eq(resource.id.to_s) + expect(json.dig('data', 'type')).to eq(resource_type) end it 'returns the correct attributes' do - expect(json.dig('data', 'attributes', 'contents')).to eq(state_change.contents) - expect(json.dig('data', 'attributes', 'previous_state')).to eq(state_change.previous_state) - expect(json.dig('data', 'attributes', 'reason')).to eq(state_change.reason) - expect(json.dig('data', 'attributes', 'target_state')).to eq(state_change.target_state) - expect(json.dig('data', 'attributes', 'uuid')).to eq(state_change.uuid) + expect(json.dig('data', 'attributes', 'contents')).to eq(resource.contents) + expect(json.dig('data', 'attributes', 'previous_state')).to eq(resource.previous_state) + expect(json.dig('data', 'attributes', 'reason')).to eq(resource.reason) + expect(json.dig('data', 'attributes', 'target_state')).to eq(resource.target_state) + expect(json.dig('data', 'attributes', 'uuid')).to eq(resource.uuid) end it 'excludes unfetchable attributes' do @@ -55,8 +60,8 @@ end it 'returns references to related resources' do - expect(json.dig('data', 'relationships', 'user')).to be_present expect(json.dig('data', 'relationships', 'target')).to be_present + expect(json.dig('data', 'relationships', 'user')).to be_present end it 'does not include attributes for related resources' do @@ -65,34 +70,30 @@ end context 'with included relationships' do - before { api_get "#{base_endpoint}/#{state_change.id}?include=user,target" } + context 'with user' do + let(:related_name) { 'user' } + let(:related_type) { 'users' } - it 'responds with a success http code' do - expect(response).to have_http_status(:success) + it_behaves_like 'a POST request including a has_one relationship' end - it 'returns the correct user relationship' do - user = json['included'].find { |i| i['type'] == 'users' } - expect(user['id']).to eq(state_change.user.id.to_s) - expect(user['type']).to eq('users') - end + context 'with target' do + let(:related_name) { 'target' } + let(:related_type) { 'labware' } - it 'returns the correct target relationship' do - target = json['included'].find { |i| i['type'] == 'labware' } - expect(target['id']).to eq(state_change.target.id.to_s) - expect(target['type']).to eq('labware') + it_behaves_like 'a POST request including a has_one relationship' end end end end - describe '#PATCH a StateChange' do - let(:resource_model) { create(:state_change) } + describe '#PATCH a resource' do + let(:resource_model) { create :state_change } let(:payload) do { 'data' => { 'id' => resource_model.id, - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => { 'target_state' => 'passed' } @@ -107,7 +108,7 @@ end end - describe '#POST a new StateChange' do + describe '#POST a new resource' do let(:user) { create(:user) } let(:plate) { create(:plate) } @@ -128,7 +129,7 @@ before { api_post base_endpoint, payload } it 'creates a new resource' do - expect { api_post base_endpoint, payload }.to change(StateChange, :count).by(1) + expect { api_post base_endpoint, payload }.to change(model_class, :count).by(1) end it 'responds with success' do @@ -136,12 +137,12 @@ end it 'responds with the correct attributes' do - expect(json.dig('data', 'type')).to eq('state_changes') - expect(json.dig('data', 'attributes', 'contents')).to eq(payload.dig('data', 'attributes', 'contents')) - expect(json.dig('data', 'attributes', 'reason')).to eq(payload.dig('data', 'attributes', 'reason')) - expect(json.dig('data', 'attributes', 'target_state')).to eq( - payload.dig('data', 'attributes', 'target_state') - ) + new_record = model_class.last + + expect(json.dig('data', 'type')).to eq(resource_type) + expect(json.dig('data', 'attributes', 'contents')).to eq(new_record.contents) + expect(json.dig('data', 'attributes', 'reason')).to eq(new_record.reason) + expect(json.dig('data', 'attributes', 'target_state')).to eq(new_record.target_state) end it 'excludes unfetchable attributes' do @@ -156,7 +157,7 @@ end it 'applies the attributes to the new record' do - new_record = StateChange.last + new_record = model_class.last expect(new_record.contents).to eq(payload.dig('data', 'attributes', 'contents')) expect(new_record.reason).to eq(payload.dig('data', 'attributes', 'reason')) @@ -164,7 +165,7 @@ end it 'applies the relationships to the new record' do - new_record = StateChange.last + new_record = model_class.last expect(new_record.user).to eq(user) expect(new_record.target).to eq(plate) @@ -175,7 +176,7 @@ let(:payload) do { 'data' => { - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid, 'target_uuid' => plate.uuid }) } } @@ -188,7 +189,7 @@ let(:payload) do { 'data' => { - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => base_attributes, 'relationships' => { 'user' => user_relationship, @@ -207,7 +208,7 @@ let(:payload) do { 'data' => { - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => base_attributes.merge({ 'user_uuid' => other_user.uuid, 'target_uuid' => other_plate.uuid }), 'relationships' => { @@ -229,7 +230,7 @@ let(:payload) do { 'data' => { - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => base_attributes.merge({ 'previous_state' => 'waiting' }) } } @@ -243,7 +244,7 @@ let(:payload) do { 'data' => { - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => base_attributes.merge({ 'uuid' => '111111-2222-3333-4444-555555666666' }) } } @@ -255,11 +256,11 @@ context 'without a required attribute' do context 'without target_state' do - let(:missing_attribute) { 'target_state' } + let(:error_detail_message) { "target_state - can't be blank" } let(:payload) do { 'data' => { - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => base_attributes.merge({ 'target_state' => nil, 'user_uuid' => user.uuid, 'target_uuid' => plate.uuid }) } @@ -272,11 +273,11 @@ context 'without a required relationship' do context 'without user_uuid' do - let(:missing_relationship) { 'user' } + let(:error_detail_message) { "user - must exist" } let(:payload) do { 'data' => { - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => base_attributes.merge({ 'target_uuid' => plate.uuid }) } } @@ -286,11 +287,11 @@ end context 'without target_uuid' do - let(:missing_relationship) { 'target' } + let(:error_detail_message) { "target - must exist" } let(:payload) do { 'data' => { - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid }) } } @@ -300,11 +301,11 @@ end context 'without user' do - let(:missing_relationship) { 'user' } + let(:error_detail_message) { "user - must exist" } let(:payload) do { 'data' => { - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => base_attributes, 'relationships' => { 'target' => target_relationship @@ -317,11 +318,11 @@ end context 'without target' do - let(:missing_relationship) { 'target' } + let(:error_detail_message) { "target - must exist" } let(:payload) do { 'data' => { - 'type' => 'state_changes', + 'type' => resource_type, 'attributes' => base_attributes, 'relationships' => { 'user' => user_relationship diff --git a/spec/requests/api/v2/transfers/transfers_spec.rb b/spec/requests/api/v2/transfers/transfers_spec.rb index 5a5f595436..411a432d0b 100644 --- a/spec/requests/api/v2/transfers/transfers_spec.rb +++ b/spec/requests/api/v2/transfers/transfers_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' require './spec/requests/api/v2/shared_examples/api_key_authenticatable' -require './spec/requests/api/v2/shared_examples/invalid_post_requests' +require './spec/requests/api/v2/shared_examples/post_requests' describe 'Transfer API', with: :api_v2 do let(:base_endpoint) { '/api/v2/transfers/transfers' } From 3647d354599cc4cf32c95d1b0f4fbc4981885f2b Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 5 Sep 2024 17:28:34 +0100 Subject: [PATCH 027/158] Rename private render_errors method It seems that it conflicts with something built in to the controllers. --- app/controllers/api/v2/bait_library_layouts_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index 0beefedff5..f6970038a3 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -30,7 +30,7 @@ def preview begin preview = BaitLibraryLayout.preview!(user: records[:user], plate: records[:plate]) rescue ActiveRecord::RecordInvalid => e - render_errors('Validation failed', e.record.errors.full_messages, :unprocessable_entity) and return + respond_with_errors('Validation failed', e.record.errors.full_messages, :unprocessable_entity) and return end json = { data: { id: 0, type: 'bait_library_layouts', attributes: { layout: preview.layout } } } @@ -39,7 +39,7 @@ def preview private - def render_errors(title, details, status) + def respond_with_errors(title, details, status) status_code = Rack::Utils::SYMBOL_TO_STATUS_CODE[status] errors = details.map { |detail| { title: title, detail: detail, code: status_code, status: status_code } } @@ -73,10 +73,10 @@ def preview_records user = preview_user(record_errors) plate = preview_plate(record_errors) rescue ActionController::ParameterMissing => e - render_errors('Missing parameter', [e.message], :bad_request) and return + respond_with_errors('Missing parameter', [e.message], :bad_request) and return end - render_errors('Record not found', record_errors, :bad_request) and return if record_errors.any? + respond_with_errors('Record not found', record_errors, :bad_request) and return if record_errors.any? { user: user, plate: plate } end From 35c57f4f4bcce615023bf532f55978d0c8ce34f4 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 5 Sep 2024 17:28:57 +0100 Subject: [PATCH 028/158] Add core set of tests for BaitLibraryLayout requests --- .../bait_library_layout_factories.rb | 4 +- .../api/v2/bait_library_layouts_spec.rb | 296 ++++++++++++++++++ 2 files changed, 297 insertions(+), 3 deletions(-) create mode 100644 spec/requests/api/v2/bait_library_layouts_spec.rb diff --git a/spec/factories/bait_library_layout_factories.rb b/spec/factories/bait_library_layout_factories.rb index efd105ece7..82041a4f84 100644 --- a/spec/factories/bait_library_layout_factories.rb +++ b/spec/factories/bait_library_layout_factories.rb @@ -4,8 +4,6 @@ factory :bait_library_layout do user plate - layout { { - 'Human all exon 50MB' => %w[A1 A2 B1 B2 C1 C2 D1 D2 E1 F1 G1 H1] - } } + layout { nil } # This is generated after creation. end end diff --git a/spec/requests/api/v2/bait_library_layouts_spec.rb b/spec/requests/api/v2/bait_library_layouts_spec.rb new file mode 100644 index 0000000000..02a344906d --- /dev/null +++ b/spec/requests/api/v2/bait_library_layouts_spec.rb @@ -0,0 +1,296 @@ +# frozen_string_literal: true + +require 'rails_helper' +require './spec/requests/api/v2/shared_examples/api_key_authenticatable' +require './spec/requests/api/v2/shared_examples/post_requests' + +describe 'Bait Library Layouts API', with: :api_v2 do + let(:model_class) { BaitLibraryLayout } + + let(:base_endpoint) { "/api/v2/#{resource_type}" } + let(:resource_type) { model_class.name.demodulize.pluralize.underscore } + + it_behaves_like 'ApiKeyAuthenticatable' + + context 'with a list of resources' do + let(:resource_count) { 5 } + + before { create_list(:bait_library_layout, resource_count) } + + describe '#GET all the resources' do + before { api_get base_endpoint } + + it 'responds with a success http code' do + expect(response).to have_http_status(:success) + end + + it 'returns data for all the resources' do + expect(json['data'].length).to eq(resource_count) + end + end + end + + context 'with a single resource' do + describe '#GET the resource by ID' do + let(:resource) { create :bait_library_layout } + + context 'without included relationships' do + before { api_get "#{base_endpoint}/#{resource.id}" } + + it 'responds with a success http code' do + expect(response).to have_http_status(:success) + end + + it 'returns the correct resource' do + expect(json.dig('data', 'id')).to eq(resource.id.to_s) + expect(json.dig('data', 'type')).to eq(resource_type) + end + + it 'returns the correct attributes' do + expect(json.dig('data', 'attributes', 'layout')).to eq(resource.layout) + expect(json.dig('data', 'attributes', 'uuid')).to eq(resource.uuid) + end + + it 'excludes unfetchable attributes' do + expect(json.dig('data', 'attributes', 'plate_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'user_uuid')).not_to be_present + end + + it 'returns references to related resources' do + expect(json.dig('data', 'relationships', 'plate')).to be_present + expect(json.dig('data', 'relationships', 'user')).to be_present + end + + it 'does not include attributes for related resources' do + expect(json['included']).not_to be_present + end + end + + context 'with included relationships' do + context 'with plate' do + let(:related_name) { 'plate' } + let(:related_type) { 'plates' } + + it_behaves_like 'a POST request including a has_one relationship' + end + + context 'with user' do + let(:related_name) { 'user' } + let(:related_type) { 'users' } + + it_behaves_like 'a POST request including a has_one relationship' + end + end + end + end + + describe '#PATCH a resource' do + let(:resource) { create :bait_library_layout } + let(:payload) do + { + 'data' => { + 'id' => resource.id, + 'type' => resource_type, + 'attributes' => { + 'user_uuid' => '11111111-2222-3333-4444-555555666666', + } + } + } + end + + it 'finds no route for the method' do + expect { api_patch "#{base_endpoint}/#{resource.id}", payload }.to raise_error( + ActionController::RoutingError + ) + end + end + + describe '#POST a new resource' do + let(:user) { create(:user) } + let(:plate) { create(:plate) } + + let(:base_attributes) { {} } # There are no attributes to set besides ones for relationships being tested. + + let(:user_relationship) { { 'data' => { 'id' => user.id, 'type' => 'users' } } } + let(:plate_relationship) { { 'data' => { 'id' => plate.id, 'type' => 'plates' } } } + + context 'with a valid payload' do + shared_examples 'a valid POST request' do + def perform_post + api_post base_endpoint, payload + end + + it 'creates a new resource' do + expect { perform_post }.to change(model_class, :count).by(1) + end + + it 'responds with success' do + perform_post + + expect(response).to have_http_status(:success) + end + + it 'responds with the correct attributes' do + perform_post + new_record = model_class.last + + expect(json.dig('data', 'type')).to eq(resource_type) + expect(json.dig('data', 'attributes', 'layout')).to eq(new_record.layout) + end + + it 'excludes unfetchable attributes' do + perform_post + + expect(json.dig('data', 'attributes', 'plate_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'user_uuid')).not_to be_present + end + + it 'returns references to related resources' do + perform_post + + expect(json.dig('data', 'relationships', 'plate')).to be_present + expect(json.dig('data', 'relationships', 'user')).to be_present + end + + it 'applies the relationships to the new record' do + perform_post + new_record = model_class.last + + expect(new_record.plate).to eq(plate) + expect(new_record.user).to eq(user) + end + end + + context 'with complete attributes' do + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid, 'plate_uuid' => plate.uuid }) + } + } + end + + it_behaves_like 'a valid POST request' + end + + context 'with relationships' do + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes, + 'relationships' => { + 'user' => user_relationship, + 'plate' => plate_relationship + } + } + } + end + + it_behaves_like 'a valid POST request' + end + + context 'with conflicting relationships' do + let(:other_user) { create(:user) } + let(:other_plate) { create(:plate) } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => + base_attributes.merge({ 'user_uuid' => other_user.uuid, 'plate_uuid' => other_plate.uuid }), + 'relationships' => { + 'user' => user_relationship, + 'plate' => plate_relationship + } + } + } + end + + # This test should pass because the relationships are preferred over the attributes. + it_behaves_like 'a valid POST request' + end + end + + context 'with a read-only attribute in the payload' do + context 'with uuid' do + let(:disallowed_attribute) { 'uuid' } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes.merge({ 'uuid' => '111111-2222-3333-4444-555555666666' }) + } + } + end + + it_behaves_like 'a POST request with a disallowed attribute' + end + end + + context 'without a required relationship' do + context 'without user_uuid' do + let(:error_detail_message) { "user - can't be blank" } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes.merge({ 'plate_uuid' => plate.uuid }) + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end + + context 'without plate_uuid' do + let(:error_detail_message) { "plate - can't be blank" } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid }) + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end + + context 'without user' do + let(:error_detail_message) { "user - can't be blank" } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes, + 'relationships' => { + 'plate' => plate_relationship + } + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end + + context 'without plate' do + let(:error_detail_message) { "plate - can't be blank" } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes, + 'relationships' => { + 'user' => user_relationship + } + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end + end + end +end From 6bf47e358fe3580e222f5b5951a593d7495f064d Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 5 Sep 2024 18:08:12 +0100 Subject: [PATCH 029/158] Complete testing of bait_library_layouts requests --- .../api/v2/bait_library_layouts_controller.rb | 2 +- .../api/v2/bait_library_layouts_spec.rb | 395 ++++++++++++------ 2 files changed, 262 insertions(+), 135 deletions(-) diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index f6970038a3..b76a2bd310 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -33,7 +33,7 @@ def preview respond_with_errors('Validation failed', e.record.errors.full_messages, :unprocessable_entity) and return end - json = { data: { id: 0, type: 'bait_library_layouts', attributes: { layout: preview.layout } } } + json = { data: { id: '0', type: 'bait_library_layouts', attributes: { layout: preview.layout } } } render json: json, status: :ok end diff --git a/spec/requests/api/v2/bait_library_layouts_spec.rb b/spec/requests/api/v2/bait_library_layouts_spec.rb index 02a344906d..693b2dc724 100644 --- a/spec/requests/api/v2/bait_library_layouts_spec.rb +++ b/spec/requests/api/v2/bait_library_layouts_spec.rb @@ -92,204 +92,331 @@ 'id' => resource.id, 'type' => resource_type, 'attributes' => { - 'user_uuid' => '11111111-2222-3333-4444-555555666666', + 'user_uuid' => '11111111-2222-3333-4444-555555666666' } } } end it 'finds no route for the method' do - expect { api_patch "#{base_endpoint}/#{resource.id}", payload }.to raise_error( - ActionController::RoutingError - ) + expect { api_patch "#{base_endpoint}/#{resource.id}", payload }.to raise_error(ActionController::RoutingError) end end - describe '#POST a new resource' do + describe '#POST' do let(:user) { create(:user) } let(:plate) { create(:plate) } - let(:base_attributes) { {} } # There are no attributes to set besides ones for relationships being tested. + describe 'a create request' do + let(:base_attributes) { {} } # There are no attributes to set besides ones for relationships being tested. - let(:user_relationship) { { 'data' => { 'id' => user.id, 'type' => 'users' } } } - let(:plate_relationship) { { 'data' => { 'id' => plate.id, 'type' => 'plates' } } } + let(:user_relationship) { { 'data' => { 'id' => user.id, 'type' => 'users' } } } + let(:plate_relationship) { { 'data' => { 'id' => plate.id, 'type' => 'plates' } } } - context 'with a valid payload' do - shared_examples 'a valid POST request' do - def perform_post - api_post base_endpoint, payload - end + context 'with a valid payload' do + shared_examples 'a valid POST request' do + def perform_post + api_post base_endpoint, payload + end - it 'creates a new resource' do - expect { perform_post }.to change(model_class, :count).by(1) - end + it 'creates a new resource' do + expect { perform_post }.to change(model_class, :count).by(1) + end - it 'responds with success' do - perform_post + it 'responds with success' do + perform_post - expect(response).to have_http_status(:success) - end + expect(response).to have_http_status(:success) + end - it 'responds with the correct attributes' do - perform_post - new_record = model_class.last + it 'responds with the correct attributes' do + perform_post + new_record = model_class.last - expect(json.dig('data', 'type')).to eq(resource_type) - expect(json.dig('data', 'attributes', 'layout')).to eq(new_record.layout) + expect(json.dig('data', 'type')).to eq(resource_type) + expect(json.dig('data', 'attributes', 'layout')).to eq(new_record.layout) + end + + it 'excludes unfetchable attributes' do + perform_post + + expect(json.dig('data', 'attributes', 'plate_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'user_uuid')).not_to be_present + end + + it 'returns references to related resources' do + perform_post + + expect(json.dig('data', 'relationships', 'plate')).to be_present + expect(json.dig('data', 'relationships', 'user')).to be_present + end + + it 'applies the relationships to the new record' do + perform_post + new_record = model_class.last + + expect(new_record.plate).to eq(plate) + expect(new_record.user).to eq(user) + end end - it 'excludes unfetchable attributes' do - perform_post + context 'with complete attributes' do + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid, 'plate_uuid' => plate.uuid }) + } + } + end - expect(json.dig('data', 'attributes', 'plate_uuid')).not_to be_present - expect(json.dig('data', 'attributes', 'user_uuid')).not_to be_present + it_behaves_like 'a valid POST request' end - it 'returns references to related resources' do - perform_post + context 'with relationships' do + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes, + 'relationships' => { + 'user' => user_relationship, + 'plate' => plate_relationship + } + } + } + end - expect(json.dig('data', 'relationships', 'plate')).to be_present - expect(json.dig('data', 'relationships', 'user')).to be_present + it_behaves_like 'a valid POST request' end - it 'applies the relationships to the new record' do - perform_post - new_record = model_class.last + context 'with conflicting relationships' do + let(:other_user) { create(:user) } + let(:other_plate) { create(:plate) } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => + base_attributes.merge({ 'user_uuid' => other_user.uuid, 'plate_uuid' => other_plate.uuid }), + 'relationships' => { + 'user' => user_relationship, + 'plate' => plate_relationship + } + } + } + end - expect(new_record.plate).to eq(plate) - expect(new_record.user).to eq(user) + # This test should pass because the relationships are preferred over the attributes. + it_behaves_like 'a valid POST request' end end - context 'with complete attributes' do - let(:payload) do - { - 'data' => { - 'type' => resource_type, - 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid, 'plate_uuid' => plate.uuid }) + context 'with a read-only attribute in the payload' do + context 'with uuid' do + let(:disallowed_attribute) { 'uuid' } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes.merge({ 'uuid' => '111111-2222-3333-4444-555555666666' }) + } } - } - end + end - it_behaves_like 'a valid POST request' + it_behaves_like 'a POST request with a disallowed attribute' + end end - context 'with relationships' do - let(:payload) do - { - 'data' => { - 'type' => resource_type, - 'attributes' => base_attributes, - 'relationships' => { - 'user' => user_relationship, - 'plate' => plate_relationship + context 'without a required relationship' do + context 'without user_uuid' do + let(:error_detail_message) { "user - can't be blank" } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes.merge({ 'plate_uuid' => plate.uuid }) } } - } + end + + it_behaves_like 'a POST request without a required relationship' end - it_behaves_like 'a valid POST request' - end + context 'without plate_uuid' do + let(:error_detail_message) { "plate - can't be blank" } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid }) + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end - context 'with conflicting relationships' do - let(:other_user) { create(:user) } - let(:other_plate) { create(:plate) } - let(:payload) do - { - 'data' => { - 'type' => resource_type, - 'attributes' => - base_attributes.merge({ 'user_uuid' => other_user.uuid, 'plate_uuid' => other_plate.uuid }), - 'relationships' => { - 'user' => user_relationship, - 'plate' => plate_relationship + context 'without user' do + let(:error_detail_message) { "user - can't be blank" } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes, + 'relationships' => { + 'plate' => plate_relationship + } } } - } + end + + it_behaves_like 'a POST request without a required relationship' end - # This test should pass because the relationships are preferred over the attributes. - it_behaves_like 'a valid POST request' + context 'without plate' do + let(:error_detail_message) { "plate - can't be blank" } + let(:payload) do + { + 'data' => { + 'type' => resource_type, + 'attributes' => base_attributes, + 'relationships' => { + 'user' => user_relationship + } + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end end end - context 'with a read-only attribute in the payload' do - context 'with uuid' do - let(:disallowed_attribute) { 'uuid' } - let(:payload) do - { - 'data' => { - 'type' => resource_type, - 'attributes' => base_attributes.merge({ 'uuid' => '111111-2222-3333-4444-555555666666' }) - } - } + describe 'a preview request' do + let(:base_endpoint) { "/api/v2/#{resource_type}/preview" } + + let(:valid_payload) { { user_uuid: user.uuid, plate_uuid: plate.uuid } } + + context 'with a valid payload' do + before { api_post base_endpoint, valid_payload } + + it 'responds with success' do + expect(response).to have_http_status(:success) end - it_behaves_like 'a POST request with a disallowed attribute' + it 'returns the correct data parameters' do + expect(json.dig('data', 'id')).to eq('0') + expect(json.dig('data', 'type')).to eq(resource_type) + end + + it 'returns a layout as an attribute' do + expect(json.dig('data', 'attributes', 'layout')).not_to be_nil + end end - end - context 'without a required relationship' do - context 'without user_uuid' do - let(:error_detail_message) { "user - can't be blank" } - let(:payload) do - { - 'data' => { - 'type' => resource_type, - 'attributes' => base_attributes.merge({ 'plate_uuid' => plate.uuid }) - } - } + context 'without a required parameter' do + shared_examples 'a request with a missing parameter' do + let(:payload) { valid_payload.except(missing_parameter) } + + before { api_post base_endpoint, payload } + + it 'responds with bad_request' do + expect(response).to have_http_status(:bad_request) + end + + it 'returns an error message' do + expect(json).to eq( + 'errors' => [ + { + 'title' => 'Missing parameter', + 'detail' => "param is missing or the value is empty: #{missing_parameter}", + 'code' => 400, + 'status' => 400 + } + ] + ) + end end - it_behaves_like 'a POST request without a required relationship' - end + context 'without plate_uuid' do + let(:missing_parameter) { :plate_uuid } - context 'without plate_uuid' do - let(:error_detail_message) { "plate - can't be blank" } - let(:payload) do - { - 'data' => { - 'type' => resource_type, - 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid }) - } - } + it_behaves_like 'a request with a missing parameter' end - it_behaves_like 'a POST request without a required relationship' + context 'without user_uuid' do + let(:missing_parameter) { :user_uuid } + + it_behaves_like 'a request with a missing parameter' + end end - context 'without user' do - let(:error_detail_message) { "user - can't be blank" } - let(:payload) do - { - 'data' => { - 'type' => resource_type, - 'attributes' => base_attributes, - 'relationships' => { - 'plate' => plate_relationship - } - } - } + context 'with a parameter for a missing record' do + shared_examples 'a request with a missing record' do + let(:payload) { valid_payload.merge(invalid_parameter => 'missing_uuid') } + + before { api_post base_endpoint, payload } + + it 'responds with bad_request' do + expect(response).to have_http_status(:bad_request) + end + + it 'returns an error message' do + expect(json).to eq( + 'errors' => [ + { + 'title' => 'Record not found', + 'detail' => "The #{resource_name} record identified by UUID 'missing_uuid' cannot be found", + 'code' => 400, + 'status' => 400 + } + ] + ) + end end - it_behaves_like 'a POST request without a required relationship' + context 'with a missing plate' do + let(:invalid_parameter) { :plate_uuid } + let(:resource_name) { 'Plate' } + + it_behaves_like 'a request with a missing record' + end + + context 'with a missing user' do + let(:invalid_parameter) { :user_uuid } + let(:resource_name) { 'User' } + + it_behaves_like 'a request with a missing record' + end end - context 'without plate' do - let(:error_detail_message) { "plate - can't be blank" } - let(:payload) do - { - 'data' => { - 'type' => resource_type, - 'attributes' => base_attributes, - 'relationships' => { - 'user' => user_relationship - } - } - } + context 'with a resource validation error' do + let(:raised_exception) do + record = BaitLibraryLayout.new + record.errors.add(:base, 'error 1') + record.errors.add(:base, 'error 2') + + ActiveRecord::RecordInvalid.new(record) end - it_behaves_like 'a POST request without a required relationship' + before do + allow(BaitLibraryLayout).to receive(:preview!).and_raise(raised_exception) + api_post base_endpoint, valid_payload + end + + it 'responds with unprocessable_entity' do + expect(response).to have_http_status(:unprocessable_entity) + end + + it 'returns all errors' do + expect(json).to eq( + 'errors' => [ + { 'title' => 'Validation failed', 'detail' => 'error 1', 'code' => 422, 'status' => 422 }, + { 'title' => 'Validation failed', 'detail' => 'error 2', 'code' => 422, 'status' => 422 } + ] + ) + end end end end From ba423548f19a7aa71f1d29f40f96b8286f60d969 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 5 Sep 2024 18:08:24 +0100 Subject: [PATCH 030/158] Apply prettier and rubocop rules --- spec/requests/api/v2/state_changes_spec.rb | 17 ++++++----------- spec/support/api_v2_resource_matchers.rb | 18 ++++++------------ 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/spec/requests/api/v2/state_changes_spec.rb b/spec/requests/api/v2/state_changes_spec.rb index f6bac10e1a..a3f63461eb 100644 --- a/spec/requests/api/v2/state_changes_spec.rb +++ b/spec/requests/api/v2/state_changes_spec.rb @@ -108,7 +108,7 @@ end end - describe '#POST a new resource' do + describe '#POST a create request' do let(:user) { create(:user) } let(:plate) { create(:plate) } @@ -273,7 +273,7 @@ context 'without a required relationship' do context 'without user_uuid' do - let(:error_detail_message) { "user - must exist" } + let(:error_detail_message) { 'user - must exist' } let(:payload) do { 'data' => { @@ -287,21 +287,16 @@ end context 'without target_uuid' do - let(:error_detail_message) { "target - must exist" } + let(:error_detail_message) { 'target - must exist' } let(:payload) do - { - 'data' => { - 'type' => resource_type, - 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid }) - } - } + { 'data' => { 'type' => resource_type, 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid }) } } end it_behaves_like 'a POST request without a required relationship' end context 'without user' do - let(:error_detail_message) { "user - must exist" } + let(:error_detail_message) { 'user - must exist' } let(:payload) do { 'data' => { @@ -318,7 +313,7 @@ end context 'without target' do - let(:error_detail_message) { "target - must exist" } + let(:error_detail_message) { 'target - must exist' } let(:payload) do { 'data' => { diff --git a/spec/support/api_v2_resource_matchers.rb b/spec/support/api_v2_resource_matchers.rb index 2b30b4325a..cb081e288e 100644 --- a/spec/support/api_v2_resource_matchers.rb +++ b/spec/support/api_v2_resource_matchers.rb @@ -2,12 +2,10 @@ module ApiV2Matchers RSpec::Matchers.define :have_readonly_attribute do |attribute| - description { "have read-only attribute `#{attribute.to_s}`" } + description { "have read-only attribute `#{attribute}`" } failure_message { "expected #{resource.class.name.demodulize} to #{description}" } - failure_message_when_negated do - "expected #{resource.class.name.demodulize} not to #{description}" - end + failure_message_when_negated { "expected #{resource.class.name.demodulize} not to #{description}" } match do |resource| expect(resource).to have_attribute attribute @@ -16,12 +14,10 @@ module ApiV2Matchers end RSpec::Matchers.define :have_readwrite_attribute do |attribute| - description { "have read-write attribute `#{attribute.to_s}`" } + description { "have read-write attribute `#{attribute}`" } failure_message { "expected #{resource.class.name.demodulize} to #{description}" } - failure_message_when_negated do - "expected #{resource.class.name.demodulize} not to #{description}" - end + failure_message_when_negated { "expected #{resource.class.name.demodulize} not to #{description}" } match do |resource| expect(resource).to have_attribute attribute @@ -30,12 +26,10 @@ module ApiV2Matchers end RSpec::Matchers.define :have_writeonly_attribute do |attribute| - description { "have write-only attribute `#{attribute.to_s}`" } + description { "have write-only attribute `#{attribute}`" } failure_message { "expected #{resource.class.name.demodulize} to #{description}" } - failure_message_when_negated do - "expected #{resource.class.name.demodulize} not to #{description}" - end + failure_message_when_negated { "expected #{resource.class.name.demodulize} not to #{description}" } match do |resource| expect(resource).not_to have_attribute attribute From ffd1e2ef1a91ded2cc69fc770d5a5f213e1b796a Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 5 Sep 2024 18:22:43 +0100 Subject: [PATCH 031/158] Fix tests affected by restructuring shared examples --- spec/requests/api/v2/shared_examples/post_requests.rb | 2 +- spec/requests/api/v2/transfers/transfers_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/requests/api/v2/shared_examples/post_requests.rb b/spec/requests/api/v2/shared_examples/post_requests.rb index acb9a5e5df..a40d2c1286 100644 --- a/spec/requests/api/v2/shared_examples/post_requests.rb +++ b/spec/requests/api/v2/shared_examples/post_requests.rb @@ -29,7 +29,7 @@ expect(response).to have_http_status(:unprocessable_entity) end - it 'specifies which attribute cannot be blank' do + it 'gives the expected error message detail' do expect(json.dig('errors', 0, 'detail')).to eq(error_detail_message) end end diff --git a/spec/requests/api/v2/transfers/transfers_spec.rb b/spec/requests/api/v2/transfers/transfers_spec.rb index 411a432d0b..741eb0909e 100644 --- a/spec/requests/api/v2/transfers/transfers_spec.rb +++ b/spec/requests/api/v2/transfers/transfers_spec.rb @@ -132,21 +132,21 @@ context 'without user_uuid' do let(:attribute_to_remove) { 'user_uuid' } - let(:missing_attribute) { 'user' } + let(:error_detail_message) { "user - can't be blank" } it_behaves_like 'a POST request with a missing attribute' end context 'without source_uuid' do let(:attribute_to_remove) { 'source_uuid' } - let(:missing_attribute) { 'source' } + let(:error_detail_message) { "source - can't be blank" } it_behaves_like 'a POST request with a missing attribute' end context 'without destination_uuid' do let(:attribute_to_remove) { 'destination_uuid' } - let(:missing_attribute) { 'destination' } + let(:error_detail_message) { "destination - can't be blank" } it_behaves_like 'a POST request with a missing attribute' end From 3005be6dff3542069691da6ac24b7d8d7c025de3 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 6 Sep 2024 10:47:09 +0100 Subject: [PATCH 032/158] Remove id from the preview response of bait_library_layout --- app/controllers/api/v2/bait_library_layouts_controller.rb | 4 ++-- spec/requests/api/v2/bait_library_layouts_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index b76a2bd310..f739d4d670 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -21,7 +21,7 @@ class BaitLibraryLayoutsController < JSONAPI::ResourceController # # @return [JSON] The JSON representation of a sparsely populated {BaitLibraryLayoutResource}. # Only the `layout` attribute is included. - # The returned `id` is always `0` and cannot be used to reference the resource. + # No `id` is included as this is a preview and not a persisted record. def preview records = preview_records return if records.nil? @@ -33,7 +33,7 @@ def preview respond_with_errors('Validation failed', e.record.errors.full_messages, :unprocessable_entity) and return end - json = { data: { id: '0', type: 'bait_library_layouts', attributes: { layout: preview.layout } } } + json = { data: { type: 'bait_library_layouts', attributes: { layout: preview.layout } } } render json: json, status: :ok end diff --git a/spec/requests/api/v2/bait_library_layouts_spec.rb b/spec/requests/api/v2/bait_library_layouts_spec.rb index 693b2dc724..44a33bab95 100644 --- a/spec/requests/api/v2/bait_library_layouts_spec.rb +++ b/spec/requests/api/v2/bait_library_layouts_spec.rb @@ -306,7 +306,7 @@ def perform_post end it 'returns the correct data parameters' do - expect(json.dig('data', 'id')).to eq('0') + expect(json.dig('data', 'id')).not_to be_present expect(json.dig('data', 'type')).to eq(resource_type) end From 76ce5400b8248fdbd80305f82ce8ad562d3473f2 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 6 Sep 2024 10:51:02 +0100 Subject: [PATCH 033/158] Remove unnecessary `private` declaration for method --- app/models/bait_library_layout.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/bait_library_layout.rb b/app/models/bait_library_layout.rb index 3c65fc4c42..896cfa575d 100644 --- a/app/models/bait_library_layout.rb +++ b/app/models/bait_library_layout.rb @@ -82,5 +82,4 @@ def each_bait_library_assignment def generate_for_preview each_bait_library_assignment { |well, bait_library| record_bait_library_assignment(well, bait_library) } end - private :generate_for_preview end From b3badb2cb9ad984621569d8cf85f15a1c72bdcb5 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 6 Sep 2024 11:30:45 +0100 Subject: [PATCH 034/158] Clean up implementation of preview functions for bait_library_layouts --- .../api/v2/bait_library_layouts_controller.rb | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index f739d4d670..1853f55155 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -47,34 +47,28 @@ def respond_with_errors(title, details, status) render json: { errors: errors }, status: status end - def preview_params - params.permit(:user_uuid, :plate_uuid) + # This should only be called once per request, as it will render an exception every time it's called when any one + # of the required parameters are not present. + def permitted_params + begin + param_keys = [:user_uuid, :plate_uuid] + param_keys.zip(params.require(param_keys)).to_h + rescue ActionController::ParameterMissing => e + respond_with_errors('Missing parameter', [e.message], :bad_request) and return + end end - def preview_user(record_errors) - user_uuid = preview_params.require(:user_uuid) - user = User.with_uuid(user_uuid).first - record_errors.append("The User record identified by UUID '#{user_uuid}' cannot be found") if user.nil? + def preview_records + param_hash = permitted_params + return if param_hash.nil? - user - end + record_errors = [] - def preview_plate(record_errors) - plate_uuid = preview_params.require(:plate_uuid) - plate = Plate.with_uuid(plate_uuid).first - record_errors.append("The Plate record identified by UUID '#{plate_uuid}' cannot be found") if plate.nil? + user = User.with_uuid(param_hash[:user_uuid]).first || + record_errors.append("The User record identified by UUID '#{permitted_params[:user_uuid]}' cannot be found") - plate - end - - def preview_records - begin - record_errors = [] - user = preview_user(record_errors) - plate = preview_plate(record_errors) - rescue ActionController::ParameterMissing => e - respond_with_errors('Missing parameter', [e.message], :bad_request) and return - end + plate = Plate.with_uuid(param_hash[:plate_uuid]).first || + record_errors.append("The Plate record identified by UUID '#{permitted_params[:plate_uuid]}' cannot be found") respond_with_errors('Record not found', record_errors, :bad_request) and return if record_errors.any? From 6893366368b6954e5f41fd930b66238b8c8c9753 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 6 Sep 2024 11:36:49 +0100 Subject: [PATCH 035/158] Apply prettier and rubocop --- .../api/v2/bait_library_layouts_controller.rb | 20 +++++++++---------- .../api/v2/bait_library_layouts_spec.rb | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index 1853f55155..0690fe4b85 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -50,12 +50,10 @@ def respond_with_errors(title, details, status) # This should only be called once per request, as it will render an exception every time it's called when any one # of the required parameters are not present. def permitted_params - begin - param_keys = [:user_uuid, :plate_uuid] - param_keys.zip(params.require(param_keys)).to_h - rescue ActionController::ParameterMissing => e - respond_with_errors('Missing parameter', [e.message], :bad_request) and return - end + param_keys = %i[user_uuid plate_uuid] + param_keys.zip(params.require(param_keys)).to_h + rescue ActionController::ParameterMissing => e + respond_with_errors('Missing parameter', [e.message], :bad_request) and return end def preview_records @@ -64,11 +62,13 @@ def preview_records record_errors = [] - user = User.with_uuid(param_hash[:user_uuid]).first || - record_errors.append("The User record identified by UUID '#{permitted_params[:user_uuid]}' cannot be found") + user = + User.with_uuid(param_hash[:user_uuid]).first || + record_errors.append("The User identified by UUID '#{permitted_params[:user_uuid]}' cannot be found") - plate = Plate.with_uuid(param_hash[:plate_uuid]).first || - record_errors.append("The Plate record identified by UUID '#{permitted_params[:plate_uuid]}' cannot be found") + plate = + Plate.with_uuid(param_hash[:plate_uuid]).first || + record_errors.append("The Plate identified by UUID '#{permitted_params[:plate_uuid]}' cannot be found") respond_with_errors('Record not found', record_errors, :bad_request) and return if record_errors.any? diff --git a/spec/requests/api/v2/bait_library_layouts_spec.rb b/spec/requests/api/v2/bait_library_layouts_spec.rb index 44a33bab95..506964c042 100644 --- a/spec/requests/api/v2/bait_library_layouts_spec.rb +++ b/spec/requests/api/v2/bait_library_layouts_spec.rb @@ -367,7 +367,7 @@ def perform_post 'errors' => [ { 'title' => 'Record not found', - 'detail' => "The #{resource_name} record identified by UUID 'missing_uuid' cannot be found", + 'detail' => "The #{resource_name} identified by UUID 'missing_uuid' cannot be found", 'code' => 400, 'status' => 400 } From 7870248e816373c236d54e710becd601a1ffd3f0 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 6 Sep 2024 11:38:46 +0100 Subject: [PATCH 036/158] Fix accidental use of wrong hash in error message --- app/controllers/api/v2/bait_library_layouts_controller.rb | 4 ++-- spec/requests/api/v2/bait_library_layouts_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index 0690fe4b85..fbdafbf478 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -64,11 +64,11 @@ def preview_records user = User.with_uuid(param_hash[:user_uuid]).first || - record_errors.append("The User identified by UUID '#{permitted_params[:user_uuid]}' cannot be found") + record_errors.append("The User record identified by UUID '#{param_hash[:user_uuid]}' cannot be found") plate = Plate.with_uuid(param_hash[:plate_uuid]).first || - record_errors.append("The Plate identified by UUID '#{permitted_params[:plate_uuid]}' cannot be found") + record_errors.append("The Plate record identified by UUID '#{param_hash[:plate_uuid]}' cannot be found") respond_with_errors('Record not found', record_errors, :bad_request) and return if record_errors.any? diff --git a/spec/requests/api/v2/bait_library_layouts_spec.rb b/spec/requests/api/v2/bait_library_layouts_spec.rb index 506964c042..44a33bab95 100644 --- a/spec/requests/api/v2/bait_library_layouts_spec.rb +++ b/spec/requests/api/v2/bait_library_layouts_spec.rb @@ -367,7 +367,7 @@ def perform_post 'errors' => [ { 'title' => 'Record not found', - 'detail' => "The #{resource_name} identified by UUID 'missing_uuid' cannot be found", + 'detail' => "The #{resource_name} record identified by UUID 'missing_uuid' cannot be found", 'code' => 400, 'status' => 400 } From 40da65cb1e884fb7446bbf8c9ad2b1d8ef81565a Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 6 Sep 2024 16:22:15 +0100 Subject: [PATCH 037/158] Create endpoint for TagLayout creation and retrieval --- .../api/v2/tag_layouts_controller.rb | 12 ++ app/resources/api/v2/tag_layout_resource.rb | 146 ++++++++++++++++++ config/routes.rb | 1 + 3 files changed, 159 insertions(+) create mode 100644 app/controllers/api/v2/tag_layouts_controller.rb create mode 100644 app/resources/api/v2/tag_layout_resource.rb diff --git a/app/controllers/api/v2/tag_layouts_controller.rb b/app/controllers/api/v2/tag_layouts_controller.rb new file mode 100644 index 0000000000..168e2197be --- /dev/null +++ b/app/controllers/api/v2/tag_layouts_controller.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Api + module V2 + # Provides a JSON API controller for Tag Layouts + # See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation + class TagLayoutsController < JSONAPI::ResourceController + # By default JSONAPI::ResourceController provides most the standard + # behaviour, and in many cases this file may be left empty. + end + end +end diff --git a/app/resources/api/v2/tag_layout_resource.rb b/app/resources/api/v2/tag_layout_resource.rb new file mode 100644 index 0000000000..1f01e60a82 --- /dev/null +++ b/app/resources/api/v2/tag_layout_resource.rb @@ -0,0 +1,146 @@ +# frozen_string_literal: true + +module Api + module V2 + # @todo This documentation does not yet include a detailed description of what this resource represents. + # @todo This documentation does not yet include detailed descriptions for relationships, attributes and filters. + # @todo This documentation does not yet include any example usage of the API via cURL or similar. + # + # @note This resource cannot be modified after creation: its endpoint will not accept `PATCH` requests. + # @note Access this resource via the `/api/v2/tag_layouts/` endpoint. + # + # Provides a JSON:API representation of {TagLayout}. + # + # For more information about JSON:API see the [JSON:API Specifications](https://jsonapi.org/format/) + # or look at the [JSONAPI::Resources](http://jsonapi-resources.com/) package for Sequencescape's implementation + # of the JSON:API standard. + class TagLayoutResource < BaseResource + ### + # Attributes + ### + + # @!attribute [rw] direction + # The name of the algorithm defining the direction of the tag layout. + # @return [String] + # @note This attribute is required. + attribute :direction + + # @!attribute [rw] initial_tag + # An offset for the tag set indicating which tag to start with in the layout. + # @return [Integer] + attribute :initial_tag + + # @!attribute [w] target_uuid + # This is declared for convenience where the {Plate} is not available to set as a relationship. + # Setting this attribute alongside the `plate` relationship will prefer the relationship value. + # @deprecated Use the `plate` relationship instead. + # @param value [String] The UUID of the {Plate} this tag layout applies to. + # @return [Void] + # @see #plate + attribute :plate_uuid + + def plate_uuid=(value) + @model.plate = Plate.with_uuid(value).first + end + + # @!attribute [rw] substitutions + # A hash of substitutions to be applied to the tag layout. + # @return [Hash] + attribute :substitutions + + # @!attribute [w] tag_group_uuid + # This is declared for convenience where the {TagGroup} is not available to set as a relationship. + # Setting this attribute alongside the `tag_group` relationship will prefer the relationship value. + # @deprecated Use the `tag_group` relationship instead. + # @param value [String] The UUID of the {TagGroup} used in this tag layout. + # @return [Void] + # @see #tag_group + attribute :tag_group_uuid + + def tag_group_uuid=(value) + @model.tag_group = TagGroup.with_uuid(value).first + end + + # @!attribute [w] tag2_group_uuid + # This is declared for convenience where the second {TagGroup} is not available to set as a relationship. + # Setting this attribute alongside the `tag2_group` relationship will prefer the relationship value. + # @deprecated Use the `tag2_group` relationship instead. + # @param value [String] The UUID of the second {TagGroup} used in this tag layout. + # @return [Void] + # @see #tag2_group + attribute :tag2_group_uuid + + def tag2_group_uuid=(value) + @model.tag2_group = TagGroup.with_uuid(value).first + end + + # @!attribute [rw] tags_per_well + # The number of tags in each well. + # @return [Integer] + attribute :tags_per_well + + # @!attribute [w] user_uuid + # This is declared for convenience where the {User} is not available to set as a relationship. + # Setting this attribute alongside the `user` relationship will prefer the relationship value. + # @deprecated Use the `user` relationship instead. + # @param value [String] The UUID of the {User} who initiated this state change. + # @return [Void] + # @see #user + attribute :user_uuid + + def user_uuid=(value) + @model.user = User.with_uuid(value).first + end + + # @!attribute [r] uuid + # @return [String] The UUID of the state change. + attribute :uuid, readonly: true + + # @!attribute [rw] walking_by + # The name of the algorithm defining the way of walking through the tag layout. + # @return [String] + # @note This attribute is required. + attribute :walking_by + + ### + # Relationships + ### + + # @!attribute [rw] plate + # Setting this relationship alongside the `plate_uuid` attribute will override the attribute value. + # @return [PlateResource] The plate this tag layout applies to. + # @note This relationship is required. + has_one :plate, class_name: 'Plate' + + # @!attribute [rw] tag_group + # Setting this relationship alongside the `tag_group_uuid` attribute will override the attribute value. + # A relationship for the primary tag group associated with the tag layout template. + # @return [Api::V2::TagGroupResource] + # @note This relationship is required. + has_one :tag_group, class_name: 'TagGroup' + + # @!attribute [rw] tag2_group + # Setting this relationship alongside the `tag2_group_uuid` attribute will override the attribute value. + # A relationship for the secondary tag group associated with the tag layout template. + # This is used during dual indexing, but will not be found during single indexing. + # @return [Api::V2::TagGroupResource] + has_one :tag2_group, class_name: 'TagGroup' + + # @!attribute [rw] user + # Setting this relationship alongside the `user_uuid` attribute will override the attribute value. + # @return [UserResource] The user who initiated this state change. + # @note This relationship is required. + has_one :user + + def self.creatable_fields(context) + # UUID is set by the system. + super - %i[uuid] + end + + def fetchable_fields + # UUIDs for relationships are not fetchable. They should be accessed via the relationship itself. + super - %i[plate_uuid tag_group_uuid tag2_group_uuid user_uuid] + end + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 9c2aa45c83..4384b50959 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -60,6 +60,7 @@ jsonapi_resources :tag_group_adapter_types jsonapi_resources :tag_groups jsonapi_resources :tag_layout_templates + jsonapi_resources :tag_layouts, except: %i[update] jsonapi_resources :tags jsonapi_resources :transfer_requests jsonapi_resources :transfer_templates From 8862a088b4dbd36309df0db409c15eb6d91c8e0a Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 6 Sep 2024 16:22:24 +0100 Subject: [PATCH 038/158] WIP: Add stubs for new tests --- spec/requests/api/v2/tag_layouts_spec.rb | 333 ++++++++++++++++++ .../api/v2/tag_layout_resource_spec.rb | 26 ++ 2 files changed, 359 insertions(+) create mode 100644 spec/requests/api/v2/tag_layouts_spec.rb create mode 100644 spec/resources/api/v2/tag_layout_resource_spec.rb diff --git a/spec/requests/api/v2/tag_layouts_spec.rb b/spec/requests/api/v2/tag_layouts_spec.rb new file mode 100644 index 0000000000..54bd4a70d6 --- /dev/null +++ b/spec/requests/api/v2/tag_layouts_spec.rb @@ -0,0 +1,333 @@ +# frozen_string_literal: true + +require 'rails_helper' +require './spec/requests/api/v2/shared_examples/api_key_authenticatable' +require './spec/requests/api/v2/shared_examples/post_requests' + +describe 'Tag Layouts API', with: :api_v2 do + # let(:model_class) { StateChange } + # let(:base_endpoint) { "/api/v2/#{resource_type}" } + # let(:resource_type) { model_class.name.demodulize.pluralize.underscore } + + # it_behaves_like 'ApiKeyAuthenticatable' + + # context 'with a list of resource' do + # let(:resource_count) { 5 } + + # before { create_list(:state_change, resource_count) } + + # describe '#GET all resources' do + # before { api_get base_endpoint } + + # it 'responds with a success http code' do + # expect(response).to have_http_status(:success) + # end + + # it 'returns all the resources' do + # expect(json['data'].length).to eq(resource_count) + # end + # end + # end + + # context 'with a single resource' do + # describe '#GET resource by ID' do + # let(:resource) { create :state_change } + + # context 'without included relationships' do + # before { api_get "#{base_endpoint}/#{resource.id}" } + + # it 'responds with a success http code' do + # expect(response).to have_http_status(:success) + # end + + # it 'returns the correct resource' do + # expect(json.dig('data', 'id')).to eq(resource.id.to_s) + # expect(json.dig('data', 'type')).to eq(resource_type) + # end + + # it 'returns the correct attributes' do + # expect(json.dig('data', 'attributes', 'contents')).to eq(resource.contents) + # expect(json.dig('data', 'attributes', 'previous_state')).to eq(resource.previous_state) + # expect(json.dig('data', 'attributes', 'reason')).to eq(resource.reason) + # expect(json.dig('data', 'attributes', 'target_state')).to eq(resource.target_state) + # expect(json.dig('data', 'attributes', 'uuid')).to eq(resource.uuid) + # end + + # it 'excludes unfetchable attributes' do + # expect(json.dig('data', 'attributes', 'customer_accepts_responsibility')).not_to be_present + # expect(json.dig('data', 'attributes', 'target_uuid')).not_to be_present + # expect(json.dig('data', 'attributes', 'user_uuid')).not_to be_present + # end + + # it 'returns references to related resources' do + # expect(json.dig('data', 'relationships', 'target')).to be_present + # expect(json.dig('data', 'relationships', 'user')).to be_present + # end + + # it 'does not include attributes for related resources' do + # expect(json['included']).not_to be_present + # end + # end + + # context 'with included relationships' do + # context 'with user' do + # let(:related_name) { 'user' } + # let(:related_type) { 'users' } + + # it_behaves_like 'a POST request including a has_one relationship' + # end + + # context 'with target' do + # let(:related_name) { 'target' } + # let(:related_type) { 'labware' } + + # it_behaves_like 'a POST request including a has_one relationship' + # end + # end + # end + # end + + # describe '#PATCH a resource' do + # let(:resource_model) { create :state_change } + # let(:payload) do + # { + # 'data' => { + # 'id' => resource_model.id, + # 'type' => resource_type, + # 'attributes' => { + # 'target_state' => 'passed' + # } + # } + # } + # end + + # it 'finds no route for the method' do + # expect { api_patch "#{base_endpoint}/#{resource_model.id}", payload }.to raise_error( + # ActionController::RoutingError + # ) + # end + # end + + # describe '#POST a create request' do + # let(:user) { create(:user) } + # let(:plate) { create(:plate) } + + # let(:base_attributes) do + # { + # 'contents' => %w[A1 D2], + # 'customer_accepts_responsibility' => true, + # 'reason' => 'The plate is now passed.', + # 'target_state' => 'passed' + # } + # end + + # let(:user_relationship) { { 'data' => { 'id' => user.id, 'type' => 'users' } } } + # let(:target_relationship) { { 'data' => { 'id' => plate.id, 'type' => 'labware' } } } + + # context 'with a valid payload' do + # shared_examples 'a valid request' do + # before { api_post base_endpoint, payload } + + # it 'creates a new resource' do + # expect { api_post base_endpoint, payload }.to change(model_class, :count).by(1) + # end + + # it 'responds with success' do + # expect(response).to have_http_status(:success) + # end + + # it 'responds with the correct attributes' do + # new_record = model_class.last + + # expect(json.dig('data', 'type')).to eq(resource_type) + # expect(json.dig('data', 'attributes', 'contents')).to eq(new_record.contents) + # expect(json.dig('data', 'attributes', 'reason')).to eq(new_record.reason) + # expect(json.dig('data', 'attributes', 'target_state')).to eq(new_record.target_state) + # end + + # it 'excludes unfetchable attributes' do + # expect(json.dig('data', 'attributes', 'customer_accepts_responsibility')).not_to be_present + # expect(json.dig('data', 'attributes', 'target_uuid')).not_to be_present + # expect(json.dig('data', 'attributes', 'user_uuid')).not_to be_present + # end + + # it 'returns references to related resources' do + # expect(json.dig('data', 'relationships', 'user')).to be_present + # expect(json.dig('data', 'relationships', 'target')).to be_present + # end + + # it 'applies the attributes to the new record' do + # new_record = model_class.last + + # expect(new_record.contents).to eq(payload.dig('data', 'attributes', 'contents')) + # expect(new_record.reason).to eq(payload.dig('data', 'attributes', 'reason')) + # expect(new_record.target_state).to eq(payload.dig('data', 'attributes', 'target_state')) + # end + + # it 'applies the relationships to the new record' do + # new_record = model_class.last + + # expect(new_record.user).to eq(user) + # expect(new_record.target).to eq(plate) + # end + # end + + # context 'with complete attributes' do + # let(:payload) do + # { + # 'data' => { + # 'type' => resource_type, + # 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid, 'target_uuid' => plate.uuid }) + # } + # } + # end + + # it_behaves_like 'a valid request' + # end + + # context 'with relationships' do + # let(:payload) do + # { + # 'data' => { + # 'type' => resource_type, + # 'attributes' => base_attributes, + # 'relationships' => { + # 'user' => user_relationship, + # 'target' => target_relationship + # } + # } + # } + # end + + # it_behaves_like 'a valid request' + # end + + # context 'with conflicting relationships' do + # let(:other_user) { create(:user) } + # let(:other_plate) { create(:plate) } + # let(:payload) do + # { + # 'data' => { + # 'type' => resource_type, + # 'attributes' => + # base_attributes.merge({ 'user_uuid' => other_user.uuid, 'target_uuid' => other_plate.uuid }), + # 'relationships' => { + # 'user' => user_relationship, + # 'target' => target_relationship + # } + # } + # } + # end + + # # This test should pass because the relationships are preferred over the attributes. + # it_behaves_like 'a valid request' + # end + # end + + # context 'with a read-only attribute in the payload' do + # context 'with previous_state' do + # let(:disallowed_attribute) { 'previous_state' } + # let(:payload) do + # { + # 'data' => { + # 'type' => resource_type, + # 'attributes' => base_attributes.merge({ 'previous_state' => 'waiting' }) + # } + # } + # end + + # it_behaves_like 'a POST request with a disallowed attribute' + # end + + # context 'with uuid' do + # let(:disallowed_attribute) { 'uuid' } + # let(:payload) do + # { + # 'data' => { + # 'type' => resource_type, + # 'attributes' => base_attributes.merge({ 'uuid' => '111111-2222-3333-4444-555555666666' }) + # } + # } + # end + + # it_behaves_like 'a POST request with a disallowed attribute' + # end + # end + + # context 'without a required attribute' do + # context 'without target_state' do + # let(:error_detail_message) { "target_state - can't be blank" } + # let(:payload) do + # { + # 'data' => { + # 'type' => resource_type, + # 'attributes' => + # base_attributes.merge({ 'target_state' => nil, 'user_uuid' => user.uuid, 'target_uuid' => plate.uuid }) + # } + # } + # end + + # it_behaves_like 'a POST request with a missing attribute' + # end + # end + + # context 'without a required relationship' do + # context 'without user_uuid' do + # let(:error_detail_message) { 'user - must exist' } + # let(:payload) do + # { + # 'data' => { + # 'type' => resource_type, + # 'attributes' => base_attributes.merge({ 'target_uuid' => plate.uuid }) + # } + # } + # end + + # it_behaves_like 'a POST request without a required relationship' + # end + + # context 'without target_uuid' do + # let(:error_detail_message) { 'target - must exist' } + # let(:payload) do + # { 'data' => { 'type' => resource_type, 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid }) } } + # end + + # it_behaves_like 'a POST request without a required relationship' + # end + + # context 'without user' do + # let(:error_detail_message) { 'user - must exist' } + # let(:payload) do + # { + # 'data' => { + # 'type' => resource_type, + # 'attributes' => base_attributes, + # 'relationships' => { + # 'target' => target_relationship + # } + # } + # } + # end + + # it_behaves_like 'a POST request without a required relationship' + # end + + # context 'without target' do + # let(:error_detail_message) { 'target - must exist' } + # let(:payload) do + # { + # 'data' => { + # 'type' => resource_type, + # 'attributes' => base_attributes, + # 'relationships' => { + # 'user' => user_relationship + # } + # } + # } + # end + + # it_behaves_like 'a POST request without a required relationship' + # end + # end + # end +end diff --git a/spec/resources/api/v2/tag_layout_resource_spec.rb b/spec/resources/api/v2/tag_layout_resource_spec.rb new file mode 100644 index 0000000000..17940ccde0 --- /dev/null +++ b/spec/resources/api/v2/tag_layout_resource_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'rails_helper' +require './app/resources/api/v2/tag_layout_resource' + +RSpec.describe Api::V2::TagLayoutResource, type: :resource do + # subject(:resource) { described_class.new(resource_model, {}) } + + # let(:resource_model) { build_stubbed :state_change } + + # # Attributes + # it { is_expected.to have_readonly_attribute :uuid } + # it { is_expected.to have_readonly_attribute :previous_state } + + # it { is_expected.to have_readwrite_attribute :contents } + # it { is_expected.to have_readwrite_attribute :reason } + # it { is_expected.to have_readwrite_attribute :target_state } + + # it { is_expected.to have_writeonly_attribute :user_uuid } + # it { is_expected.to have_writeonly_attribute :target_uuid } + # it { is_expected.to have_writeonly_attribute :customer_accepts_responsibility } + + # # Relationships + # it { is_expected.to have_one(:target).with_class_name('Labware') } + # it { is_expected.to have_one(:user).with_class_name('User') } +end From 2d05515792a37030ccd9347f3a63a9155238bf75 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Mon, 9 Sep 2024 13:55:11 +0100 Subject: [PATCH 039/158] Generate tests for the tay_layout_resource attributes and relationships --- app/resources/api/v2/tag_layout_resource.rb | 8 ++--- .../api/v2/tag_layout_resource_spec.rb | 32 +++++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/resources/api/v2/tag_layout_resource.rb b/app/resources/api/v2/tag_layout_resource.rb index 1f01e60a82..fe9b9a3718 100644 --- a/app/resources/api/v2/tag_layout_resource.rb +++ b/app/resources/api/v2/tag_layout_resource.rb @@ -108,16 +108,16 @@ def user_uuid=(value) # @!attribute [rw] plate # Setting this relationship alongside the `plate_uuid` attribute will override the attribute value. - # @return [PlateResource] The plate this tag layout applies to. + # @return [Api::V2::PlateResource] The plate this tag layout applies to. # @note This relationship is required. - has_one :plate, class_name: 'Plate' + has_one :plate # @!attribute [rw] tag_group # Setting this relationship alongside the `tag_group_uuid` attribute will override the attribute value. # A relationship for the primary tag group associated with the tag layout template. # @return [Api::V2::TagGroupResource] # @note This relationship is required. - has_one :tag_group, class_name: 'TagGroup' + has_one :tag_group # @!attribute [rw] tag2_group # Setting this relationship alongside the `tag2_group_uuid` attribute will override the attribute value. @@ -128,7 +128,7 @@ def user_uuid=(value) # @!attribute [rw] user # Setting this relationship alongside the `user_uuid` attribute will override the attribute value. - # @return [UserResource] The user who initiated this state change. + # @return [Api::V2::UserResource] The user who initiated this state change. # @note This relationship is required. has_one :user diff --git a/spec/resources/api/v2/tag_layout_resource_spec.rb b/spec/resources/api/v2/tag_layout_resource_spec.rb index 17940ccde0..2c46b31bef 100644 --- a/spec/resources/api/v2/tag_layout_resource_spec.rb +++ b/spec/resources/api/v2/tag_layout_resource_spec.rb @@ -4,23 +4,27 @@ require './app/resources/api/v2/tag_layout_resource' RSpec.describe Api::V2::TagLayoutResource, type: :resource do - # subject(:resource) { described_class.new(resource_model, {}) } + subject(:resource) { described_class.new(resource_model, {}) } - # let(:resource_model) { build_stubbed :state_change } + let(:resource_model) { build_stubbed :tag_layout } - # # Attributes - # it { is_expected.to have_readonly_attribute :uuid } - # it { is_expected.to have_readonly_attribute :previous_state } + # Attributes + it { is_expected.to have_readonly_attribute :uuid } - # it { is_expected.to have_readwrite_attribute :contents } - # it { is_expected.to have_readwrite_attribute :reason } - # it { is_expected.to have_readwrite_attribute :target_state } + it { is_expected.to have_readwrite_attribute :direction } + it { is_expected.to have_readwrite_attribute :initial_tag } + it { is_expected.to have_readwrite_attribute :substitutions } + it { is_expected.to have_readwrite_attribute :tags_per_well } + it { is_expected.to have_readwrite_attribute :walking_by } - # it { is_expected.to have_writeonly_attribute :user_uuid } - # it { is_expected.to have_writeonly_attribute :target_uuid } - # it { is_expected.to have_writeonly_attribute :customer_accepts_responsibility } + it { is_expected.to have_writeonly_attribute :plate_uuid } + it { is_expected.to have_writeonly_attribute :tag_group_uuid } + it { is_expected.to have_writeonly_attribute :tag2_group_uuid } + it { is_expected.to have_writeonly_attribute :user_uuid } - # # Relationships - # it { is_expected.to have_one(:target).with_class_name('Labware') } - # it { is_expected.to have_one(:user).with_class_name('User') } + # Relationships + it { is_expected.to have_one(:plate).with_class_name('Plate') } + it { is_expected.to have_one(:tag_group).with_class_name('TagGroup') } + it { is_expected.to have_one(:tag2_group).with_class_name('TagGroup') } + it { is_expected.to have_one(:user).with_class_name('User') } end From 1716200f6034f2db8080ee725a80d79453521ddd Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Mon, 9 Sep 2024 14:33:31 +0100 Subject: [PATCH 040/158] Add GET and PATCH request tests for TagLayoutResource --- spec/requests/api/v2/tag_layouts_spec.rb | 200 +++++++++++------------ 1 file changed, 98 insertions(+), 102 deletions(-) diff --git a/spec/requests/api/v2/tag_layouts_spec.rb b/spec/requests/api/v2/tag_layouts_spec.rb index 54bd4a70d6..10db078ca8 100644 --- a/spec/requests/api/v2/tag_layouts_spec.rb +++ b/spec/requests/api/v2/tag_layouts_spec.rb @@ -5,108 +5,104 @@ require './spec/requests/api/v2/shared_examples/post_requests' describe 'Tag Layouts API', with: :api_v2 do - # let(:model_class) { StateChange } - # let(:base_endpoint) { "/api/v2/#{resource_type}" } - # let(:resource_type) { model_class.name.demodulize.pluralize.underscore } - - # it_behaves_like 'ApiKeyAuthenticatable' - - # context 'with a list of resource' do - # let(:resource_count) { 5 } - - # before { create_list(:state_change, resource_count) } - - # describe '#GET all resources' do - # before { api_get base_endpoint } - - # it 'responds with a success http code' do - # expect(response).to have_http_status(:success) - # end - - # it 'returns all the resources' do - # expect(json['data'].length).to eq(resource_count) - # end - # end - # end - - # context 'with a single resource' do - # describe '#GET resource by ID' do - # let(:resource) { create :state_change } - - # context 'without included relationships' do - # before { api_get "#{base_endpoint}/#{resource.id}" } - - # it 'responds with a success http code' do - # expect(response).to have_http_status(:success) - # end - - # it 'returns the correct resource' do - # expect(json.dig('data', 'id')).to eq(resource.id.to_s) - # expect(json.dig('data', 'type')).to eq(resource_type) - # end - - # it 'returns the correct attributes' do - # expect(json.dig('data', 'attributes', 'contents')).to eq(resource.contents) - # expect(json.dig('data', 'attributes', 'previous_state')).to eq(resource.previous_state) - # expect(json.dig('data', 'attributes', 'reason')).to eq(resource.reason) - # expect(json.dig('data', 'attributes', 'target_state')).to eq(resource.target_state) - # expect(json.dig('data', 'attributes', 'uuid')).to eq(resource.uuid) - # end - - # it 'excludes unfetchable attributes' do - # expect(json.dig('data', 'attributes', 'customer_accepts_responsibility')).not_to be_present - # expect(json.dig('data', 'attributes', 'target_uuid')).not_to be_present - # expect(json.dig('data', 'attributes', 'user_uuid')).not_to be_present - # end - - # it 'returns references to related resources' do - # expect(json.dig('data', 'relationships', 'target')).to be_present - # expect(json.dig('data', 'relationships', 'user')).to be_present - # end - - # it 'does not include attributes for related resources' do - # expect(json['included']).not_to be_present - # end - # end - - # context 'with included relationships' do - # context 'with user' do - # let(:related_name) { 'user' } - # let(:related_type) { 'users' } - - # it_behaves_like 'a POST request including a has_one relationship' - # end - - # context 'with target' do - # let(:related_name) { 'target' } - # let(:related_type) { 'labware' } - - # it_behaves_like 'a POST request including a has_one relationship' - # end - # end - # end - # end - - # describe '#PATCH a resource' do - # let(:resource_model) { create :state_change } - # let(:payload) do - # { - # 'data' => { - # 'id' => resource_model.id, - # 'type' => resource_type, - # 'attributes' => { - # 'target_state' => 'passed' - # } - # } - # } - # end - - # it 'finds no route for the method' do - # expect { api_patch "#{base_endpoint}/#{resource_model.id}", payload }.to raise_error( - # ActionController::RoutingError - # ) - # end - # end + let(:model_class) { TagLayout } + let(:base_endpoint) { "/api/v2/#{resource_type}" } + let(:resource_type) { model_class.name.demodulize.pluralize.underscore } + + it_behaves_like 'ApiKeyAuthenticatable' + + context 'with a list of resources' do + let(:resource_count) { 5 } + + before { create_list(:tag_layout, resource_count) } + + describe '#GET all resources' do + before { api_get base_endpoint } + + it 'responds with a success http code' do + expect(response).to have_http_status(:success) + end + + it 'returns all the resources' do + expect(json['data'].length).to eq(resource_count) + end + end + end + + context 'with a single resource' do + describe '#GET resource by ID' do + let(:resource) { create :tag_layout } + + context 'without included relationships' do + before { api_get "#{base_endpoint}/#{resource.id}" } + + it 'responds with a success http code' do + expect(response).to have_http_status(:success) + end + + it 'returns the correct resource' do + expect(json.dig('data', 'id')).to eq(resource.id.to_s) + expect(json.dig('data', 'type')).to eq(resource_type) + end + + it 'returns the correct attributes' do + expect(json.dig('data', 'attributes', 'direction')).to eq(resource.direction) + expect(json.dig('data', 'attributes', 'initial_tag')).to eq(resource.initial_tag) + expect(json.dig('data', 'attributes', 'substitutions')).to eq(resource.substitutions) + expect(json.dig('data', 'attributes', 'tags_per_well')).to eq(resource.tags_per_well) + expect(json.dig('data', 'attributes', 'walking_by')).to eq(resource.walking_by) + expect(json.dig('data', 'attributes', 'uuid')).to eq(resource.uuid) + end + + it 'excludes unfetchable attributes' do + expect(json.dig('data', 'attributes', 'plate_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'tag_group_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'tag2_group_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'user_uuid')).not_to be_present + end + + it 'returns references to related resources' do + expect(json.dig('data', 'relationships', 'plate')).to be_present + expect(json.dig('data', 'relationships', 'tag_group')).to be_present + expect(json.dig('data', 'relationships', 'tag2_group')).to be_present + expect(json.dig('data', 'relationships', 'user')).to be_present + end + + it 'does not include attributes for related resources' do + expect(json['included']).not_to be_present + end + end + + context 'with included relationships' do + context 'with plate' do + let(:related_name) { 'plate' } + let(:related_type) { 'plates' } + + it_behaves_like 'a POST request including a has_one relationship' + end + + context 'with user' do + let(:related_name) { 'user' } + let(:related_type) { 'users' } + + it_behaves_like 'a POST request including a has_one relationship' + end + end + end + end + + describe '#PATCH a resource' do + let(:resource_model) { create :tag_layout } + let(:payload) do + { 'data' => { 'id' => resource_model.id, 'type' => resource_type, 'attributes' => { 'direction' => 'columns' } } } + end + + it 'finds no route for the method' do + expect { api_patch "#{base_endpoint}/#{resource_model.id}", payload }.to raise_error( + ActionController::RoutingError + ) + end + end # describe '#POST a create request' do # let(:user) { create(:user) } From 800059a52677b86b27e175ddd97ae006d2c56c60 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Mon, 9 Sep 2024 15:39:54 +0100 Subject: [PATCH 041/158] Add tests for valid POST requests on TransferResource --- app/resources/api/v2/tag_layout_resource.rb | 11 + spec/requests/api/v2/tag_layouts_spec.rb | 387 ++++++++------------ 2 files changed, 173 insertions(+), 225 deletions(-) diff --git a/app/resources/api/v2/tag_layout_resource.rb b/app/resources/api/v2/tag_layout_resource.rb index fe9b9a3718..90c6be2d08 100644 --- a/app/resources/api/v2/tag_layout_resource.rb +++ b/app/resources/api/v2/tag_layout_resource.rb @@ -48,6 +48,15 @@ def plate_uuid=(value) # @return [Hash] attribute :substitutions + def substitutions=(value) + @model.substitutions = + if value.is_a?(ActionController::Parameters) + value.to_unsafe_h # We must unwrap the parameters to a real Hash. + else + value + end + end + # @!attribute [w] tag_group_uuid # This is declared for convenience where the {TagGroup} is not available to set as a relationship. # Setting this attribute alongside the `tag_group` relationship will prefer the relationship value. @@ -76,6 +85,8 @@ def tag2_group_uuid=(value) # @!attribute [rw] tags_per_well # The number of tags in each well. + # This is only used and/or returned by specific tag layout {walking_by} algorithms. + # At other times, this value will be `nil`. # @return [Integer] attribute :tags_per_well diff --git a/spec/requests/api/v2/tag_layouts_spec.rb b/spec/requests/api/v2/tag_layouts_spec.rb index 10db078ca8..a5c1df02a3 100644 --- a/spec/requests/api/v2/tag_layouts_spec.rb +++ b/spec/requests/api/v2/tag_layouts_spec.rb @@ -93,9 +93,7 @@ describe '#PATCH a resource' do let(:resource_model) { create :tag_layout } - let(:payload) do - { 'data' => { 'id' => resource_model.id, 'type' => resource_type, 'attributes' => { 'direction' => 'columns' } } } - end + let(:payload) { { data: { id: resource_model.id, type: resource_type, attributes: { direction: 'columns' } } } } it 'finds no route for the method' do expect { api_patch "#{base_endpoint}/#{resource_model.id}", payload }.to raise_error( @@ -104,226 +102,165 @@ end end - # describe '#POST a create request' do - # let(:user) { create(:user) } - # let(:plate) { create(:plate) } - - # let(:base_attributes) do - # { - # 'contents' => %w[A1 D2], - # 'customer_accepts_responsibility' => true, - # 'reason' => 'The plate is now passed.', - # 'target_state' => 'passed' - # } - # end - - # let(:user_relationship) { { 'data' => { 'id' => user.id, 'type' => 'users' } } } - # let(:target_relationship) { { 'data' => { 'id' => plate.id, 'type' => 'labware' } } } - - # context 'with a valid payload' do - # shared_examples 'a valid request' do - # before { api_post base_endpoint, payload } - - # it 'creates a new resource' do - # expect { api_post base_endpoint, payload }.to change(model_class, :count).by(1) - # end - - # it 'responds with success' do - # expect(response).to have_http_status(:success) - # end - - # it 'responds with the correct attributes' do - # new_record = model_class.last - - # expect(json.dig('data', 'type')).to eq(resource_type) - # expect(json.dig('data', 'attributes', 'contents')).to eq(new_record.contents) - # expect(json.dig('data', 'attributes', 'reason')).to eq(new_record.reason) - # expect(json.dig('data', 'attributes', 'target_state')).to eq(new_record.target_state) - # end - - # it 'excludes unfetchable attributes' do - # expect(json.dig('data', 'attributes', 'customer_accepts_responsibility')).not_to be_present - # expect(json.dig('data', 'attributes', 'target_uuid')).not_to be_present - # expect(json.dig('data', 'attributes', 'user_uuid')).not_to be_present - # end - - # it 'returns references to related resources' do - # expect(json.dig('data', 'relationships', 'user')).to be_present - # expect(json.dig('data', 'relationships', 'target')).to be_present - # end - - # it 'applies the attributes to the new record' do - # new_record = model_class.last - - # expect(new_record.contents).to eq(payload.dig('data', 'attributes', 'contents')) - # expect(new_record.reason).to eq(payload.dig('data', 'attributes', 'reason')) - # expect(new_record.target_state).to eq(payload.dig('data', 'attributes', 'target_state')) - # end - - # it 'applies the relationships to the new record' do - # new_record = model_class.last - - # expect(new_record.user).to eq(user) - # expect(new_record.target).to eq(plate) - # end - # end - - # context 'with complete attributes' do - # let(:payload) do - # { - # 'data' => { - # 'type' => resource_type, - # 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid, 'target_uuid' => plate.uuid }) - # } - # } - # end - - # it_behaves_like 'a valid request' - # end - - # context 'with relationships' do - # let(:payload) do - # { - # 'data' => { - # 'type' => resource_type, - # 'attributes' => base_attributes, - # 'relationships' => { - # 'user' => user_relationship, - # 'target' => target_relationship - # } - # } - # } - # end - - # it_behaves_like 'a valid request' - # end - - # context 'with conflicting relationships' do - # let(:other_user) { create(:user) } - # let(:other_plate) { create(:plate) } - # let(:payload) do - # { - # 'data' => { - # 'type' => resource_type, - # 'attributes' => - # base_attributes.merge({ 'user_uuid' => other_user.uuid, 'target_uuid' => other_plate.uuid }), - # 'relationships' => { - # 'user' => user_relationship, - # 'target' => target_relationship - # } - # } - # } - # end - - # # This test should pass because the relationships are preferred over the attributes. - # it_behaves_like 'a valid request' - # end - # end - - # context 'with a read-only attribute in the payload' do - # context 'with previous_state' do - # let(:disallowed_attribute) { 'previous_state' } - # let(:payload) do - # { - # 'data' => { - # 'type' => resource_type, - # 'attributes' => base_attributes.merge({ 'previous_state' => 'waiting' }) - # } - # } - # end - - # it_behaves_like 'a POST request with a disallowed attribute' - # end - - # context 'with uuid' do - # let(:disallowed_attribute) { 'uuid' } - # let(:payload) do - # { - # 'data' => { - # 'type' => resource_type, - # 'attributes' => base_attributes.merge({ 'uuid' => '111111-2222-3333-4444-555555666666' }) - # } - # } - # end - - # it_behaves_like 'a POST request with a disallowed attribute' - # end - # end - - # context 'without a required attribute' do - # context 'without target_state' do - # let(:error_detail_message) { "target_state - can't be blank" } - # let(:payload) do - # { - # 'data' => { - # 'type' => resource_type, - # 'attributes' => - # base_attributes.merge({ 'target_state' => nil, 'user_uuid' => user.uuid, 'target_uuid' => plate.uuid }) - # } - # } - # end - - # it_behaves_like 'a POST request with a missing attribute' - # end - # end - - # context 'without a required relationship' do - # context 'without user_uuid' do - # let(:error_detail_message) { 'user - must exist' } - # let(:payload) do - # { - # 'data' => { - # 'type' => resource_type, - # 'attributes' => base_attributes.merge({ 'target_uuid' => plate.uuid }) - # } - # } - # end - - # it_behaves_like 'a POST request without a required relationship' - # end - - # context 'without target_uuid' do - # let(:error_detail_message) { 'target - must exist' } - # let(:payload) do - # { 'data' => { 'type' => resource_type, 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid }) } } - # end - - # it_behaves_like 'a POST request without a required relationship' - # end - - # context 'without user' do - # let(:error_detail_message) { 'user - must exist' } - # let(:payload) do - # { - # 'data' => { - # 'type' => resource_type, - # 'attributes' => base_attributes, - # 'relationships' => { - # 'target' => target_relationship - # } - # } - # } - # end - - # it_behaves_like 'a POST request without a required relationship' - # end - - # context 'without target' do - # let(:error_detail_message) { 'target - must exist' } - # let(:payload) do - # { - # 'data' => { - # 'type' => resource_type, - # 'attributes' => base_attributes, - # 'relationships' => { - # 'user' => user_relationship - # } - # } - # } - # end - - # it_behaves_like 'a POST request without a required relationship' - # end - # end - # end + describe '#POST a create request' do + let(:plate) { create(:plate) } + let(:tag_group) { create(:tag_group) } + let(:tag2_group) { create(:tag_group) } + let(:user) { create(:user) } + + let(:base_attributes) do + { + direction: 'column', + initial_tag: 0, + substitutions: { + 'A1' => 'B2' + }, + tags_per_well: 1, # Ignored by the walking_by algorithm below + walking_by: 'wells of plate' + } + end + + let(:plate_relationship) { { data: { id: plate.id, type: 'plates' } } } + let(:tag_group_relationship) { { data: { id: tag_group.id, type: 'tag_groups' } } } + let(:tag2_group_relationship) { { data: { id: tag2_group.id, type: 'tag_groups' } } } + let(:user_relationship) { { data: { id: user.id, type: 'users' } } } + + context 'with a valid payload' do + shared_examples 'a valid request' do + before { api_post base_endpoint, payload } + + it 'creates a new resource' do + expect { api_post base_endpoint, payload }.to change(model_class, :count).by(1) + end + + it 'responds with success' do + expect(response).to have_http_status(:success) + end + + it 'responds with the correct attributes' do + new_record = model_class.last + + expect(json.dig('data', 'type')).to eq(resource_type) + expect(json.dig('data', 'attributes', 'direction')).to eq(new_record.direction) + expect(json.dig('data', 'attributes', 'initial_tag')).to eq(new_record.initial_tag) + expect(json.dig('data', 'attributes', 'substitutions')).to eq(new_record.substitutions) + expect(json.dig('data', 'attributes', 'walking_by')).to eq(new_record.walking_by) + expect(json.dig('data', 'attributes', 'uuid')).to eq(new_record.uuid) + + # Note that the tags per well will not be saved with the record as it isn't a stored attribute in the + # database. The response is based on the model after being saved, which still holds the value given in the + # payload. + expect(json.dig('data', 'attributes', 'tags_per_well')).to eq(payload.dig(:data, :attributes, :tags_per_well)) + end + + it 'excludes unfetchable attributes' do + expect(json.dig('data', 'attributes', 'plate_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'tag_group_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'tag2_group_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'user_uuid')).not_to be_present + end + + it 'returns references to related resources' do + expect(json.dig('data', 'relationships', 'plate')).to be_present + expect(json.dig('data', 'relationships', 'tag_group')).to be_present + expect(json.dig('data', 'relationships', 'tag2_group')).to be_present + expect(json.dig('data', 'relationships', 'user')).to be_present + end + + it 'applies the attributes to the new record' do + new_record = model_class.last + + expect(new_record.direction).to eq(payload.dig(:data, :attributes, :direction)) + expect(new_record.initial_tag).to eq(payload.dig(:data, :attributes, :initial_tag)) + expect(new_record.substitutions).to eq(payload.dig(:data, :attributes, :substitutions)) + expect(new_record.walking_by).to eq(payload.dig(:data, :attributes, :walking_by)) + + # Note that the tags_per_well from the quieried record will be nil as it isn't a stored attribute in the + # database. + expect(new_record.tags_per_well).to be_nil + end + + it 'applies the relationships to the new record' do + new_record = model_class.last + + expect(new_record.plate).to eq(plate) + expect(new_record.tag_group).to eq(tag_group) + expect(new_record.tag2_group).to eq(tag2_group) + expect(new_record.user).to eq(user) + end + end + + context 'with complete attributes' do + let(:payload) do + { + data: { + type: resource_type, + attributes: + base_attributes.merge( + { + plate_uuid: plate.uuid, + tag_group_uuid: tag_group.uuid, + tag2_group_uuid: tag2_group.uuid, + user_uuid: user.uuid + } + ) + } + } + end + + it_behaves_like 'a valid request' + end + + context 'with relationships' do + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes, + relationships: { + plate: plate_relationship, + tag_group: tag_group_relationship, + tag2_group: tag2_group_relationship, + user: user_relationship + } + } + } + end + + it_behaves_like 'a valid request' + end + + context 'with conflicting relationships' do + let(:other_plate) { create(:plate) } + let(:other_tag_group) { create(:tag_group) } + let(:other_tag2_group) { create(:tag_group) } + let(:other_user) { create(:user) } + let(:payload) do + { + data: { + type: resource_type, + attributes: + base_attributes.merge( + { + plate_uuid: other_plate.uuid, + tag_group_uuid: other_tag_group.uuid, + tag2_group_uuid: other_tag2_group.uuid, + user_uuid: other_user.uuid + } + ), + relationships: { + plate: plate_relationship, + tag_group: tag_group_relationship, + tag2_group: tag2_group_relationship, + user: user_relationship + } + } + } + end + + # This test should pass because the relationships are preferred over the attributes. + it_behaves_like 'a valid request' + end + end + end end From b22ee77d4108173e3d5bbdc25d386ae7b26f0d64 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Mon, 9 Sep 2024 16:14:34 +0100 Subject: [PATCH 042/158] Implement all remaining tests The ones about missing attributes are currently failing --- spec/requests/api/v2/tag_layouts_spec.rb | 150 +++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/spec/requests/api/v2/tag_layouts_spec.rb b/spec/requests/api/v2/tag_layouts_spec.rb index a5c1df02a3..195341a3cd 100644 --- a/spec/requests/api/v2/tag_layouts_spec.rb +++ b/spec/requests/api/v2/tag_layouts_spec.rb @@ -262,5 +262,155 @@ it_behaves_like 'a valid request' end end + + context 'with a read-only attribute in the payload' do + context 'with uuid' do + let(:disallowed_attribute) { 'uuid' } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes.merge({ uuid: '111111-2222-3333-4444-555555666666' }) + } + } + end + + it_behaves_like 'a POST request with a disallowed attribute' + end + end + + context 'without a required attribute' do + context 'without direction' do + let(:error_detail_message) { "direction - can't be blank" } + let(:payload) do + { + data: { + type: resource_type, + attributes: + base_attributes.merge( + { direction: nil, plate_uuid: plate.uuid, tag_group_uuid: tag_group.uuid, user_uuid: user.uuid } + ) + } + } + end + + it_behaves_like 'a POST request with a missing attribute' + end + + context 'without walking_by' do + let(:error_detail_message) { "walking_by - can't be blank" } + let(:payload) do + { + data: { + type: resource_type, + attributes: + base_attributes.merge( + { walking_by: nil, plate_uuid: plate.uuid, tag_group_uuid: tag_group.uuid, user_uuid: user.uuid } + ) + } + } + end + + it_behaves_like 'a POST request with a missing attribute' + end + end + + context 'without a required relationship' do + context 'without plate_uuid' do + let(:error_detail_message) { 'plate - must exist' } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes.merge({ tag_group_uuid: tag_group.uuid, user_uuid: user.uuid }) + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end + + context 'without tag_group_uuid' do + let(:error_detail_message) { 'tag_group - must exist' } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes.merge({ plate_uuid: plate.uuid, user_uuid: user.uuid }) + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end + + context 'without user_uuid' do + let(:error_detail_message) { 'user - must exist' } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes.merge({ plate_uuid: plate.uuid, tag_group_uuid: tag_group.uuid }) + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end + + context 'without plate' do + let(:error_detail_message) { 'plate - must exist' } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes, + relationships: { + tag_group: tag_group_relationship, + user: user_relationship + } + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end + + context 'without tag_group' do + let(:error_detail_message) { 'tag_group - must exist' } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes, + relationships: { + plate: plate_relationship, + user: user_relationship + } + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end + + context 'without user' do + let(:error_detail_message) { 'user - must exist' } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes, + relationships: { + plate: plate_relationship, + tag_group: tag_group_relationship + } + } + } + end + + it_behaves_like 'a POST request without a required relationship' + end + end end end From f05aa28ae984f2aacf5a246d1f3352bc17166f3b Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Tue, 10 Sep 2024 15:51:57 +0100 Subject: [PATCH 043/158] Combine two identical shared examples --- .../api/v2/bait_library_layouts_spec.rb | 8 ++++---- .../api/v2/shared_examples/post_requests.rb | 18 +---------------- spec/requests/api/v2/state_changes_spec.rb | 10 +++++----- spec/requests/api/v2/tag_layouts_spec.rb | 20 +++++++++---------- .../api/v2/transfers/transfers_spec.rb | 6 +++--- 5 files changed, 23 insertions(+), 39 deletions(-) diff --git a/spec/requests/api/v2/bait_library_layouts_spec.rb b/spec/requests/api/v2/bait_library_layouts_spec.rb index 693b2dc724..b38b68eb4f 100644 --- a/spec/requests/api/v2/bait_library_layouts_spec.rb +++ b/spec/requests/api/v2/bait_library_layouts_spec.rb @@ -240,7 +240,7 @@ def perform_post } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without plate_uuid' do @@ -254,7 +254,7 @@ def perform_post } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without user' do @@ -271,7 +271,7 @@ def perform_post } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without plate' do @@ -288,7 +288,7 @@ def perform_post } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end end end diff --git a/spec/requests/api/v2/shared_examples/post_requests.rb b/spec/requests/api/v2/shared_examples/post_requests.rb index a40d2c1286..af78bb3ba8 100644 --- a/spec/requests/api/v2/shared_examples/post_requests.rb +++ b/spec/requests/api/v2/shared_examples/post_requests.rb @@ -18,23 +18,7 @@ end end -shared_examples 'a POST request with a missing attribute' do - before { api_post base_endpoint, payload } - - it 'does not create a new resource' do - expect { api_post base_endpoint, payload }.not_to change(model_class, :count) - end - - it 'responds with unprocessable_entity' do - expect(response).to have_http_status(:unprocessable_entity) - end - - it 'gives the expected error message detail' do - expect(json.dig('errors', 0, 'detail')).to eq(error_detail_message) - end -end - -shared_examples 'a POST request without a required relationship' do +shared_examples 'an unprocessable POST request with a specific error' do before { api_post base_endpoint, payload } it 'does not create a new resource' do diff --git a/spec/requests/api/v2/state_changes_spec.rb b/spec/requests/api/v2/state_changes_spec.rb index a3f63461eb..5e6dab6a46 100644 --- a/spec/requests/api/v2/state_changes_spec.rb +++ b/spec/requests/api/v2/state_changes_spec.rb @@ -267,7 +267,7 @@ } end - it_behaves_like 'a POST request with a missing attribute' + it_behaves_like 'an unprocessable POST request with a specific error' end end @@ -283,7 +283,7 @@ } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without target_uuid' do @@ -292,7 +292,7 @@ { 'data' => { 'type' => resource_type, 'attributes' => base_attributes.merge({ 'user_uuid' => user.uuid }) } } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without user' do @@ -309,7 +309,7 @@ } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without target' do @@ -326,7 +326,7 @@ } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end end end diff --git a/spec/requests/api/v2/tag_layouts_spec.rb b/spec/requests/api/v2/tag_layouts_spec.rb index 195341a3cd..44662df318 100644 --- a/spec/requests/api/v2/tag_layouts_spec.rb +++ b/spec/requests/api/v2/tag_layouts_spec.rb @@ -281,7 +281,7 @@ context 'without a required attribute' do context 'without direction' do - let(:error_detail_message) { "direction - can't be blank" } + let(:error_detail_message) { 'direction - must define a valid algorithm' } let(:payload) do { data: { @@ -294,11 +294,11 @@ } end - it_behaves_like 'a POST request with a missing attribute' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without walking_by' do - let(:error_detail_message) { "walking_by - can't be blank" } + let(:error_detail_message) { 'walking_by - must define a valid algorithm' } let(:payload) do { data: { @@ -311,7 +311,7 @@ } end - it_behaves_like 'a POST request with a missing attribute' + it_behaves_like 'an unprocessable POST request with a specific error' end end @@ -327,7 +327,7 @@ } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without tag_group_uuid' do @@ -341,7 +341,7 @@ } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without user_uuid' do @@ -355,7 +355,7 @@ } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without plate' do @@ -373,7 +373,7 @@ } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without tag_group' do @@ -391,7 +391,7 @@ } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without user' do @@ -409,7 +409,7 @@ } end - it_behaves_like 'a POST request without a required relationship' + it_behaves_like 'an unprocessable POST request with a specific error' end end end diff --git a/spec/requests/api/v2/transfers/transfers_spec.rb b/spec/requests/api/v2/transfers/transfers_spec.rb index dd34758aba..8d27d7f018 100644 --- a/spec/requests/api/v2/transfers/transfers_spec.rb +++ b/spec/requests/api/v2/transfers/transfers_spec.rb @@ -167,21 +167,21 @@ let(:attribute_to_remove) { 'user_uuid' } let(:error_detail_message) { "user - can't be blank" } - it_behaves_like 'a POST request with a missing attribute' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without source_uuid' do let(:attribute_to_remove) { 'source_uuid' } let(:error_detail_message) { "source - can't be blank" } - it_behaves_like 'a POST request with a missing attribute' + it_behaves_like 'an unprocessable POST request with a specific error' end context 'without destination_uuid' do let(:attribute_to_remove) { 'destination_uuid' } let(:error_detail_message) { "destination - can't be blank" } - it_behaves_like 'a POST request with a missing attribute' + it_behaves_like 'an unprocessable POST request with a specific error' end end From bd21429a822a68bb4c05faa11a1f6f32a962e296 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Tue, 10 Sep 2024 15:52:41 +0100 Subject: [PATCH 044/158] Try to better handle missing or invalid algorithms direction and walking_by on TagLayout --- app/models/tag_layout.rb | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/models/tag_layout.rb b/app/models/tag_layout.rb index f4976bad9f..d51f979a1f 100644 --- a/app/models/tag_layout.rb +++ b/app/models/tag_layout.rb @@ -12,9 +12,6 @@ class TagLayout < ApplicationRecord attr_accessor :tags_per_well - UnknownDirection = Struct.new(:direction) - UnknownWalking = Struct.new(:walking_by) - DIRECTION_ALGORITHMS = { 'column' => 'TagLayout::InColumns', 'row' => 'TagLayout::InRows', @@ -36,6 +33,19 @@ class TagLayout < ApplicationRecord 'combinatorial sequential' => 'TagLayout::CombinatorialSequential' }.freeze + module TagLayout::DummyDirectionModule + def self.direction + end + end + + class TagLayout::DummyWalkingHelper + def initialize(_layout) + end + + def walking_by + end + end + self.inheritance_column = 'sti_type' serialize :substitutions, Hash @@ -50,11 +60,8 @@ class TagLayout < ApplicationRecord # The plate we'll be laying out the tags into belongs_to :plate, optional: false - validates :direction, inclusion: { in: DIRECTION_ALGORITHMS.keys } - validates :walking_by, inclusion: { in: WALKING_ALGORITHMS.keys } - - validates :direction_algorithm, presence: true - validates :walking_algorithm, presence: true + validates_presence_of :direction, message: 'must define a valid algorithm' + validates_presence_of :walking_by, message: 'must define a valid algorithm' # After creating the instance we can layout the tags into the wells. after_create :layout_tags_into_wells, if: :valid? @@ -65,11 +72,11 @@ class TagLayout < ApplicationRecord delegate :walking_by, :walk_wells, :apply_tags, to: :walking_algorithm_helper def direction=(new_direction) - self.direction_algorithm = DIRECTION_ALGORITHMS.fetch(new_direction) { UnknownDirection.new(new_direction) } + self.direction_algorithm = DIRECTION_ALGORITHMS.fetch(new_direction, TagLayout::DummyDirectionModule) end def walking_by=(walk) - self.walking_algorithm = WALKING_ALGORITHMS.fetch(walk) { UnknownWalking.new(walk) } + self.walking_algorithm = WALKING_ALGORITHMS.fetch(walk, TagLayout::DummyWalkingHelper) end def wells_in_walking_order From f79b3fe89e73a46728c9133479739aee6445c3c4 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Tue, 10 Sep 2024 16:10:14 +0100 Subject: [PATCH 045/158] Add tests for invalid values in direction and walking_by --- spec/requests/api/v2/tag_layouts_spec.rb | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/spec/requests/api/v2/tag_layouts_spec.rb b/spec/requests/api/v2/tag_layouts_spec.rb index 44662df318..0f0ca2b3fa 100644 --- a/spec/requests/api/v2/tag_layouts_spec.rb +++ b/spec/requests/api/v2/tag_layouts_spec.rb @@ -315,6 +315,42 @@ end end + context 'with an invalid attribute value' do + context 'invalid direction' do + let(:error_detail_message) { 'direction - must define a valid algorithm' } + let(:payload) do + { + data: { + type: resource_type, + attributes: + base_attributes.merge( + { direction: '1', plate_uuid: plate.uuid, tag_group_uuid: tag_group.uuid, user_uuid: user.uuid } + ) + } + } + end + + it_behaves_like 'an unprocessable POST request with a specific error' + end + + context 'invalid walking_by' do + let(:error_detail_message) { 'walking_by - must define a valid algorithm' } + let(:payload) do + { + data: { + type: resource_type, + attributes: + base_attributes.merge( + { walking_by: '1', plate_uuid: plate.uuid, tag_group_uuid: tag_group.uuid, user_uuid: user.uuid } + ) + } + } + end + + it_behaves_like 'an unprocessable POST request with a specific error' + end + end + context 'without a required relationship' do context 'without plate_uuid' do let(:error_detail_message) { 'plate - must exist' } From 09f2b392cb932d8d0532b8fc32222aba78566514 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Tue, 10 Sep 2024 16:29:37 +0100 Subject: [PATCH 046/158] Apply Rubocop rules --- app/models/tag_layout.rb | 6 +++--- spec/requests/api/v2/tag_layouts_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/tag_layout.rb b/app/models/tag_layout.rb index d51f979a1f..55bf3c9228 100644 --- a/app/models/tag_layout.rb +++ b/app/models/tag_layout.rb @@ -39,7 +39,7 @@ def self.direction end class TagLayout::DummyWalkingHelper - def initialize(_layout) + def initialize(*) end def walking_by @@ -60,8 +60,8 @@ def walking_by # The plate we'll be laying out the tags into belongs_to :plate, optional: false - validates_presence_of :direction, message: 'must define a valid algorithm' - validates_presence_of :walking_by, message: 'must define a valid algorithm' + validates :direction, presence: { message: 'must define a valid algorithm' } + validates :walking_by, presence: { message: 'must define a valid algorithm' } # After creating the instance we can layout the tags into the wells. after_create :layout_tags_into_wells, if: :valid? diff --git a/spec/requests/api/v2/tag_layouts_spec.rb b/spec/requests/api/v2/tag_layouts_spec.rb index 0f0ca2b3fa..98dfcb6545 100644 --- a/spec/requests/api/v2/tag_layouts_spec.rb +++ b/spec/requests/api/v2/tag_layouts_spec.rb @@ -316,7 +316,7 @@ end context 'with an invalid attribute value' do - context 'invalid direction' do + context 'with an invalid direction' do let(:error_detail_message) { 'direction - must define a valid algorithm' } let(:payload) do { @@ -333,7 +333,7 @@ it_behaves_like 'an unprocessable POST request with a specific error' end - context 'invalid walking_by' do + context 'with an invalid walking_by' do let(:error_detail_message) { 'walking_by - must define a valid algorithm' } let(:payload) do { From 066423609534cc49daf13c349957604fa98f0e8a Mon Sep 17 00:00:00 2001 From: yoldas Date: Wed, 11 Sep 2024 12:53:14 +0100 Subject: [PATCH 047/158] Rename product catalogue name to LCM Triomics --- .../product_catalogues/013_lcm_triomics_catalogue.wip.yml | 2 +- .../014_lcm_triomics_submission_templates.wip.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml b/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml index 4bf791e027..6a36dcf6e5 100644 --- a/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml +++ b/config/default_records/product_catalogues/013_lcm_triomics_catalogue.wip.yml @@ -1,3 +1,3 @@ --- -LCM Triomics WGS and EMSeq: +LCM Triomics: selection_behaviour: SingleProduct diff --git a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml index a10355f5ef..e6b178b444 100644 --- a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml +++ b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml @@ -6,4 +6,4 @@ Limber-Htp - LCM Triomics EMSeq: related_records: request_type_keys: ["limber_lcm_triomics_emseq"] product_line_name: LCM Triomics WGS and EMSeq - product_catalogue_name: LCM Triomics WGS and EMSeq + product_catalogue_name: LCM Triomics From 039c640ac4f47770d0aebbf344fb5726f1acf488 Mon Sep 17 00:00:00 2001 From: yoldas Date: Wed, 11 Sep 2024 13:07:03 +0100 Subject: [PATCH 048/158] Rename product line to LCM Triomics --- .../014_lcm_triomics_submission_templates.wip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml index e6b178b444..e1eece756c 100644 --- a/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml +++ b/config/default_records/submission_templates/014_lcm_triomics_submission_templates.wip.yml @@ -5,5 +5,5 @@ Limber-Htp - LCM Triomics EMSeq: submission_class_name: "LinearSubmission" related_records: request_type_keys: ["limber_lcm_triomics_emseq"] - product_line_name: LCM Triomics WGS and EMSeq + product_line_name: LCM Triomics product_catalogue_name: LCM Triomics From 4da0b16674d79857c4909da21d5fb3fbde6fc010 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 12 Sep 2024 17:39:26 +0100 Subject: [PATCH 049/158] Create an endpoint for SpecificTubeCreations --- .../v2/specific_tube_creations_controller.rb | 12 +++ .../api/v2/specific_tube_creation.rb | 96 +++++++++++++++++++ config/routes.rb | 1 + 3 files changed, 109 insertions(+) create mode 100644 app/controllers/api/v2/specific_tube_creations_controller.rb create mode 100644 app/resources/api/v2/specific_tube_creation.rb diff --git a/app/controllers/api/v2/specific_tube_creations_controller.rb b/app/controllers/api/v2/specific_tube_creations_controller.rb new file mode 100644 index 0000000000..0b3d3ec94e --- /dev/null +++ b/app/controllers/api/v2/specific_tube_creations_controller.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Api + module V2 + # Provides a JSON API controller for Specific Tube Creations + # See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation + class SpecificTubeCreationsController < JSONAPI::ResourceController + # By default JSONAPI::ResourceController provides most the standard + # behaviour, and in many cases this file may be left empty. + end + end +end diff --git a/app/resources/api/v2/specific_tube_creation.rb b/app/resources/api/v2/specific_tube_creation.rb new file mode 100644 index 0000000000..945e148326 --- /dev/null +++ b/app/resources/api/v2/specific_tube_creation.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: true + +module Api + module V2 + # @todo This documentation does not yet include a detailed description of what this resource represents. + # @todo This documentation does not yet include detailed descriptions for relationships, attributes and filters. + # @todo This documentation does not yet include any example usage of the API via cURL or similar. + # + # @note This resource cannot be modified after creation: its endpoint will not accept `PATCH` requests. + # @note Access this resource via the `/api/v2/specific_tube_creations/` endpoint. + # + # Provides a JSON:API representation of {SpecificTubeCreation}. + # + # For more information about JSON:API see the [JSON:API Specifications](https://jsonapi.org/format/) + # or look at the [JSONAPI::Resources](http://jsonapi-resources.com/) package for Sequencescape's implementation + # of the JSON:API standard. + class SpecificTubeCreationResource < BaseResource + ### + # Attributes + ### + + # @!attribute [w] child_purpose_uuids + # @param value [Array] Array of UUIDs for child purposes to use in the creation of tubes. + # @return [Void] + attribute :child_purpose_uuids + + def child_purpose_uuids=(value) + @model.set_child_purposes(value) + end + + # @!attribute [w] parent_uuid + # This is declared for convenience where the parent is not available to set as a relationship. + # Setting this attribute alongside the `parent` relationship will prefer the relationship value. + # @param value [String] The UUID of a single parent plate that will be the parent for all tubes created. + # @return [Void] + # @see #parent + attribute :parent_uuid + + def parent_uuid=(value) + @model.parent = Plate.with_uuid(value).first + end + + # @!attribute [w] tube_attributes + # @param value [Array] Hashes defining the attributes to apply to each tube being created. + # @return [Void] + attribute :tube_attributes + + # @!attribute [w] user_uuid + # This is declared for convenience where the user is not available to set as a relationship. + # Setting this attribute alongside the `user` relationship will prefer the relationship value. + # @param value [String] The UUID of the user who initiated the creation of tubes. + # @return [Void] + # @see #user + attribute :user_uuid + + def user_uuid=(value) + @model.user = User.with_uuid(value).first + end + + # @!attribute [r] uuid + # @return [String] The UUID of the state change. + attribute :uuid, readonly: true + + ### + # Relationships + ### + + # @!attribute [rw] user + # Setting this relationship alongside the `user_uuid` attribute will override the attribute value. + # @return [UserResource] The user who initiated the creation of tubes. + # @note This relationship is required. + has_one :user + + # @!attribute [rw] parents + # Setting this relationship alongside the `parent_uuid` attribute will override the attribute value. + # @return [Array] An array of the parents of the tubes being created. + # @note This relationship is required. + has_many :parents, class_name: 'Asset' + + # @!attribute [r] children + # @return [Array] An array of tubes that were created. + has_many :children, class_name: 'Tube' + + def self.creatable_fields(context) + # UUID is set by the system. + super - %i[uuid] + end + + def fetchable_fields + # The tube_attributes attribute is only available during resource creation. + # UUIDs for relationships are not fetchable. They should be accessed via the relationship itself. + super - %i[child_purpose_uuids parent_uuid tube_attributes user_uuid] + end + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 62092406f7..0ffc38d605 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -48,6 +48,7 @@ jsonapi_resources :samples jsonapi_resources :sample_manifests jsonapi_resources :sample_metadata + jsonapi_resources :specific_tube_creations, except: %i[update] jsonapi_resources :state_changes, except: %i[update] jsonapi_resources :studies jsonapi_resources :submission_templates From 37bc09fd41825bd70a62b54532e16a4e90c0ca6a Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 12 Sep 2024 17:41:26 +0100 Subject: [PATCH 050/158] Add better documentation for tube_attributes --- app/resources/api/v2/specific_tube_creation.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/resources/api/v2/specific_tube_creation.rb b/app/resources/api/v2/specific_tube_creation.rb index 945e148326..80236ff67f 100644 --- a/app/resources/api/v2/specific_tube_creation.rb +++ b/app/resources/api/v2/specific_tube_creation.rb @@ -42,6 +42,9 @@ def parent_uuid=(value) # @!attribute [w] tube_attributes # @param value [Array] Hashes defining the attributes to apply to each tube being created. + # This might be used to set custom attributes on the tubes, such as name. + # @example Setting the name of the tubes being created. + # [{ name: 'Tube one' }, { name: 'Tube two' }] # @return [Void] attribute :tube_attributes From 0b8a0a533586b130efe5b630949faaf391718355 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 12 Sep 2024 17:53:51 +0100 Subject: [PATCH 051/158] Fix plate_uuid attribute name in documentation --- app/resources/api/v2/tag_layout_resource.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/resources/api/v2/tag_layout_resource.rb b/app/resources/api/v2/tag_layout_resource.rb index 90c6be2d08..edbf0661a8 100644 --- a/app/resources/api/v2/tag_layout_resource.rb +++ b/app/resources/api/v2/tag_layout_resource.rb @@ -30,7 +30,7 @@ class TagLayoutResource < BaseResource # @return [Integer] attribute :initial_tag - # @!attribute [w] target_uuid + # @!attribute [w] plate_uuid # This is declared for convenience where the {Plate} is not available to set as a relationship. # Setting this attribute alongside the `plate` relationship will prefer the relationship value. # @deprecated Use the `plate` relationship instead. From 40b9a9bce0d643576d6c83eedf415b3de903857f Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 12 Sep 2024 18:00:36 +0100 Subject: [PATCH 052/158] Fix naming of the resource class --- ...ecific_tube_creation.rb => specific_tube_creation_resource.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/resources/api/v2/{specific_tube_creation.rb => specific_tube_creation_resource.rb} (100%) diff --git a/app/resources/api/v2/specific_tube_creation.rb b/app/resources/api/v2/specific_tube_creation_resource.rb similarity index 100% rename from app/resources/api/v2/specific_tube_creation.rb rename to app/resources/api/v2/specific_tube_creation_resource.rb From 605f4274dd5532e8df34ac5f37efd1570869b678 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 13 Sep 2024 11:34:40 +0100 Subject: [PATCH 053/158] Fix attributes that are not working during creation --- .../api/v2/specific_tube_creation_resource.rb | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/app/resources/api/v2/specific_tube_creation_resource.rb b/app/resources/api/v2/specific_tube_creation_resource.rb index 80236ff67f..e78c9003c7 100644 --- a/app/resources/api/v2/specific_tube_creation_resource.rb +++ b/app/resources/api/v2/specific_tube_creation_resource.rb @@ -20,24 +20,24 @@ class SpecificTubeCreationResource < BaseResource ### # @!attribute [w] child_purpose_uuids - # @param value [Array] Array of UUIDs for child purposes to use in the creation of tubes. + # @param value [Array] Array of UUIDs for child purposes to use in the creation of tubes. # @return [Void] attribute :child_purpose_uuids def child_purpose_uuids=(value) - @model.set_child_purposes(value) + @model.child_purposes = value.map { |uuid| Purpose.with_uuid(uuid).first } end - # @!attribute [w] parent_uuid + # @!attribute [w] parent_uuids # This is declared for convenience where the parent is not available to set as a relationship. - # Setting this attribute alongside the `parent` relationship will prefer the relationship value. - # @param value [String] The UUID of a single parent plate that will be the parent for all tubes created. + # Setting this attribute alongside the `parents` relationship will prefer the relationship value. + # @param value [Array] The UUIDs of labware that will be the parents for all tubes created. # @return [Void] - # @see #parent - attribute :parent_uuid + # @see #parents + attribute :parent_uuids - def parent_uuid=(value) - @model.parent = Plate.with_uuid(value).first + def parent_uuids=(value) + @model.parents = value.map { |uuid| Labware.with_uuid(uuid).first } end # @!attribute [w] tube_attributes @@ -48,6 +48,11 @@ def parent_uuid=(value) # @return [Void] attribute :tube_attributes + def tube_attributes=(value) + # Convert ActionController::Parameters into hashes. + @model.tube_attributes = value.map(&:to_unsafe_h) + end + # @!attribute [w] user_uuid # This is declared for convenience where the user is not available to set as a relationship. # Setting this attribute alongside the `user` relationship will prefer the relationship value. @@ -68,21 +73,21 @@ def user_uuid=(value) # Relationships ### - # @!attribute [rw] user - # Setting this relationship alongside the `user_uuid` attribute will override the attribute value. - # @return [UserResource] The user who initiated the creation of tubes. - # @note This relationship is required. - has_one :user + # @!attribute [r] children + # @return [Array] An array of tubes that were created. + has_many :children, class_name: 'Tube' # @!attribute [rw] parents - # Setting this relationship alongside the `parent_uuid` attribute will override the attribute value. + # Setting this relationship alongside the `parent_uuids` attribute will override the attribute value. # @return [Array] An array of the parents of the tubes being created. # @note This relationship is required. has_many :parents, class_name: 'Asset' - # @!attribute [r] children - # @return [Array] An array of tubes that were created. - has_many :children, class_name: 'Tube' + # @!attribute [rw] user + # Setting this relationship alongside the `user_uuid` attribute will override the attribute value. + # @return [UserResource] The user who initiated the creation of tubes. + # @note This relationship is required. + has_one :user def self.creatable_fields(context) # UUID is set by the system. @@ -92,7 +97,7 @@ def self.creatable_fields(context) def fetchable_fields # The tube_attributes attribute is only available during resource creation. # UUIDs for relationships are not fetchable. They should be accessed via the relationship itself. - super - %i[child_purpose_uuids parent_uuid tube_attributes user_uuid] + super - %i[child_purpose_uuids parent_uuids tube_attributes user_uuid] end end end From 3cb15b62f1d236f580c98dcf6a318275aaab05ce Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 13 Sep 2024 15:35:31 +0100 Subject: [PATCH 054/158] Simplify shared example for included has_one relationships --- spec/requests/api/v2/bait_library_layouts_spec.rb | 2 -- spec/requests/api/v2/shared_examples/post_requests.rb | 6 +++--- spec/requests/api/v2/state_changes_spec.rb | 2 -- spec/requests/api/v2/tag_layouts_spec.rb | 2 -- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/spec/requests/api/v2/bait_library_layouts_spec.rb b/spec/requests/api/v2/bait_library_layouts_spec.rb index 7b715f481d..209cd30c3f 100644 --- a/spec/requests/api/v2/bait_library_layouts_spec.rb +++ b/spec/requests/api/v2/bait_library_layouts_spec.rb @@ -69,14 +69,12 @@ context 'with included relationships' do context 'with plate' do let(:related_name) { 'plate' } - let(:related_type) { 'plates' } it_behaves_like 'a POST request including a has_one relationship' end context 'with user' do let(:related_name) { 'user' } - let(:related_type) { 'users' } it_behaves_like 'a POST request including a has_one relationship' end diff --git a/spec/requests/api/v2/shared_examples/post_requests.rb b/spec/requests/api/v2/shared_examples/post_requests.rb index af78bb3ba8..1b7c3dfbcd 100644 --- a/spec/requests/api/v2/shared_examples/post_requests.rb +++ b/spec/requests/api/v2/shared_examples/post_requests.rb @@ -42,8 +42,8 @@ end it 'returns the expected relationship' do - related = json['included'].find { |i| i['type'] == related_type } - expect(related['id']).to eq(resource.send(related_name).id.to_s) - expect(related['type']).to eq(related_type) + related = json['data']['relationships'][related_name]['data'] + included = json['included'].map { |i| i.slice('id', 'type') } + expect(included).to include(related) end end diff --git a/spec/requests/api/v2/state_changes_spec.rb b/spec/requests/api/v2/state_changes_spec.rb index 5e6dab6a46..a8a2e7e3c6 100644 --- a/spec/requests/api/v2/state_changes_spec.rb +++ b/spec/requests/api/v2/state_changes_spec.rb @@ -72,14 +72,12 @@ context 'with included relationships' do context 'with user' do let(:related_name) { 'user' } - let(:related_type) { 'users' } it_behaves_like 'a POST request including a has_one relationship' end context 'with target' do let(:related_name) { 'target' } - let(:related_type) { 'labware' } it_behaves_like 'a POST request including a has_one relationship' end diff --git a/spec/requests/api/v2/tag_layouts_spec.rb b/spec/requests/api/v2/tag_layouts_spec.rb index 98dfcb6545..d29b10426c 100644 --- a/spec/requests/api/v2/tag_layouts_spec.rb +++ b/spec/requests/api/v2/tag_layouts_spec.rb @@ -76,14 +76,12 @@ context 'with included relationships' do context 'with plate' do let(:related_name) { 'plate' } - let(:related_type) { 'plates' } it_behaves_like 'a POST request including a has_one relationship' end context 'with user' do let(:related_name) { 'user' } - let(:related_type) { 'users' } it_behaves_like 'a POST request including a has_one relationship' end From 5676d6f5ecb73b60ae07ffe1ea61923f0670b023 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 13 Sep 2024 16:31:15 +0100 Subject: [PATCH 055/158] Create tests for SpecificTubeCreation resources --- .../api/v2/specific_tube_creation_resource.rb | 4 + spec/factories/specific_tube_creation.rb | 13 + .../api/v2/shared_examples/post_requests.rb | 16 +- .../api/v2/specific_tube_creations_spec.rb | 295 ++++++++++++++++++ spec/requests/api/v2/tag_layouts_spec.rb | 2 +- .../specific_tube_creation_resource_spec.rb | 23 ++ 6 files changed, 351 insertions(+), 2 deletions(-) create mode 100644 spec/factories/specific_tube_creation.rb create mode 100644 spec/requests/api/v2/specific_tube_creations_spec.rb create mode 100644 spec/resources/api/v2/specific_tube_creation_resource_spec.rb diff --git a/app/resources/api/v2/specific_tube_creation_resource.rb b/app/resources/api/v2/specific_tube_creation_resource.rb index e78c9003c7..641dc929a2 100644 --- a/app/resources/api/v2/specific_tube_creation_resource.rb +++ b/app/resources/api/v2/specific_tube_creation_resource.rb @@ -31,6 +31,7 @@ def child_purpose_uuids=(value) # @!attribute [w] parent_uuids # This is declared for convenience where the parent is not available to set as a relationship. # Setting this attribute alongside the `parents` relationship will prefer the relationship value. + # @deprecated Use the `parents` relationship instead. # @param value [Array] The UUIDs of labware that will be the parents for all tubes created. # @return [Void] # @see #parents @@ -49,6 +50,8 @@ def parent_uuids=(value) attribute :tube_attributes def tube_attributes=(value) + return if value.nil? + # Convert ActionController::Parameters into hashes. @model.tube_attributes = value.map(&:to_unsafe_h) end @@ -56,6 +59,7 @@ def tube_attributes=(value) # @!attribute [w] user_uuid # This is declared for convenience where the user is not available to set as a relationship. # Setting this attribute alongside the `user` relationship will prefer the relationship value. + # @deprecated Use the `user` relationship instead. # @param value [String] The UUID of the user who initiated the creation of tubes. # @return [Void] # @see #user diff --git a/spec/factories/specific_tube_creation.rb b/spec/factories/specific_tube_creation.rb new file mode 100644 index 0000000000..9b84c0daf3 --- /dev/null +++ b/spec/factories/specific_tube_creation.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory(:specific_tube_creation) do + child_purposes { |target| [target.association(:tube_purpose), target.association(:tube_purpose)] } + tube_attributes { [{ name: 'Tube one' }, { name: 'Tube two' }] } + user { |target| target.association(:user) } + + # When giving a tube as a parent, we change the prefix away from NT to avoid clashes with tubes created as children + # by other instances of this model. + parents { |target| [target.association(:plate), target.association(:tube, prefix: 'PT')] } + end +end diff --git a/spec/requests/api/v2/shared_examples/post_requests.rb b/spec/requests/api/v2/shared_examples/post_requests.rb index 1b7c3dfbcd..84194a9a1c 100644 --- a/spec/requests/api/v2/shared_examples/post_requests.rb +++ b/spec/requests/api/v2/shared_examples/post_requests.rb @@ -29,7 +29,7 @@ expect(response).to have_http_status(:unprocessable_entity) end - it 'specifies which relationship must exist' do + it 'specifies the expected error message' do expect(json.dig('errors', 0, 'detail')).to eq(error_detail_message) end end @@ -47,3 +47,17 @@ expect(included).to include(related) end end + +shared_examples 'a POST request including a has_many relationship' do + before { api_get "#{base_endpoint}/#{resource.id}?include=#{related_name}" } + + it 'responds with a success http code' do + expect(response).to have_http_status(:success) + end + + it 'includes the expected relationships' do + related = json['data']['relationships'][related_name]['data'] + included = json['included'].map { |i| i.slice('id', 'type') } + expect(included).to include(*related) + end +end diff --git a/spec/requests/api/v2/specific_tube_creations_spec.rb b/spec/requests/api/v2/specific_tube_creations_spec.rb new file mode 100644 index 0000000000..5db4635a25 --- /dev/null +++ b/spec/requests/api/v2/specific_tube_creations_spec.rb @@ -0,0 +1,295 @@ +# frozen_string_literal: true + +require 'rails_helper' +require './spec/requests/api/v2/shared_examples/api_key_authenticatable' +require './spec/requests/api/v2/shared_examples/post_requests' + +describe 'Specific Tube Creations API', with: :api_v2 do + let(:model_class) { SpecificTubeCreation } + let(:base_endpoint) { "/api/v2/#{resource_type}" } + let(:resource_type) { model_class.name.demodulize.pluralize.underscore } + + it_behaves_like 'ApiKeyAuthenticatable' + + context 'with a list of resources' do + let(:resource_count) { 5 } + + before { create_list(:specific_tube_creation, resource_count) } + + describe '#GET all resources' do + before { api_get base_endpoint } + + it 'responds with a success http code' do + expect(response).to have_http_status(:success) + end + + it 'returns all the resources' do + expect(json['data'].length).to eq(resource_count) + end + end + end + + context 'with a single resource' do + describe '#GET resource by ID' do + let(:resource) { create :specific_tube_creation } + + context 'without included relationships' do + before { api_get "#{base_endpoint}/#{resource.id}" } + + it 'responds with a success http code' do + expect(response).to have_http_status(:success) + end + + it 'returns the correct resource' do + expect(json.dig('data', 'id')).to eq(resource.id.to_s) + expect(json.dig('data', 'type')).to eq(resource_type) + end + + it 'returns the correct attributes' do + expect(json.dig('data', 'attributes', 'uuid')).to eq(resource.uuid) + end + + it 'excludes unfetchable attributes' do + expect(json.dig('data', 'attributes', 'child_purpose_uuids')).not_to be_present + expect(json.dig('data', 'attributes', 'parent_uuids')).not_to be_present + expect(json.dig('data', 'attributes', 'tube_attributes')).not_to be_present + end + + it 'returns references to related resources' do + expect(json.dig('data', 'relationships', 'children')).to be_present + expect(json.dig('data', 'relationships', 'parents')).to be_present + expect(json.dig('data', 'relationships', 'user')).to be_present + end + + it 'does not include attributes for related resources' do + expect(json['included']).not_to be_present + end + end + + context 'with included relationships' do + context 'with children' do + let(:related_name) { 'parents' } + + it_behaves_like 'a POST request including a has_many relationship' + end + + context 'with parents' do + let(:related_name) { 'parents' } + + it_behaves_like 'a POST request including a has_many relationship' + end + + context 'with user' do + let(:related_name) { 'user' } + + it_behaves_like 'a POST request including a has_one relationship' + end + end + end + end + + describe '#PATCH a resource' do + let(:resource_model) { create :specific_tube_creation } + let(:purpose) { create :tube_purpose } + let(:payload) do + { data: { id: resource_model.id, type: resource_type, attributes: { child_purpose_uuids: [purpose.uuid] } } } + end + + it 'finds no route for the method' do + expect { api_patch "#{base_endpoint}/#{resource_model.id}", payload }.to raise_error( + ActionController::RoutingError + ) + end + end + + describe '#POST a create request' do + let(:child_purposes) { create_list :tube_purpose, 2 } + let(:parents) { [create(:plate), create(:tube, prefix: 'PT')] } + let(:user) { create(:user) } + + let(:base_attributes) do + { + child_purpose_uuids: child_purposes.map { |cp| cp.uuid }, + tube_attributes: [{ name: 'Tube one' }, { name: 'Tube two' }] + } + end + + let(:parents_relationship) { { data: parents.map { |p| { id: p.id, type: 'assets' } } } } + let(:user_relationship) { { data: { id: user.id, type: 'users' } } } + + context 'with a valid payload' do + shared_examples 'a valid request' do + before { api_post base_endpoint, payload } + + it 'creates a new resource' do + expect { api_post base_endpoint, payload }.to change(model_class, :count).by(1) + end + + it 'responds with success' do + expect(response).to have_http_status(:success) + end + + it 'responds with the correct attributes' do + new_record = model_class.last + + expect(json.dig('data', 'type')).to eq(resource_type) + expect(json.dig('data', 'attributes', 'uuid')).to eq(new_record.uuid) + end + + it 'excludes unfetchable attributes' do + expect(json.dig('data', 'attributes', 'child_purpose_uuids')).not_to be_present + expect(json.dig('data', 'attributes', 'parent_uuids')).not_to be_present + expect(json.dig('data', 'attributes', 'tube_attributes')).not_to be_present + end + + it 'returns references to related resources' do + expect(json.dig('data', 'relationships', 'children')).to be_present + expect(json.dig('data', 'relationships', 'parents')).to be_present + expect(json.dig('data', 'relationships', 'user')).to be_present + end + + it 'applies the attributes to the new record' do + new_record = model_class.last + + # Note that the tube_attributes from the queried record will not match the submitted values, but it will + # consist of empty hashes equalling the number of child purposes, as defined in the model. + expect(new_record.tube_attributes).to eq(Array.new(child_purposes.length, {})) + end + + it 'applies the relationships to the new record' do + new_record = model_class.last + + expect(new_record.child_purposes).to eq(child_purposes) + expect(new_record.parents).to eq(parents) + expect(new_record.user).to eq(user) + end + + it 'generated children with valid attributes' do + new_record = model_class.last + + expect(new_record.children.length).to eq(2) + expect(new_record.children.map(&:name)).to eq(['Tube one', 'Tube two']) + expect(new_record.children.map(&:purpose)).to eq(child_purposes) + end + end + + context 'with complete attributes' do + let(:payload) do + { + data: { + type: resource_type, + attributes: + base_attributes.merge( + { + child_purpose_uuids: child_purposes.map { |cp| cp.uuid }, + parent_uuids: parents.map { |p| p.uuid }, + user_uuid: user.uuid + } + ) + } + } + end + + it_behaves_like 'a valid request' + end + + context 'with relationships' do + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes, + relationships: { + parents: parents_relationship, + user: user_relationship + } + } + } + end + + it_behaves_like 'a valid request' + end + + context 'with conflicting relationships' do + let(:other_parents) { create_list :plate, 2 } + let(:other_user) { create :user } + let(:payload) do + { + data: { + type: resource_type, + attributes: + base_attributes.merge({ parent_uuids: other_parents.map(&:uuid), user_uuid: other_user.uuid }), + relationships: { + parents: parents_relationship, + user: user_relationship + } + } + } + end + + # This test should pass because the relationships are preferred over the attributes. + it_behaves_like 'a valid request' + end + end + + context 'with a read-only attribute in the payload' do + context 'with uuid' do + let(:disallowed_attribute) { 'uuid' } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes.merge({ uuid: '111111-2222-3333-4444-555555666666' }) + } + } + end + + it_behaves_like 'a POST request with a disallowed attribute' + end + end + + context 'without a required relationship' do + context 'without parent_uuids' do + let(:error_detail_message) { "parent - can't be blank" } + let(:payload) { { data: { type: resource_type, attributes: base_attributes.merge({ user_uuid: user.uuid }) } } } + + it_behaves_like 'an unprocessable POST request with a specific error' + end + + context 'without user_uuid' do + let(:error_detail_message) { "user - can't be blank" } + let(:payload) do + { data: { type: resource_type, attributes: base_attributes.merge({ parent_uuids: parents.map(&:uuid) }) } } + end + + it_behaves_like 'an unprocessable POST request with a specific error' + end + + context 'without parents' do + let(:error_detail_message) { "parent - can't be blank" } + let(:payload) do + { data: { type: resource_type, attributes: base_attributes, relationships: { user: user_relationship } } } + end + + it_behaves_like 'an unprocessable POST request with a specific error' + end + + context 'without user' do + let(:error_detail_message) { "user - can't be blank" } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes, + relationships: { + parents: parents_relationship + } + } + } + end + + it_behaves_like 'an unprocessable POST request with a specific error' + end + end + end +end diff --git a/spec/requests/api/v2/tag_layouts_spec.rb b/spec/requests/api/v2/tag_layouts_spec.rb index d29b10426c..aa995ae7bb 100644 --- a/spec/requests/api/v2/tag_layouts_spec.rb +++ b/spec/requests/api/v2/tag_layouts_spec.rb @@ -173,7 +173,7 @@ expect(new_record.substitutions).to eq(payload.dig(:data, :attributes, :substitutions)) expect(new_record.walking_by).to eq(payload.dig(:data, :attributes, :walking_by)) - # Note that the tags_per_well from the quieried record will be nil as it isn't a stored attribute in the + # Note that the tags_per_well from the queried record will be nil as it isn't a stored attribute in the # database. expect(new_record.tags_per_well).to be_nil end diff --git a/spec/resources/api/v2/specific_tube_creation_resource_spec.rb b/spec/resources/api/v2/specific_tube_creation_resource_spec.rb new file mode 100644 index 0000000000..c5b9f6caec --- /dev/null +++ b/spec/resources/api/v2/specific_tube_creation_resource_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' +require './app/resources/api/v2/specific_tube_creation_resource' + +RSpec.describe Api::V2::SpecificTubeCreationResource, type: :resource do + subject(:resource) { described_class.new(resource_model, {}) } + + let(:resource_model) { build_stubbed :specific_tube_creation } + + # Attributes + it { is_expected.to have_readonly_attribute :uuid } + + it { is_expected.to have_writeonly_attribute :child_purpose_uuids } + it { is_expected.to have_writeonly_attribute :parent_uuids } + it { is_expected.to have_writeonly_attribute :tube_attributes } + it { is_expected.to have_writeonly_attribute :user_uuid } + + # Relationships + it { is_expected.to have_many(:children).with_class_name('Tube') } + it { is_expected.to have_many(:parents).with_class_name('Asset') } + it { is_expected.to have_one(:user).with_class_name('User') } +end From 69bc72d3fcb32b2dcabcd2671136c512264327c3 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Fri, 13 Sep 2024 16:43:09 +0100 Subject: [PATCH 056/158] Fix Rubocop concerns --- spec/requests/api/v2/specific_tube_creations_spec.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/spec/requests/api/v2/specific_tube_creations_spec.rb b/spec/requests/api/v2/specific_tube_creations_spec.rb index 5db4635a25..986e66b824 100644 --- a/spec/requests/api/v2/specific_tube_creations_spec.rb +++ b/spec/requests/api/v2/specific_tube_creations_spec.rb @@ -68,7 +68,7 @@ context 'with included relationships' do context 'with children' do - let(:related_name) { 'parents' } + let(:related_name) { 'children' } it_behaves_like 'a POST request including a has_many relationship' end @@ -108,10 +108,7 @@ let(:user) { create(:user) } let(:base_attributes) do - { - child_purpose_uuids: child_purposes.map { |cp| cp.uuid }, - tube_attributes: [{ name: 'Tube one' }, { name: 'Tube two' }] - } + { child_purpose_uuids: child_purposes.map(&:uuid), tube_attributes: [{ name: 'Tube one' }, { name: 'Tube two' }] } end let(:parents_relationship) { { data: parents.map { |p| { id: p.id, type: 'assets' } } } } @@ -181,8 +178,8 @@ attributes: base_attributes.merge( { - child_purpose_uuids: child_purposes.map { |cp| cp.uuid }, - parent_uuids: parents.map { |p| p.uuid }, + child_purpose_uuids: child_purposes.map(&:uuid), + parent_uuids: parents.map(&:uuid), user_uuid: user.uuid } ) From 544064d13f8e3c8960a446a348cf41f619162126 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Mon, 16 Sep 2024 13:36:01 +0100 Subject: [PATCH 057/158] Adding a rake task for populating samples per pool --- .../populate_number_of_samples_per_pool.rake | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/tasks/populate_number_of_samples_per_pool.rake diff --git a/lib/tasks/populate_number_of_samples_per_pool.rake b/lib/tasks/populate_number_of_samples_per_pool.rake new file mode 100644 index 0000000000..2fa3da97b5 --- /dev/null +++ b/lib/tasks/populate_number_of_samples_per_pool.rake @@ -0,0 +1,43 @@ +# frozen_string_literal: true +namespace :number_of_samples_per_pool do + + desc 'Populate number of samples per pool column in request_metadata table' + + task :populate, %i[samples_per_pool submission_id] => :environment do |_, args| + + # TODO: Replace it with the pre-determined number of samples per pool + args.with_defaults(samples_per_pool: 96) + + if args[:submission_id].nil? + puts 'Please provide a submission_id to populate the number of samples per pool column.' + return + end + + puts "Populating number of samples per pool column with #{args[:samples_per_pool]} in request_metadata + table for submission: #{args[:submission_id]}..." + + ActiveRecord::Base.transaction do + saved_count = 0 + request_metadatas = Request::Metadata.where(number_of_samples_per_pool: nil, submission_id: args[:submission_id]) + # Assuming there are multiple requests for a submission + request_metadatas.find_each(batch_size: 50) do |request_metadata| + puts "Processing request_metadata #{request_metadata.id}..." + saved_count = process_request_metadata(request_metadata, saved_count) + end + puts "Populated number of samples per pool column for #{saved_count} request_metadata items." + end + end + + def process_request_metadata(request_metadata, saved_count) + request_metadata.number_of_samples_per_pool = 96 + begin + request_metadata.save! + saved_count += 1 + rescue ActiveRecord::ActiveRecordError, StandardError => e + puts "Error processing request_metadata #{request_metadata.id}: #{e.message}" + raise e + end + saved_count + end + +end \ No newline at end of file From 231c58eca422c125e5bc2c7db5c2206aa4710149 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Mon, 16 Sep 2024 13:40:40 +0100 Subject: [PATCH 058/158] Adding migrations for column --- .../20240916123807_add_number_of_samples_per_pool_column.rb | 5 +++++ db/schema.rb | 3 ++- lib/tasks/populate_number_of_samples_per_pool.rake | 5 +---- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb diff --git a/db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb b/db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb new file mode 100644 index 0000000000..49e57530e9 --- /dev/null +++ b/db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb @@ -0,0 +1,5 @@ +class AddNumberOfSamplesPerPoolColumn < ActiveRecord::Migration[6.1] + def change + add_column :request_metadata, :number_of_samples_per_pool, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 207c08263d..192a680508 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: 2024_08_13_130010) do +ActiveRecord::Schema.define(version: 2024_09_16_123807) do create_table "aliquot_indices", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", options: "ENGINE=InnoDB ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.integer "aliquot_id", null: false @@ -1174,6 +1174,7 @@ t.string "data_type" t.integer "primer_panel_id" t.string "requested_flowcell_type" + t.integer "number_of_samples_per_pool" t.index ["request_id"], name: "index_request_metadata_on_request_id" end diff --git a/lib/tasks/populate_number_of_samples_per_pool.rake b/lib/tasks/populate_number_of_samples_per_pool.rake index 2fa3da97b5..0270ec30bb 100644 --- a/lib/tasks/populate_number_of_samples_per_pool.rake +++ b/lib/tasks/populate_number_of_samples_per_pool.rake @@ -1,10 +1,8 @@ # frozen_string_literal: true namespace :number_of_samples_per_pool do - desc 'Populate number of samples per pool column in request_metadata table' task :populate, %i[samples_per_pool submission_id] => :environment do |_, args| - # TODO: Replace it with the pre-determined number of samples per pool args.with_defaults(samples_per_pool: 96) @@ -39,5 +37,4 @@ namespace :number_of_samples_per_pool do end saved_count end - -end \ No newline at end of file +end From 72146787e9e6516f6b9421dc82c8b62470528a50 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Mon, 16 Sep 2024 13:45:16 +0100 Subject: [PATCH 059/158] Making rubocop happy --- .../20240916123807_add_number_of_samples_per_pool_column.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb b/db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb index 49e57530e9..9987655827 100644 --- a/db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb +++ b/db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true class AddNumberOfSamplesPerPoolColumn < ActiveRecord::Migration[6.1] def change add_column :request_metadata, :number_of_samples_per_pool, :integer From 33d2504b173e37be6fcf1496345a6bea09451e96 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Mon, 16 Sep 2024 15:00:51 +0100 Subject: [PATCH 060/158] Adding tests for populate job --- .../populate_number_of_samples_per_pool.rake | 19 +++++----- ...populate_numer_of_samples_per_pool_spec.rb | 36 +++++++++++++++++++ 2 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 spec/lib/populate_numer_of_samples_per_pool_spec.rb diff --git a/lib/tasks/populate_number_of_samples_per_pool.rake b/lib/tasks/populate_number_of_samples_per_pool.rake index 0270ec30bb..3c4f2c0b53 100644 --- a/lib/tasks/populate_number_of_samples_per_pool.rake +++ b/lib/tasks/populate_number_of_samples_per_pool.rake @@ -16,18 +16,19 @@ namespace :number_of_samples_per_pool do ActiveRecord::Base.transaction do saved_count = 0 - request_metadatas = Request::Metadata.where(number_of_samples_per_pool: nil, submission_id: args[:submission_id]) - # Assuming there are multiple requests for a submission - request_metadatas.find_each(batch_size: 50) do |request_metadata| - puts "Processing request_metadata #{request_metadata.id}..." - saved_count = process_request_metadata(request_metadata, saved_count) - end - puts "Populated number of samples per pool column for #{saved_count} request_metadata items." + # Find request_metadata for each request + Request::Metadata + .joins(:request) + .where(requests: { submission_id: args[:submission_id] }) + .find_each(batch_size: 50) do |request_metadata| + puts "Processing request_metadata #{request_metadata.id}..." + saved_count = process_request_metadata(request_metadata, saved_count, args[:samples_per_pool]) + end end end - def process_request_metadata(request_metadata, saved_count) - request_metadata.number_of_samples_per_pool = 96 + def process_request_metadata(request_metadata, saved_count, samples_per_pool) + request_metadata.number_of_samples_per_pool = samples_per_pool begin request_metadata.save! saved_count += 1 diff --git a/spec/lib/populate_numer_of_samples_per_pool_spec.rb b/spec/lib/populate_numer_of_samples_per_pool_spec.rb new file mode 100644 index 0000000000..2c6d8fe701 --- /dev/null +++ b/spec/lib/populate_numer_of_samples_per_pool_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +# rubocop:disable RSpec/DescribeClass +require 'rails_helper' +require 'rake' + +RSpec.describe 'number_of_samples_per_pool:populate' do + def run_rake_task_with_args(task_name, *args) + Rake::Task[task_name].reenable + Rake.application.invoke_task("#{task_name}[#{args.join(',')}]") + end + + shared_examples 'populating number of samples per pool' do + it 'populates number of samples per pool' do + submission = create(:submission) + tube = create(:tube) + request = create(:well_request, asset: tube, submission: submission) + + # Execute + run_rake_task_with_args('number_of_samples_per_pool:populate', 96, submission.reload.id) + + # Verify + expect(request.reload.request_metadata.number_of_samples_per_pool).to eq(96) + end + end + + context 'when all okay, populates number of samples per pool' do + before do + Rake.application.rake_require 'tasks/populate_number_of_samples_per_pool' + Rake::Task.define_task(:environment) + end + + it_behaves_like 'populating number of samples per pool' + end +end +# rubocop:enable RSpec/DescribeClass From 4d0673b61c7ecf107e4e29e5fb4e12935d1dd219 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Tue, 17 Sep 2024 16:40:00 +0100 Subject: [PATCH 061/158] Change parents to Labware instead of Assets --- app/resources/api/v2/specific_tube_creation_resource.rb | 4 ++-- spec/requests/api/v2/specific_tube_creations_spec.rb | 2 +- spec/resources/api/v2/specific_tube_creation_resource_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/resources/api/v2/specific_tube_creation_resource.rb b/app/resources/api/v2/specific_tube_creation_resource.rb index 641dc929a2..d3cfae2529 100644 --- a/app/resources/api/v2/specific_tube_creation_resource.rb +++ b/app/resources/api/v2/specific_tube_creation_resource.rb @@ -83,9 +83,9 @@ def user_uuid=(value) # @!attribute [rw] parents # Setting this relationship alongside the `parent_uuids` attribute will override the attribute value. - # @return [Array] An array of the parents of the tubes being created. + # @return [Array] An array of the parents of the tubes being created. # @note This relationship is required. - has_many :parents, class_name: 'Asset' + has_many :parents, class_name: 'Labware' # @!attribute [rw] user # Setting this relationship alongside the `user_uuid` attribute will override the attribute value. diff --git a/spec/requests/api/v2/specific_tube_creations_spec.rb b/spec/requests/api/v2/specific_tube_creations_spec.rb index 986e66b824..83338967a7 100644 --- a/spec/requests/api/v2/specific_tube_creations_spec.rb +++ b/spec/requests/api/v2/specific_tube_creations_spec.rb @@ -111,7 +111,7 @@ { child_purpose_uuids: child_purposes.map(&:uuid), tube_attributes: [{ name: 'Tube one' }, { name: 'Tube two' }] } end - let(:parents_relationship) { { data: parents.map { |p| { id: p.id, type: 'assets' } } } } + let(:parents_relationship) { { data: parents.map { |p| { id: p.id, type: 'labware' } } } } let(:user_relationship) { { data: { id: user.id, type: 'users' } } } context 'with a valid payload' do diff --git a/spec/resources/api/v2/specific_tube_creation_resource_spec.rb b/spec/resources/api/v2/specific_tube_creation_resource_spec.rb index c5b9f6caec..13f9fd33ab 100644 --- a/spec/resources/api/v2/specific_tube_creation_resource_spec.rb +++ b/spec/resources/api/v2/specific_tube_creation_resource_spec.rb @@ -18,6 +18,6 @@ # Relationships it { is_expected.to have_many(:children).with_class_name('Tube') } - it { is_expected.to have_many(:parents).with_class_name('Asset') } + it { is_expected.to have_many(:parents).with_class_name('Labware') } it { is_expected.to have_one(:user).with_class_name('User') } end From ec54f0f9eabd8dc5b79f81553216e0bcadf1ee02 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 20:20:25 +0000 Subject: [PATCH 062/158] Update vite to version 5.3.6 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0346bb98cc..97f2f22691 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "jest": "^26.6.3", "miragejs": "^0.1.48", "prettier": "^3.3.2", - "vite": "^5.3.2", + "vite": "^5.3.6", "vite-plugin-ruby": "^5.0.0", "vite-plugin-vue2": "^1.9.3", "vue-jest": "^3.0.7" diff --git a/yarn.lock b/yarn.lock index 086c4d60ba..ced00bab85 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7281,10 +7281,10 @@ vite-plugin-vue2@^1.9.3: source-map "^0.7.3" vue-template-es2015-compiler "^1.9.1" -vite@^5.3.2: - version "5.3.3" - resolved "https://registry.yarnpkg.com/vite/-/vite-5.3.3.tgz#5265b1f0a825b3b6564c2d07524777c83e3c04c2" - integrity sha512-NPQdeCU0Dv2z5fu+ULotpuq5yfCS1BzKUIPhNbP3YBfAMGJXbt2nS+sbTFu+qchaqWTD+H3JK++nRwr6XIcp6A== +vite@^5.3.6: + version "5.3.6" + resolved "https://registry.yarnpkg.com/vite/-/vite-5.3.6.tgz#e097c0a7b79adb2e60bec9ef7907354f09d027bd" + integrity sha512-es78AlrylO8mTVBygC0gTC0FENv0C6T496vvd33ydbjF/mIi9q3XQ9A3NWo5qLGFKywvz10J26813OkLvcQleA== dependencies: esbuild "^0.21.3" postcss "^8.4.39" From 933695f9a1848b41619f92b1946b8757e7f44980 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Wed, 18 Sep 2024 10:21:10 +0100 Subject: [PATCH 063/158] Added migration for creating scRNA fields in the request_metadata table --- .../20240917133813_addsc_rna_fields_to_request_metadata.rb | 7 +++++++ db/schema.rb | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20240917133813_addsc_rna_fields_to_request_metadata.rb diff --git a/db/migrate/20240917133813_addsc_rna_fields_to_request_metadata.rb b/db/migrate/20240917133813_addsc_rna_fields_to_request_metadata.rb new file mode 100644 index 0000000000..551b12ffb4 --- /dev/null +++ b/db/migrate/20240917133813_addsc_rna_fields_to_request_metadata.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true +class AddscRnaFieldsToRequestMetadata < ActiveRecord::Migration[6.1] + def change + add_column :request_metadata, :number_of_samples_per_pool, :integer, null: true + add_column :request_metadata, :cells_per_chip_well, :integer, null: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 207c08263d..682fe2630e 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: 2024_08_13_130010) do +ActiveRecord::Schema.define(version: 2024_09_17_133813) do create_table "aliquot_indices", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", options: "ENGINE=InnoDB ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.integer "aliquot_id", null: false @@ -1174,6 +1174,8 @@ t.string "data_type" t.integer "primer_panel_id" t.string "requested_flowcell_type" + t.integer "number_of_samples_per_pool" + t.integer "cells_per_chip_well" t.index ["request_id"], name: "index_request_metadata_on_request_id" end From f529ef3abcedba6dc1d1e1eb6450570776b95f71 Mon Sep 17 00:00:00 2001 From: Harriet Craven Date: Wed, 18 Sep 2024 11:49:05 +0100 Subject: [PATCH 064/158] Update installation instructions for Vite and MySQL in Readme --- README.md | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ddf679d5a1..b43832cf4b 100644 --- a/README.md +++ b/README.md @@ -101,8 +101,8 @@ bundle exec yard-junk --sanity The following tools are required for development: - ruby (version defined in the `.ruby-version`) -- yarn -- node (version defined in the `.nvmrc`) +- yarn (`brew install yarn`) +- node (`brew install node@` version defined in the `.nvmrc`, ensure node is in your PATH) - mysql client libraries - if you do not want to install mysql server on your machine, consider using mysql-client: `brew install mysql-client`. Alternatively, to install the MySQL required by Sequencescape (currently 8.0) @@ -220,6 +220,13 @@ bundle exec rails s Once setup, the default user/password is `admin/admin`. +### Vite + +Ensure Node is installed, and in your PATH. You might need to run +`bin/vite build --clear --mode=development` + +To start vite + #### Delayed job For background processing Sequencescape uses `delayed_job` to ensure that the server is running. It @@ -389,11 +396,21 @@ cluster formation batch which represents a flowcell. #### MySQL errors when installing -If you are using homebrew with rbenv and run into errors relating to SSL, have a look [here](https://github.com/brianmario/mysql2/issues/795#issuecomment-433219176) +- If you are using homebrew with rbenv and run into errors relating to SSL, have a look [here](https://github.com/brianmario/mysql2/issues/795#issuecomment-433219176) -If you are upgrading a homebrew MySQL locally and have an error about a missing libmysqlclient dylib file, you may need to redownload the mysql2 gem to fix it i.e. `bundle install --redownload` +- If you are upgrading a homebrew MySQL locally and have an error about a missing libmysqlclient dylib file, you may need to redownload the mysql2 gem to fix it i.e. `bundle install --redownload` This is because the mysql2 gem is simlinked to the homebrew mysql. +- If bundle install is failing to install the `mysql2` gem, try the below (updating the paths as required): + +``` +gem install mysql2 -v '0.5.6' -- \ +--with-mysql-lib=/opt/homebrew/Cellar/mysql/ \ +--with-mysql-dir=/opt/homebrew/Cellar/mysql/9.0.1_1 \ +--with-mysql-config=/opt/homebrew/Cellar/mysql/9.0.1_1/bin/mysql_config \ +--with-mysql-include=/opt/homebrew/Cellar/mysql/9.0.1_1/include +``` + #### Installing on Apple Silicon (M1) If installation issues are encountered with Docker on M1 processors, try the fixes below: From 49abbefccc1436b93400c37de4b44d2c26d9e357 Mon Sep 17 00:00:00 2001 From: Harriet Craven Date: Wed, 18 Sep 2024 12:08:00 +0100 Subject: [PATCH 065/158] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b43832cf4b..7893302632 100644 --- a/README.md +++ b/README.md @@ -225,8 +225,6 @@ Once setup, the default user/password is `admin/admin`. Ensure Node is installed, and in your PATH. You might need to run `bin/vite build --clear --mode=development` -To start vite - #### Delayed job For background processing Sequencescape uses `delayed_job` to ensure that the server is running. It @@ -321,6 +319,8 @@ yarn prettier --check . yarn prettier --write . ``` +(If prettier is not yet installed, run `yarn`. This should have ben run in `bin/setup`) + - Prettier rules are configured in .prettierrc.json - Whole files can be ignored in .prettierignore - Sections of files can be disabled using #prettier-ignore From db1217e243ce0672cae084a714eb177bedb56358 Mon Sep 17 00:00:00 2001 From: Harriet Craven Date: Wed, 18 Sep 2024 12:12:20 +0100 Subject: [PATCH 066/158] prettier --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7893302632..b8cb7e3c5c 100644 --- a/README.md +++ b/README.md @@ -399,7 +399,7 @@ cluster formation batch which represents a flowcell. - If you are using homebrew with rbenv and run into errors relating to SSL, have a look [here](https://github.com/brianmario/mysql2/issues/795#issuecomment-433219176) - If you are upgrading a homebrew MySQL locally and have an error about a missing libmysqlclient dylib file, you may need to redownload the mysql2 gem to fix it i.e. `bundle install --redownload` -This is because the mysql2 gem is simlinked to the homebrew mysql. + This is because the mysql2 gem is simlinked to the homebrew mysql. - If bundle install is failing to install the `mysql2` gem, try the below (updating the paths as required): From d5f51d3874ad37ecc324e7539729f6b618588644 Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Wed, 18 Sep 2024 13:43:55 +0100 Subject: [PATCH 067/158] add check if asset_id, labware exists --- app/models/comment.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 06e2070052..9fe395f73b 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -34,13 +34,20 @@ def self.counts_for(commentables) # @return [Hash] Hash of counts indexed by request_id # def self.counts_for_requests(requests) # rubocop:todo Metrics/AbcSize - all_commentables = requests.flat_map { |request| [request, request.asset, request.asset&.labware] } - counts = where(commentable: all_commentables.compact).group(:commentable_type, :commentable_id).count - requests.each_with_object({}) do |request, counter_cache| - request_count = counts.fetch(['Request', request.id], 0) - receptacle_count = counts.fetch(['Receptacle', request.asset_id], 0) - labware_count = counts.fetch(['Labware', request.asset.labware_id], 0) - counter_cache[request.id] = request_count + receptacle_count + labware_count + begin + all_commentables = requests.flat_map do |request| + [request, request.try(:asset), request.try(:asset).try(:labware)] + end + counts = where(commentable: all_commentables.compact).group(:commentable_type, :commentable_id).count + + requests.each_with_object({}) do |request, counter_cache| + request_count = counts.fetch(['Request', request.id], 0) + receptacle_count = counts.fetch(['Receptacle', request.try(:asset_id)], 0) + labware_count = counts.fetch(['Labware', request.try(:asset).try(:labware_id)], 0) + counter_cache[request.id] = request_count + receptacle_count + labware_count + end + rescue StandardError => e + puts "An error of type #{e.class} happened, message is #{e.message}" end end From 5d7cb124fa3f18e38f929f6a60924d35f747f5fb Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Wed, 18 Sep 2024 14:00:38 +0100 Subject: [PATCH 068/158] fix the format --- app/models/comment.rb | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 9fe395f73b..329d221530 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -34,20 +34,14 @@ def self.counts_for(commentables) # @return [Hash] Hash of counts indexed by request_id # def self.counts_for_requests(requests) # rubocop:todo Metrics/AbcSize - begin - all_commentables = requests.flat_map do |request| - [request, request.try(:asset), request.try(:asset).try(:labware)] - end - counts = where(commentable: all_commentables.compact).group(:commentable_type, :commentable_id).count - - requests.each_with_object({}) do |request, counter_cache| - request_count = counts.fetch(['Request', request.id], 0) - receptacle_count = counts.fetch(['Receptacle', request.try(:asset_id)], 0) - labware_count = counts.fetch(['Labware', request.try(:asset).try(:labware_id)], 0) - counter_cache[request.id] = request_count + receptacle_count + labware_count - end - rescue StandardError => e - puts "An error of type #{e.class} happened, message is #{e.message}" + all_commentables = requests.flat_map { |request| [request, request.try(:asset), request.try(:asset).try(:labware)] } + counts = where(commentable: all_commentables.compact).group(:commentable_type, :commentable_id).count + + requests.each_with_object({}) do |request, counter_cache| + request_count = counts.fetch(['Request', request.id], 0) + receptacle_count = counts.fetch(['Receptacle', request.try(:asset_id)], 0) + labware_count = counts.fetch(['Labware', request.try(:asset).try(:labware_id)], 0) + counter_cache[request.id] = request_count + receptacle_count + labware_count end end From 3761ab281adae21ad5f877d3b51424831539d9a2 Mon Sep 17 00:00:00 2001 From: Harriet Craven Date: Wed, 18 Sep 2024 14:27:38 +0100 Subject: [PATCH 069/158] Update Dockerfile to use Ruby version 3.2.5 for m1 chip --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f4f75b7182..f64ba4780f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ ARG CHIPSET=default # Use the correct base image depending on the architecture # For Apple M1 Chip, run: docker build --build-arg CHIPSET=m1 . FROM ruby:3.2.5-slim AS base_default -FROM --platform=linux/amd64 ruby:3.2.4-slim AS base_m1 +FROM --platform=linux/amd64 ruby:3.2.5-slim AS base_m1 FROM base_${CHIPSET} AS base COPY .nvmrc /.nvmrc From fa6f4d5c4bdac90d06a9e0cbea406bbef3a77140 Mon Sep 17 00:00:00 2001 From: Harriet Craven Date: Wed, 18 Sep 2024 14:46:59 +0100 Subject: [PATCH 070/158] un-WIP scRNA Core pipeline record loader files --- ...rposes.wip.yml => 011_scrna_core_cdna_prep_plate_purposes.yml} | 0 ..._scrna_core_catalogue.wip.yml => 011_scrna_core_catalogue.yml} | 0 ....wip.yml => 014_limber_scrna_core_cdna_prep_request_types.yml} | 0 ...p.yml => 015_limber_scrna_core_library_prep_request_types.yml} | 0 ....wip.yml => 011_scrna_core_cdna_prep_submission_templates.yml} | 0 ...p.yml => 012_scrna_core_library_prep_submission_templates.yml} | 0 ...urposes.wip.yml => 008_scrna_core_cdna_prep_tube_purposes.yml} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename config/default_records/plate_purposes/{011_scrna_core_cdna_prep_plate_purposes.wip.yml => 011_scrna_core_cdna_prep_plate_purposes.yml} (100%) rename config/default_records/product_catalogues/{011_scrna_core_catalogue.wip.yml => 011_scrna_core_catalogue.yml} (100%) rename config/default_records/request_types/{014_limber_scrna_core_cdna_prep_request_types.wip.yml => 014_limber_scrna_core_cdna_prep_request_types.yml} (100%) rename config/default_records/request_types/{015_limber_scrna_core_library_prep_request_types.wip.yml => 015_limber_scrna_core_library_prep_request_types.yml} (100%) rename config/default_records/submission_templates/{011_scrna_core_cdna_prep_submission_templates.wip.yml => 011_scrna_core_cdna_prep_submission_templates.yml} (100%) rename config/default_records/submission_templates/{012_scrna_core_library_prep_submission_templates.wip.yml => 012_scrna_core_library_prep_submission_templates.yml} (100%) rename config/default_records/tube_purposes/{008_scrna_core_cdna_prep_tube_purposes.wip.yml => 008_scrna_core_cdna_prep_tube_purposes.yml} (100%) diff --git a/config/default_records/plate_purposes/011_scrna_core_cdna_prep_plate_purposes.wip.yml b/config/default_records/plate_purposes/011_scrna_core_cdna_prep_plate_purposes.yml similarity index 100% rename from config/default_records/plate_purposes/011_scrna_core_cdna_prep_plate_purposes.wip.yml rename to config/default_records/plate_purposes/011_scrna_core_cdna_prep_plate_purposes.yml diff --git a/config/default_records/product_catalogues/011_scrna_core_catalogue.wip.yml b/config/default_records/product_catalogues/011_scrna_core_catalogue.yml similarity index 100% rename from config/default_records/product_catalogues/011_scrna_core_catalogue.wip.yml rename to config/default_records/product_catalogues/011_scrna_core_catalogue.yml diff --git a/config/default_records/request_types/014_limber_scrna_core_cdna_prep_request_types.wip.yml b/config/default_records/request_types/014_limber_scrna_core_cdna_prep_request_types.yml similarity index 100% rename from config/default_records/request_types/014_limber_scrna_core_cdna_prep_request_types.wip.yml rename to config/default_records/request_types/014_limber_scrna_core_cdna_prep_request_types.yml diff --git a/config/default_records/request_types/015_limber_scrna_core_library_prep_request_types.wip.yml b/config/default_records/request_types/015_limber_scrna_core_library_prep_request_types.yml similarity index 100% rename from config/default_records/request_types/015_limber_scrna_core_library_prep_request_types.wip.yml rename to config/default_records/request_types/015_limber_scrna_core_library_prep_request_types.yml diff --git a/config/default_records/submission_templates/011_scrna_core_cdna_prep_submission_templates.wip.yml b/config/default_records/submission_templates/011_scrna_core_cdna_prep_submission_templates.yml similarity index 100% rename from config/default_records/submission_templates/011_scrna_core_cdna_prep_submission_templates.wip.yml rename to config/default_records/submission_templates/011_scrna_core_cdna_prep_submission_templates.yml diff --git a/config/default_records/submission_templates/012_scrna_core_library_prep_submission_templates.wip.yml b/config/default_records/submission_templates/012_scrna_core_library_prep_submission_templates.yml similarity index 100% rename from config/default_records/submission_templates/012_scrna_core_library_prep_submission_templates.wip.yml rename to config/default_records/submission_templates/012_scrna_core_library_prep_submission_templates.yml diff --git a/config/default_records/tube_purposes/008_scrna_core_cdna_prep_tube_purposes.wip.yml b/config/default_records/tube_purposes/008_scrna_core_cdna_prep_tube_purposes.yml similarity index 100% rename from config/default_records/tube_purposes/008_scrna_core_cdna_prep_tube_purposes.wip.yml rename to config/default_records/tube_purposes/008_scrna_core_cdna_prep_tube_purposes.yml From a3f29ff983c4b2b7da9a9d4cddf8415a15498582 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Thu, 19 Sep 2024 10:56:21 +0100 Subject: [PATCH 071/158] Updating from branch --- .../20240916123807_add_number_of_samples_per_pool_column.rb | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb diff --git a/db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb b/db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb deleted file mode 100644 index 9987655827..0000000000 --- a/db/migrate/20240916123807_add_number_of_samples_per_pool_column.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true -class AddNumberOfSamplesPerPoolColumn < ActiveRecord::Migration[6.1] - def change - add_column :request_metadata, :number_of_samples_per_pool, :integer - end -end From d2bb898ba1bc24d9c0694238b5e78b6fe605deec Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Thu, 19 Sep 2024 11:19:41 +0100 Subject: [PATCH 072/158] [skip ci] Naming changes --- lib/tasks/populate_number_of_samples_per_pool.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/populate_number_of_samples_per_pool.rake b/lib/tasks/populate_number_of_samples_per_pool.rake index 3c4f2c0b53..8df86b1042 100644 --- a/lib/tasks/populate_number_of_samples_per_pool.rake +++ b/lib/tasks/populate_number_of_samples_per_pool.rake @@ -1,6 +1,6 @@ # frozen_string_literal: true namespace :number_of_samples_per_pool do - desc 'Populate number of samples per pool column in request_metadata table' + desc 'Populate number of samples per pool column in request_metadata table for a given submission ID' task :populate, %i[samples_per_pool submission_id] => :environment do |_, args| # TODO: Replace it with the pre-determined number of samples per pool From c7068c9bb4ab75aa17af2c2f92509c3a7eb24328 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 19 Sep 2024 12:00:35 +0100 Subject: [PATCH 073/158] Create an API v2 endpoint for PooledPlateCreations --- .../v2/pooled_plate_creations_controller.rb | 12 +++ .../api/v2/pooled_plate_creation_resource.rb | 93 +++++++++++++++++++ config/routes.rb | 1 + 3 files changed, 106 insertions(+) create mode 100644 app/controllers/api/v2/pooled_plate_creations_controller.rb create mode 100644 app/resources/api/v2/pooled_plate_creation_resource.rb diff --git a/app/controllers/api/v2/pooled_plate_creations_controller.rb b/app/controllers/api/v2/pooled_plate_creations_controller.rb new file mode 100644 index 0000000000..07a8524041 --- /dev/null +++ b/app/controllers/api/v2/pooled_plate_creations_controller.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Api + module V2 + # Provides a JSON API controller for Pooled Plate Creations + # See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation + class PooledPlateCreationsController < JSONAPI::ResourceController + # By default JSONAPI::ResourceController provides most the standard + # behaviour, and in many cases this file may be left empty. + end + end +end diff --git a/app/resources/api/v2/pooled_plate_creation_resource.rb b/app/resources/api/v2/pooled_plate_creation_resource.rb new file mode 100644 index 0000000000..958d9449c8 --- /dev/null +++ b/app/resources/api/v2/pooled_plate_creation_resource.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +module Api + module V2 + # @todo This documentation does not yet include a detailed description of what this resource represents. + # @todo This documentation does not yet include detailed descriptions for relationships, attributes and filters. + # @todo This documentation does not yet include any example usage of the API via cURL or similar. + # + # @note This resource cannot be modified after creation: its endpoint will not accept `PATCH` requests. + # @note Access this resource via the `/api/v2/pooled_plate_creation/` endpoint. + # + # Provides a JSON:API representation of {PooledPlateCreation}. + # + # For more information about JSON:API see the [JSON:API Specifications](https://jsonapi.org/format/) + # or look at the [JSONAPI::Resources](http://jsonapi-resources.com/) package for Sequencescape's implementation + # of the JSON:API standard. + class PooledPlateCreationResource < BaseResource + ### + # Attributes + ### + + # @!attribute [w] child_purpose_uuid + # @param value [String] The UUID of a child purpose to use in the creation of the child plate. + # @return [Void] + attribute :child_purpose_uuid + + def child_purpose_uuid=(value) + @model.child_purpose = Purpose.with_uuid(value).first + end + + # @!attribute [w] parent_uuids + # This is declared for convenience where parents are not available to set as a relationship. + # Setting this attribute alongside the `parents` relationship will prefer the relationship value. + # @deprecated Use the `parents` relationship instead. + # @param value [Array] The UUIDs of labware that will be the parents for the created plate. + # @return [Void] + # @see #parents + attribute :parent_uuids + + def parent_uuids=(value) + @model.parents = value.map { |uuid| Labware.with_uuid(uuid).first } + end + + # @!attribute [w] user_uuid + # This is declared for convenience where the user is not available to set as a relationship. + # Setting this attribute alongside the `user` relationship will prefer the relationship value. + # @deprecated Use the `user` relationship instead. + # @param value [String] The UUID of the user who initiated the creation of this pooled plate. + # @return [Void] + # @see #user + attribute :user_uuid + + def user_uuid=(value) + @model.user = User.with_uuid(value).first + end + + # @!attribute [r] uuid + # @return [String] The UUID of the state change. + attribute :uuid, readonly: true + + ### + # Relationships + ### + + # @!attribute [r] child + # @return [PlateResource] The child plate which was created. + has_many :child, class_name: 'Plate' + + # @!attribute [rw] parents + # Setting this relationship alongside the `parent_uuids` attribute will override the attribute value. + # @return [Array] An array of the parents of the plate being created. + # @note This relationship is required. + has_many :parents, class_name: 'Labware' + + # @!attribute [rw] user + # Setting this relationship alongside the `user_uuid` attribute will override the attribute value. + # @return [UserResource] The user who initiated the creation of the pooled plate. + # @note This relationship is required. + has_one :user + + def self.creatable_fields(context) + # UUID is set by the system. + super - %i[uuid] + end + + def fetchable_fields + # The tube_attributes attribute is only available during resource creation. + # UUIDs for relationships are not fetchable. They should be accessed via the relationship itself. + super - %i[child_purpose_uuid parent_uuids user_uuid] + end + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 575a660901..4367197daf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -39,6 +39,7 @@ jsonapi_resources :plate_templates jsonapi_resources :plates jsonapi_resources :poly_metadata + jsonapi_resources :pooled_plate_creations, except: %i[update] jsonapi_resources :pre_capture_pools jsonapi_resources :primer_panels jsonapi_resources :projects From 3a8e12200d2ae09141cce97e2407fb4d60d56991 Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Thu, 19 Sep 2024 14:05:38 +0100 Subject: [PATCH 074/158] add test --- app/models/comment.rb | 6 +++--- spec/models/comment_spec.rb | 26 +++++++++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 329d221530..c792088dbc 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -34,13 +34,13 @@ def self.counts_for(commentables) # @return [Hash] Hash of counts indexed by request_id # def self.counts_for_requests(requests) # rubocop:todo Metrics/AbcSize - all_commentables = requests.flat_map { |request| [request, request.try(:asset), request.try(:asset).try(:labware)] } + all_commentables = requests.flat_map { |request| [request, request.asset, request.asset&.labware] } counts = where(commentable: all_commentables.compact).group(:commentable_type, :commentable_id).count requests.each_with_object({}) do |request, counter_cache| request_count = counts.fetch(['Request', request.id], 0) - receptacle_count = counts.fetch(['Receptacle', request.try(:asset_id)], 0) - labware_count = counts.fetch(['Labware', request.try(:asset).try(:labware_id)], 0) + receptacle_count = counts.fetch(['Receptacle', request.asset_id], 0) + labware_count = counts.fetch(['Labware', request.asset&.labware_id], 0) counter_cache[request.id] = request_count + receptacle_count + labware_count end end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 153ea85bee..97b52c8206 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -18,17 +18,29 @@ end describe '#counts_for_requests' do - let(:request) { create :sequencing_request, asset: tube } + let(:request1) { create :sequencing_request, asset: tube } let(:tube) { create :multiplexed_library_tube } - before do - create :comment, commentable: tube, description: 'An excellent tube' - create :comment, commentable: tube.receptacle, description: 'A good receptacle' - create :comment, commentable: request, description: 'A reasonable request' + let(:request2) { create :sequencing_request } + + context 'when request has asset' do + before do + create :comment, commentable: tube, description: 'An excellent tube' + create :comment, commentable: tube.receptacle, description: 'A good receptacle' + create :comment, commentable: request1, description: 'A reasonable request1' + end + + it 'counts comments on requests, their assets and receptacles' do + expect(described_class.counts_for_requests([request1])).to eq({ request1.id => 3 }) + end end - it 'counts comments on requests, their assets and receptacles' do - expect(described_class.counts_for_requests([request])).to eq({ request.id => 3 }) + context 'when request has no asset' do + before { create :comment, commentable: request2, description: 'A reasonable request2' } + + it 'counts comments on requests only' do + expect(described_class.counts_for_requests([request2])).to eq({ request2.id => 1 }) + end end end From cc0703d6edc2dfd22fefb800df6d04eb4a4da24e Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Thu, 19 Sep 2024 14:26:13 +0100 Subject: [PATCH 075/158] refactor the tests --- spec/models/comment_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 97b52c8206..e0e14f2c2d 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -18,28 +18,28 @@ end describe '#counts_for_requests' do - let(:request1) { create :sequencing_request, asset: tube } - let(:tube) { create :multiplexed_library_tube } - - let(:request2) { create :sequencing_request } - context 'when request has asset' do + let(:request) { create :sequencing_request, asset: tube } + let(:tube) { create :multiplexed_library_tube } + before do create :comment, commentable: tube, description: 'An excellent tube' create :comment, commentable: tube.receptacle, description: 'A good receptacle' - create :comment, commentable: request1, description: 'A reasonable request1' + create :comment, commentable: request, description: 'A reasonable request' end it 'counts comments on requests, their assets and receptacles' do - expect(described_class.counts_for_requests([request1])).to eq({ request1.id => 3 }) + expect(described_class.counts_for_requests([request])).to eq({ request.id => 3 }) end end context 'when request has no asset' do - before { create :comment, commentable: request2, description: 'A reasonable request2' } + let(:request) { create :sequencing_request } + + before { create :comment, commentable: request, description: 'A reasonable request' } it 'counts comments on requests only' do - expect(described_class.counts_for_requests([request2])).to eq({ request2.id => 1 }) + expect(described_class.counts_for_requests([request])).to eq({ request.id => 1 }) end end end From 7f7be81c751e561df72916251e31ebce1d5adc58 Mon Sep 17 00:00:00 2001 From: Harriet Craven Date: Thu, 19 Sep 2024 14:48:51 +0100 Subject: [PATCH 076/158] added comment --- config/sample_manifest_excel/columns.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/sample_manifest_excel/columns.yml b/config/sample_manifest_excel/columns.yml index c045eb2e81..ff069169a7 100644 --- a/config/sample_manifest_excel/columns.yml +++ b/config/sample_manifest_excel/columns.yml @@ -498,7 +498,7 @@ dna_source: empty_cell: is_error: date_of_sample_collection: - heading: DATE OF SAMPLE COLLECTION (YYYY-MM-DD) + heading: DATE OF SAMPLE COLLECTION (YYY-MM-DD) # Correcting this typo to YYYY-MM-DD prevents manifests to be re-uploaded unlocked: true validation: options: From 2ef64d8a2c7f7b1abfe2daf12b670ffa8a0c3b88 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 19 Sep 2024 14:52:23 +0100 Subject: [PATCH 077/158] Use correct plurality for child relationship --- app/resources/api/v2/pooled_plate_creation_resource.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/resources/api/v2/pooled_plate_creation_resource.rb b/app/resources/api/v2/pooled_plate_creation_resource.rb index 958d9449c8..3db50371c7 100644 --- a/app/resources/api/v2/pooled_plate_creation_resource.rb +++ b/app/resources/api/v2/pooled_plate_creation_resource.rb @@ -64,7 +64,7 @@ def user_uuid=(value) # @!attribute [r] child # @return [PlateResource] The child plate which was created. - has_many :child, class_name: 'Plate' + has_one :child, class_name: 'Plate' # @!attribute [rw] parents # Setting this relationship alongside the `parent_uuids` attribute will override the attribute value. From 366b02362b3cf118b6aa7eade8a1973f032756ad Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 19 Sep 2024 15:08:02 +0100 Subject: [PATCH 078/158] Create attribute/relationship tests for PooledPlateCreationResource --- spec/factories/pooled_plate_creation.rb | 12 ++++++++++ .../v2/pooled_plate_creation_resource_spec.rb | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 spec/factories/pooled_plate_creation.rb create mode 100644 spec/resources/api/v2/pooled_plate_creation_resource_spec.rb diff --git a/spec/factories/pooled_plate_creation.rb b/spec/factories/pooled_plate_creation.rb new file mode 100644 index 0000000000..785555881b --- /dev/null +++ b/spec/factories/pooled_plate_creation.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory(:pooled_plate_creation) do + child_purpose { |target| target.association(:plate_purpose) } + user { |target| target.association(:user) } + + # When giving a tube as a parent, we change the prefix away from NT to avoid clashes with tubes created as children + # by other instances of this model. + parents { |target| [target.association(:plate), target.association(:tube, prefix: 'PT')] } + end +end diff --git a/spec/resources/api/v2/pooled_plate_creation_resource_spec.rb b/spec/resources/api/v2/pooled_plate_creation_resource_spec.rb new file mode 100644 index 0000000000..0f076f663f --- /dev/null +++ b/spec/resources/api/v2/pooled_plate_creation_resource_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'rails_helper' +require './app/resources/api/v2/pooled_plate_creation_resource' + +RSpec.describe Api::V2::PooledPlateCreationResource, type: :resource do + subject(:resource) { described_class.new(resource_model, {}) } + + let(:resource_model) { build_stubbed :pooled_plate_creation } + + # Attributes + it { is_expected.to have_readonly_attribute :uuid } + + it { is_expected.to have_writeonly_attribute :child_purpose_uuid } + it { is_expected.to have_writeonly_attribute :parent_uuids } + it { is_expected.to have_writeonly_attribute :user_uuid } + + # Relationships + it { is_expected.to have_one(:child).with_class_name('Plate') } + it { is_expected.to have_many(:parents).with_class_name('Labware') } + it { is_expected.to have_one(:user).with_class_name('User') } +end From 7f58ee0aabffcf2f40d6969672ee139bcd2543f3 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Thu, 19 Sep 2024 16:04:30 +0100 Subject: [PATCH 079/158] feat(cardinal-pbmc-parse): adds total_cell_count to qc results --- .../parsers/cardinal_pbmc_count_parser.rb | 4 ++- .../cardinal_pbmc_count_parser_spec.rb | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/models/parsers/cardinal_pbmc_count_parser.rb b/app/models/parsers/cardinal_pbmc_count_parser.rb index c6489be771..31fb3b65c1 100644 --- a/app/models/parsers/cardinal_pbmc_count_parser.rb +++ b/app/models/parsers/cardinal_pbmc_count_parser.rb @@ -38,8 +38,9 @@ def rows end # 0 - well name - # 2 - cell count + # 2 - live cell count # 4 - viability + # 9 - total cell count def qc_data @qc_data ||= {}.tap do |qc_data| @@ -67,6 +68,7 @@ def each_well_and_parameters(&block) def qc_metrics_hash(row) {}.tap do |hash| hash[:live_cell_count] = Unit.new(row[2], 'cells') + hash[:total_cell_count] = Unit.new(row[9], 'cells') viability = row[4] hash[:viability] = Unit.new(viability) unless viability == 'NaN' end diff --git a/spec/models/parsers/cardinal_pbmc_count_parser_spec.rb b/spec/models/parsers/cardinal_pbmc_count_parser_spec.rb index a4f0c2988c..7b659b28f2 100644 --- a/spec/models/parsers/cardinal_pbmc_count_parser_spec.rb +++ b/spec/models/parsers/cardinal_pbmc_count_parser_spec.rb @@ -54,6 +54,7 @@ def read_file(filename) expect(row[0]).to eq('DN871908M:A1') expect(row[2]).to eq('2030000') expect(row[4]).to eq('75.00%') + expect(row[9]).to eq('2710000') end it 'will have the correct csv for well H1' do @@ -61,6 +62,7 @@ def read_file(filename) expect(row[0]).to eq('DN871908M:H1') expect(row[2]).to eq('1940000') expect(row[4]).to eq('74.00%') + expect(row[9]).to eq('2610000') end end @@ -75,12 +77,14 @@ def read_file(filename) row = qc_data['A1'] expect(row[:live_cell_count]).to eq(Unit.new('2030000', 'cells')) expect(row[:viability]).to eq(Unit.new('75.00', '%')) + expect(row[:total_cell_count]).to eq(Unit.new('2710000', 'cells')) end it 'will have the correct data for well H1' do row = qc_data['H1'] expect(row[:live_cell_count]).to eq(Unit.new('1940000', 'cells')) expect(row[:viability]).to eq(Unit.new('74.00', '%')) + expect(row[:total_cell_count]).to eq(Unit.new('2610000', 'cells')) end end end @@ -117,13 +121,14 @@ def read_file(filename) end it 'will have cell count and viability metrics for the normal row' do - expect(parser.qc_data['A4'].keys).to eq(%i[live_cell_count viability]) + expect(parser.qc_data['A4'].keys).to eq(%i[live_cell_count total_cell_count viability]) end it 'will have just cell count for the rows with 0 cells' do - expect(parser.qc_data['A5'].keys).to eq([:live_cell_count]) - expect(parser.qc_data['E5'].keys).to eq([:live_cell_count]) + expect(parser.qc_data['A5'].keys).to eq([:live_cell_count, :total_cell_count]) + expect(parser.qc_data['E5'].keys).to eq([:live_cell_count, :total_cell_count]) expect(parser.qc_data['E5'][:live_cell_count].zero?).to be(true) + expect(parser.qc_data['E5'][:total_cell_count].zero?).to be(true) end end @@ -138,7 +143,7 @@ def read_file(filename) before { plate.update_qc_values_with_parser(parser) } it 'will have the correct number of results' do - expect(QcResult.count).to eq(16) + expect(QcResult.count).to eq(24) end it 'will create the qc results for well A1' do @@ -158,6 +163,13 @@ def read_file(filename) expect(qc_result.units).to eq('cells/ml') expect(qc_result.assay_type).to eq('Cardinal_PBMC_Count') expect(qc_result.assay_version).to eq('v1.0') + + qc_result = qc_results.find_by(key: 'total_cell_count') + + expect(qc_result.value).to eq('2710000') + expect(qc_result.units).to eq('cells/ml') + expect(qc_result.assay_type).to eq('Cardinal_PBMC_Count') + expect(qc_result.assay_version).to eq('v1.0') end it 'will create the qc results for well H1' do @@ -173,6 +185,11 @@ def read_file(filename) expect(qc_result.value).to eq('1940000') expect(qc_result.units).to eq('cells/ml') + + qc_result = qc_results.find_by(key: 'total_cell_count') + + expect(qc_result.value).to eq('2610000') + expect(qc_result.units).to eq('cells/ml') end end end From 9fc4fd313cff37d00f966943a8c90a54f90506ac Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 19 Sep 2024 16:43:06 +0100 Subject: [PATCH 080/158] Add request tests for PooledPlateCreations --- .../api/v2/pooled_plate_creations_spec.rb | 286 ++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 spec/requests/api/v2/pooled_plate_creations_spec.rb diff --git a/spec/requests/api/v2/pooled_plate_creations_spec.rb b/spec/requests/api/v2/pooled_plate_creations_spec.rb new file mode 100644 index 0000000000..f61fde5046 --- /dev/null +++ b/spec/requests/api/v2/pooled_plate_creations_spec.rb @@ -0,0 +1,286 @@ +# frozen_string_literal: true + +require 'rails_helper' +require './spec/requests/api/v2/shared_examples/api_key_authenticatable' +require './spec/requests/api/v2/shared_examples/post_requests' + +describe 'Pooled Plate Creations API', with: :api_v2 do + let(:model_class) { PooledPlateCreation } + let(:base_endpoint) { "/api/v2/#{resource_type}" } + let(:resource_type) { model_class.name.demodulize.pluralize.underscore } + + it_behaves_like 'ApiKeyAuthenticatable' + + include BarcodeHelper + before { mock_plate_barcode_service } + + context 'with a list of resources' do + let(:resource_count) { 5 } + + before do + create_list(:pooled_plate_creation, resource_count) + end + + describe '#GET all resources' do + before { api_get base_endpoint } + + it 'responds with a success http code' do + expect(response).to have_http_status(:success) + end + + it 'returns all the resources' do + expect(json['data'].length).to eq(resource_count) + end + end + end + + context 'with a single resource' do + describe '#GET resource by ID' do + let(:resource) { create :pooled_plate_creation } + + context 'without included relationships' do + before { api_get "#{base_endpoint}/#{resource.id}" } + + it 'responds with a success http code' do + expect(response).to have_http_status(:success) + end + + it 'returns the correct resource' do + expect(json.dig('data', 'id')).to eq(resource.id.to_s) + expect(json.dig('data', 'type')).to eq(resource_type) + end + + it 'returns the correct attributes' do + expect(json.dig('data', 'attributes', 'uuid')).to eq(resource.uuid) + end + + it 'excludes unfetchable attributes' do + expect(json.dig('data', 'attributes', 'child_purpose_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'parent_uuids')).not_to be_present + expect(json.dig('data', 'attributes', 'tube_attributes')).not_to be_present + end + + it 'returns references to related resources' do + expect(json.dig('data', 'relationships', 'child')).to be_present + expect(json.dig('data', 'relationships', 'parents')).to be_present + expect(json.dig('data', 'relationships', 'user')).to be_present + end + + it 'does not include attributes for related resources' do + expect(json['included']).not_to be_present + end + end + + context 'with included relationships' do + context 'with child' do + let(:related_name) { 'child' } + + it_behaves_like 'a POST request including a has_one relationship' + end + + context 'with parents' do + let(:related_name) { 'parents' } + + it_behaves_like 'a POST request including a has_many relationship' + end + + context 'with user' do + let(:related_name) { 'user' } + + it_behaves_like 'a POST request including a has_one relationship' + end + end + end + end + + describe '#PATCH a resource' do + let(:resource_model) { create :pooled_plate_creation } + let(:purpose) { create :plate_purpose } + let(:payload) do + { data: { id: resource_model.id, type: resource_type, attributes: { child_purpose_uuid: [purpose.uuid] } } } + end + + it 'finds no route for the method' do + expect { api_patch "#{base_endpoint}/#{resource_model.id}", payload }.to raise_error( + ActionController::RoutingError + ) + end + end + + describe '#POST a create request' do + let(:purpose) { create :plate_purpose } + let(:parents) { [create(:plate), create(:tube, prefix: 'PT')] } + let(:user) { create(:user) } + + let(:base_attributes) do + { child_purpose_uuid: purpose.uuid } + end + + let(:parents_relationship) { { data: parents.map { |p| { id: p.id, type: 'labware' } } } } + let(:user_relationship) { { data: { id: user.id, type: 'users' } } } + + context 'with a valid payload' do + shared_examples 'a valid request' do + before { api_post base_endpoint, payload } + + it 'creates a new resource' do + expect { api_post base_endpoint, payload }.to change(model_class, :count).by(1) + end + + it 'responds with success' do + expect(response).to have_http_status(:success) + end + + it 'responds with the correct attributes' do + new_record = model_class.last + + expect(json.dig('data', 'type')).to eq(resource_type) + expect(json.dig('data', 'attributes', 'uuid')).to eq(new_record.uuid) + end + + it 'excludes unfetchable attributes' do + expect(json.dig('data', 'attributes', 'child_purpose_uuid')).not_to be_present + expect(json.dig('data', 'attributes', 'parent_uuids')).not_to be_present + expect(json.dig('data', 'attributes', 'tube_attributes')).not_to be_present + end + + it 'returns references to related resources' do + expect(json.dig('data', 'relationships', 'child')).to be_present + expect(json.dig('data', 'relationships', 'parents')).to be_present + expect(json.dig('data', 'relationships', 'user')).to be_present + end + + it 'applies the relationships to the new record' do + new_record = model_class.last + + expect(new_record.child_purpose).to eq(purpose) + expect(new_record.parents).to eq(parents) + expect(new_record.user).to eq(user) + end + + it 'generated a child with valid attributes' do + new_record = model_class.last + + expect(new_record.child.purpose).to eq(purpose) + end + end + + context 'with complete attributes' do + let(:payload) do + { + data: { + type: resource_type, + attributes: + base_attributes.merge( + { + parent_uuids: parents.map(&:uuid), + user_uuid: user.uuid + } + ) + } + } + end + + it_behaves_like 'a valid request' + end + + context 'with relationships' do + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes, + relationships: { + parents: parents_relationship, + user: user_relationship + } + } + } + end + + it_behaves_like 'a valid request' + end + + context 'with conflicting relationships' do + let(:other_parents) { create_list :plate, 2 } + let(:other_user) { create :user } + let(:payload) do + { + data: { + type: resource_type, + attributes: + base_attributes.merge({ parent_uuids: other_parents.map(&:uuid), user_uuid: other_user.uuid }), + relationships: { + parents: parents_relationship, + user: user_relationship + } + } + } + end + + # This test should pass because the relationships are preferred over the attributes. + it_behaves_like 'a valid request' + end + end + + context 'with a read-only attribute in the payload' do + context 'with uuid' do + let(:disallowed_attribute) { 'uuid' } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes.merge({ uuid: '111111-2222-3333-4444-555555666666' }) + } + } + end + + it_behaves_like 'a POST request with a disallowed attribute' + end + end + + context 'without a required relationship' do + context 'without parent_uuids' do + let(:error_detail_message) { "parent - can't be blank" } + let(:payload) { { data: { type: resource_type, attributes: base_attributes.merge({ user_uuid: user.uuid }) } } } + + it_behaves_like 'an unprocessable POST request with a specific error' + end + + context 'without user_uuid' do + let(:error_detail_message) { "user - can't be blank" } + let(:payload) do + { data: { type: resource_type, attributes: base_attributes.merge({ parent_uuids: parents.map(&:uuid) }) } } + end + + it_behaves_like 'an unprocessable POST request with a specific error' + end + + context 'without parents' do + let(:error_detail_message) { "parent - can't be blank" } + let(:payload) do + { data: { type: resource_type, attributes: base_attributes, relationships: { user: user_relationship } } } + end + + it_behaves_like 'an unprocessable POST request with a specific error' + end + + context 'without user' do + let(:error_detail_message) { "user - can't be blank" } + let(:payload) do + { + data: { + type: resource_type, + attributes: base_attributes, + relationships: { + parents: parents_relationship + } + } + } + end + + it_behaves_like 'an unprocessable POST request with a specific error' + end + end + end +end From 0a8ac9d021256c1c23056b0b145127fb5259aa9a Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 19 Sep 2024 17:02:33 +0100 Subject: [PATCH 081/158] Rubocop and prettier --- .../api/v2/pooled_plate_creations_spec.rb | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/spec/requests/api/v2/pooled_plate_creations_spec.rb b/spec/requests/api/v2/pooled_plate_creations_spec.rb index f61fde5046..b8798b7f7e 100644 --- a/spec/requests/api/v2/pooled_plate_creations_spec.rb +++ b/spec/requests/api/v2/pooled_plate_creations_spec.rb @@ -9,17 +9,15 @@ let(:base_endpoint) { "/api/v2/#{resource_type}" } let(:resource_type) { model_class.name.demodulize.pluralize.underscore } - it_behaves_like 'ApiKeyAuthenticatable' - include BarcodeHelper before { mock_plate_barcode_service } + it_behaves_like 'ApiKeyAuthenticatable' + context 'with a list of resources' do let(:resource_count) { 5 } - before do - create_list(:pooled_plate_creation, resource_count) - end + before { create_list(:pooled_plate_creation, resource_count) } describe '#GET all resources' do before { api_get base_endpoint } @@ -112,9 +110,7 @@ let(:parents) { [create(:plate), create(:tube, prefix: 'PT')] } let(:user) { create(:user) } - let(:base_attributes) do - { child_purpose_uuid: purpose.uuid } - end + let(:base_attributes) { { child_purpose_uuid: purpose.uuid } } let(:parents_relationship) { { data: parents.map { |p| { id: p.id, type: 'labware' } } } } let(:user_relationship) { { data: { id: user.id, type: 'users' } } } @@ -170,13 +166,7 @@ { data: { type: resource_type, - attributes: - base_attributes.merge( - { - parent_uuids: parents.map(&:uuid), - user_uuid: user.uuid - } - ) + attributes: base_attributes.merge({ parent_uuids: parents.map(&:uuid), user_uuid: user.uuid }) } } end From 219a09ee219648319cbfd97d9d5c0dc15ff7a28f Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 19 Sep 2024 17:05:26 +0100 Subject: [PATCH 082/158] Remove unnecessary override of Tube prefixes in factory --- spec/factories/pooled_plate_creation.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/factories/pooled_plate_creation.rb b/spec/factories/pooled_plate_creation.rb index 785555881b..dc28ba39ba 100644 --- a/spec/factories/pooled_plate_creation.rb +++ b/spec/factories/pooled_plate_creation.rb @@ -3,10 +3,7 @@ FactoryBot.define do factory(:pooled_plate_creation) do child_purpose { |target| target.association(:plate_purpose) } + parents { |target| [target.association(:plate), target.association(:tube)] } user { |target| target.association(:user) } - - # When giving a tube as a parent, we change the prefix away from NT to avoid clashes with tubes created as children - # by other instances of this model. - parents { |target| [target.association(:plate), target.association(:tube, prefix: 'PT')] } end end From 4605a7482c6a4cab9215f9930545f0b3c18fb1b1 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 19 Sep 2024 17:46:31 +0100 Subject: [PATCH 083/158] Jump through hoops to avoid calling Baracoda during tests --- app/models/plate_creation.rb | 2 +- spec/factories/pooled_plate_creation.rb | 3 ++- spec/requests/api/v2/pooled_plate_creations_spec.rb | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/models/plate_creation.rb b/app/models/plate_creation.rb index 84cd06da7e..411ff9a4cf 100644 --- a/app/models/plate_creation.rb +++ b/app/models/plate_creation.rb @@ -34,7 +34,7 @@ def children private :children def create_children! - self.child = child_purpose.create!(barcode: barcode) + self.child = child_purpose.create!(sanger_barcode: barcode) end private :create_children! end diff --git a/spec/factories/pooled_plate_creation.rb b/spec/factories/pooled_plate_creation.rb index dc28ba39ba..756ab779ec 100644 --- a/spec/factories/pooled_plate_creation.rb +++ b/spec/factories/pooled_plate_creation.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true FactoryBot.define do - factory(:pooled_plate_creation) do + factory :pooled_plate_creation do + barcode { create(:plate_barcode) } child_purpose { |target| target.association(:plate_purpose) } parents { |target| [target.association(:plate), target.association(:tube)] } user { |target| target.association(:user) } diff --git a/spec/requests/api/v2/pooled_plate_creations_spec.rb b/spec/requests/api/v2/pooled_plate_creations_spec.rb index b8798b7f7e..e029379ed4 100644 --- a/spec/requests/api/v2/pooled_plate_creations_spec.rb +++ b/spec/requests/api/v2/pooled_plate_creations_spec.rb @@ -9,9 +9,6 @@ let(:base_endpoint) { "/api/v2/#{resource_type}" } let(:resource_type) { model_class.name.demodulize.pluralize.underscore } - include BarcodeHelper - before { mock_plate_barcode_service } - it_behaves_like 'ApiKeyAuthenticatable' context 'with a list of resources' do @@ -115,6 +112,11 @@ let(:parents_relationship) { { data: parents.map { |p| { id: p.id, type: 'labware' } } } } let(:user_relationship) { { data: { id: user.id, type: 'users' } } } + # Mock the plate barcode service because it is not available in the test environment. + # This wasn't needed above because the only records being created were via the factory which supplies a barcode. + include BarcodeHelper + before { mock_plate_barcode_service } + context 'with a valid payload' do shared_examples 'a valid request' do before { api_post base_endpoint, payload } From fee438c5a91cdf166385e7d76dd973fce9716a29 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 19 Sep 2024 18:21:54 +0100 Subject: [PATCH 084/158] Continue to fight with tests trying to go to Baracoda --- app/models/plate_creation.rb | 3 ++- app/models/pooled_plate_creation.rb | 2 +- features/api/plate_creations.feature | 2 +- spec/factories/pooled_plate_creation.rb | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/models/plate_creation.rb b/app/models/plate_creation.rb index 411ff9a4cf..04cc1537c7 100644 --- a/app/models/plate_creation.rb +++ b/app/models/plate_creation.rb @@ -7,6 +7,7 @@ class PlateCreation < AssetCreation # This is the child that is created from the parent. It cannot be assigned before validation. belongs_to :parent, class_name: 'Plate' attr_accessor :barcode + attr_accessor :sanger_barcode def record_creation_of_children parent.events.create_plate!(child_purpose, child, user) @@ -34,7 +35,7 @@ def children private :children def create_children! - self.child = child_purpose.create!(sanger_barcode: barcode) + self.child = child_purpose.create!(sanger_barcode: sanger_barcode) end private :create_children! end diff --git a/app/models/pooled_plate_creation.rb b/app/models/pooled_plate_creation.rb index dc6f4e4001..9ddb938606 100644 --- a/app/models/pooled_plate_creation.rb +++ b/app/models/pooled_plate_creation.rb @@ -2,7 +2,7 @@ # Creating an instance of this class causes a child plate, with the specified plate type, to be created from # the parent. class PooledPlateCreation < AssetCreation - attr_accessor :barcode + attr_accessor :sanger_barcode has_many :parent_associations, foreign_key: 'asset_creation_id', class_name: 'AssetCreation::ParentAssociation' diff --git a/features/api/plate_creations.feature b/features/api/plate_creations.feature index b4ad4bd126..6d74b77e6f 100644 --- a/features/api/plate_creations.feature +++ b/features/api/plate_creations.feature @@ -12,7 +12,7 @@ Feature: Access plate creations through the API And the WTSI single sign-on service recognises "I-am-authenticated" as "John Smith" Given I am using the latest version of the API -And I have a "full" authorised user with the key "cucumber" + And I have a "full" authorised user with the key "cucumber" Given a user with UUID "99999999-8888-7777-6666-555555555555" exists diff --git a/spec/factories/pooled_plate_creation.rb b/spec/factories/pooled_plate_creation.rb index 756ab779ec..b60b41a6d8 100644 --- a/spec/factories/pooled_plate_creation.rb +++ b/spec/factories/pooled_plate_creation.rb @@ -2,7 +2,9 @@ FactoryBot.define do factory :pooled_plate_creation do - barcode { create(:plate_barcode) } + # Without this, create_children! tries to go to Baracoda for a barcode. + sanger_barcode { create(:plate_barcode) } + child_purpose { |target| target.association(:plate_purpose) } parents { |target| [target.association(:plate), target.association(:tube)] } user { |target| target.association(:user) } From ae8be7db44cb54123165e0bf1dc9b92ee75604c8 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Fri, 20 Sep 2024 10:45:28 +0100 Subject: [PATCH 085/158] style: prettier'd --- spec/models/parsers/cardinal_pbmc_count_parser_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/models/parsers/cardinal_pbmc_count_parser_spec.rb b/spec/models/parsers/cardinal_pbmc_count_parser_spec.rb index 7b659b28f2..927e6758f2 100644 --- a/spec/models/parsers/cardinal_pbmc_count_parser_spec.rb +++ b/spec/models/parsers/cardinal_pbmc_count_parser_spec.rb @@ -125,8 +125,8 @@ def read_file(filename) end it 'will have just cell count for the rows with 0 cells' do - expect(parser.qc_data['A5'].keys).to eq([:live_cell_count, :total_cell_count]) - expect(parser.qc_data['E5'].keys).to eq([:live_cell_count, :total_cell_count]) + expect(parser.qc_data['A5'].keys).to eq(%i[live_cell_count total_cell_count]) + expect(parser.qc_data['E5'].keys).to eq(%i[live_cell_count total_cell_count]) expect(parser.qc_data['E5'][:live_cell_count].zero?).to be(true) expect(parser.qc_data['E5'][:total_cell_count].zero?).to be(true) end From e2743ef7cf6768267180dd9d42477fa23954c080 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 20 Sep 2024 11:17:39 +0100 Subject: [PATCH 086/158] added request_metadata api v2 endpoint --- .../api/v2/request_metadata_controller.rb | 12 +++++ .../api/v2/request_metadata_resource.rb | 48 +++++++++++++++++++ config/initializers/inflections.rb | 2 +- config/locales/metadata/en.yml | 6 +++ config/routes.rb | 1 + 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 app/controllers/api/v2/request_metadata_controller.rb create mode 100644 app/resources/api/v2/request_metadata_resource.rb diff --git a/app/controllers/api/v2/request_metadata_controller.rb b/app/controllers/api/v2/request_metadata_controller.rb new file mode 100644 index 0000000000..1145c42c0d --- /dev/null +++ b/app/controllers/api/v2/request_metadata_controller.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Api + module V2 + # Provides a JSON API controller for RequestMetadata + # See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation + class RequestMetadataController < JSONAPI::ResourceController + # By default JSONAPI::ResourceController provides most the standard + # behaviour, and in many cases this file may be left empty. + end + end +end diff --git a/app/resources/api/v2/request_metadata_resource.rb b/app/resources/api/v2/request_metadata_resource.rb new file mode 100644 index 0000000000..7ca444d639 --- /dev/null +++ b/app/resources/api/v2/request_metadata_resource.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +module Api + module V2 + # @todo This documentation does not yet include a detailed description of what this resource represents. + # @todo This documentation does not yet include detailed descriptions for relationships, attributes and filters. + # @todo This documentation does not yet include any example usage of the API via cURL or similar. + # + # @note Access this resource via the `/api/v2/requests_metadata/` endpoint. + # + # Provides a JSON:API representation of {Request::Metadata}. + # + # For more information about JSON:API see the [JSON:API Specifications](https://jsonapi.org/format/) + # or look at the [JSONAPI::Resources](http://jsonapi-resources.com/) package for Sequencescape's implementation + # of the JSON:API standard. + class RequestMetadataResource < BaseResource + # NB. request_metadata has been added to config/initializers/inflections.rb to make this class name work otherwise it + # expects RequestMetadatumResource + + # Sets add_model_hint true by default, this allows updates from Limber, otherwise get a + # 500 error as it looks for resource Api::V2::MetadatumResource + model_name 'Request::Metadata' + + # Associations: + has_one :request + + ### + # Attributes + ### + + # @!attribute [r] number_of_samples_per_pool + # @return [Int] the number_of_samples_per_pool. + attribute :number_of_samples_per_pool, readonly: true + + # @!attribute [r] cells_per_chip_well + # @return [Int] the cells_per_chip_well. + attribute :cells_per_chip_well, readonly: true + + # Filters + + # Custom methods + # These shouldn't be used for business logic, and a more about + # I/O and isolating implementation details. + + # Class method overrides + end + end +end diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 8e830495a5..b5b6344f9d 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -11,7 +11,7 @@ # inflect.uncountable %w( fish sheep ) # end -ActiveSupport::Inflector.inflections(:en) { |inflect| inflect.uncountable %w[health sample_metadata labware] } +ActiveSupport::Inflector.inflections(:en) { |inflect| inflect.uncountable %w[health sample_metadata request_metadata labware] } # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| diff --git a/config/locales/metadata/en.yml b/config/locales/metadata/en.yml index d9ca5560aa..2abb785013 100644 --- a/config/locales/metadata/en.yml +++ b/config/locales/metadata/en.yml @@ -58,6 +58,12 @@ en: requested_flowcell_type: label: Flowcell type + number_of_samples_per_pool: + label: Number of samples per pool + + cells_per_chip_well: + label: Cells per chip well + library_creation_request: <<: *REQUEST sequencing_request: diff --git a/config/routes.rb b/config/routes.rb index 62092406f7..2140b91d64 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -43,6 +43,7 @@ jsonapi_resources :qcables jsonapi_resources :racked_tubes jsonapi_resources :receptacles + jsonapi_resources :request_metadata jsonapi_resources :request_types jsonapi_resources :requests jsonapi_resources :samples From 4581a3c26eeb53d329ad1473f8b98a44679e5b04 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Fri, 20 Sep 2024 13:35:38 +0100 Subject: [PATCH 087/158] tests: correct qcresult count for qc file api --- spec/requests/qc_files_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/requests/qc_files_spec.rb b/spec/requests/qc_files_spec.rb index 83d3f5714e..443f76ea9b 100644 --- a/spec/requests/qc_files_spec.rb +++ b/spec/requests/qc_files_spec.rb @@ -22,7 +22,7 @@ expect(response).to have_http_status(:success) - expect(QcResult.count).to eq(16) + expect(QcResult.count).to eq(24) end end end From ffe6d495375624bacc6d3c056a44d0af577fd9ae Mon Sep 17 00:00:00 2001 From: Shiv <44001656+SHIV5T3R@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:10:41 +0100 Subject: [PATCH 088/158] Added chrome65 + es2019 as vite build targets --- app/frontend/.eslintrc.js | 1 + vite.config.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/frontend/.eslintrc.js b/app/frontend/.eslintrc.js index 9131da78f5..5325db6df8 100644 --- a/app/frontend/.eslintrc.js +++ b/app/frontend/.eslintrc.js @@ -11,6 +11,7 @@ module.exports = { parserOptions: { parser: "babel-eslint", sourceType: "module", + ecmaVersion: 2018, }, rules: { "no-unused-vars": [ diff --git a/vite.config.ts b/vite.config.ts index 1abea1717d..d97d2c4b44 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,7 +5,10 @@ import { createVuePlugin } from "vite-plugin-vue2"; import legacy from "@vitejs/plugin-legacy"; export default defineConfig({ - build: { emptyOutDir: true }, + build: { + emptyOutDir: true, + target: ["chrome65", "es2019"], + }, plugins: [RubyPlugin(), createVuePlugin(), legacy({ targets: ["defaults"] })], resolve: { alias: { From b9be22b29aa507332ab3d55a7458f67ccbd054ef Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 20 Sep 2024 14:23:35 +0100 Subject: [PATCH 089/158] build: update rubocop --- Gemfile.lock | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0437a39463..047bd74524 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -305,8 +305,8 @@ GEM racc (~> 1.4) nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) - parallel (1.24.0) - parser (3.3.0.5) + parallel (1.26.3) + parser (3.3.5.0) ast (~> 2.4.1) racc prettier_print (1.2.1) @@ -383,14 +383,13 @@ GEM rbs (3.5.1) logger rbtree (0.4.6) - regexp_parser (2.9.0) + regexp_parser (2.9.2) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.3.6) - strscan + rexml (3.3.7) roo (2.10.1) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) @@ -425,19 +424,18 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) - rubocop (1.61.0) + rubocop (1.66.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) 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.30.0, < 2.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.1) - parser (>= 3.3.0.4) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) rubocop-capybara (2.20.0) rubocop (~> 1.41) rubocop-factory_bot (2.25.1) @@ -507,7 +505,6 @@ GEM activesupport (>= 6.1) sprockets (>= 3.0.0) ssrf_filter (1.1.2) - strscan (3.1.0) syntax_tree (6.2.0) prettier_print (>= 1.2.0) syntax_tree-haml (4.0.3) @@ -530,7 +527,7 @@ GEM rails (>= 3.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) + unicode-display_width (2.6.0) uniform_notifier (1.16.0) uuidtools (2.2.0) vite_rails (3.0.17) From a528ee68fe6177457da19e4fba02a5779315f1d6 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 20 Sep 2024 14:31:02 +0100 Subject: [PATCH 090/158] style: update rubocop todo --- .rubocop_todo.yml | 751 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 662 insertions(+), 89 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a63c3341a5..0bba5a4b46 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by -# `rubocop --auto-gen-config --exclude-limit 10000` -# on 2024-03-15 15:37:36 UTC using RuboCop version 1.61.0. +# `rubocop --auto-gen-config --no-exclude-limit` +# on 2024-09-20 13:29:34 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -107,11 +107,10 @@ Lint/DuplicateRegexpCharacterClassElement: Exclude: - 'app/models/barcode/format_handlers.rb' -# Offense count: 67 +# Offense count: 66 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: Exclude: - - 'app/api/core/endpoint/basic_handler/actions/inner_action.rb' - 'app/api/endpoints/asset_groups.rb' - 'app/api/endpoints/assets.rb' - 'app/api/endpoints/barcode_printers.rb' @@ -211,12 +210,10 @@ Lint/MissingSuper: - 'lib/label_printer/label_printer/label/sample_manifest_tube.rb' - 'test/unit/tasks/plate_transfer_task_test.rb' -# Offense count: 3 +# Offense count: 1 # Configuration parameters: AllowedMethods, AllowedPatterns. Lint/NestedMethodDefinition: Exclude: - - 'app/api/endpoints/uuids.rb' - - 'app/middleware/api/root_service.rb' - 'lib/eventful_record.rb' # Offense count: 4 @@ -226,10 +223,16 @@ Lint/NonLocalExitFromIterator: - 'app/api/core/io/json/grammar.rb' - 'app/models/create_asset_request.rb' -# Offense count: 1 +# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). Lint/RedundantCopDisableDirective: - Enabled: false + Exclude: + - 'app/controllers/npg_actions/assets_controller.rb' + - 'app/heron/factories/event.rb' + - 'app/models/barcode/format_handlers.rb' + - 'app/models/illumina_htp/initial_stock_tube_purpose.rb' + - 'app/models/metadata/form_builder.rb' + - 'lib/tasks/retention_instructions.rake' # Offense count: 4 Lint/ReturnInVoidContext: @@ -284,7 +287,7 @@ Lint/UselessAccessModifier: - 'app/models/product_criteria/basic.rb' # Offense count: 67 -# This cop supports unsafe autocorrection (--autocorrect-all). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect. Lint/UselessAssignment: Exclude: @@ -336,32 +339,41 @@ Lint/UselessAssignment: - 'test/lib/label_printer/plate_creator_test.rb' - 'test/unit/tasks/plate_transfer_task_test.rb' -# Offense count: 4 -# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. +# Offense count: 3 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. Metrics/AbcSize: - Max: 24 + Exclude: + - 'app/controllers/api/v2/transfers/transfers_controller.rb' + - 'app/jobs/export_pool_xp_to_traction_job.rb' + - 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb' # Offense count: 1 -# Configuration parameters: CountComments, CountAsOne. +# Configuration parameters: CountComments, Max, CountAsOne. Metrics/ClassLength: - Max: 205 + Exclude: + - 'app/middleware/api/endpoint_handler.rb' -# Offense count: 2 -# Configuration parameters: AllowedMethods, AllowedPatterns. +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns, Max. Metrics/CyclomaticComplexity: - Max: 9 + Exclude: + - 'lib/limber/helper.rb' -# Offense count: 2 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +# Offense count: 9 +# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 12 - -# Offense count: 1 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Metrics/PerceivedComplexity: - Max: 10 - -# Offense count: 14 + Exclude: + - 'app/controllers/tag_layout_templates_controller.rb' + - 'app/jobs/export_pool_xp_to_traction_job.rb' + - 'app/models/plate/quad_creator.rb' + - 'app/models/tag_group/form_object.rb' + - 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/plate.rb' + - 'app/uat_actions/uat_actions/test_submission.rb' + - 'app/uat_actions/uat_actions/tube_submission.rb' + - 'app/validators/novaseqx_pe_validator.rb' + - 'lib/record_loader/application_record_loader.rb' + +# Offense count: 13 Naming/AccessorMethodName: Exclude: - 'app/api/core/io/base/json_formatting_behaviour.rb' @@ -371,7 +383,6 @@ Naming/AccessorMethodName: - 'app/models/broadcast_event.rb' - 'app/models/lib_pool_norm_tube_generator.rb' - 'app/models/receptacle.rb' - - 'app/models/specific_tube_creation.rb' - 'app/models/well.rb' - 'lib/authenticated_system.rb' - 'lib/tasks/add_templates_and_printers_to_pmb.rake' @@ -465,7 +476,7 @@ Naming/PredicateName: - 'lib/has_behaviour.rb' - 'lib/manifest_util.rb' -# Offense count: 242 +# Offense count: 243 # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. # SupportedStyles: snake_case, normalcase, non_integer # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 @@ -592,7 +603,7 @@ RSpec/BeforeAfterAll: - 'spec/sample_manifest_excel/worksheet_spec.rb' - 'spec/sequencescape_excel/worksheet_spec.rb' -# Offense count: 335 +# Offense count: 339 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -674,12 +685,133 @@ RSpec/EmptyExampleGroup: - 'spec/models/pulldown/requests_spec.rb' - 'spec/models/tag_substitutions_spec.rb' -# Offense count: 345 -# Configuration parameters: CountAsOne. +# Offense count: 386 +# Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: - Max: 21 + Exclude: + - 'spec/api/extraction_attributes_spec.rb' + - 'spec/bulk_submission_excel/configuration_spec.rb' + - 'spec/bulk_submission_excel/data_worksheet_spec.rb' + - 'spec/controllers/npg_actions/assets_controller_spec.rb' + - 'spec/controllers/studies_controller_spec.rb' + - 'spec/controllers/submissions_controller_spec.rb' + - 'spec/lib/accession/accessionable_spec.rb' + - 'spec/lib/accession/request_spec.rb' + - 'spec/lib/accession/sample_spec.rb' + - 'spec/lib/accession/service_spec.rb' + - 'spec/lib/accession/study_spec.rb' + - 'spec/lib/accession/submission_spec.rb' + - 'spec/lib/accession/tag_list_spec.rb' + - 'spec/lib/accession/tag_spec.rb' + - 'spec/lib/add_missing_asset_audit_records_spec.rb' + - 'spec/lib/dev/plate_barcode/cache_barcodes_spec.rb' + - 'spec/lib/lab_where_client_spec.rb' + - 'spec/lib/limber/helper_spec.rb' + - 'spec/lib/mbrave_tags_creator_spec.rb' + - 'spec/lib/retention_instructions_spec.rb' + - 'spec/models/aliquot_spec.rb' + - 'spec/models/bait_library_type_spec.rb' + - 'spec/models/barcode_printer_spec.rb' + - 'spec/models/batch_spec.rb' + - 'spec/models/broadcast_event/broadcast_event_spec.rb' + - 'spec/models/bulk_submission_spec.rb' + - 'spec/models/labware_spec.rb' + - 'spec/models/labwhere_reception_spec.rb' + - 'spec/models/lane_spec.rb' + - 'spec/models/linear_submission_spec.rb' + - 'spec/models/location_report_form_spec.rb' + - 'spec/models/map_spec.rb' + - 'spec/models/orders/order_spec.rb' + - 'spec/models/parsers/cardinal_pbmc_count_parser_spec.rb' + - 'spec/models/plate/quad_creator_spec.rb' + - 'spec/models/plate_volume_spec.rb' + - 'spec/models/pooling_spec.rb' + - 'spec/models/primer_panel_spec.rb' + - 'spec/models/qc_report_spec.rb' + - 'spec/models/qc_result/qc_result_factory_spec.rb' + - 'spec/models/qc_result/qc_result_spec.rb' + - 'spec/models/qcable_creator_spec.rb' + - 'spec/models/request/sample_compound_aliquot_transfer_spec.rb' + - 'spec/models/request/statistics/counter_spec.rb' + - 'spec/models/request_spec.rb' + - 'spec/models/sample_manifest/generator_spec.rb' + - 'spec/models/sample_manifest/uploader_spec.rb' + - 'spec/models/sample_manifest_spec.rb' + - 'spec/models/sample_spec.rb' + - 'spec/models/state_changer/mx_tube_spec.rb' + - 'spec/models/stock_stamper_spec.rb' + - 'spec/models/study_spec.rb' + - 'spec/models/submission/submission_creator_spec.rb' + - 'spec/models/submission_spec.rb' + - 'spec/models/tag_layout_template_spec.rb' + - 'spec/models/tag_substitutions_spec.rb' + - 'spec/models/transfer/between_plates_spec.rb' + - 'spec/models/tube_rack_spec.rb' + - 'spec/models/user_query_spec.rb' + - 'spec/models/user_spec.rb' + - 'spec/models/well_attribute_spec.rb' + - 'spec/models/well_spec.rb' + - 'spec/models/work_completion_spec.rb' + - 'spec/models/work_order_spec.rb' + - 'spec/requests/api/v2/barcode_printers_spec.rb' + - 'spec/requests/api/v2/custom_metadatum_collections_spec.rb' + - 'spec/requests/api/v2/heron/tube_racks_spec.rb' + - 'spec/requests/api/v2/labware_spec.rb' + - 'spec/requests/api/v2/plate_purposes_spec.rb' + - 'spec/requests/api/v2/plates_spec.rb' + - 'spec/requests/api/v2/qc_assays_spec.rb' + - 'spec/requests/api/v2/qc_results_spec.rb' + - 'spec/requests/api/v2/sample_metadata_spec.rb' + - 'spec/requests/api/v2/shared_examples/api_key_authenticatable.rb' + - 'spec/requests/api/v2/state_changes_spec.rb' + - 'spec/requests/api/v2/tag_layout_templates_spec.rb' + - 'spec/requests/api/v2/transfers/transfers_spec.rb' + - 'spec/requests/api/v2/tube_purposes_spec.rb' + - 'spec/requests/api/v2/users_spec.rb' + - 'spec/requests/api/v2/volume_update_spec.rb' + - 'spec/requests/api/v2/wells_spec.rb' + - 'spec/requests/users_request_spec.rb' + - 'spec/resources/api/v2/aliquot_resource_spec.rb' + - 'spec/resources/api/v2/lot_resource_spec.rb' + - 'spec/resources/api/v2/lot_type_resource_spec.rb' + - 'spec/resources/api/v2/pick_list_resource_spec.rb' + - 'spec/resources/api/v2/plate_purpose_resource_spec.rb' + - 'spec/resources/api/v2/purpose_resource_spec.rb' + - 'spec/resources/api/v2/qcable_resource_spec.rb' + - 'spec/resources/api/v2/receptacle_resource_spec.rb' + - 'spec/resources/api/v2/request_resource_spec.rb' + - 'spec/resources/api/v2/request_type_resource_spec.rb' + - 'spec/resources/api/v2/sample_metadata_resource_spec.rb' + - 'spec/resources/api/v2/state_change_resource_spec.rb' + - 'spec/resources/api/v2/submission_resource_spec.rb' + - 'spec/resources/api/v2/tag_group_resource_spec.rb' + - 'spec/resources/api/v2/transfers/transfer_resource_spec.rb' + - 'spec/resources/api/v2/tube_rack_resource_spec.rb' + - 'spec/resources/api/v2/tube_resource_spec.rb' + - 'spec/sample_manifest_excel/configuration_spec.rb' + - 'spec/sample_manifest_excel/download_spec.rb' + - 'spec/sample_manifest_excel/manifest_type_list_spec.rb' + - 'spec/sample_manifest_excel/tags_spec.rb' + - 'spec/sample_manifest_excel/upload/data_spec.rb' + - 'spec/sample_manifest_excel/upload/processor_spec.rb' + - 'spec/sample_manifest_excel/upload/row_spec.rb' + - 'spec/sample_manifest_excel/upload/upload_spec.rb' + - 'spec/sample_manifest_excel/worksheet_spec.rb' + - 'spec/sequencescape_excel/column_list_spec.rb' + - 'spec/sequencescape_excel/column_spec.rb' + - 'spec/sequencescape_excel/conditional_formatting_list_spec.rb' + - 'spec/sequencescape_excel/configuration_spec.rb' + - 'spec/sequencescape_excel/formula_spec.rb' + - 'spec/sequencescape_excel/list_spec.rb' + - 'spec/sequencescape_excel/range_list_spec.rb' + - 'spec/sequencescape_excel/specialised_field_spec.rb' + - 'spec/sequencescape_excel/validation_spec.rb' + - 'spec/tasks/support/disable_hiseq_submission_templates_spec.rb' + - 'spec/views/labware/show_chromium_chip_spec.rb' + - 'spec/views/samples/index_html_erb_spec.rb' + - 'spec/views/samples/show_html_erb_spec.rb' -# Offense count: 274 +# Offense count: 291 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. # DisallowedExamples: works @@ -785,7 +917,7 @@ RSpec/LeakyConstantDeclaration: - 'spec/sample_manifest_excel/tags_spec.rb' - 'spec/sequencescape_excel/list_spec.rb' -# Offense count: 39 +# Offense count: 40 RSpec/LetSetup: Exclude: - 'spec/controllers/searches_controller_spec.rb' @@ -842,16 +974,390 @@ RSpec/MultipleDescribes: - 'spec/lib/label_printer/asset_labels_spec.rb' - 'spec/models/qc_result/qc_result_spec.rb' -# Offense count: 815 +# Offense count: 911 +# Configuration parameters: Max. RSpec/MultipleExpectations: - Max: 18 + Exclude: + - 'spec/api/api_root_spec.rb' + - 'spec/api/asset_audit_spec.rb' + - 'spec/api/dilution_plate_purpose_spec.rb' + - 'spec/api/extraction_attributes_spec.rb' + - 'spec/api/labware_spec.rb' + - 'spec/api/multiplexed_library_tube_spec.rb' + - 'spec/api/plate_purpose_spec.rb' + - 'spec/api/plate_spec.rb' + - 'spec/api/qcable_creator_spec.rb' + - 'spec/api/receptacle_spec.rb' + - 'spec/api/request_types_spec.rb' + - 'spec/api/shared_examples.rb' + - 'spec/api/specific_tube_creation_spec.rb' + - 'spec/api/tag_layout_template_spec.rb' + - 'spec/api/transfer_request_collection_spec.rb' + - 'spec/api/tube_creation_spec.rb' + - 'spec/api/tube_purpose_spec.rb' + - 'spec/api/well_spec.rb' + - 'spec/api/work_completion_spec.rb' + - 'spec/bulk_submission_excel/configuration_spec.rb' + - 'spec/bulk_submission_excel/data_worksheet_spec.rb' + - 'spec/bulk_submission_excel/download_spec.rb' + - 'spec/controllers/admin/abilities_controller_spec.rb' + - 'spec/controllers/api/v2/heron/plates_controller_spec.rb' + - 'spec/controllers/api/v2/heron/tube_racks_controller_spec.rb' + - 'spec/controllers/bulk_submission_excel/downloads_controller_spec.rb' + - 'spec/controllers/driver_files_controller_spec.rb' + - 'spec/controllers/labwhere_receptions_controller_spec.rb' + - 'spec/controllers/npg_actions/assets_controller_spec.rb' + - 'spec/controllers/receptacles_controller_spec.rb' + - 'spec/controllers/report_fails_controller_spec.rb' + - 'spec/controllers/robot_verifications_controller_spec.rb' + - 'spec/controllers/studies_controller_spec.rb' + - 'spec/controllers/submissions_controller_spec.rb' + - 'spec/controllers/tag_sets_controller_spec.rb' + - 'spec/helpers/compound_sample_helper_spec.rb' + - 'spec/heron/factories/concerns/contents_spec.rb' + - 'spec/heron/factories/plate_spec.rb' + - 'spec/heron/factories/sample_spec.rb' + - 'spec/heron/factories/tube_spec.rb' + - 'spec/jobs/export_pool_xp_to_traction_job_spec.rb' + - 'spec/lib/accession/accessionable_spec.rb' + - 'spec/lib/accession/configuration_spec.rb' + - 'spec/lib/accession/contact_spec.rb' + - 'spec/lib/accession/request_spec.rb' + - 'spec/lib/accession/response_spec.rb' + - 'spec/lib/accession/sample_spec.rb' + - 'spec/lib/accession/service_spec.rb' + - 'spec/lib/accession/study_spec.rb' + - 'spec/lib/accession/submission_spec.rb' + - 'spec/lib/accession/tag_list_spec.rb' + - 'spec/lib/accession/tag_spec.rb' + - 'spec/lib/add_missing_asset_audit_records_spec.rb' + - 'spec/lib/dev/plate_barcode/cache_barcodes_spec.rb' + - 'spec/lib/lab_where_client_spec.rb' + - 'spec/lib/limber/helper_spec.rb' + - 'spec/lib/mbrave_tags_creator_spec.rb' + - 'spec/lib/migration_extensions/encoding_changes_spec.rb' + - 'spec/lib/record_loader/flowcell_type_request_type_loader_spec.rb' + - 'spec/lib/record_loader/pipeline_loader_spec.rb' + - 'spec/lib/record_loader/pipeline_request_information_type_loader_spec.rb' + - 'spec/lib/record_loader/plate_purpose_loader_spec.rb' + - 'spec/lib/record_loader/product_catalogue_loader_spec.rb' + - 'spec/lib/record_loader/submission_template_loader_spec.rb' + - 'spec/lib/record_loader/tag_set_loader_spec.rb' + - 'spec/lib/retention_instructions_spec.rb' + - 'spec/mailers/user_query_mailer_spec.rb' + - 'spec/models/aliquot_spec.rb' + - 'spec/models/bait_library_type_spec.rb' + - 'spec/models/barcode_printer_spec.rb' + - 'spec/models/barcode_spec.rb' + - 'spec/models/batch_spec.rb' + - 'spec/models/broadcast_event/broadcast_event_spec.rb' + - 'spec/models/broadcast_event/helpers/external_subjects_spec.rb' + - 'spec/models/broadcast_event/library_complete_spec.rb' + - 'spec/models/broadcast_event/plate_cherrypicked_spec.rb' + - 'spec/models/broadcast_event/pool_released_spec.rb' + - 'spec/models/broadcast_event/qc_assay_spec.rb' + - 'spec/models/broadcast_event/sequencing_complete_spec.rb' + - 'spec/models/bulk_submission_spec.rb' + - 'spec/models/cherrypick_request_spec.rb' + - 'spec/models/cherrypick_task/control_locator_spec.rb' + - 'spec/models/comment_spec.rb' + - 'spec/models/illumina_htp/requests/gbs_request_spec.rb' + - 'spec/models/illumina_htp/requests/heron_request_spec.rb' + - 'spec/models/illumina_htp/requests/heron_tailed_request_spec.rb' + - 'spec/models/lab_event_spec.rb' + - 'spec/models/labwhere_reception_spec.rb' + - 'spec/models/lane_spec.rb' + - 'spec/models/linear_submission_spec.rb' + - 'spec/models/location_report_spec.rb' + - 'spec/models/lot_type_spec.rb' + - 'spec/models/map_spec.rb' + - 'spec/models/orders/order_spec.rb' + - 'spec/models/parsers/cardinal_pbmc_count_parser_spec.rb' + - 'spec/models/phi_x/spiked_buffer_spec.rb' + - 'spec/models/phi_x/stock_spec.rb' + - 'spec/models/plate/quad_creator_spec.rb' + - 'spec/models/plate_barcode_spec.rb' + - 'spec/models/plate_spec.rb' + - 'spec/models/plate_type_spec.rb' + - 'spec/models/plate_volume_spec.rb' + - 'spec/models/poly_metadatum_spec.rb' + - 'spec/models/pooling_spec.rb' + - 'spec/models/primer_panel_spec.rb' + - 'spec/models/qc_report_spec.rb' + - 'spec/models/qc_result/qc_result_factory_spec.rb' + - 'spec/models/qc_result/qc_result_spec.rb' + - 'spec/models/qcable_creator_spec.rb' + - 'spec/models/racked_tube_spec.rb' + - 'spec/models/report_fail_spec.rb' + - 'spec/models/request/sample_compound_aliquot_transfer_spec.rb' + - 'spec/models/request/traction/grid_ion_spec.rb' + - 'spec/models/request_event_spec.rb' + - 'spec/models/request_spec.rb' + - 'spec/models/robot/pick_data_spec.rb' + - 'spec/models/sample_manifest/generator_spec.rb' + - 'spec/models/sample_manifest/uploader_spec.rb' + - 'spec/models/sample_manifest_spec.rb' + - 'spec/models/sample_spec.rb' + - 'spec/models/sequencing_request_spec.rb' + - 'spec/models/state_changer/mx_tube_spec.rb' + - 'spec/models/state_changer/qcable_library_plate_spec.rb' + - 'spec/models/stock_stamper_spec.rb' + - 'spec/models/study_spec.rb' + - 'spec/models/submission/submission_creator_spec.rb' + - 'spec/models/submission_spec.rb' + - 'spec/models/tag2_layout_spec.rb' + - 'spec/models/tag2_layout_template_spec.rb' + - 'spec/models/tag_layout_template_spec.rb' + - 'spec/models/tag_set_spec.rb' + - 'spec/models/tag_substitutions_spec.rb' + - 'spec/models/transfer/between_plates_spec.rb' + - 'spec/models/transfer_request_spec.rb' + - 'spec/models/tube_rack_spec.rb' + - 'spec/models/tube_spec.rb' + - 'spec/models/user_query_spec.rb' + - 'spec/models/user_spec.rb' + - 'spec/models/well_attribute_spec.rb' + - 'spec/models/well_spec.rb' + - 'spec/models/work_completion_spec.rb' + - 'spec/models/work_order_spec.rb' + - 'spec/requests/api/v2/aliquots_spec.rb' + - 'spec/requests/api/v2/asset_audits_spec.rb' + - 'spec/requests/api/v2/barcode_printers_spec.rb' + - 'spec/requests/api/v2/comments_spec.rb' + - 'spec/requests/api/v2/custom_metadatum_collections_spec.rb' + - 'spec/requests/api/v2/heron/plates_spec.rb' + - 'spec/requests/api/v2/labware_spec.rb' + - 'spec/requests/api/v2/lanes_spec.rb' + - 'spec/requests/api/v2/lot_types_spec.rb' + - 'spec/requests/api/v2/lots_spec.rb' + - 'spec/requests/api/v2/orders_spec.rb' + - 'spec/requests/api/v2/pick_lists_spec.rb' + - 'spec/requests/api/v2/plate_purposes_spec.rb' + - 'spec/requests/api/v2/plate_templates_spec.rb' + - 'spec/requests/api/v2/plates_spec.rb' + - 'spec/requests/api/v2/poly_metadata_spec.rb' + - 'spec/requests/api/v2/pre_capture_pools_spec.rb' + - 'spec/requests/api/v2/primer_panels_spec.rb' + - 'spec/requests/api/v2/purposes_spec.rb' + - 'spec/requests/api/v2/qc_assays_spec.rb' + - 'spec/requests/api/v2/qc_results_spec.rb' + - 'spec/requests/api/v2/qcables_spec.rb' + - 'spec/requests/api/v2/receptacles_spec.rb' + - 'spec/requests/api/v2/request_types_spec.rb' + - 'spec/requests/api/v2/requests_spec.rb' + - 'spec/requests/api/v2/sample_metadata_spec.rb' + - 'spec/requests/api/v2/shared_examples/api_key_authenticatable.rb' + - 'spec/requests/api/v2/state_changes_spec.rb' + - 'spec/requests/api/v2/studies_spec.rb' + - 'spec/requests/api/v2/submission_templates_spec.rb' + - 'spec/requests/api/v2/submissions_spec.rb' + - 'spec/requests/api/v2/tag_groups_spec.rb' + - 'spec/requests/api/v2/tag_layout_templates_spec.rb' + - 'spec/requests/api/v2/transfer_requests_spec.rb' + - 'spec/requests/api/v2/transfer_templates_spec.rb' + - 'spec/requests/api/v2/transfers/transfers_spec.rb' + - 'spec/requests/api/v2/tube_purposes_spec.rb' + - 'spec/requests/api/v2/tube_racks_spec.rb' + - 'spec/requests/api/v2/tubes_spec.rb' + - 'spec/requests/api/v2/users_spec.rb' + - 'spec/requests/api/v2/volume_update_spec.rb' + - 'spec/requests/api/v2/wells_spec.rb' + - 'spec/requests/api/v2/work_orders_spec.rb' + - 'spec/requests/qc_files_spec.rb' + - 'spec/resources/api/v2/plate_purpose_resource_spec.rb' + - 'spec/resources/api/v2/tube_rack_resource_spec.rb' + - 'spec/sample_manifest_excel/configuration_spec.rb' + - 'spec/sample_manifest_excel/download_spec.rb' + - 'spec/sample_manifest_excel/manifest_type_list_spec.rb' + - 'spec/sample_manifest_excel/sample_manifest_excel_spec.rb' + - 'spec/sample_manifest_excel/tags_spec.rb' + - 'spec/sample_manifest_excel/upload/data_spec.rb' + - 'spec/sample_manifest_excel/upload/processor_spec.rb' + - 'spec/sample_manifest_excel/upload/row_spec.rb' + - 'spec/sample_manifest_excel/upload/upload_spec.rb' + - 'spec/sample_manifest_excel/worksheet_spec.rb' + - 'spec/sequencescape_excel/cell_spec.rb' + - 'spec/sequencescape_excel/column_list_spec.rb' + - 'spec/sequencescape_excel/column_spec.rb' + - 'spec/sequencescape_excel/conditional_formatting_default_list_spec.rb' + - 'spec/sequencescape_excel/conditional_formatting_default_spec.rb' + - 'spec/sequencescape_excel/conditional_formatting_list_spec.rb' + - 'spec/sequencescape_excel/conditional_formatting_spec.rb' + - 'spec/sequencescape_excel/configuration_spec.rb' + - 'spec/sequencescape_excel/formula_spec.rb' + - 'spec/sequencescape_excel/list_spec.rb' + - 'spec/sequencescape_excel/range_list_spec.rb' + - 'spec/sequencescape_excel/range_spec.rb' + - 'spec/sequencescape_excel/specialised_field_spec.rb' + - 'spec/sequencescape_excel/validation_spec.rb' + - 'spec/sequencescape_excel/worksheet_spec.rb' + - 'spec/tasks/support/add_stock_rna_plate_to_working_dilution_parents_spec.rb' + - 'spec/tasks/support/disable_hiseq_submission_templates_spec.rb' + - 'spec/uat_actions/generate_plate_concentrations_spec.rb' + - 'spec/uat_actions/generate_plates_spec.rb' + - 'spec/uat_actions/generate_primer_panel_spec.rb' + - 'spec/uat_actions/generate_qc_results_spec.rb' + - 'spec/uat_actions/generate_sample_manifest_spec.rb' + - 'spec/uat_actions/generate_spiked_buffer_tube_spec.rb' + - 'spec/uat_actions/generate_tag_group_spec.rb' + - 'spec/uat_actions/generate_tag_layout_template_spec.rb' + - 'spec/uat_actions/generate_tagged_plates_spec.rb' + - 'spec/uat_actions/generate_tube_racks_spec.rb' + - 'spec/uat_actions/generate_tubes_spec.rb' + - 'spec/uat_actions/integration_suite_tools_spec.rb' + - 'spec/uat_actions/plate_information_spec.rb' + - 'spec/uat_actions/test_submission_spec.rb' + - 'spec/uat_actions/uat_actions_spec.rb' + - 'spec/views/labware/retention_instruction_spec.rb' + - 'spec/views/labware/show_chromium_chip_spec.rb' + - 'spec/views/samples/index_html_erb_spec.rb' -# Offense count: 959 -# Configuration parameters: AllowSubject. +# Offense count: 1037 +# Configuration parameters: AllowSubject, Max. RSpec/MultipleMemoizedHelpers: - Max: 46 + Exclude: + - 'spec/api/extraction_attributes_spec.rb' + - 'spec/api/labware_spec.rb' + - 'spec/api/multiplexed_library_tube_spec.rb' + - 'spec/api/plate_spec.rb' + - 'spec/api/qcable_creator_spec.rb' + - 'spec/api/receptacle_spec.rb' + - 'spec/api/specific_tube_creation_spec.rb' + - 'spec/api/state_change_spec.rb' + - 'spec/api/submission_pool_spec.rb' + - 'spec/api/tag_layout_template_spec.rb' + - 'spec/api/transfer_request_collection_spec.rb' + - 'spec/api/tube_creation_spec.rb' + - 'spec/api/well_spec.rb' + - 'spec/api/work_completion_spec.rb' + - 'spec/bulk_submission_excel/data_worksheet_spec.rb' + - 'spec/bulk_submission_excel/download_spec.rb' + - 'spec/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller_spec.rb' + - 'spec/controllers/api/v2/heron/plates_controller_spec.rb' + - 'spec/controllers/api/v2/heron/tube_racks_controller_spec.rb' + - 'spec/controllers/driver_files_controller_spec.rb' + - 'spec/controllers/npg_actions/assets_controller_spec.rb' + - 'spec/controllers/receptacles_controller_spec.rb' + - 'spec/controllers/robot_verifications_controller_spec.rb' + - 'spec/controllers/searches_controller_spec.rb' + - 'spec/controllers/studies/information_controller_spec.rb' + - 'spec/controllers/studies_controller_spec.rb' + - 'spec/features/assets/asset_submission_spec.rb' + - 'spec/features/creating_a_quad_stamp_spec.rb' + - 'spec/features/generate_a_bulk_submission_template_spec.rb' + - 'spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb' + - 'spec/features/location_reports/location_reports_spec.rb' + - 'spec/features/patient_consent_withdrawl_spec.rb' + - 'spec/features/perform_a_tag_substitution_spec.rb' + - 'spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb' + - 'spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb' + - 'spec/features/pipelines/creating_an_empty_batch_spec.rb' + - 'spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb' + - 'spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb' + - 'spec/features/pipelines/viewing_request_comments_spec.rb' + - 'spec/features/pooling_spec.rb' + - 'spec/features/retrospective_failure_spec.rb' + - 'spec/features/sample_manifests/create_manifest_spec.rb' + - 'spec/features/starting_transfers_on_repools_starts_repools_spec.rb' + - 'spec/features/studies/view_study_request_links_spec.rb' + - 'spec/features/submissions/bulk_submissions_spec.rb' + - 'spec/helpers/batches_helper_spec.rb' + - 'spec/heron/factories/concerns/contents_spec.rb' + - 'spec/heron/factories/plate_spec.rb' + - 'spec/insdc/import_countries_spec.rb' + - 'spec/jobs/export_pool_xp_to_traction_job_spec.rb' + - 'spec/lib/label_printer/batch_plate_spec.rb' + - 'spec/lib/label_printer/swipecard_spec.rb' + - 'spec/lib/record_loader/submission_template_loader_spec.rb' + - 'spec/models/ability_spec.rb' + - 'spec/models/aliquot_spec.rb' + - 'spec/models/api/aliquot_io_spec.rb' + - 'spec/models/api/messages/flowcell_io_spec.rb' + - 'spec/models/api/messages/pac_bio_run_io_spec.rb' + - 'spec/models/api/messages/pac_bio_run_with_tag2_io_spec.rb' + - 'spec/models/api/messages/well_stock_resource_io_spec.rb' + - 'spec/models/barcode_spec.rb' + - 'spec/models/broadcast_event/broadcast_event_spec.rb' + - 'spec/models/broadcast_event/helpers/external_subjects_spec.rb' + - 'spec/models/broadcast_event/lab_event_spec.rb' + - 'spec/models/broadcast_event/plate_cherrypicked_spec.rb' + - 'spec/models/broadcast_event/pool_released_spec.rb' + - 'spec/models/broadcast_event/qc_assay_spec.rb' + - 'spec/models/broadcast_event/sequencing_complete_spec.rb' + - 'spec/models/bulk_submission_spec.rb' + - 'spec/models/comment_spec.rb' + - 'spec/models/external_release_event_spec.rb' + - 'spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb' + - 'spec/models/labware_spec.rb' + - 'spec/models/linear_submission_spec.rb' + - 'spec/models/location_report_form_spec.rb' + - 'spec/models/orders/order_spec.rb' + - 'spec/models/plate/quad_creator_spec.rb' + - 'spec/models/plate_barcode_spec.rb' + - 'spec/models/pooling_spec.rb' + - 'spec/models/qc_result/qc_result_factory_spec.rb' + - 'spec/models/receptacle/downstream_aliquots_removal_spec.rb' + - 'spec/models/receptacle_spec.rb' + - 'spec/models/request/sample_compound_aliquot_transfer_spec.rb' + - 'spec/models/request/traction/grid_ion_spec.rb' + - 'spec/models/request_information_type_spec.rb' + - 'spec/models/request_spec.rb' + - 'spec/models/robot/pick_data_spec.rb' + - 'spec/models/robot/verification/source_dest_beds_spec.rb' + - 'spec/models/robot/verification/source_dest_control_beds_spec.rb' + - 'spec/models/sample_manifest/generator_spec.rb' + - 'spec/models/sample_manifest_spec.rb' + - 'spec/models/sequencing_request_spec.rb' + - 'spec/models/specific_tube_creations_spec.rb' + - 'spec/models/state_changer/initial_stock_tube_spec.rb' + - 'spec/models/state_changer/mx_tube_spec.rb' + - 'spec/models/state_changer/qcable_library_plate_spec.rb' + - 'spec/models/state_changer/standard_plate_spec.rb' + - 'spec/models/state_changer/stock_tube_spec.rb' + - 'spec/models/std_library_request_spec.rb' + - 'spec/models/study_spec.rb' + - 'spec/models/submission_spec.rb' + - 'spec/models/tag_layout_spec.rb' + - 'spec/models/tag_layout_template_spec.rb' + - 'spec/models/tag_set_spec.rb' + - 'spec/models/tag_substitutions_spec.rb' + - 'spec/models/tasks/cherrypick_task_spec.rb' + - 'spec/models/tasks/plate_template_task_spec.rb' + - 'spec/models/tasks/set_descriptors_handler/handler_spec.rb' + - 'spec/models/transfer_request_collection_spec.rb' + - 'spec/models/transfer_request_spec.rb' + - 'spec/models/tube_rack_spec.rb' + - 'spec/models/work_completion_spec.rb' + - 'spec/requests/api/v2/custom_metadatum_collections_spec.rb' + - 'spec/requests/api/v2/heron/plates_spec.rb' + - 'spec/requests/api/v2/heron/tube_racks_spec.rb' + - 'spec/requests/api/v2/plates_spec.rb' + - 'spec/requests/api/v2/receptacles_spec.rb' + - 'spec/requests/api/v2/state_changes_spec.rb' + - 'spec/requests/api/v2/transfers/transfers_spec.rb' + - 'spec/requests/api/v2/wells_spec.rb' + - 'spec/requests/plate_picks_request_spec.rb' + - 'spec/resources/api/v2/plate_purpose_resource_spec.rb' + - 'spec/sample_manifest_excel/upload/processor_spec.rb' + - 'spec/sample_manifest_excel/upload/row_spec.rb' + - 'spec/sample_manifest_excel/upload/upload_spec.rb' + - 'spec/sample_manifest_excel/worksheet_spec.rb' + - 'spec/sequencescape_excel/column_spec.rb' + - 'spec/sequencescape_excel/specialised_field_spec.rb' + - 'spec/shared_contexts/limber_shared_context.rb' + - 'spec/tasks/support/add_stock_rna_plate_to_working_dilution_parents_spec.rb' + - 'spec/uat_actions/generate_plates_spec.rb' + - 'spec/uat_actions/generate_sample_manifest_spec.rb' + - 'spec/uat_actions/generate_tag_layout_template_spec.rb' + - 'spec/uat_actions/generate_tagged_plates_spec.rb' + - 'spec/uat_actions/plate_information_spec.rb' + - 'spec/uat_actions/test_submission_spec.rb' + - 'spec/uat_actions/uat_actions_spec.rb' + - 'spec/views/labware/show_chromium_chip_spec.rb' + - 'spec/views/labware/show_html_erb_spec.rb' + - 'spec/views/tube_rack_summaries/show_html_erb_spec.rb' -# Offense count: 388 +# Offense count: 376 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: @@ -917,12 +1423,83 @@ RSpec/NamedSubject: - 'spec/resources/api/v2/submission_resource_spec.rb' - 'spec/resources/api/v2/tag_group_resource_spec.rb' - 'spec/resources/api/v2/tube_resource_spec.rb' - - 'spec/resources/api/v2/user_resource_spec.rb' -# Offense count: 391 -# Configuration parameters: AllowedGroups. +# Offense count: 454 +# Configuration parameters: Max, AllowedGroups. RSpec/NestedGroups: - Max: 6 + Exclude: + - 'spec/api/extraction_attributes_spec.rb' + - 'spec/api/specific_tube_creation_spec.rb' + - 'spec/api/tube_creation_spec.rb' + - 'spec/controllers/bulk_submission_excel/downloads_controller_spec.rb' + - 'spec/controllers/lab_searches_controller_spec.rb' + - 'spec/controllers/labwhere_receptions_controller_spec.rb' + - 'spec/controllers/report_fails_controller_spec.rb' + - 'spec/controllers/robot_verifications_controller_spec.rb' + - 'spec/controllers/samples_controller_spec.rb' + - 'spec/controllers/searches_controller_spec.rb' + - 'spec/controllers/studies_controller_spec.rb' + - 'spec/controllers/submissions_controller_spec.rb' + - 'spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb' + - 'spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb' + - 'spec/features/submissions/bulk_submissions_spec.rb' + - 'spec/helpers/assets_helper_spec.rb' + - 'spec/heron/factories/concerns/contents_spec.rb' + - 'spec/heron/factories/plate_spec.rb' + - 'spec/heron/factories/sample_spec.rb' + - 'spec/models/api/messages/flowcell_io_spec.rb' + - 'spec/models/broadcast_event/broadcast_event_spec.rb' + - 'spec/models/broadcast_event/plate_cherrypicked_spec.rb' + - 'spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb' + - 'spec/models/labware_spec.rb' + - 'spec/models/linear_submission_spec.rb' + - 'spec/models/location_report_form_spec.rb' + - 'spec/models/location_report_spec.rb' + - 'spec/models/map_spec.rb' + - 'spec/models/orders/order_spec.rb' + - 'spec/models/phi_x/spiked_buffer_spec.rb' + - 'spec/models/phi_x/stock_spec.rb' + - 'spec/models/plate/quad_creator_spec.rb' + - 'spec/models/plate_purpose/additional_input_spec.rb' + - 'spec/models/plate_spec.rb' + - 'spec/models/qc_result/qc_result_factory_spec.rb' + - 'spec/models/receptacle_spec.rb' + - 'spec/models/request/sample_compound_aliquot_transfer_spec.rb' + - 'spec/models/request_spec.rb' + - 'spec/models/request_type_spec.rb' + - 'spec/models/robot/pick_data_spec.rb' + - 'spec/models/sample_manifest_spec.rb' + - 'spec/models/sequencing_request_spec.rb' + - 'spec/models/state_changer/mx_tube_spec.rb' + - 'spec/models/state_changer/standard_plate_spec.rb' + - 'spec/models/std_library_request_spec.rb' + - 'spec/models/study_spec.rb' + - 'spec/models/tag_group/adapter_type_spec.rb' + - 'spec/models/tag_layout_spec.rb' + - 'spec/models/tag_layout_template_spec.rb' + - 'spec/models/tag_set_spec.rb' + - 'spec/models/tag_substitutions_spec.rb' + - 'spec/models/tasks/cherrypick_task_spec.rb' + - 'spec/models/transfer_request_collection_spec.rb' + - 'spec/models/transfer_request_spec.rb' + - 'spec/models/tube_rack_spec.rb' + - 'spec/models/well_spec.rb' + - 'spec/requests/api/v2/custom_metadatum_collections_spec.rb' + - 'spec/requests/api/v2/heron/plates_spec.rb' + - 'spec/requests/api/v2/heron/tube_racks_spec.rb' + - 'spec/requests/api/v2/sample_metadata_spec.rb' + - 'spec/requests/api/v2/state_changes_spec.rb' + - 'spec/requests/api/v2/transfers/transfers_spec.rb' + - 'spec/requests/api/v2/users_spec.rb' + - 'spec/sample_manifest_excel/upload/processor_spec.rb' + - 'spec/sample_manifest_excel/upload/upload_spec.rb' + - 'spec/sequencescape_excel/specialised_field_spec.rb' + - 'spec/tasks/create_mbrave_tags_spec.rb' + - 'spec/uat_actions/generate_plates_spec.rb' + - 'spec/uat_actions/generate_project_spec.rb' + - 'spec/uat_actions/generate_sample_manifest_spec.rb' + - 'spec/uat_actions/generate_study_spec.rb' + - 'spec/validators/novaseqx_pe_validator_spec.rb' # Offense count: 10 # This cop supports safe autocorrection (--autocorrect). @@ -1200,12 +1777,6 @@ Rails/RakeEnvironment: Exclude: - 'lib/tasks/views_schema.rake' -# Offense count: 1 -# Configuration parameters: TransactionMethods. -Rails/TransactionExitStatement: - Exclude: - - 'app/models/sample_manifest/uploader.rb' - # Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/WhereEquals: @@ -1222,6 +1793,14 @@ Rails/WhereNot: - 'app/models/request.rb' - 'app/models/well.rb' +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/WhereRange: + Exclude: + - 'app/models/product_criteria.rb' + - 'db/migrate/20190829125347_populate_labware_table.rb' + - 'db/migrate/20190829125348_populate_receptacles_table.rb' + # Offense count: 5 Security/Eval: Exclude: @@ -1234,15 +1813,6 @@ Security/Open: Exclude: - 'app/api/core/io/json/stream.rb' -# Offense count: 4 -# This cop supports unsafe autocorrection (--autocorrect-all). -Security/YAMLLoad: - Exclude: - - 'app/models/submission/request_options_behaviour.rb' - - 'config/initializers/failure_reasons.rb' - - 'config/initializers/process_locale_files_with_erb.rb' - - 'db/seeds/0001_snp_plate_purposes.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowOnConstant, AllowOnSelfClass. @@ -1327,34 +1897,18 @@ Style/Encoding: - 'app/models/sequencing_request.rb' - 'config/initializers/formtastic.rb' -# Offense count: 30 +# Offense count: 10 # This cop supports safe autocorrection (--autocorrect). Style/EvalWithLocation: Exclude: - - 'app/api/core/abilities.rb' - - 'app/api/core/endpoint/basic_handler/actions.rb' - 'app/api/core/endpoint/basic_handler/actions/bound.rb' - - 'app/api/core/endpoint/basic_handler/actions/guards.rb' - - 'app/api/core/endpoint/basic_handler/actions/inner_action.rb' - - 'app/api/core/endpoint/basic_handler/associations/has_many/handler.rb' - 'app/api/core/initializable.rb' - - 'app/api/core/io/base/json_formatting_behaviour/input.rb' - 'app/api/core/logging.rb' - - 'app/api/endpoints/studies.rb' - - 'app/api/endpoints/uuids.rb' - - 'app/models/asset_link.rb' - 'app/models/attributable/association.rb' - 'app/models/attributable/attribute.rb' - - 'app/models/delegate_validation.rb' - - 'app/models/document.rb' - - 'app/models/metadata.rb' - 'app/models/metadata/form_builder.rb' - - 'app/models/request/statistics.rb' - 'app/models/tube.rb' - - 'app/models/validation_state_guard.rb' - 'app/models/well.rb' - - 'features/support/api.rb' - - 'lib/eventful_record.rb' # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). @@ -1400,14 +1954,13 @@ Style/FormatStringToken: - 'lib/label_printer/label_printer/pmb_client.rb' - 'lib/views_schema.rb' -# Offense count: 2 +# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Exclude: - 'config/initializers/new_framework_defaults_6_1.rb' - - 'config/initializers/permissions_policy.rb' # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -1416,7 +1969,7 @@ Style/GlobalStdStream: - 'config/environments/production.rb' - 'lib/tasks/limber_dev.rake' -# Offense count: 46 +# Offense count: 43 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: @@ -1505,12 +2058,6 @@ Style/IfInsideElse: - 'app/models/accession_service.rb' - 'app/models/bulk_submission.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/IfUnlessModifier: - Exclude: - - 'app/models/delegate_validation.rb' - # Offense count: 5 # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifierOfIfUnless: @@ -1535,6 +2082,13 @@ Style/LineEndConcatenation: Exclude: - 'features/support/paths.rb' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/MapIntoArray: + Exclude: + - 'app/models/plate_barcode.rb' + - 'spec/models/tasks/plate_template_task_spec.rb' + # Offense count: 7 Style/MissingRespondToMissing: Exclude: @@ -1792,7 +2346,13 @@ Style/RedundantFreeze: Exclude: - 'lib/psd_formatter.rb' -# Offense count: 61 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantInterpolationUnfreeze: + Exclude: + - 'app/models/tag_substitution/substitution.rb' + +# Offense count: 60 # This cop supports safe autocorrection (--autocorrect). Style/RedundantParentheses: Exclude: @@ -1857,7 +2417,7 @@ Style/RescueStandardError: - 'app/models/qc_report.rb' - 'app/models/submission/delayed_job_behaviour.rb' -# Offense count: 17 +# Offense count: 18 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! @@ -1978,6 +2538,19 @@ Style/StringConcatenation: - 'test/unit/product_criteria/basic_test.rb' - 'test/unit/qc_file_test.rb' +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +Style/SuperArguments: + Exclude: + - 'app/api/model_extensions/order.rb' + - 'app/controllers/api/v2/transfers/transfers_controller.rb' + - 'app/models/broadcast_event/plate_cherrypicked.rb' + - 'app/models/pipeline.rb' + - 'app/models/plate_purpose/additional_input.rb' + - 'app/models/qc_result_factory.rb' + - 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/tube_rack.rb' + - 'features/support/accession_service.rb' + # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. From c8ad087b592bb029d3c293d128d9c32b6f4ffcd5 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 20 Sep 2024 14:34:22 +0100 Subject: [PATCH 091/158] build: update rubocop-rails --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 047bd74524..e22b565472 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -241,7 +241,7 @@ GEM http-accept (1.7.0) http-cookie (1.0.5) domain_name (~> 0.5) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) @@ -443,10 +443,10 @@ GEM rubocop-performance (1.20.2) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rails (2.24.0) + rubocop-rails (2.26.1) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) + rubocop (>= 1.52.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) rubocop-rspec (2.27.1) rubocop (~> 1.40) @@ -559,7 +559,7 @@ GEM backports (>= 3.18) rainbow yard - zeitwerk (2.6.17) + zeitwerk (2.6.18) PLATFORMS arm64-darwin From 43716a5aab493701771ddfecfafd55917c986e09 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 20 Sep 2024 14:42:20 +0100 Subject: [PATCH 092/158] style: update rubocop todo --- .rubocop_todo.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0bba5a4b46..010d3451e8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-20 13:29:34 UTC using RuboCop version 1.66.1. +# on 2024-09-20 13:39:57 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -1568,6 +1568,42 @@ RSpec/VoidExpect: - 'spec/sample_manifest_excel/test_download_spec.rb' - 'spec/sequencescape_excel/column_spec.rb' +# Offense count: 58 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/ActionControllerFlashBeforeRender: + Exclude: + - 'app/controllers/admin/bait_libraries/bait_library_suppliers_controller.rb' + - 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb' + - 'app/controllers/admin/bait_libraries_controller.rb' + - 'app/controllers/admin/custom_texts_controller.rb' + - 'app/controllers/admin/faculty_sponsors_controller.rb' + - 'app/controllers/admin/plate_purposes_controller.rb' + - 'app/controllers/admin/primer_panels_controller.rb' + - 'app/controllers/admin/programs_controller.rb' + - 'app/controllers/admin/projects_controller.rb' + - 'app/controllers/admin/robots_controller.rb' + - 'app/controllers/admin/roles_controller.rb' + - 'app/controllers/admin/users_controller.rb' + - 'app/controllers/barcode_printers_controller.rb' + - 'app/controllers/batches_controller.rb' + - 'app/controllers/labware_controller.rb' + - 'app/controllers/location_reports_controller.rb' + - 'app/controllers/plates_controller.rb' + - 'app/controllers/projects_controller.rb' + - 'app/controllers/qc_reports_controller.rb' + - 'app/controllers/quad_stamp_controller.rb' + - 'app/controllers/receptacles_controller.rb' + - 'app/controllers/requests_controller.rb' + - 'app/controllers/samples_controller.rb' + - 'app/controllers/sessions_controller.rb' + - 'app/controllers/studies/asset_groups_controller.rb' + - 'app/controllers/studies_controller.rb' + - 'app/controllers/study_reports_controller.rb' + - 'app/controllers/tag_groups_controller.rb' + - 'app/controllers/tag_layout_templates_controller.rb' + - 'app/controllers/tag_sets_controller.rb' + - 'app/controllers/users_controller.rb' + # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/ApplicationMailer: @@ -1575,12 +1611,15 @@ Rails/ApplicationMailer: - 'app/mailers/user_query_mailer.rb' - 'lib/eventful_mailer.rb' -# Offense count: 5 +# Offense count: 8 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/CompactBlank: Exclude: + - 'app/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet.rb' + - 'app/models/batch.rb' - 'app/models/bulk_submission.rb' - 'app/sample_manifest_excel/sample_manifest_excel/upload/base.rb' + - 'db/migrate/20210813103531_migrate_descriptor_fields_into_descriptors.rb' - 'features/support/step_definitions/delayed_job_steps.rb' - 'lib/event_factory.rb' @@ -1777,6 +1816,12 @@ Rails/RakeEnvironment: Exclude: - 'lib/tasks/views_schema.rake' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/RootPathnameMethods: + Exclude: + - 'spec/rails_helper.rb' + # Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/WhereEquals: From 865b56d819239582c3ce02f41c8f1987ad9cea58 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 20 Sep 2024 14:45:57 +0100 Subject: [PATCH 093/158] style: remove disables bundle exec rubocop -a --- app/controllers/admin/users_controller.rb | 8 ++++---- app/controllers/plates_controller.rb | 4 ++-- app/controllers/projects_controller.rb | 8 ++++---- app/controllers/requests_controller.rb | 2 +- spec/lib/accession/sample_spec.rb | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 1de54c7c4f..0b29372eb8 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -56,11 +56,11 @@ def grant_user_role # rubocop:todo Metrics/AbcSize, Metrics/MethodLength @user.grant_role(params[:role][:authorizable_name].to_s, authorizable_object) @users_roles = @user.study_and_project_roles.order(name: :asc) - flash[:notice] = 'Role added' # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:notice] = 'Role added' render partial: 'roles', status: 200 else @users_roles = @user.study_and_project_roles.order(name: :asc) - flash[:error] = 'A problem occurred while adding the role' # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:error] = 'A problem occurred while adding the role' render partial: 'roles', status: 500 end else @@ -82,11 +82,11 @@ def remove_user_role # rubocop:todo Metrics/AbcSize, Metrics/MethodLength @user.remove_role(params[:role][:authorizable_name].to_s, authorizable_object) @users_roles = @user.study_and_project_roles.order(name: :asc) - flash[:error] = 'Role was removed' # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:error] = 'Role was removed' render partial: 'roles', status: 200 else @users_roles = @user.study_and_project_roles.order(name: :asc) - flash[:error] = 'A problem occurred while removing the role' # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:error] = 'A problem occurred while removing the role' render partial: 'roles', status: 500 end else diff --git a/app/controllers/plates_controller.rb b/app/controllers/plates_controller.rb index 95c6499895..f76d55eaed 100644 --- a/app/controllers/plates_controller.rb +++ b/app/controllers/plates_controller.rb @@ -30,7 +30,7 @@ def create # rubocop:todo Metrics/AbcSize respond_to do |format| if scanned_user.nil? - flash[:error] = 'Please scan your user barcode' # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:error] = 'Please scan your user barcode' elsif tube_rack_sources? plate_creator.create_plates_from_tube_racks!(tube_racks, barcode_printer, scanned_user, create_asset_group) else @@ -43,7 +43,7 @@ def create # rubocop:todo Metrics/AbcSize ) end flash[:notice] = 'Created plates successfully' - flash[:warning] = plate_creator.warnings if plate_creator.warnings.present? # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:warning] = plate_creator.warnings if plate_creator.warnings.present? format.html { render(new_plate_path) } end rescue StandardError => e diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d495a8f524..3c8b099f9d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -130,11 +130,11 @@ def grant_role # rubocop:todo Metrics/AbcSize if params[:role] @user.grant_role(params[:role][:authorizable_type].to_s, @project) @roles = @project.roles - flash[:notice] = 'Role added' # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:notice] = 'Role added' render partial: 'roles', status: 200 else @roles = @project.roles - flash[:error] = 'A problem occurred while adding the role' # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:error] = 'A problem occurred while adding the role' render partial: 'roles', status: 500 end else @@ -156,11 +156,11 @@ def remove_role # rubocop:todo Metrics/AbcSize if params[:role] @user.remove_role(params[:role][:authorizable_type].to_s, @project) @roles = @project.roles - flash[:error] = 'Role was removed' # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:error] = 'Role was removed' render partial: 'roles', status: 200 else @roles = @project.roles - flash[:error] = 'A problem occurred while removing the role' # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:error] = 'A problem occurred while removing the role' render partial: 'roles', status: 500 end else diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 62b0cf9878..f5ed92db97 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -82,7 +82,7 @@ def update # rubocop:todo Metrics/AbcSize flash[:notice] = 'Request details have been updated' redirect_to request_path(@request) else - flash[:error] = 'Request was not updated. No change specified ?' # rubocop:disable Rails/ActionControllerFlashBeforeRender + flash[:error] = 'Request was not updated. No change specified ?' render action: 'edit', id: @request.id end rescue => e diff --git a/spec/lib/accession/sample_spec.rb b/spec/lib/accession/sample_spec.rb index 8872a1d7f8..61ebe3bf0e 100644 --- a/spec/lib/accession/sample_spec.rb +++ b/spec/lib/accession/sample_spec.rb @@ -41,7 +41,7 @@ def find_value_at_tag(xml_received, tag_name) expect(described_class.new(tag_list, sample)).not_to be_valid end - it "is not sent for accessioning if the sample doesn't have the required fields" do # rubocop:todo RSpec/ExampleLength + it "is not sent for accessioning if the sample doesn't have the required fields" do sample = create( :sample_for_accessioning_with_open_study, From bfe25d6d3b46a31d0f1e96d4cbd855e0b7afc9ec Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 20 Sep 2024 14:49:28 +0100 Subject: [PATCH 094/158] build: update rubocop-rspec --- Gemfile.lock | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e22b565472..6bce73a289 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -436,10 +436,6 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.32.3) parser (>= 3.3.1.0) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) - rubocop (~> 1.41) rubocop-performance (1.20.2) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) @@ -448,10 +444,8 @@ GEM rack (>= 1.1) rubocop (>= 1.52.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (2.27.1) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) + rubocop-rspec (3.0.5) + rubocop (~> 1.61) ruby-graphviz (1.2.5) rexml ruby-prof (1.7.0) From 5ff0f0bf5b484ec684e3fb396618e1ca23d7098c Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 20 Sep 2024 15:03:05 +0100 Subject: [PATCH 095/158] build: install rubocop-rspec_rails --- .rubocop.yml | 5 +++-- Gemfile | 1 + Gemfile.lock | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 41e6ec50bd..d167f3e1e7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,7 @@ require: - rubocop-performance - rubocop-rails - rubocop-rspec + - rubocop-rspec_rails RSpec/AggregateExamples: # Aggregate examples can be useful, but the cop gets into nasty battles with @@ -154,7 +155,7 @@ Metrics/ClassLength: Exclude: - "spec/**/*" - "test/**/*" -RSpec/Rails/AvoidSetupHook: +RSpecRails/AvoidSetupHook: Exclude: - "test/**/*" @@ -180,7 +181,7 @@ FactoryBot/ConsistentParenthesesStyle: Rails/I18nLocaleTexts: # new in 2.14 Enabled: false -RSpec/Rails/InferredSpecType: # new in 2.14 +RSpecRails/InferredSpecType: # new in 2.14 Enabled: false Lint/NonAtomicFileOperation: # new in 1.31 diff --git a/Gemfile b/Gemfile index 51bb14aaab..0f0320cd81 100644 --- a/Gemfile +++ b/Gemfile @@ -149,6 +149,7 @@ group :development, :linting do gem 'rubocop-performance', require: false gem 'rubocop-rails', require: false gem 'rubocop-rspec', require: false + gem 'rubocop-rspec_rails', require: false gem 'prettier_print', require: false gem 'syntax_tree', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 6bce73a289..61600a650a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -446,6 +446,9 @@ GEM rubocop-ast (>= 1.31.1, < 2.0) rubocop-rspec (3.0.5) rubocop (~> 1.61) + rubocop-rspec_rails (2.30.0) + rubocop (~> 1.61) + rubocop-rspec (~> 3, >= 3.0.1) ruby-graphviz (1.2.5) rexml ruby-prof (1.7.0) @@ -628,6 +631,7 @@ DEPENDENCIES rubocop-performance rubocop-rails rubocop-rspec + rubocop-rspec_rails ruby-prof ruby-units sanger_barcode_format! From 1bf7a68231bfe202c00108c5b853e3f989a617dd Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 20 Sep 2024 15:50:54 +0100 Subject: [PATCH 096/158] build: re-install rubocop-capybara and rubocop-factory_bot --- Gemfile | 2 ++ Gemfile.lock | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/Gemfile b/Gemfile index 0f0320cd81..ddabb89cad 100644 --- a/Gemfile +++ b/Gemfile @@ -150,6 +150,8 @@ group :development, :linting do gem 'rubocop-rails', require: false gem 'rubocop-rspec', require: false gem 'rubocop-rspec_rails', require: false + gem 'rubocop-capybara', require: false + gem 'rubocop-factory_bot', require: false gem 'prettier_print', require: false gem 'syntax_tree', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 61600a650a..288a38f54a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -436,6 +436,10 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.32.3) parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.26.1) + rubocop (~> 1.61) rubocop-performance (1.20.2) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) @@ -628,6 +632,8 @@ DEPENDENCIES rspec-longrun rspec-rails rubocop + rubocop-capybara + rubocop-factory_bot rubocop-performance rubocop-rails rubocop-rspec From a5eea2eba0808c4f9c8271fdc5ac3e3d139d7f24 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 20 Sep 2024 16:26:13 +0100 Subject: [PATCH 097/158] linted --- app/resources/api/v2/request_metadata_resource.rb | 4 ++-- app/resources/api/v2/sample_metadata_resource.rb | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/resources/api/v2/request_metadata_resource.rb b/app/resources/api/v2/request_metadata_resource.rb index 7ca444d639..ba29d757bc 100644 --- a/app/resources/api/v2/request_metadata_resource.rb +++ b/app/resources/api/v2/request_metadata_resource.rb @@ -14,8 +14,8 @@ module V2 # or look at the [JSONAPI::Resources](http://jsonapi-resources.com/) package for Sequencescape's implementation # of the JSON:API standard. class RequestMetadataResource < BaseResource - # NB. request_metadata has been added to config/initializers/inflections.rb to make this class name work otherwise it - # expects RequestMetadatumResource + # NB. request_metadata has been added to config/initializers/inflections.rb to make this class name + # work otherwise it expects RequestMetadatumResource # Sets add_model_hint true by default, this allows updates from Limber, otherwise get a # 500 error as it looks for resource Api::V2::MetadatumResource diff --git a/app/resources/api/v2/sample_metadata_resource.rb b/app/resources/api/v2/sample_metadata_resource.rb index 200bf8c489..23dc18d269 100644 --- a/app/resources/api/v2/sample_metadata_resource.rb +++ b/app/resources/api/v2/sample_metadata_resource.rb @@ -15,6 +15,9 @@ module V2 # or look at the [JSONAPI::Resources](http://jsonapi-resources.com/) package for Sequencescape's implementation # of the JSON:API standard. class SampleMetadataResource < BaseResource + # NB. sample_metadata has been added to config/initializers/inflections.rb to make this class name + # work otherwise it expects SampleMetadatumResource + # Set add_model_hint true to allow updates from Limber, otherwise get a # 500 error as it looks for resource Api::V2::MetadatumResource model_name 'Sample::Metadata', add_model_hint: true From 3b7948cd453d7e02f28eb1d076b3e48e189f073f Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 20 Sep 2024 16:27:25 +0100 Subject: [PATCH 098/158] added inflection for request_metadata --- config/initializers/inflections.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index b5b6344f9d..e777bef7f3 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -11,7 +11,9 @@ # inflect.uncountable %w( fish sheep ) # end -ActiveSupport::Inflector.inflections(:en) { |inflect| inflect.uncountable %w[health sample_metadata request_metadata labware] } +ActiveSupport::Inflector.inflections(:en) do |inflect| + inflect.uncountable %w[health sample_metadata request_metadata labware] +end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| From 723f4294cef62483681a77cc9ccd468c05c4c7b3 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 20 Sep 2024 16:28:55 +0100 Subject: [PATCH 099/158] fixed typos and added submission template to factory --- spec/bulk_submission_excel/download_spec.rb | 2 +- spec/factories/submission_factories.rb | 10 +++++++--- .../generate_a_bulk_submission_template_spec.rb | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/spec/bulk_submission_excel/download_spec.rb b/spec/bulk_submission_excel/download_spec.rb index 52375e7a63..d625855de4 100644 --- a/spec/bulk_submission_excel/download_spec.rb +++ b/spec/bulk_submission_excel/download_spec.rb @@ -30,7 +30,7 @@ let(:columns) { configuration.columns.all.dup } let(:ranges) { configuration.ranges.dup } let(:assets) { create(:plate_with_untagged_wells).wells } - let(:submission_template) { create :libray_and_sequencing_template } + let(:submission_template) { create :library_and_sequencing_template } after { File.delete(test_file) if File.exist?(test_file) } diff --git a/spec/factories/submission_factories.rb b/spec/factories/submission_factories.rb index 12ae5caa42..b585afdfe1 100644 --- a/spec/factories/submission_factories.rb +++ b/spec/factories/submission_factories.rb @@ -30,17 +30,21 @@ transient { request_types { [create(:library_request_type)] } } end - factory :libray_and_sequencing_template do + factory :library_and_sequencing_template do transient { request_types { [create(:library_request_type), create(:sequencing_request_type)] } } end - factory :heron_libray_and_sequencing_template do + factory :heron_library_and_sequencing_template do transient { request_types { [create(:heron_request_type), create(:sequencing_request_type)] } } end - factory :isc_libray_and_sequencing_template do + factory :isc_library_and_sequencing_template do transient { request_types { [create(:isc_library_request_type), create(:sequencing_request_type)] } } end + + factory :pbmc_pooling_submission_template do + transient { request_types { [create(:pbmc_pooling_customer_request_type)] } } + end end factory :order do diff --git a/spec/features/generate_a_bulk_submission_template_spec.rb b/spec/features/generate_a_bulk_submission_template_spec.rb index 462ceb4b0b..3329d12200 100644 --- a/spec/features/generate_a_bulk_submission_template_spec.rb +++ b/spec/features/generate_a_bulk_submission_template_spec.rb @@ -9,7 +9,7 @@ # We only use two wells of out partial plate in our submission. However we are generating 13 # to ensure we are only using the specified well. The other two will be ignored. let!(:partial_plate) { create(:plate_with_untagged_wells, well_count: 13) } - let!(:submission_template) { create :libray_and_sequencing_template } + let!(:submission_template) { create :library_and_sequencing_template } let(:iso_date) { Time.current.utc.strftime('%Y%m%d') } let(:filename) { "#{plate.human_barcode}_to_#{partial_plate.human_barcode}_#{iso_date}_#{user.login}.xlsx" } @@ -37,7 +37,7 @@ end context 'with a primer panel submission' do - let!(:submission_template) { create :heron_libray_and_sequencing_template } + let!(:submission_template) { create :heron_library_and_sequencing_template } let!(:primer_panel) { create :primer_panel } it 'populates the primer panel column' do @@ -58,7 +58,7 @@ end context 'with a bait_library submission' do - let!(:submission_template) { create :isc_libray_and_sequencing_template } + let!(:submission_template) { create :isc_library_and_sequencing_template } let!(:bait_library) { create :bait_library } it 'populates the primer panel column' do From 2ddeea6951fed12c3a3c65aff3bb1172f90dedea Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 20 Sep 2024 16:30:51 +0100 Subject: [PATCH 100/158] modified uat action for tube submission to allow optional setting of request metadata for pbmc pooling --- app/models/pbmc_pooling_customer_request.rb | 9 +++ .../uat_actions/tube_submission.rb | 31 +++++++ ...scrna_core_cdna_prep_request_types.wip.yml | 2 +- spec/factories/request_type_factories.rb | 4 + spec/uat_actions/tube_submission_spec.rb | 81 +++++++++++++++++++ 5 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 app/models/pbmc_pooling_customer_request.rb create mode 100644 spec/uat_actions/tube_submission_spec.rb diff --git a/app/models/pbmc_pooling_customer_request.rb b/app/models/pbmc_pooling_customer_request.rb new file mode 100644 index 0000000000..b98639e7e1 --- /dev/null +++ b/app/models/pbmc_pooling_customer_request.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# A class for customer requests that need the extra metadata fields used for PBMC pooling calculations +class PbmcPoolingCustomerRequest < CustomerRequest + has_metadata as: Request do + custom_attribute(:number_of_samples_per_pool, integer: true, required: false, default: nil) + custom_attribute(:cells_per_chip_well, integer: true, required: false, default: nil) + end +end diff --git a/app/uat_actions/uat_actions/tube_submission.rb b/app/uat_actions/uat_actions/tube_submission.rb index 35e7e506c9..db35dce31c 100644 --- a/app/uat_actions/uat_actions/tube_submission.rb +++ b/app/uat_actions/uat_actions/tube_submission.rb @@ -31,6 +31,26 @@ class UatActions::TubeSubmission < UatActions include_blank: 'Using default library type...' } + form_field :number_of_samples_per_pool, + :number_field, + label: 'Number of samples per pool', + help: + 'Optional field to set the number_of_samples_per_pool field on the ' \ + 'submission request. Leave blank if not required.', + options: { + minimum: 0 + } + + form_field :cells_per_chip_well, + :number_field, + label: 'Cells per Chip Well', + help: + 'Optional field to set the cells_per_chip_well field on the ' \ + 'submission request. Leave blank if not required.', + options: { + minimum: 0 + } + validates :submission_template, presence: { message: 'could not be found' } # Returns a default copy of the UatAction which will be used to fill in the form @@ -74,12 +94,21 @@ def perform # Fills the report with the information from the submission # # @return [Void] + # rubocop:disable Metrics/AbcSize def fill_report(order) report['tube_barcodes'] = assets.map(&:human_barcode) report['submission_id'] = order.submission.id report['library_type'] = order.request_options[:library_type] if order.request_options[:library_type].present? + report['number_of_samples_per_pool'] = order.request_options[:number_of_samples_per_pool] if order.request_options[ + :number_of_samples_per_pool + ].present? + report['cells_per_chip_well'] = order.request_options[:cells_per_chip_well] if order.request_options[ + :cells_per_chip_well + ].present? end + # rubocop:enable Metrics/AbcSize + # Returns the submisssion template to use for the submission # # @return [SubmissionTemplate] The submission template to use @@ -131,6 +160,8 @@ def default_request_options def custom_request_options options = {} options[:library_type] = library_type_name if library_type_name.present? + options[:number_of_samples_per_pool] = number_of_samples_per_pool.presence + options[:cells_per_chip_well] = cells_per_chip_well.presence options end diff --git a/config/default_records/request_types/014_limber_scrna_core_cdna_prep_request_types.wip.yml b/config/default_records/request_types/014_limber_scrna_core_cdna_prep_request_types.wip.yml index 31c2f9352c..4c35b0b22a 100644 --- a/config/default_records/request_types/014_limber_scrna_core_cdna_prep_request_types.wip.yml +++ b/config/default_records/request_types/014_limber_scrna_core_cdna_prep_request_types.wip.yml @@ -8,7 +8,7 @@ limber_scrna_core_cdna_prep_gem_x_5p: name: scRNA Core cDNA Prep GEM-X 5p asset_type: SampleTube order: 1 - request_class_name: CustomerRequest + request_class_name: PbmcPoolingCustomerRequest for_multiplexing: false billable: true product_line_name: Short Read diff --git a/spec/factories/request_type_factories.rb b/spec/factories/request_type_factories.rb index 97a40577f9..0893a902d4 100644 --- a/spec/factories/request_type_factories.rb +++ b/spec/factories/request_type_factories.rb @@ -35,6 +35,10 @@ request_class { CustomerRequest } end + factory :pbmc_pooling_customer_request_type do + request_class { PbmcPoolingCustomerRequest } + end + factory :cherrypick_request_type do request_class { CherrypickRequest } asset_type { 'Well' } diff --git a/spec/uat_actions/tube_submission_spec.rb b/spec/uat_actions/tube_submission_spec.rb new file mode 100644 index 0000000000..f6c631b92d --- /dev/null +++ b/spec/uat_actions/tube_submission_spec.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe UatActions::TubeSubmission do + context 'with valid options' do + let(:tube) { create :sample_tube, purpose: create(:sample_tube_purpose) } + let(:tube_barcode) { tube.barcodes.last.barcode } + let(:submission_template) { create :pbmc_pooling_submission_template } + let(:parameters) { { submission_template_name: submission_template.name, tube_barcodes: tube_barcode } } + let(:uat_action) { described_class.new(parameters) } + let(:report) do + # A report is a hash of key value pairs which get returned to the user. + # It should include information such as barcodes and identifiers + { 'tube_barcodes' => [tube_barcode] } + end + + it 'can be performed' do + expect(uat_action.perform).to be true + expect(uat_action.report['tube_barcodes']).to eq report['tube_barcodes'] + expect(uat_action.report['submission_id']).to be_a Integer + end + + context 'with optional library type supplied' do + let(:parameters) do + { + submission_template_name: submission_template.name, + tube_barcodes: tube_barcode, + library_type_name: 'Standard' + } + end + + it 'can be performed' do + expect(uat_action.perform).to be true + expect(uat_action.report['tube_barcodes']).to eq report['tube_barcodes'] + expect(uat_action.report['submission_id']).to be_a Integer + expect(uat_action.report['library_type']).to eq 'Standard' + end + end + + context 'with optional number of samples per pool supplied' do + let(:num_samples) { 15 } + let(:parameters) do + { + submission_template_name: submission_template.name, + tube_barcodes: tube_barcode, + number_of_samples_per_pool: num_samples + } + end + + it 'can be performed' do + expect(uat_action.perform).to be true + expect(uat_action.report['tube_barcodes']).to eq report['tube_barcodes'] + expect(uat_action.report['submission_id']).to be_a Integer + expect(uat_action.report['number_of_samples_per_pool']).to eq num_samples + end + end + + context 'with optional cells per chip well supplied' do + let(:num_cells) { 20_000 } + let(:parameters) do + { + submission_template_name: submission_template.name, + tube_barcodes: tube_barcode, + cells_per_chip_well: num_cells + } + end + + it 'can be performed' do + expect(uat_action.perform).to be true + expect(uat_action.report['tube_barcodes']).to eq report['tube_barcodes'] + expect(uat_action.report['submission_id']).to be_a Integer + expect(uat_action.report['cells_per_chip_well']).to eq num_cells + end + end + end + + it 'returns a default' do + expect(described_class.default).to be_a described_class + end +end From f90d418a24254982f2c0ed3cc94d45b425f3090c Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:36:04 +0000 Subject: [PATCH 101/158] Update puma to version 6.4.3 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0437a39463..34a69335f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -320,7 +320,7 @@ GEM pry (>= 0.13.0) psych (3.3.4) public_suffix (6.0.0) - puma (6.4.2) + puma (6.4.3) nio4r (~> 2.0) racc (1.8.1) rack (2.2.9) From 251abe9d3398125793bd582a6d8f84673fdafe0e Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Sat, 21 Sep 2024 19:00:29 +0000 Subject: [PATCH 102/158] Update selenium-webdriver to version 4.25.0 --- Gemfile.lock | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0437a39463..4cc91ae93a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -258,7 +258,7 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.0) + logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -389,8 +389,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.3.6) - strscan + rexml (3.3.7) roo (2.10.1) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) @@ -471,7 +470,7 @@ GEM sanitize (6.1.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) - selenium-webdriver (4.22.0) + selenium-webdriver (4.25.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) @@ -507,7 +506,6 @@ GEM activesupport (>= 6.1) sprockets (>= 3.0.0) ssrf_filter (1.1.2) - strscan (3.1.0) syntax_tree (6.2.0) prettier_print (>= 1.2.0) syntax_tree-haml (4.0.3) @@ -544,7 +542,7 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket (1.2.10) + websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) From 0a44a13e875387df6ce3c44fb9263122dfb7abbf Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Mon, 23 Sep 2024 11:09:19 +0100 Subject: [PATCH 103/158] feat(pbmc-parser): renames pbmc-parser to remove cardinal specificity --- app/models/parsers.rb | 2 +- ...c_count_parser.rb => pbmc_count_parser.rb} | 6 +- ...cardinal_pbmc_count.csv => pbmc_count.csv} | 0 ...ank_rows.csv => pbmc_count_blank_rows.csv} | 0 ...t_no_cells.csv => pbmc_count_no_cells.csv} | 0 ...rser_spec.rb => pbmc_count_parser_spec.rb} | 60 +++++++++---------- 6 files changed, 34 insertions(+), 34 deletions(-) rename app/models/parsers/{cardinal_pbmc_count_parser.rb => pbmc_count_parser.rb} (92%) rename spec/data/parsers/{cardinal_pbmc_count.csv => pbmc_count.csv} (100%) rename spec/data/parsers/{cardinal_pbmc_count_blank_rows.csv => pbmc_count_blank_rows.csv} (100%) rename spec/data/parsers/{cardinal_pbmc_count_no_cells.csv => pbmc_count_no_cells.csv} (100%) rename spec/models/parsers/{cardinal_pbmc_count_parser_spec.rb => pbmc_count_parser_spec.rb} (73%) diff --git a/app/models/parsers.rb b/app/models/parsers.rb index 0c9ba40335..dc8637f45c 100644 --- a/app/models/parsers.rb +++ b/app/models/parsers.rb @@ -4,7 +4,7 @@ module Parsers ENCODINGS = %w[Windows-1252 iso-8859-1 utf-8 utf-16].freeze - PARSERS = [QuantParser, BioanalysisCsvParser, PlateReaderParser, CardinalPbmcCountParser].freeze + PARSERS = [QuantParser, BioanalysisCsvParser, PlateReaderParser, PbmcCountParser].freeze def self.parser_for(filename, content_type, content) return nil unless filename.downcase.end_with?('.csv') || content_type == 'text/csv' diff --git a/app/models/parsers/cardinal_pbmc_count_parser.rb b/app/models/parsers/pbmc_count_parser.rb similarity index 92% rename from app/models/parsers/cardinal_pbmc_count_parser.rb rename to app/models/parsers/pbmc_count_parser.rb index 31fb3b65c1..abf5d7eb77 100644 --- a/app/models/parsers/cardinal_pbmc_count_parser.rb +++ b/app/models/parsers/pbmc_count_parser.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Parsers - # A parser for the cardinal pipeline qc file - class CardinalPbmcCountParser + # A parser for the cardinal and scrna pipeline qc files + class PbmcCountParser class_attribute :assay_type, :assay_version HEADERS = [ @@ -20,7 +20,7 @@ class CardinalPbmcCountParser 'Errors:' ].freeze - self.assay_type = 'Cardinal_PBMC_Count' + self.assay_type = 'PBMC_Count' self.assay_version = 'v1.0' def self.parses?(content) diff --git a/spec/data/parsers/cardinal_pbmc_count.csv b/spec/data/parsers/pbmc_count.csv similarity index 100% rename from spec/data/parsers/cardinal_pbmc_count.csv rename to spec/data/parsers/pbmc_count.csv diff --git a/spec/data/parsers/cardinal_pbmc_count_blank_rows.csv b/spec/data/parsers/pbmc_count_blank_rows.csv similarity index 100% rename from spec/data/parsers/cardinal_pbmc_count_blank_rows.csv rename to spec/data/parsers/pbmc_count_blank_rows.csv diff --git a/spec/data/parsers/cardinal_pbmc_count_no_cells.csv b/spec/data/parsers/pbmc_count_no_cells.csv similarity index 100% rename from spec/data/parsers/cardinal_pbmc_count_no_cells.csv rename to spec/data/parsers/pbmc_count_no_cells.csv diff --git a/spec/models/parsers/cardinal_pbmc_count_parser_spec.rb b/spec/models/parsers/pbmc_count_parser_spec.rb similarity index 73% rename from spec/models/parsers/cardinal_pbmc_count_parser_spec.rb rename to spec/models/parsers/pbmc_count_parser_spec.rb index 927e6758f2..24222a49ec 100644 --- a/spec/models/parsers/cardinal_pbmc_count_parser_spec.rb +++ b/spec/models/parsers/pbmc_count_parser_spec.rb @@ -19,37 +19,37 @@ def read_file(filename) File.read(filename) end -RSpec.describe Parsers::CardinalPbmcCountParser do - it 'will have an assay type' do - expect(described_class.assay_type).to eq('Cardinal_PBMC_Count') +RSpec.describe Parsers::PbmcCountParser do + it 'has an assay type' do + expect(described_class.assay_type).to eq('PBMC_Count') end - it 'will have an assay version' do + it 'has an assay version' do expect(described_class.assay_version).to eq('v1.0') end context 'when a file is parsed' do - let(:filename) { Rails.root.join('spec/data/parsers/cardinal_pbmc_count.csv') } + let(:filename) { Rails.root.join('spec/data/parsers/pbmc_count.csv') } let(:content) { read_file(filename) } let(:csv) { CSV.parse(content) } let(:parser) { described_class.new(csv) } - it 'will return the correct parser' do - expect(Parsers.parser_for('cardinal_pbmc_count.csv', nil, content)).to be_a(described_class) + it 'returns the correct parser' do + expect(Parsers.parser_for('pbmc_count.csv', nil, content)).to be_a(described_class) end - it 'will have some content' do + it 'has some content' do expect(parser.content).to eq(csv) end context 'when parsing rows' do let(:rows) { parser.rows } - it 'will have the correct number of rows' do + it 'has the correct number of rows' do expect(rows.length).to eq(8) end - it 'will have the correct csv for well A1' do + it 'has the correct csv for well A1' do row = rows[0] expect(row[0]).to eq('DN871908M:A1') expect(row[2]).to eq('2030000') @@ -57,7 +57,7 @@ def read_file(filename) expect(row[9]).to eq('2710000') end - it 'will have the correct csv for well H1' do + it 'has the correct csv for well H1' do row = rows[7] expect(row[0]).to eq('DN871908M:H1') expect(row[2]).to eq('1940000') @@ -69,18 +69,18 @@ def read_file(filename) context 'when formatting into qc data' do let(:qc_data) { parser.qc_data } - it 'will have the correct number of values' do + it 'has the correct number of values' do expect(qc_data.values.length).to eq(8) end - it 'will have the correct data for well A1' do + it 'has the correct data for well A1' do row = qc_data['A1'] expect(row[:live_cell_count]).to eq(Unit.new('2030000', 'cells')) expect(row[:viability]).to eq(Unit.new('75.00', '%')) expect(row[:total_cell_count]).to eq(Unit.new('2710000', 'cells')) end - it 'will have the correct data for well H1' do + it 'has the correct data for well H1' do row = qc_data['H1'] expect(row[:live_cell_count]).to eq(Unit.new('1940000', 'cells')) expect(row[:viability]).to eq(Unit.new('74.00', '%')) @@ -91,40 +91,40 @@ def read_file(filename) context 'when the file has blank rows' do # this file has 1 row and 23 blank rows - let(:filename) { Rails.root.join('spec/data/parsers/cardinal_pbmc_count_blank_rows.csv') } + let(:filename) { Rails.root.join('spec/data/parsers/pbmc_count_blank_rows.csv') } let(:content) { read_file(filename) } let(:csv) { CSV.parse(content) } let(:parser) { described_class.new(csv) } - it 'will return the correct parser' do - expect(Parsers.parser_for('cardinal_pbmc_count.csv', nil, content)).to be_a(described_class) + it 'has the correct parser' do + expect(Parsers.parser_for('pbmc_count.csv', nil, content)).to be_a(described_class) end - it 'will have some content' do + it 'has some content' do expect(parser.content).to eq(csv) end - it 'will have some qc data' do + it 'has some qc data' do expect(parser.qc_data.values.length).to eq(1) end end context 'when a row has no cells' do # this file has 1 normal row, and a couple of rows with 0 live cells, and NaN viability - let(:filename) { Rails.root.join('spec/data/parsers/cardinal_pbmc_count_no_cells.csv') } + let(:filename) { Rails.root.join('spec/data/parsers/pbmc_count_no_cells.csv') } let(:content) { read_file(filename) } let(:csv) { CSV.parse(content) } let(:parser) { described_class.new(csv) } - it 'will have three qc data entries - one for each row in the file' do + it 'has three qc data entries - one for each row in the file' do expect(parser.qc_data.values.length).to eq(3) end - it 'will have cell count and viability metrics for the normal row' do + it 'has cell count and viability metrics for the normal row' do expect(parser.qc_data['A4'].keys).to eq(%i[live_cell_count total_cell_count viability]) end - it 'will have just cell count for the rows with 0 cells' do + it 'has just cell count for the rows with 0 cells' do expect(parser.qc_data['A5'].keys).to eq(%i[live_cell_count total_cell_count]) expect(parser.qc_data['E5'].keys).to eq(%i[live_cell_count total_cell_count]) expect(parser.qc_data['E5'][:live_cell_count].zero?).to be(true) @@ -134,7 +134,7 @@ def read_file(filename) context 'when updating qc results' do let(:plate) { create(:plate_with_empty_wells, well_count: 96) } - let(:filename) { Rails.root.join('spec/data/parsers/cardinal_pbmc_count.csv') } + let(:filename) { Rails.root.join('spec/data/parsers/pbmc_count.csv') } let(:content) { read_file(filename) } let(:csv) { CSV.parse(content) } let(:parser) { described_class.new(csv) } @@ -142,11 +142,11 @@ def read_file(filename) context 'when creating some qc results' do before { plate.update_qc_values_with_parser(parser) } - it 'will have the correct number of results' do + it 'has the correct number of results' do expect(QcResult.count).to eq(24) end - it 'will create the qc results for well A1' do + it 'has the qc results for well A1' do well = plate.wells.located_at('A1').first qc_results = QcResult.where(asset_id: well.id) @@ -154,25 +154,25 @@ def read_file(filename) expect(qc_result.value).to eq('75') expect(qc_result.units).to eq('%') - expect(qc_result.assay_type).to eq('Cardinal_PBMC_Count') + expect(qc_result.assay_type).to eq('PBMC_Count') expect(qc_result.assay_version).to eq('v1.0') qc_result = qc_results.find_by(key: 'live_cell_count') expect(qc_result.value).to eq('2030000') expect(qc_result.units).to eq('cells/ml') - expect(qc_result.assay_type).to eq('Cardinal_PBMC_Count') + expect(qc_result.assay_type).to eq('PBMC_Count') expect(qc_result.assay_version).to eq('v1.0') qc_result = qc_results.find_by(key: 'total_cell_count') expect(qc_result.value).to eq('2710000') expect(qc_result.units).to eq('cells/ml') - expect(qc_result.assay_type).to eq('Cardinal_PBMC_Count') + expect(qc_result.assay_type).to eq('PBMC_Count') expect(qc_result.assay_version).to eq('v1.0') end - it 'will create the qc results for well H1' do + it 'creates the qc results for well H1' do well = plate.wells.located_at('H1').first qc_results = QcResult.where(asset_id: well.id) From ab61276cd62d6cd55237190af47bdb1f3b75b871 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 23 Sep 2024 11:12:33 +0100 Subject: [PATCH 104/158] style: remove faulty bots --- .rubocop.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d167f3e1e7..b4b868c7cb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -175,9 +175,6 @@ Rails/UniqueValidationWithoutIndex: Enabled: false # Disabling newly introduced cops until we have time to sort out the offenses -FactoryBot/ConsistentParenthesesStyle: - Enabled: false - Rails/I18nLocaleTexts: # new in 2.14 Enabled: false @@ -203,12 +200,6 @@ RSpec/SpecFilePathFormat: RSpec/PendingWithoutReason: Enabled: false -Capybara/ClickLinkOrButtonStyle: - Enabled: false - -FactoryBot/FactoryAssociationWithStrategy: - Enabled: false - Performance/MapMethodChain: Enabled: false From 7f65406c3fc52f7133f5a353cc3e7caf46874e5b Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 23 Sep 2024 11:22:17 +0100 Subject: [PATCH 105/158] build: update rubocop todo rubocop --auto-gen-config --no-exclude-limit --- .rubocop_todo.yml | 77 +++++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 53 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 010d3451e8..a9f7a735d6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,37 +1,18 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-20 13:39:57 UTC using RuboCop version 1.66.1. +# on 2024-09-23 10:19:34 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 17 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: have_no, not_to -Capybara/NegationMatcher: - Exclude: - - 'features/support/step_definitions/web_steps.rb' - - 'spec/features/assets/asset_submission_spec.rb' - - 'spec/features/patient_consent_withdrawl_spec.rb' - - 'spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb' - - 'spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb' - - 'spec/features/sample_logistics/lab/stock_stamping_spec.rb' - - 'spec/features/sample_manifests/create_manifest_spec.rb' - - 'spec/features/shared_examples/sequencing.rb' - - 'spec/features/studies/change_study_roles_spec.rb' - - 'spec/features/studies/create_study_spec.rb' - - 'spec/features/studies/manage_study_spec.rb' - - 'spec/features/studies/view_study_request_links_spec.rb' - - 'spec/helpers/deprecation_helper_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: DefaultSelector. -Capybara/RSpec/HaveSelector: +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/OrderedGems: Exclude: - - 'spec/features/plate_qc_display_spec.rb' + - 'Gemfile' # Offense count: 21 # This cop supports safe autocorrection (--autocorrect). @@ -679,13 +660,14 @@ RSpec/ContextWording: # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. RSpec/EmptyExampleGroup: Exclude: - 'spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb' - 'spec/models/pulldown/requests_spec.rb' - 'spec/models/tag_substitutions_spec.rb' -# Offense count: 386 +# Offense count: 387 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: @@ -849,24 +831,6 @@ RSpec/ExpectActual: Exclude: - 'spec/models/qc_report_spec.rb' -# Offense count: 12 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. -# Include: **/*_spec*rb*, **/spec/**/* -RSpec/FilePath: - Exclude: - - 'spec/bulk_submission_excel/data_worksheet_spec.rb' - - 'spec/lib/accession/configuration_spec.rb' - - 'spec/lib/label_printer/sample_manifest_plate_double_spec.rb' - - 'spec/models/location_report_form_spec.rb' - - 'spec/models/std_library_request_spec.rb' - - 'spec/models/tag_group_form_object_spec.rb' - - 'spec/models/tube_purpose_spec.rb' - - 'spec/requests/api/v2/qc_assays_spec.rb' - - 'spec/requests/api/v2/qc_results_spec.rb' - - 'spec/resources/api/v2/project_resource_spec.rb' - - 'spec/sample_manifest_excel/upload/upload_spec.rb' - - 'spec/sequencescape_excel/configuration_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. @@ -967,6 +931,12 @@ RSpec/MessageSpies: - 'spec/tasks/create_mbrave_tags_spec.rb' - 'spec/uat_actions/test_submission_spec.rb' +# Offense count: 2 +RSpec/MissingExpectationTargetMethod: + Exclude: + - 'spec/models/robot/generator/beckman_spec.rb' + - 'spec/models/robot/generator/hamilton_spec.rb' + # Offense count: 3 RSpec/MultipleDescribes: Exclude: @@ -1501,15 +1471,6 @@ RSpec/NestedGroups: - 'spec/uat_actions/generate_study_spec.rb' - 'spec/validators/novaseqx_pe_validator_spec.rb' -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -RSpec/Rails/MinitestAssertions: - Exclude: - - 'spec/models/robot/generator/beckman_spec.rb' - - 'spec/models/robot/generator/hamilton_spec.rb' - - 'spec/models/robot/generator/tecan_spec.rb' - - 'spec/models/tag_substitutions_spec.rb' - # Offense count: 6 RSpec/RepeatedDescription: Exclude: @@ -1536,6 +1497,7 @@ RSpec/RepeatedExampleGroupDescription: # Offense count: 25 # This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect. RSpec/ScatteredLet: Exclude: - 'spec/api/plate_spec.rb' @@ -1568,7 +1530,16 @@ RSpec/VoidExpect: - 'spec/sample_manifest_excel/test_download_spec.rb' - 'spec/sequencescape_excel/column_spec.rb' -# Offense count: 58 +# Offense count: 10 +# This cop supports safe autocorrection (--autocorrect). +RSpecRails/MinitestAssertions: + Exclude: + - 'spec/models/robot/generator/beckman_spec.rb' + - 'spec/models/robot/generator/hamilton_spec.rb' + - 'spec/models/robot/generator/tecan_spec.rb' + - 'spec/models/tag_substitutions_spec.rb' + +# Offense count: 69 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/ActionControllerFlashBeforeRender: Exclude: From 663cafba2266353d9f74eb7855e731f1f4494674 Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Mon, 23 Sep 2024 11:53:38 +0100 Subject: [PATCH 106/158] Remove barcode attribute from PlateCreation --- app/models/plate_creation.rb | 1 - spec/factories/pulldown_factories.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/plate_creation.rb b/app/models/plate_creation.rb index 04cc1537c7..3066eec729 100644 --- a/app/models/plate_creation.rb +++ b/app/models/plate_creation.rb @@ -6,7 +6,6 @@ class PlateCreation < AssetCreation # This is the child that is created from the parent. It cannot be assigned before validation. belongs_to :parent, class_name: 'Plate' - attr_accessor :barcode attr_accessor :sanger_barcode def record_creation_of_children diff --git a/spec/factories/pulldown_factories.rb b/spec/factories/pulldown_factories.rb index 9bd4bf6a39..7af01ec0f5 100644 --- a/spec/factories/pulldown_factories.rb +++ b/spec/factories/pulldown_factories.rb @@ -61,7 +61,7 @@ factory(:plate_creation) do user - barcode { create(:sequencescape22).barcode } + sanger_barcode { create(:sequencescape22).barcode } parent factory: %i[full_plate], well_count: 2 child_purpose factory: %i[plate_purpose] From 52e909e3aa55757a2cdd9c60c980c9c1158392ae Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 23 Sep 2024 12:59:24 +0100 Subject: [PATCH 107/158] build: repair option dependencies bug --- package.json | 6 ++++++ yarn.lock | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/package.json b/package.json index 0346bb98cc..873d3d8105 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,12 @@ "vite-plugin-vue2": "^1.9.3", "vue-jest": "^3.0.7" }, + "_comment": "Required to address https://github.com/npm/cli/issues/4828", + "optionalDependencies": { + "@rollup/rollup-darwin-arm64": "*", + "@rollup/rollup-linux-x64-gnu": "*", + "@rollup/rollup-win32-x64-msvc": "*" + }, "scripts": { "test": "jest", "lint": "eslint --ext .js --ext .vue app/frontend", diff --git a/yarn.lock b/yarn.lock index 086c4d60ba..9334fa8c47 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1934,6 +1934,11 @@ resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.18.1.tgz#82ab3c575f4235fb647abea5e08eec6cf325964e" integrity sha512-F/tkdw0WSs4ojqz5Ovrw5r9odqzFjb5LIgHdHZG65dFI1lWTWRVy32KDJLKRISHgJvqUeUhdIvy43fX41znyDg== +"@rollup/rollup-darwin-arm64@*": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz#6d241d099d1518ef0c2205d96b3fa52e0fe1954b" + integrity sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q== + "@rollup/rollup-darwin-arm64@4.18.1": version "4.18.1" resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.18.1.tgz#6a530452e68a9152809ce58de1f89597632a085b" @@ -1979,6 +1984,11 @@ resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.18.1.tgz#f1043d9f4026bf6995863cb3f8dd4732606e4baa" integrity sha512-qb1hMMT3Fr/Qz1OKovCuUM11MUNLUuHeBC2DPPAWUYYUAOFWaxInaTwTQmc7Fl5La7DShTEpmYwgdt2hG+4TEg== +"@rollup/rollup-linux-x64-gnu@*": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz#70116ae6c577fe367f58559e2cffb5641a1dd9d0" + integrity sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg== + "@rollup/rollup-linux-x64-gnu@4.18.1": version "4.18.1" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.18.1.tgz#1e781730be445119f06c9df5f185e193bc82c610" @@ -1999,6 +2009,11 @@ resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.18.1.tgz#075b0713de627843a73b4cf0e087c56b53e9d780" integrity sha512-ELfEX1/+eGZYMaCIbK4jqLxO1gyTSOIlZr6pbC4SRYFaSIDVKOnZNMdoZ+ON0mrFDp4+H5MhwNC1H/AhE3zQLg== +"@rollup/rollup-win32-x64-msvc@*": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz#3dd5d53e900df2a40841882c02e56f866c04d202" + integrity sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q== + "@rollup/rollup-win32-x64-msvc@4.18.1": version "4.18.1" resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.18.1.tgz#0cb240c147c0dfd0e3eaff4cc060a772d39e155c" From a56a08128c4d36846853d253fcab2645b868136c Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Mon, 23 Sep 2024 13:17:24 +0100 Subject: [PATCH 108/158] fixed relationship on request to metadata --- app/resources/api/v2/request_resource.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/resources/api/v2/request_resource.rb b/app/resources/api/v2/request_resource.rb index 1c5788ed2f..bf12598965 100644 --- a/app/resources/api/v2/request_resource.rb +++ b/app/resources/api/v2/request_resource.rb @@ -31,6 +31,7 @@ class RequestResource < BaseResource has_one :primer_panel has_one :pre_capture_pool has_many :poly_metadata, as: :metadatable, class_name: 'PolyMetadatum' + has_one :request_metadata, class_name: 'RequestMetadata', foreign_key_on: :related # Attributes attribute :uuid, readonly: true From c376ee8cb552a153a0eb88db6321b7baa38588bf Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Mon, 23 Sep 2024 15:11:00 +0100 Subject: [PATCH 109/158] Stop pulling the string from the barcode object during testing --- spec/factories/pulldown_factories.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/factories/pulldown_factories.rb b/spec/factories/pulldown_factories.rb index 7af01ec0f5..c9786a425c 100644 --- a/spec/factories/pulldown_factories.rb +++ b/spec/factories/pulldown_factories.rb @@ -61,7 +61,7 @@ factory(:plate_creation) do user - sanger_barcode { create(:sequencescape22).barcode } + sanger_barcode { create(:sequencescape22) } parent factory: %i[full_plate], well_count: 2 child_purpose factory: %i[plate_purpose] From e9a2293d708cde01f6525d07506162a242fafbf4 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Mon, 23 Sep 2024 15:34:45 +0100 Subject: [PATCH 110/158] tests: corrects filename in qc files spec --- .rubocop_todo.yml | 1 - spec/requests/qc_files_spec.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a63c3341a5..ada44bf812 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -691,7 +691,6 @@ RSpec/ExampleWording: - 'spec/heron/factories/sample_spec.rb' - 'spec/heron/factories/tube_rack_spec.rb' - 'spec/lib/accession/study_spec.rb' - - 'spec/models/parsers/cardinal_pbmc_count_parser_spec.rb' - 'spec/models/plate/quad_creator_spec.rb' - 'spec/models/qc_result/qc_result_factory_spec.rb' - 'spec/models/qcable_creator_spec.rb' diff --git a/spec/requests/qc_files_spec.rb b/spec/requests/qc_files_spec.rb index 443f76ea9b..cca444b5ff 100644 --- a/spec/requests/qc_files_spec.rb +++ b/spec/requests/qc_files_spec.rb @@ -5,7 +5,7 @@ let(:authorised_app) { create :api_application } describe 'create qc file' do - let(:filename) { Rails.root.join('spec/data/parsers/cardinal_pbmc_count.csv').expand_path } + let(:filename) { Rails.root.join('spec/data/parsers/pbmc_count.csv').expand_path } let(:file) { File.open(filename) } let(:plate) { create(:plate_with_empty_wells, well_count: 96) } @@ -13,7 +13,7 @@ headers = { 'HTTP_ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'sequencescape/qc_file', - 'HTTP_CONTENT_DISPOSITION' => 'form-data; filename="cardinal_pbmc_count.csv"', + 'HTTP_CONTENT_DISPOSITION' => 'form-data; filename="pbmc_count.csv"', 'HTTP_X_SEQUENCESCAPE_CLIENT_ID' => authorised_app.key, 'HTTP_COOKIE' => '' } From 85f6188ee852457dd9793ff893b260b002bf343b Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 23 Sep 2024 15:52:36 +0100 Subject: [PATCH 111/158] build: update rubocop todo for Ruby 3.2 rubocop --auto-gen-config --no-exclude-limit --- .rubocop.yml | 16 +----- .rubocop_todo.yml | 125 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 125 insertions(+), 16 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b4b868c7cb..d9dc181618 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -210,18 +210,4 @@ RSpec/ExpectInHook: Enabled: false # New in Ruby 3.2 upgrade - -Naming/BlockForwarding: - Enabled: false - -Style/ArgumentsForwarding: - Enabled: false - -Style/ArrayIntersect: - Enabled: false - -Style/EmptyMethod: - Enabled: false - -Style/HashSyntax: - Enabled: false +# Added to Rubocop Todo and handling from there diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a9f7a735d6..c3717c6db0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-23 10:19:34 UTC using RuboCop version 1.66.1. +# on 2024-09-23 14:09:39 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -368,6 +368,63 @@ Naming/AccessorMethodName: - 'lib/authenticated_system.rb' - 'lib/tasks/add_templates_and_printers_to_pmb.rake' +# Offense count: 148 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, BlockForwardingName. +# SupportedStyles: anonymous, explicit +Naming/BlockForwarding: + Exclude: + - 'app/api/core/endpoint/base.rb' + - 'app/api/core/endpoint/basic_handler/actions.rb' + - 'app/api/core/endpoint/basic_handler/actions/bound.rb' + - 'app/api/core/endpoint/basic_handler/actions/bound/handler.rb' + - 'app/api/core/endpoint/basic_handler/actions/factory.rb' + - 'app/api/core/endpoint/basic_handler/actions/guards.rb' + - 'app/api/core/endpoint/basic_handler/actions/inner_action.rb' + - 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb' + - 'app/api/core/endpoint/basic_handler/associations/has_many.rb' + - 'app/api/core/endpoint/basic_handler/associations/has_many/handler.rb' + - 'app/api/core/io/json/grammar.rb' + - 'app/api/core/service.rb' + - 'app/helpers/application_helper.rb' + - 'app/helpers/assets_helper.rb' + - 'app/helpers/bootstrap_helper.rb' + - 'app/helpers/descriptor_javascript_helper.rb' + - 'app/models/aliquot/aliquotable.rb' + - 'app/models/api/base.rb' + - 'app/models/metadata.rb' + - 'app/models/metadata/builder_base.rb' + - 'app/models/metadata/form_builder.rb' + - 'app/models/metadata/view_builder.rb' + - 'app/models/parsers/cardinal_pbmc_count_parser.rb' + - 'app/models/plate.rb' + - 'app/models/presenters/batch_submenu_presenter.rb' + - 'app/models/request_type.rb' + - 'app/models/sample_manifest/core_behaviour.rb' + - 'app/models/strip_tube.rb' + - 'app/models/study_report/study_details.rb' + - 'app/models/submission/presenter_skeleton.rb' + - 'app/models/tube.rb' + - 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb' + - 'app/sample_manifest_excel/sample_manifest_excel/upload/data.rb' + - 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb' + - 'app/sequencescape_excel/sequencescape_excel/list.rb' + - 'app/sequencescape_excel/sequencescape_excel/range_list.rb' + - 'app/uploaders/polymorphic_uploader.rb' + - 'config/initializers/api_routing.rb' + - 'features/support/step_definitions/api_steps.rb' + - 'features/support/step_definitions/submission_steps.rb' + - 'lib/accession/accession/submission.rb' + - 'lib/accession/accession/tag_list.rb' + - 'lib/authenticated_test_helper.rb' + - 'lib/capybara_failure_logger.rb' + - 'lib/eventful_record.rb' + - 'lib/informatics/test/helpers/authentication_helper.rb' + - 'lib/mbrave_tags_creator.rb' + - 'spec/lib/mock_parser.rb' + - 'test/unit/tag_qc/qcable_statemachine_checks.rb' + - 'test/unit/task_test_base.rb' + # Offense count: 6 Naming/ConstantName: Exclude: @@ -1829,6 +1886,72 @@ Security/Open: Exclude: - 'app/api/core/io/json/stream.rb' +# Offense count: 167 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames. +# RedundantRestArgumentNames: args, arguments +# RedundantKeywordRestArgumentNames: kwargs, options, opts +# RedundantBlockArgumentNames: blk, block, proc +Style/ArgumentsForwarding: + Exclude: + - 'app/api/core/endpoint/base.rb' + - 'app/api/core/endpoint/basic_handler/actions.rb' + - 'app/api/core/endpoint/basic_handler/actions/bound.rb' + - 'app/api/core/endpoint/basic_handler/actions/bound/handler.rb' + - 'app/api/core/endpoint/basic_handler/actions/factory.rb' + - 'app/api/core/endpoint/basic_handler/actions/guards.rb' + - 'app/api/core/endpoint/basic_handler/actions/inner_action.rb' + - 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb' + - 'app/api/core/endpoint/basic_handler/associations/has_many.rb' + - 'app/api/core/endpoint/basic_handler/associations/has_many/handler.rb' + - 'app/api/core/io/json/grammar.rb' + - 'app/api/core/service.rb' + - 'app/helpers/application_helper.rb' + - 'app/helpers/assets_helper.rb' + - 'app/helpers/bootstrap_helper.rb' + - 'app/helpers/descriptor_javascript_helper.rb' + - 'app/models/aliquot/aliquotable.rb' + - 'app/models/api/base.rb' + - 'app/models/attributable.rb' + - 'app/models/comments_proxy/base.rb' + - 'app/models/metadata.rb' + - 'app/models/metadata/builder_base.rb' + - 'app/models/metadata/form_builder.rb' + - 'app/models/parsers/cardinal_pbmc_count_parser.rb' + - 'app/models/plate.rb' + - 'app/models/presenters/batch_submenu_presenter.rb' + - 'app/models/request_type.rb' + - 'app/models/sample_manifest/core_behaviour.rb' + - 'app/models/strip_tube.rb' + - 'app/models/study_report/study_details.rb' + - 'app/models/submission/presenter_skeleton.rb' + - 'app/models/tube.rb' + - 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb' + - 'app/sample_manifest_excel/sample_manifest_excel/upload/data.rb' + - 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb' + - 'app/sequencescape_excel/sequencescape_excel/list.rb' + - 'app/sequencescape_excel/sequencescape_excel/range_list.rb' + - 'config/initializers/api_routing.rb' + - 'features/support/cucumber_github_formatter.rb' + - 'features/support/step_definitions/api_steps.rb' + - 'features/support/step_definitions/submission_steps.rb' + - 'lib/accession/accession/submission.rb' + - 'lib/accession/accession/tag_list.rb' + - 'lib/authenticated_test_helper.rb' + - 'lib/capybara_failure_logger.rb' + - 'lib/eventful_record.rb' + - 'lib/informatics/test/helpers/authentication_helper.rb' + - 'lib/mbrave_tags_creator.rb' + - 'spec/lib/mock_parser.rb' + - 'test/unit/tag_qc/qcable_statemachine_checks.rb' + - 'test/unit/task_test_base.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ArrayIntersect: + Exclude: + - 'test/unit/flexible_submission_test.rb' + # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowOnConstant, AllowOnSelfClass. From e79a7980d7e9afe9a624d8f81d1cb9f662485425 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 23 Sep 2024 16:02:07 +0100 Subject: [PATCH 112/158] style: rubocop Style/HashSyntax bundle exec rubocop -a --- .../basic_handler/actions/inner_action.rb | 2 +- app/api/core/endpoint/basic_handler/paged.rb | 2 +- app/api/core/io/collection.rb | 2 +- app/api/core/io/json/stream.rb | 2 +- app/api/core/service.rb | 2 +- app/api/model_extensions/order.rb | 2 +- app/api/model_extensions/sample.rb | 2 +- .../bulk_submission_excel/download.rb | 12 +- .../export_pool_xp_to_traction_controller.rb | 2 +- app/controllers/batches_controller.rb | 2 +- .../concerns/plate_picks/batches_json.rb | 2 +- app/controllers/driver_files_controller.rb | 2 +- app/controllers/plate_picks_controller.rb | 2 +- app/controllers/qc_reports_controller.rb | 4 +- app/controllers/receptacles_controller.rb | 2 +- app/controllers/studies_controller.rb | 2 +- app/controllers/study_reports_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/controllers/workflows_controller.rb | 2 +- app/helpers/application_helper.rb | 8 +- app/helpers/assets_helper.rb | 2 +- app/helpers/bootstrap_helper.rb | 2 +- app/helpers/compound_sample_helper.rb | 2 +- app/helpers/prototype_replacement_helper.rb | 2 +- app/helpers/submissions_helper.rb | 6 +- app/heron/factories/concerns/contents.rb | 2 +- app/heron/factories/plate.rb | 2 +- app/heron/factories/sample.rb | 4 +- app/heron/factories/tube.rb | 2 +- app/heron/factories/tube_rack.rb | 8 +- app/heron/factories/tube_rack_status.rb | 2 +- app/jobs/export_pool_xp_to_traction_job.rb | 4 +- .../sample_manifest/generate_wells_job.rb | 2 +- app/middleware/api/root_service.rb | 2 +- app/models/accessionable/dac.rb | 2 +- app/models/accessionable/policy.rb | 2 +- app/models/accessionable/submission.rb | 2 +- app/models/add_spiked_in_control_task.rb | 4 +- app/models/aliquot.rb | 2 +- app/models/aliquot/data_for_substitution.rb | 6 +- app/models/api/sample_io.rb | 2 +- app/models/application_record.rb | 2 +- app/models/asset_audit.rb | 2 +- app/models/asset_group.rb | 4 +- app/models/attributable/association.rb | 4 +- app/models/attributable/attribute.rb | 6 +- app/models/bait_library_layout.rb | 2 +- app/models/barcode.rb | 2 +- app/models/barcode/barcodeable.rb | 2 +- app/models/batch.rb | 18 +- app/models/batch/state_machine_behaviour.rb | 4 +- app/models/batch_request.rb | 4 +- app/models/broadcast_event/qc_assay.rb | 2 +- app/models/bulk_submission.rb | 10 +- app/models/bulk_transfer.rb | 8 +- app/models/cherrypick_request.rb | 4 +- app/models/cherrypick_task.rb | 8 +- app/models/compound_aliquot.rb | 4 +- app/models/event/labware_failed_event.rb | 2 +- app/models/event/sample_logistics_qc_event.rb | 4 +- app/models/event/scanned_into_lab_event.rb | 2 +- app/models/event_sender.rb | 4 +- app/models/field_info.rb | 2 +- .../illumina_htp/requests/gbs_request.rb | 6 +- .../illumina_htp/requests/heron_request.rb | 6 +- .../requests/heron_tailed_request.rb | 6 +- app/models/item.rb | 2 +- app/models/lab_event.rb | 4 +- app/models/labware.rb | 2 +- app/models/labwhere_reception.rb | 8 +- app/models/lib_pool_norm_tube_generator.rb | 8 +- app/models/library_creation_request.rb | 4 +- app/models/location_report.rb | 12 +- .../location_report/location_report_form.rb | 16 +- app/models/lot.rb | 2 +- app/models/messenger_creator.rb | 2 +- app/models/metadata.rb | 2 +- app/models/metadata/builder_base.rb | 2 +- app/models/metadata/form_builder.rb | 4 +- app/models/order.rb | 6 +- app/models/phi_x.rb | 4 +- app/models/phi_x/spiked_buffer.rb | 6 +- app/models/phi_x/stock.rb | 2 +- app/models/pick_list.rb | 8 +- app/models/pick_list/pick.rb | 2 +- app/models/pick_list/record_cache.rb | 2 +- app/models/plate.rb | 6 +- app/models/plate/creator.rb | 12 +- app/models/plate/fluidigm_behaviour.rb | 4 +- app/models/plate/quad_creator.rb | 6 +- app/models/plate/sample_tube_factory.rb | 2 +- app/models/plate_barcode.rb | 6 +- app/models/plate_creation.rb | 2 +- app/models/plate_volume.rb | 2 +- app/models/pooling.rb | 4 +- app/models/presenters/qc_report_presenter.rb | 2 +- app/models/product_criteria.rb | 2 +- app/models/project.rb | 2 +- app/models/purpose.rb | 2 +- app/models/qc_file.rb | 2 +- app/models/qc_report.rb | 2 +- app/models/qc_report/file.rb | 4 +- app/models/qc_result.rb | 2 +- app/models/qc_result_factory.rb | 20 +- app/models/qcable/statemachine.rb | 2 +- app/models/qcable_creator.rb | 4 +- app/models/receptacle.rb | 8 +- app/models/report_fail.rb | 2 +- app/models/request.rb | 12 +- app/models/request/library_creation.rb | 4 +- .../sample_compound_aliquot_transfer.rb | 2 +- app/models/request/statemachine.rb | 2 +- app/models/request_factory.rb | 4 +- app/models/request_type/validation.rb | 2 +- app/models/robot.rb | 4 +- app/models/robot/verification/base.rb | 2 +- app/models/role.rb | 4 +- app/models/role/user_role_helper.rb | 2 +- app/models/sample.rb | 2 +- app/models/sample_manifest.rb | 4 +- app/models/sample_manifest/core_behaviour.rb | 4 +- app/models/sample_manifest/generator.rb | 12 +- .../sample_manifest/library_tube_behaviour.rb | 2 +- .../multiplexed_library_behaviour.rb | 2 +- app/models/sample_manifest/plate_behaviour.rb | 2 +- .../sample_manifest/sample_tube_behaviour.rb | 2 +- .../sample_manifest/shared_tube_behaviour.rb | 2 +- app/models/sample_manifest/uploader.rb | 2 +- app/models/sequencing_pipeline.rb | 2 +- app/models/set_descriptors_task.rb | 8 +- app/models/state_change.rb | 8 +- app/models/state_changer/mx_tube.rb | 2 +- app/models/state_changer/standard_plate.rb | 2 +- app/models/stock_stamper.rb | 2 +- app/models/study.rb | 2 +- app/models/study/poly_metadata_handler.rb | 2 +- app/models/study_report.rb | 2 +- app/models/study_report/well_details.rb | 4 +- app/models/submission/accession_behaviour.rb | 2 +- .../submission/asset_group_behaviour.rb | 2 +- .../submission/flexible_request_graph.rb | 8 +- app/models/submission/linear_request_graph.rb | 6 +- app/models/submission/submission_creator.rb | 12 +- app/models/submission_template.rb | 2 +- app/models/supplier.rb | 2 +- app/models/tag2_layout_template.rb | 4 +- app/models/tag_group.rb | 2 +- app/models/tag_group/form_object.rb | 2 +- app/models/tag_layout_template.rb | 16 +- app/models/tag_set.rb | 4 +- app/models/tag_substitution.rb | 4 +- app/models/tag_substitution/substitution.rb | 2 +- .../tasks/add_spiked_in_control_handler.rb | 4 +- app/models/tasks/base_handler.rb | 2 +- app/models/tasks/cherrypick_handler.rb | 2 +- app/models/tasks/set_descriptors_handler.rb | 4 +- .../transfer/between_plate_and_tubes.rb | 2 +- app/models/tube.rb | 4 +- app/models/user/authentication.rb | 12 +- app/models/uuid.rb | 14 +- app/models/well.rb | 6 +- .../work_completion/labware_completion.rb | 2 +- app/models/work_order/factory.rb | 2 +- .../api/v2/plate_purpose_resource.rb | 2 +- app/resources/api/v2/tube_rack_resource.rb | 2 +- .../sample_manifest_excel/download.rb | 8 +- .../sample_manifest_excel/test_download.rb | 2 +- .../sample_manifest_excel/upload/base.rb | 4 +- .../upload/processor/base.rb | 4 +- .../upload/processor/tube_rack.rb | 4 +- .../sample_manifest_excel/upload/row.rb | 4 +- .../sample_manifest_excel/upload/rows.rb | 2 +- .../worksheet/data_worksheet.rb | 2 +- .../worksheet/test_worksheet.rb | 18 +- .../sequencescape_excel/column.rb | 6 +- .../conditional_formatting_default.rb | 4 +- .../sequencescape_excel/formula.rb | 10 +- .../sequencescape_excel/range.rb | 8 +- .../sequencescape_excel/range_list.rb | 2 +- .../specialised_field/chromium_tag_well.rb | 2 +- .../specialised_field/dual_index_tag_well.rb | 4 +- .../specialised_field/volume.rb | 2 +- .../sequencescape_excel/validation.rb | 2 +- .../sequencescape_excel/worksheet/base.rb | 4 +- app/uat_actions/uat_actions.rb | 2 +- .../generate_plate_concentrations.rb | 6 +- .../uat_actions/generate_plates.rb | 4 +- .../uat_actions/generate_primer_panel.rb | 6 +- .../uat_actions/generate_project.rb | 2 +- .../uat_actions/generate_qc_results.rb | 2 +- .../uat_actions/generate_sample_manifest.rb | 6 +- .../uat_actions/generate_tag_group.rb | 6 +- .../generate_tag_layout_template.rb | 6 +- .../uat_actions/generate_tag_plates.rb | 4 +- .../uat_actions/generate_tagged_plates.rb | 12 +- .../uat_actions/generate_tube_racks.rb | 4 +- app/uat_actions/uat_actions/generate_tubes.rb | 2 +- app/uat_actions/uat_actions/static_records.rb | 10 +- .../uat_actions/test_submission.rb | 8 +- .../uat_actions/tube_submission.rb | 8 +- config/initializers/api_routing.rb | 2 +- ...late_existing_purposes_with_prefix_data.rb | 2 +- ...29080953_remove_redundant_plate_classes.rb | 2 +- ...4_migrate_sanger_barcodes_to_new_tables.rb | 4 +- ...52_migrate_other_barcodes_to_new_tables.rb | 4 +- ...123113_migrate_plate_type_to_new_column.rb | 2 +- ...0094528_migrate_legacy_pipeline_classes.rb | 4 +- ...grate_removed_pipelines_to_legacy_class.rb | 4 +- ...815_remove_flexible_cherrypick_pipeline.rb | 4 +- ...30512102847_add_missing_insdc_countries.rb | 2 +- db/seeds/0001_tube_purposes.rb | 2 +- db/seeds/0001_workflows.rb | 78 ++--- db/seeds/0010_budget_division.rb | 2 +- db/seeds/0013_reference_genome.rb | 2 +- db/seeds/0015_tags.rb | 2 +- db/seeds/0016_tag_layout_templates.rb | 12 +- db/seeds/0017_bait_libraries.rb | 2 +- db/seeds/0019_plate_creators.rb | 6 +- db/seeds/3000_library_types_setup.rb | 18 +- db/seeds/9999_tag_qc_setup.rb | 4 +- features/support/accession_service.rb | 2 +- features/support/barcode_service.rb | 4 +- features/support/capybara.rb | 4 +- features/support/parameter_types.rb | 12 +- features/support/paths.rb | 4 +- ...97_change_request_type_on_request_steps.rb | 6 +- ...equest_xml_exception_on_nil_study_steps.rb | 6 +- ...3383_bug_NPG_batch_state_released_steps.rb | 4 +- ...5_add_bait_library_editor_to_admin_view.rb | 14 +- ...5177179_updating_released_samples_steps.rb | 4 +- .../3550676_search_functionality_steps.rb | 2 +- ...92_links_from_study_workflow_view_steps.rb | 4 +- ..._sample_update_filters_properties_steps.rb | 2 +- ..._descriptors_etc_to_table_columns_steps.rb | 12 +- .../4759010_bug_on_reset_batches_steps.rb | 4 +- ...sting_additional_hiseq_sequencing_steps.rb | 4 +- .../5158172_gel_hide_blank_wells_steps.rb | 2 +- .../5197615_external_release_flag_steps.rb | 4 +- .../5393882_spiked_in_control_steps.rb | 4 +- .../5397680_sequenome_plate_details_steps.rb | 4 +- ...xternal_data_release_interactions_steps.rb | 6 +- ...0471_truncate_sample_name_barcode_steps.rb | 2 +- ...play_concentration_inbox_pipeline_steps.rb | 4 +- ...cate_SE_pipeline_with_no_controls_steps.rb | 2 +- .../step_definitions/65192392_tag_qc_steps.rb | 38 +- ...01_batch_request_recycling_broken_steps.rb | 14 +- ...9309_pulldown_cherrypick_pipeline_steps.rb | 2 +- .../support/step_definitions/aliquot_steps.rb | 2 +- .../support/step_definitions/api_steps.rb | 14 +- .../support/step_definitions/asset_steps.rb | 22 +- .../step_definitions/authentication_steps.rb | 6 +- .../step_definitions/bait_library_steps.rb | 2 +- .../support/step_definitions/barcode_steps.rb | 2 +- .../support/step_definitions/batch_steps.rb | 6 +- .../step_definitions/bulk_submission_steps.rb | 4 +- .../custom_metadatum_collection_steps.rb | 2 +- .../step_definitions/custom_text_steps.rb | 2 +- ...splay_submitted_at_inbox_pipeline_steps.rb | 4 +- .../step_definitions/genotyping_steps.rb | 12 +- .../support/step_definitions/order_steps.rb | 8 +- .../step_definitions/pipeline_steps.rb | 14 +- .../support/step_definitions/plate_steps.rb | 42 +-- .../support/step_definitions/project_steps.rb | 4 +- .../step_definitions/pulldown_steps.rb | 18 +- .../reference_genome_steps.rb | 2 +- .../support/step_definitions/request_steps.rb | 2 +- .../robot_verification_steps.rb | 2 +- .../support/step_definitions/role_steps.rb | 2 +- .../step_definitions/sample_manifest_steps.rb | 18 +- .../step_definitions/sample_metadata_steps.rb | 2 +- .../support/step_definitions/samples_steps.rb | 52 +-- .../step_definitions/study_report_steps.rb | 4 +- .../support/step_definitions/study_steps.rb | 26 +- .../step_definitions/submission_steps.rb | 14 +- .../step_definitions/tag_layout_steps.rb | 14 +- .../step_definitions/transfer_steps.rb | 24 +- .../support/step_definitions/tube_steps.rb | 2 +- .../support/step_definitions/user_steps.rb | 8 +- .../support/step_definitions/uuid_steps.rb | 12 +- .../various_object_construction_steps.rb | 4 +- .../support/step_definitions/web_steps.rb | 10 +- lib/ability_analysis.rb | 2 +- lib/ability_analysis/spec_generator.rb | 6 +- lib/accession/accession/contact.rb | 2 +- lib/acts_as_descriptable.rb | 2 +- lib/event_factory.rb | 8 +- lib/insdc/import_countries.rb | 2 +- lib/lab_where_client.rb | 2 +- .../label_printer/label/base_plate.rb | 2 +- lib/label_printer/label_printer/pmb_client.rb | 2 +- lib/label_printer/label_printer/print_job.rb | 4 +- lib/limber/helper.rb | 8 +- lib/mbrave_tags_creator.rb | 14 +- lib/object_space_profile.rb | 2 +- lib/product_helpers.rb | 2 +- lib/record_loader/asset_shape_loader.rb | 2 +- .../barcode_printer_type_loader.rb | 2 +- lib/record_loader/flowcell_type_loader.rb | 2 +- lib/record_loader/library_type_loader.rb | 2 +- lib/record_loader/pipeline_loader.rb | 6 +- ...ipeline_request_information_type_loader.rb | 4 +- lib/record_loader/plate_type_loader.rb | 2 +- lib/record_loader/primer_panel_loader.rb | 2 +- lib/record_loader/product_catalogue_loader.rb | 2 +- .../request_information_type_loader.rb | 2 +- lib/record_loader/request_type_loader.rb | 8 +- .../request_type_validators_loader.rb | 2 +- lib/record_loader/robot_loader.rb | 2 +- lib/record_loader/robot_property_loader.rb | 2 +- .../submission_template_loader.rb | 10 +- .../tag_group_adapter_type_loader.rb | 2 +- lib/record_loader/tag_group_loader.rb | 4 +- .../tag_layout_templates_loader.rb | 2 +- lib/record_loader/tag_set_loader.rb | 2 +- lib/record_loader/transfer_template_loader.rb | 2 +- lib/record_loader/tube_purpose_loader.rb | 2 +- lib/record_loader/tube_rack_purpose_loader.rb | 2 +- lib/record_loader/workflow_loader.rb | 2 +- lib/request_class_deprecator.rb | 2 +- lib/tasks/add_heron_product.rake | 2 +- .../add_missing_asset_audit_records.rake | 2 +- lib/tasks/add_traction_records.rake | 2 +- lib/tasks/benchmark_plate_transfer.rake | 6 +- lib/tasks/devour.rake | 2 +- lib/tasks/hic_library_types.rake | 4 +- lib/tasks/limber.rake | 10 +- lib/tasks/limber_dev.rake | 6 +- ...gister_auto_imported_samples_as_stock.rake | 2 +- lib/tasks/retention_instructions.rake | 2 +- lib/views_schema.rb | 4 +- lib/working_setup/standard_seeder.rb | 16 +- spec/api/dilution_plate_purpose_spec.rb | 2 +- spec/api/extraction_attributes_spec.rb | 2 +- spec/api/multiplexed_library_tube_spec.rb | 2 +- spec/api/plate_purpose_spec.rb | 2 +- spec/api/request_types_spec.rb | 2 +- spec/api/specific_tube_creation_spec.rb | 8 +- spec/api/state_change_spec.rb | 20 +- spec/api/submission_pool_spec.rb | 22 +- spec/api/tube_creation_spec.rb | 8 +- .../data_worksheet_spec.rb | 8 +- spec/bulk_submission_excel/download_spec.rb | 2 +- ...ort_pool_xp_to_traction_controller_spec.rb | 2 +- .../api/v2/heron/plates_controller_spec.rb | 10 +- .../v2/heron/tube_racks_controller_spec.rb | 4 +- .../driver_files_controller_spec.rb | 2 +- .../labwhere_receptions_controller_spec.rb | 4 +- .../npg_actions/assets_controller_spec.rb | 12 +- .../receptacles_controller_spec.rb | 4 +- .../report_fails_controller_spec.rb | 4 +- .../robot_verifications_controller_spec.rb | 18 +- spec/controllers/searches_controller_spec.rb | 2 +- .../studies/information_controller_spec.rb | 2 +- spec/controllers/studies_controller_spec.rb | 4 +- spec/factories/accession/tags.rb | 2 +- spec/factories/barcode_factories.rb | 4 +- spec/factories/batch_factories.rb | 6 +- .../custom_metadatum_collection_factories.rb | 2 +- spec/factories/lib_pcr_xp_factories.rb | 4 +- spec/factories/pipelines_factories.rb | 14 +- spec/factories/plate_factories.rb | 10 +- spec/factories/projects.rb | 2 +- spec/factories/pulldown_factories.rb | 8 +- spec/factories/request_factories.rb | 2 +- spec/factories/request_type_factories.rb | 24 +- .../sample_manifest_excel/columns.rb | 2 +- .../conditional_formattings.rb | 4 +- .../factories/sample_manifest_excel/ranges.rb | 2 +- .../test_download_plates.rb | 24 +- .../test_download_tubes.rb | 22 +- .../test_download_tubes_in_rack.rb | 22 +- .../sample_manifest_excel/validations.rb | 2 +- spec/factories/sample_manifest_factories.rb | 6 +- spec/factories/samples.rb | 2 +- spec/factories/shared_traits.rb | 2 +- spec/factories/submission_factories.rb | 2 +- spec/factories/tag2_layout_factories.rb | 2 +- spec/factories/tag_group_factories.rb | 2 +- spec/factories/tube_factories.rb | 8 +- spec/factories/well_factories.rb | 6 +- spec/features/assets/asset_submission_spec.rb | 4 +- .../features/batches/failing_requests_spec.rb | 2 +- spec/features/batches/sort_requests_spec.rb | 2 +- ...ncorrect_submission_id_on_transfer_spec.rb | 2 +- .../patient_consent_withdrawl_spec.rb | 14 +- ..._for_fluidigm_pipeline_micro_litre_spec.rb | 10 +- .../cherrypick/cherrypick_pipeline_spec.rb | 10 +- .../pipelines/creating_an_empty_batch_spec.rb | 2 +- .../following_a_sequencing_pipeline_spec.rb | 12 +- ...line_with_compound_sample_creation_spec.rb | 2 +- .../viewing_request_comments_spec.rb | 2 +- .../track_sample_manifest_updates_spec.rb | 2 +- ...r_for_manifests_with_tag_sequences_spec.rb | 44 +-- ...ransfers_on_repools_starts_repools_spec.rb | 8 +- spec/features/studies/qc_reports_spec.rb | 6 +- .../studies/view_study_properties_spec.rb | 2 +- .../studies/view_study_request_links_spec.rb | 4 +- .../submissions/bulk_submissions_spec.rb | 2 +- spec/features/tag_set_spec.rb | 4 +- spec/helpers/batches_helper_spec.rb | 4 +- spec/helpers/compound_sample_helper_spec.rb | 2 +- .../heron/factories/concerns/contents_spec.rb | 4 +- .../heron/factories/concerns/eventful_spec.rb | 2 +- spec/heron/factories/event_spec.rb | 2 +- spec/heron/factories/plate_spec.rb | 14 +- spec/heron/factories/sample_spec.rb | 42 +-- spec/heron/factories/tube_spec.rb | 2 +- spec/insdc/import_countries_spec.rb | 2 +- spec/lib/ability_analysis_spec.rb | 2 +- spec/lib/label_printer/batch_plate_spec.rb | 12 +- .../sample_manifest_plate_double_spec.rb | 2 +- spec/lib/label_printer/swipecard_spec.rb | 8 +- spec/lib/limber/helper_spec.rb | 4 +- spec/lib/mbrave_tags_creator_spec.rb | 2 +- .../record_loader/request_type_loader_spec.rb | 2 +- .../tag_layout_templates_loader_spec.rb | 4 +- spec/models/aliquot_spec.rb | 8 +- spec/models/api/aliquot_io_spec.rb | 10 +- spec/models/api/asset_link_io_spec.rb | 2 +- spec/models/api/batch_io_spec.rb | 2 +- spec/models/api/batch_request_io_spec.rb | 2 +- spec/models/api/library_tube_io_spec.rb | 4 +- spec/models/api/messages/flowcell_io_spec.rb | 2 +- spec/models/api/messages/qc_result_io_spec.rb | 2 +- .../messages/well_stock_resource_io_spec.rb | 2 +- spec/models/api/order_io_spec.rb | 6 +- spec/models/api/project_io_spec.rb | 2 +- spec/models/api/request_io_spec.rb | 2 +- spec/models/api/sample_tube_io_spec.rb | 2 +- spec/models/api/study_io_spec.rb | 2 +- spec/models/api/study_sample_io_spec.rb | 2 +- spec/models/api/submission_io_spec.rb | 2 +- spec/models/api/well_io_spec.rb | 4 +- spec/models/barcode/format_handlers_spec.rb | 2 +- spec/models/batch_spec.rb | 4 +- .../broadcast_event/broadcast_event_spec.rb | 2 +- spec/models/broadcast_event/lab_event_spec.rb | 6 +- .../broadcast_event/library_complete_spec.rb | 4 +- .../plate_cherrypicked_spec.rb | 2 +- .../broadcast_event/pool_released_spec.rb | 4 +- spec/models/broadcast_event/qc_assay_spec.rb | 4 +- .../sequencing_complete_spec.rb | 10 +- spec/models/bulk_submission_spec.rb | 4 +- spec/models/cherrypick_request_spec.rb | 2 +- .../cherrypick_task/control_locator_spec.rb | 10 +- spec/models/comment_spec.rb | 16 +- spec/models/external_release_event_spec.rb | 2 +- spec/models/flowcell_type_spec.rb | 2 +- spec/models/library_type_spec.rb | 2 +- spec/models/linear_submission_spec.rb | 54 +-- spec/models/location_report_form_spec.rb | 18 +- spec/models/location_report_spec.rb | 28 +- spec/models/lot_type_spec.rb | 2 +- spec/models/orders/automated_order_spec.rb | 4 +- spec/models/orders/order_spec.rb | 14 +- spec/models/orders/shared_order_specs.rb | 2 +- spec/models/phi_x/spiked_buffer_spec.rb | 4 +- spec/models/phi_x/stock_spec.rb | 4 +- spec/models/pick_list_spec.rb | 4 +- spec/models/plate/quad_creator_spec.rb | 4 +- spec/models/plate_purpose_spec.rb | 2 +- spec/models/plate_spec.rb | 12 +- spec/models/pooling_spec.rb | 6 +- .../requests/isc_library_request_spec.rb | 2 +- spec/models/qc_report_spec.rb | 34 +- spec/models/qc_result/qc_result_spec.rb | 2 +- spec/models/qcable_creator_spec.rb | 6 +- spec/models/qcable_spec.rb | 2 +- spec/models/racked_tube_spec.rb | 2 +- .../downstream_aliquots_removal_spec.rb | 2 +- spec/models/receptacle_spec.rb | 4 +- spec/models/request/traction/grid_ion_spec.rb | 10 +- spec/models/request_information_type_spec.rb | 8 +- spec/models/request_spec.rb | 30 +- .../validator/library_type_validator_spec.rb | 14 +- spec/models/robot/generator/tecan_spec.rb | 2 +- spec/models/robot/pick_data_spec.rb | 2 +- .../verification/source_dest_beds_spec.rb | 2 +- .../source_dest_control_beds_spec.rb | 2 +- spec/models/sample/metadata_spec.rb | 2 +- spec/models/sample_manifest/generator_spec.rb | 2 +- spec/models/sample_manifest_spec.rb | 10 +- spec/models/sample_spec.rb | 2 +- spec/models/sequencing_request_spec.rb | 24 +- spec/models/specific_tube_creations_spec.rb | 10 +- .../state_changer/initial_stock_tube_spec.rb | 10 +- spec/models/state_changer/input_plate_spec.rb | 8 +- spec/models/state_changer/mx_tube_spec.rb | 10 +- .../state_changer/qcable_labware_spec.rb | 2 +- .../qcable_library_plate_spec.rb | 8 +- .../state_changer/standard_plate_spec.rb | 8 +- spec/models/state_changer/stock_tube_spec.rb | 10 +- spec/models/std_library_request_spec.rb | 14 +- spec/models/study_spec.rb | 40 +-- .../submission/submission_creator_spec.rb | 2 +- spec/models/submission_spec.rb | 34 +- spec/models/tag2_layout_spec.rb | 4 +- spec/models/tag2_layout_template_spec.rb | 4 +- spec/models/tag_group/adapter_type_spec.rb | 4 +- spec/models/tag_group_spec.rb | 4 +- spec/models/tag_layout_spec.rb | 28 +- spec/models/tag_layout_template_spec.rb | 10 +- spec/models/tag_set_spec.rb | 14 +- spec/models/tasks/cherrypick_task_spec.rb | 10 +- spec/models/tasks/plate_template_task_spec.rb | 6 +- .../set_descriptors_handler/handler_spec.rb | 6 +- spec/models/transfer/between_plates_spec.rb | 6 +- .../transfer_request_collection_spec.rb | 24 +- spec/models/transfer_request_spec.rb | 36 +- spec/models/tube_purpose_spec.rb | 2 +- spec/models/tube_rack_spec.rb | 10 +- spec/models/tube_spec.rb | 14 +- spec/models/user_query_spec.rb | 2 +- spec/models/well_attribute_spec.rb | 2 +- spec/models/well_spec.rb | 10 +- spec/models/work_order_spec.rb | 10 +- spec/models/work_order_type_spec.rb | 4 +- spec/requests/api/v2/heron/plates_spec.rb | 2 +- spec/requests/api/v2/heron/tube_racks_spec.rb | 4 +- spec/requests/api/v2/receptacles_spec.rb | 10 +- .../api_key_authenticatable.rb | 6 +- spec/requests/api/v2/users_spec.rb | 2 +- spec/requests/api/v2/wells_spec.rb | 10 +- spec/requests/api/v2/work_orders_spec.rb | 2 +- spec/requests/plate_picks_request_spec.rb | 10 +- spec/requests/qc_files_spec.rb | 2 +- .../api/v2/lot_type_resource_spec.rb | 2 +- .../api/v2/plate_purpose_resource_spec.rb | 2 +- .../resources/api/v2/request_resource_spec.rb | 2 +- .../api/v2/submission_resource_spec.rb | 2 +- .../api/v2/tag_group_resource_spec.rb | 2 +- spec/resources/api/v2/well_resource_spec.rb | 2 +- .../api/v2/work_order_resource_spec.rb | 2 +- .../sample_manifest_excel/upload/data_spec.rb | 2 +- .../upload/processor_spec.rb | 74 ++-- spec/sample_manifest_excel/upload/row_spec.rb | 56 +-- .../sample_manifest_excel/upload/rows_spec.rb | 10 +- .../upload/upload_spec.rb | 6 +- spec/sample_manifest_excel/worksheet_spec.rb | 38 +- spec/sequencescape_excel/column_spec.rb | 2 +- .../conditional_formatting_list_spec.rb | 2 +- .../conditional_formatting_spec.rb | 10 +- spec/sequencescape_excel/range_spec.rb | 8 +- .../specialised_field_spec.rb | 328 +++++++++--------- spec/sequencescape_excel/validation_spec.rb | 28 +- spec/sequencescape_excel/worksheet_spec.rb | 2 +- spec/shared_contexts/it_requires_login.rb | 4 +- spec/shared_contexts/limber_shared_context.rb | 4 +- spec/spec_helper.rb | 4 +- spec/support/api_helper.rb | 6 +- spec/support/api_v2_helper.rb | 6 +- spec/uat_actions/generate_project_spec.rb | 2 +- .../generate_sample_manifest_spec.rb | 26 +- spec/uat_actions/generate_study_spec.rb | 2 +- .../generate_tag_layout_template_spec.rb | 4 +- spec/uat_actions/plate_information_spec.rb | 52 +-- spec/views/labware/show_chromium_chip_spec.rb | 2 +- spec/views/labware/show_html_erb_spec.rb | 6 +- .../tube_rack_summaries/show_html_erb_spec.rb | 2 +- test/controllers/batches_controller_test.rb | 10 +- .../plate_summaries_controller_test.rb | 4 +- test/controllers/plates_controller_test.rb | 2 +- .../requests_comments_controller_test.rb | 2 +- test/functional/pre_cap_groups_test.rb | 2 +- test/lib/label_printer/batch_tube_test.rb | 4 +- test/lib/label_printer/plate_creator_test.rb | 6 +- test/lib/label_printer/plate_to_tube_test.rb | 2 +- test/lib/label_printer/print_job_test.rb | 6 +- test/performance/state_change_test.rb | 2 +- test/shoulda_macros/sanger_macros.rb | 4 +- test/unit/accession_service_test.rb | 2 +- test/unit/aliquot_indexer_test.rb | 8 +- test/unit/fluidigm_plate_test.rb | 4 +- test/unit/import_fluidigm_data_test.rb | 6 +- test/unit/lab_interface/workflow_test.rb | 4 +- .../unit/lib_pool_norm_tube_generator_test.rb | 2 +- test/unit/plate_test.rb | 4 +- .../product_catalogue/library_driven_test.rb | 4 +- test/unit/product_criteria_test.rb | 2 +- test/unit/qc_report_test.rb | 4 +- 580 files changed, 1971 insertions(+), 1979 deletions(-) diff --git a/app/api/core/endpoint/basic_handler/actions/inner_action.rb b/app/api/core/endpoint/basic_handler/actions/inner_action.rb index 161a760e3e..8f998c73a4 100644 --- a/app/api/core/endpoint/basic_handler/actions/inner_action.rb +++ b/app/api/core/endpoint/basic_handler/actions/inner_action.rb @@ -28,7 +28,7 @@ def rooted_json(options, &block) private :rooted_json def generate_json_actions(object, options) - rooted_json(options) { |stream| super(object, options.merge(stream: stream)) } + rooted_json(options) { |stream| super(object, options.merge(stream:)) } end def declare_action(name, _options) # rubocop:todo Metrics/MethodLength diff --git a/app/api/core/endpoint/basic_handler/paged.rb b/app/api/core/endpoint/basic_handler/paged.rb index 39bc0fccb3..d4a741373d 100644 --- a/app/api/core/endpoint/basic_handler/paged.rb +++ b/app/api/core/endpoint/basic_handler/paged.rb @@ -47,7 +47,7 @@ def page_of_results(target, page = 1, model = target) raise ActiveRecord::RecordNotFound, 'before the start of the results' if page <= 0 target - .paginate(page: page, per_page: results_per_page, total_entries: model.count(:all)) + .paginate(page:, per_page: results_per_page, total_entries: model.count(:all)) .tap do |results| raise ActiveRecord::RecordNotFound, 'past the end of the results' if (page > 1) && (page > results.total_pages) end diff --git a/app/api/core/io/collection.rb b/app/api/core/io/collection.rb index ac2b42e6b2..c05e05de0f 100644 --- a/app/api/core/io/collection.rb +++ b/app/api/core/io/collection.rb @@ -9,7 +9,7 @@ def as_json(options = {}) ::Core::Io::Registry .instance .lookup_for_object(object) - .object_json(object, options.merge(stream: stream, target: object, nested: true)) + .object_json(object, options.merge(stream:, target: object, nested: true)) end end end diff --git a/app/api/core/io/json/stream.rb b/app/api/core/io/json/stream.rb index 523117eec6..bd2c07bfee 100644 --- a/app/api/core/io/json/stream.rb +++ b/app/api/core/io/json/stream.rb @@ -80,7 +80,7 @@ def object_encode(object, options) ::Core::Io::Registry .instance .lookup_for_object(object) - .object_json(object, options.merge(stream: self, object: object, nested: true)) + .object_json(object, options.merge(stream: self, object:, nested: true)) end end private :object_encode diff --git a/app/api/core/service.rb b/app/api/core/service.rb index aef4957cc7..31692d790c 100644 --- a/app/api/core/service.rb +++ b/app/api/core/service.rb @@ -238,7 +238,7 @@ def each(&block) # rubocop:todo Metrics/AbcSize ::Core::Io::Registry .instance .lookup_for_object(object) - .as_json(response: self, target: object, stream: stream, object: object, handled_by: handled_by) + .as_json(response: self, target: object, stream:, object:, handled_by:) end end diff --git a/app/api/model_extensions/order.rb b/app/api/model_extensions/order.rb index 1dad43d300..7214664bf1 100644 --- a/app/api/model_extensions/order.rb +++ b/app/api/model_extensions/order.rb @@ -72,7 +72,7 @@ def <<(associated) end scope :that_submitted_asset_id, - ->(asset_id) { where(submitted_assets: { asset_id: asset_id }).joins(:submitted_assets) } + ->(asset_id) { where(submitted_assets: { asset_id: }).joins(:submitted_assets) } validate :extended_validation def extended_validation diff --git a/app/api/model_extensions/sample.rb b/app/api/model_extensions/sample.rb index 8dbdbdd93c..5827f1fd32 100644 --- a/app/api/model_extensions/sample.rb +++ b/app/api/model_extensions/sample.rb @@ -19,6 +19,6 @@ def sample_reference_genome_name end def sample_reference_genome_name=(name) - sample_metadata.reference_genome = ReferenceGenome.find_by(name: name) + sample_metadata.reference_genome = ReferenceGenome.find_by(name:) end end diff --git a/app/bulk_submission_excel/bulk_submission_excel/download.rb b/app/bulk_submission_excel/bulk_submission_excel/download.rb index cbe1e26fc3..0bf511bb2d 100644 --- a/app/bulk_submission_excel/bulk_submission_excel/download.rb +++ b/app/bulk_submission_excel/bulk_submission_excel/download.rb @@ -22,13 +22,11 @@ def new_record? end def ranges_worksheet - if valid? - @ranges_worksheet ||= SequencescapeExcel::Worksheet::RangesWorksheet.new(ranges: range_list, workbook: workbook) - end + @ranges_worksheet ||= SequencescapeExcel::Worksheet::RangesWorksheet.new(ranges: range_list, workbook:) if valid? end def submission_template_id=(id) - self.submission_template = SubmissionTemplate.find_by(id: id) + self.submission_template = SubmissionTemplate.find_by(id:) end def submission_template_id @@ -40,11 +38,11 @@ def data_worksheet @data_worksheet ||= BulkSubmissionExcel::Worksheet::DataWorksheet.new( - workbook: workbook, + workbook:, columns: column_list, - assets: assets, + assets:, ranges: range_list, - defaults: defaults + defaults: ) end diff --git a/app/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller.rb b/app/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller.rb index f7daa808ec..f1675569ec 100644 --- a/app/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller.rb +++ b/app/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller.rb @@ -12,7 +12,7 @@ def create Rails.logger.debug { "Creating export_pool_xp_to_traction job for tube with barcode '#{barcode}'" } errors = preflight_errors(barcode) - render json: { errors: errors }, status: :unprocessable_entity and return unless errors.empty? + render json: { errors: }, status: :unprocessable_entity and return unless errors.empty? Delayed::Job.enqueue ExportPoolXpToTractionJob.new(barcode) render json: {}, status: :ok diff --git a/app/controllers/batches_controller.rb b/app/controllers/batches_controller.rb index 40dbb73554..90436c6f86 100644 --- a/app/controllers/batches_controller.rb +++ b/app/controllers/batches_controller.rb @@ -401,7 +401,7 @@ def standard_create(requests) # rubocop:todo Metrics/CyclomaticComplexity return pipeline_error_on_batch_creation('Batches must contain at least one request') if requests.empty? begin - ActiveRecord::Base.transaction { @batch = @pipeline.batches.create!(requests: requests, user: current_user) } + ActiveRecord::Base.transaction { @batch = @pipeline.batches.create!(requests:, user: current_user) } rescue ActiveRecord::RecordNotUnique => e # We don't explicitly check for this on creation of batch_request for performance reasons, and the front end # usually ensures this situation isn't possible. However if the user opens duplicate tabs it is possible. diff --git a/app/controllers/concerns/plate_picks/batches_json.rb b/app/controllers/concerns/plate_picks/batches_json.rb index 5458059ceb..e92f4e19b3 100644 --- a/app/controllers/concerns/plate_picks/batches_json.rb +++ b/app/controllers/concerns/plate_picks/batches_json.rb @@ -9,7 +9,7 @@ def initialize(batch_id, pick_information, plate_information) end def to_json(_ = nil) - { batch: { id: @batch_id.to_s, picks: picks } } + { batch: { id: @batch_id.to_s, picks: } } end private diff --git a/app/controllers/driver_files_controller.rb b/app/controllers/driver_files_controller.rb index 3dcd917368..261be0b57e 100644 --- a/app/controllers/driver_files_controller.rb +++ b/app/controllers/driver_files_controller.rb @@ -11,7 +11,7 @@ class DriverFilesController < ApplicationController def show @plate_barcode = @batch.plate_barcode(params[:barcode]) - generator = @robot.generator(batch: @batch, plate_barcode: @plate_barcode, pick_number: pick_number) + generator = @robot.generator(batch: @batch, plate_barcode: @plate_barcode, pick_number:) base_filename = "#{@batch.id}_batch_#{@plate_barcode}_#{pick_number}" send_data generator.as_text, type: generator.type, diff --git a/app/controllers/plate_picks_controller.rb b/app/controllers/plate_picks_controller.rb index b9015b4bfc..e1abc3f105 100644 --- a/app/controllers/plate_picks_controller.rb +++ b/app/controllers/plate_picks_controller.rb @@ -32,7 +32,7 @@ def plates # rubocop:todo Metrics/AbcSize plate: { id: plate.id, barcode: plate.machine_barcode, - batches: batches, + batches:, control: plate.pick_as_control? } } diff --git a/app/controllers/qc_reports_controller.rb b/app/controllers/qc_reports_controller.rb index 00be5cc7ea..3759991916 100644 --- a/app/controllers/qc_reports_controller.rb +++ b/app/controllers/qc_reports_controller.rb @@ -47,9 +47,9 @@ def create # rubocop:todo Metrics/AbcSize, Metrics/MethodLength exclude_existing = params[:qc_report][:exclude_existing] == '1' qc_report = QcReport.new( - study: study, + study:, product_criteria: @product.stock_criteria, - exclude_existing: exclude_existing, + exclude_existing:, plate_purposes: params[:qc_report][:plate_purposes].try(:reject, &:blank?) ) diff --git a/app/controllers/receptacles_controller.rb b/app/controllers/receptacles_controller.rb index dfc929bd8c..67881ae8aa 100644 --- a/app/controllers/receptacles_controller.rb +++ b/app/controllers/receptacles_controller.rb @@ -154,7 +154,7 @@ def create_request # rubocop:todo Metrics/AbcSize assets: [@asset], request_types: [@request_type.id], request_options: request_options.to_unsafe_h, - submission: submission, + submission:, comments: params[:comments] ) resubmission_order.save! diff --git a/app/controllers/studies_controller.rb b/app/controllers/studies_controller.rb index a202258b68..49afb40407 100644 --- a/app/controllers/studies_controller.rb +++ b/app/controllers/studies_controller.rb @@ -301,7 +301,7 @@ def self.role_helper(name, success_action, error_action) # rubocop:todo Metrics/ end @roles = @study.roles.reload - render partial: 'roles', status: status + render partial: 'roles', status: end end end diff --git a/app/controllers/study_reports_controller.rb b/app/controllers/study_reports_controller.rb index bf7d15b54f..660fdea4ce 100644 --- a/app/controllers/study_reports_controller.rb +++ b/app/controllers/study_reports_controller.rb @@ -26,7 +26,7 @@ def new def create # rubocop:todo Metrics/AbcSize, Metrics/MethodLength study = Study.find_by(id: params[:study_report][:study]) - study_report = StudyReport.create!(study: study, user: @current_user) + study_report = StudyReport.create!(study:, user: @current_user) study_report.schedule_report diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6c5cee0fc2..2231dc9af4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -56,7 +56,7 @@ def print_swipecard_with_pmb(swipecard, printer) # rubocop:todo Metrics/MethodLe printer, LabelPrinter::Label::Swipecard, user_login: @user.login.truncate(10, omission: '..'), - swipecard: swipecard, + swipecard:, label_template_name: configatron.swipecard_pmb_template ) if print_job.execute diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb index e8cb84a6c8..5815236d8d 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -94,7 +94,7 @@ def render_task(task, params) private def create_batch_events(batch, task) - event = batch.lab_events.build(description: 'Complete', user: current_user, batch: batch) + event = batch.lab_events.build(description: 'Complete', user: current_user, batch:) event.add_descriptor Descriptor.new(name: 'task_id', value: task.id) event.add_descriptor Descriptor.new(name: 'task', value: task.name) event.save! diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9db8efe1ab..bcfde2c15a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,7 +8,7 @@ def custom_text(identifier, differential = nil) Rails .cache .fetch("#{identifier}-#{differential}") do - custom_text = CustomText.find_by(identifier: identifier, differential: differential) + custom_text = CustomText.find_by(identifier:, differential:) custom_text.try(:content) || '' end @@ -170,7 +170,7 @@ def request_count_link(study, asset, state, request_type) # rubocop:todo Metrics url_path = request_path(matching_requests.first) link_to count, url_path, html_options elsif count > 1 - url_path = study_requests_path(study, state: state, request_type_id: request_type.id, asset_id: asset.id) + url_path = study_requests_path(study, state:, request_type_id: request_type.id, asset_id: asset.id) link_to count, url_path, html_options end end @@ -230,7 +230,7 @@ def tab(name, target: nil, active: false, id: nil) tag.li(class: 'nav-item') do link_to name, "##{target}", - id: id, + id:, data: { toggle: 'tab' }, @@ -249,7 +249,7 @@ def tab_pane(name, id: nil, tab_id: nil, active: false, &block) active_class = active ? 'active' : '' tag.div( class: ['tab-pane', 'fade', 'show', active_class], - id: id, + id:, role: 'tabpanel', aria_labelledby: tab_id, &block diff --git a/app/helpers/assets_helper.rb b/app/helpers/assets_helper.rb index 23c43893af..7acca83674 100644 --- a/app/helpers/assets_helper.rb +++ b/app/helpers/assets_helper.rb @@ -56,7 +56,7 @@ def select_field_sorted_by_name(field, select_options_source, selected, can_edit select_tag( field, options_for_select(select_options_source.sorted_by_name.pluck(:name, :id), selected.try(:to_i)), - options.merge(disabled: disabled, class: 'form-control select2') + options.merge(disabled:, class: 'form-control select2') ) end end diff --git a/app/helpers/bootstrap_helper.rb b/app/helpers/bootstrap_helper.rb index 2b50fca449..3893ddfdf2 100644 --- a/app/helpers/bootstrap_helper.rb +++ b/app/helpers/bootstrap_helper.rb @@ -128,7 +128,7 @@ def progress_bar(count) # rubocop:todo Metrics/MethodLength # rubocop:enable Layout/LineLength def loading_bar(id = 'update_loader', show: false, text: 'Loading') tag.div(class: 'loading-bar-placeholder') do - tag.div(id: id, class: 'loading-bar-container', style: show ? '' : 'display: none;') do + tag.div(id:, class: 'loading-bar-container', style: show ? '' : 'display: none;') do tag.div(text, class: 'loading-bar', role: 'progressbar') end end diff --git a/app/helpers/compound_sample_helper.rb b/app/helpers/compound_sample_helper.rb index 41cee51014..bea665f86e 100644 --- a/app/helpers/compound_sample_helper.rb +++ b/app/helpers/compound_sample_helper.rb @@ -24,7 +24,7 @@ def find_compound_sample_for_component_samples(component_samples) def create_compound_sample(study, component_samples) study.samples.create!( name: SangerSampleId.generate_sanger_sample_id!(study.abbreviation), - component_samples: component_samples + component_samples: ) end end diff --git a/app/helpers/prototype_replacement_helper.rb b/app/helpers/prototype_replacement_helper.rb index 1dca76a984..291302dd16 100644 --- a/app/helpers/prototype_replacement_helper.rb +++ b/app/helpers/prototype_replacement_helper.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PrototypeReplacementHelper def remote_button(label, url, data, html_options = {}) - form_tag url, remote: true, data: data, class: 'remote-form' do + form_tag url, remote: true, data:, class: 'remote-form' do submit_tag(label, html_options) end end diff --git a/app/helpers/submissions_helper.rb b/app/helpers/submissions_helper.rb index 3ab2308b58..203f8786c9 100644 --- a/app/helpers/submissions_helper.rb +++ b/app/helpers/submissions_helper.rb @@ -43,7 +43,7 @@ def studies_select(form, studies) # rubocop:todo Metrics/MethodLength studies, :id, :name, - { prompt: prompt }, + { prompt: }, disabled: true, class: 'study_id custom-select' ) @@ -62,7 +62,7 @@ def projects_select(form, projects) # rubocop:todo Metrics/MethodLength projects, :name, :name, - { prompt: prompt }, + { prompt: }, disabled: true, class: 'submission_project_name custom-select' ) @@ -83,7 +83,7 @@ def asset_group_select(asset_groups) # rubocop:todo Metrics/MethodLength asset_groups, :id, :name, - { prompt: prompt }, + { prompt: }, class: 'submission_asset_group_id required form-control', disabled: asset_groups.empty? ) diff --git a/app/heron/factories/concerns/contents.rb b/app/heron/factories/concerns/contents.rb index 05ebc98754..445baec59b 100644 --- a/app/heron/factories/concerns/contents.rb +++ b/app/heron/factories/concerns/contents.rb @@ -80,7 +80,7 @@ def params_for_contents def _factories_for_location(location, samples_params) samples_params.each_with_index.map do |sample_params, pos| - sample_params = sample_params.merge(study_uuid: study_uuid) if study_uuid + sample_params = sample_params.merge(study_uuid:) if study_uuid factory = content_factory.new(sample_params) unless factory.valid? label = label_for_error_message(location, pos, samples_params) diff --git a/app/heron/factories/plate.rb b/app/heron/factories/plate.rb index 902dcdaab9..f8cfd7a8f2 100644 --- a/app/heron/factories/plate.rb +++ b/app/heron/factories/plate.rb @@ -38,7 +38,7 @@ def save # rubocop:todo Metrics/MethodLength ActiveRecord::Base.transaction do @plate = purpose.create! - Barcode.create!(labware: @plate, barcode: barcode, format: barcode_format) + Barcode.create!(labware: @plate, barcode:, format: barcode_format) create_contents! diff --git a/app/heron/factories/sample.rb b/app/heron/factories/sample.rb index 263f90d827..d90e5fcf9c 100644 --- a/app/heron/factories/sample.rb +++ b/app/heron/factories/sample.rb @@ -101,11 +101,11 @@ def all_fields_are_existing_columns end def params_for_sample_creation - { name: sanger_sample_id, sanger_sample_id: sanger_sample_id }.merge(params_for_sample_table) + { name: sanger_sample_id, sanger_sample_id: }.merge(params_for_sample_table) end def params_for_aliquot_creation - { sample: sample, study: study }.merge(@params.dig(:aliquot) || {}) + { sample:, study: }.merge(@params.dig(:aliquot) || {}) end def params_for_sample_table diff --git a/app/heron/factories/tube.rb b/app/heron/factories/tube.rb index aa3822ac39..d7ef6f2860 100644 --- a/app/heron/factories/tube.rb +++ b/app/heron/factories/tube.rb @@ -16,7 +16,7 @@ def create return unless valid? @sample_tube = SampleTube.create! - Barcode.create!(labware_id: @sample_tube.id, barcode: barcode, format: barcode_format) + Barcode.create!(labware_id: @sample_tube.id, barcode:, format: barcode_format) @sample_tube end diff --git a/app/heron/factories/tube_rack.rb b/app/heron/factories/tube_rack.rb index 03ac010e76..e6708fde3b 100644 --- a/app/heron/factories/tube_rack.rb +++ b/app/heron/factories/tube_rack.rb @@ -50,14 +50,14 @@ def save return false unless valid? ActiveRecord::Base.transaction do - @tube_rack = ::TubeRack.create!(size: size, purpose: purpose) + @tube_rack = ::TubeRack.create!(size:, purpose:) - Barcode.create!(labware: tube_rack, barcode: barcode, format: barcode_format) + Barcode.create!(labware: tube_rack, barcode:, format: barcode_format) create_recipients! create_contents! - ::TubeRackStatus.create!(barcode: barcode, status: :created, labware: @tube_rack) + ::TubeRackStatus.create!(barcode:, status: :created, labware: @tube_rack) end true end @@ -85,7 +85,7 @@ def create_tubes!(tube_rack) recipients.keys.map do |coordinate| tube_factory = recipients[coordinate] sample_tube = tube_factory.create - RackedTube.create(tube: sample_tube, coordinate: unpad_coordinate(coordinate), tube_rack: tube_rack) + RackedTube.create(tube: sample_tube, coordinate: unpad_coordinate(coordinate), tube_rack:) end end diff --git a/app/heron/factories/tube_rack_status.rb b/app/heron/factories/tube_rack_status.rb index d7f1790b15..755f985dce 100644 --- a/app/heron/factories/tube_rack_status.rb +++ b/app/heron/factories/tube_rack_status.rb @@ -16,7 +16,7 @@ def save return false unless valid? ActiveRecord::Base.transaction do - @tube_rack_status = ::TubeRackStatus.create!(barcode: barcode, status: status, messages: messages) + @tube_rack_status = ::TubeRackStatus.create!(barcode:, status:, messages:) end true end diff --git a/app/jobs/export_pool_xp_to_traction_job.rb b/app/jobs/export_pool_xp_to_traction_job.rb index e30c7d5acc..593b8173d0 100644 --- a/app/jobs/export_pool_xp_to_traction_job.rb +++ b/app/jobs/export_pool_xp_to_traction_job.rb @@ -99,8 +99,8 @@ def send_message(message, subject, version) begin channel = conn.create_channel exchange = channel.headers(configatron.amqp.isg.exchange, passive: true) - headers = { subject: subject, version: version, encoder_type: 'binary' } - exchange.publish(message, headers: headers, persistent: true) + headers = { subject:, version:, encoder_type: 'binary' } + exchange.publish(message, headers:, persistent: true) ensure conn.close end diff --git a/app/jobs/sample_manifest/generate_wells_job.rb b/app/jobs/sample_manifest/generate_wells_job.rb index a2e090c863..e381259e5f 100644 --- a/app/jobs/sample_manifest/generate_wells_job.rb +++ b/app/jobs/sample_manifest/generate_wells_job.rb @@ -22,7 +22,7 @@ def plate def create_sample_manifest_assets(well, sanger_sample_ids) sanger_sample_ids.each do |sanger_sample_id| - SampleManifestAsset.create(sanger_sample_id: sanger_sample_id, asset: well, sample_manifest: sample_manifest) + SampleManifestAsset.create(sanger_sample_id:, asset: well, sample_manifest:) end end diff --git a/app/middleware/api/root_service.rb b/app/middleware/api/root_service.rb index 28cc35f687..aa7a9dd8ca 100644 --- a/app/middleware/api/root_service.rb +++ b/app/middleware/api/root_service.rb @@ -32,7 +32,7 @@ def @owner.each(&block) nested_stream.block('actions') do |actions_stream| endpoint .model_handler - .send(:actions, endpoint.model_handler, response: self, endpoint: endpoint) + .send(:actions, endpoint.model_handler, response: self, endpoint:) .map { |action, url| actions_stream.attribute(action, url) } end end diff --git a/app/models/accessionable/dac.rb b/app/models/accessionable/dac.rb index 2819e8cf0b..0813e3df4b 100644 --- a/app/models/accessionable/dac.rb +++ b/app/models/accessionable/dac.rb @@ -24,7 +24,7 @@ def xml # rubocop:todo Metrics/MethodLength xml = Builder::XmlMarkup.new xml.instruct! xml.DAC_SET('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') do - xml.DAC(alias: self.alias, accession: accession_number, center_name: center_name) do + xml.DAC(alias: self.alias, accession: accession_number, center_name:) do xml.CONTACTS do contacts.each do |contact| xml.CONTACT(name: contact[:name], email: contact[:email], organisation: contact[:organisation]) diff --git a/app/models/accessionable/policy.rb b/app/models/accessionable/policy.rb index da8ade3600..b055b020ed 100644 --- a/app/models/accessionable/policy.rb +++ b/app/models/accessionable/policy.rb @@ -31,7 +31,7 @@ def xml xml = Builder::XmlMarkup.new xml.instruct! xml.POLICY_SET('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') do - xml.POLICY(alias: self.alias, accession: accession_number, center_name: center_name) do + xml.POLICY(alias: self.alias, accession: accession_number, center_name:) do xml.TITLE title xml.DAC_REF(accession: dac_accession_number) xml.POLICY_FILE policy_url diff --git a/app/models/accessionable/submission.rb b/app/models/accessionable/submission.rb index d3b3defce8..40d17082a3 100644 --- a/app/models/accessionable/submission.rb +++ b/app/models/accessionable/submission.rb @@ -88,7 +88,7 @@ def initialize(user) end def build(markup) - markup.CONTACT(inform_on_error: inform_on_error, inform_on_status: inform_on_status, name: name) + markup.CONTACT(inform_on_error:, inform_on_status:, name:) end end end diff --git a/app/models/add_spiked_in_control_task.rb b/app/models/add_spiked_in_control_task.rb index 61f37433dc..34c5735100 100644 --- a/app/models/add_spiked_in_control_task.rb +++ b/app/models/add_spiked_in_control_task.rb @@ -32,9 +32,9 @@ def can_process?(batch) def do_task(workflows_controller, params, user) Tasks::AddSpikedInControlHandler::Handler.new( controller: workflows_controller, - params: params, + params:, task: self, - user: user + user: ).perform end diff --git a/app/models/aliquot.rb b/app/models/aliquot.rb index ed6b507b4a..a9c9ea889b 100644 --- a/app/models/aliquot.rb +++ b/app/models/aliquot.rb @@ -118,7 +118,7 @@ def created_with_request_options { fragment_size_required_from: insert_size_from, fragment_size_required_to: insert_size_to, - library_type: library_type + library_type: } end diff --git a/app/models/aliquot/data_for_substitution.rb b/app/models/aliquot/data_for_substitution.rb index 456df0f781..90bb1b2bd4 100644 --- a/app/models/aliquot/data_for_substitution.rb +++ b/app/models/aliquot/data_for_substitution.rb @@ -17,13 +17,13 @@ def generate_substitution_hash def tag_id_substitution return {} if changes[:tag_id].blank? - { original_tag_id: original_tag_id, substitute_tag_id: substitute_tag_id } + { original_tag_id:, substitute_tag_id: } end def tag2_id_substitution return {} if changes[:tag2_id].blank? - { original_tag2_id: original_tag2_id, substitute_tag2_id: substitute_tag2_id } + { original_tag2_id:, substitute_tag2_id: } end def original_tag_id @@ -53,6 +53,6 @@ def changes private def aliquot_identifiers - { sample_id: sample_id, library_id: library_id } + { sample_id:, library_id: } end end diff --git a/app/models/api/sample_io.rb b/app/models/api/sample_io.rb index f2ec7f4193..feff41cc6e 100644 --- a/app/models/api/sample_io.rb +++ b/app/models/api/sample_io.rb @@ -110,6 +110,6 @@ def json_root # Whenever we create samples through the API we also need to register a sample tube too. The user # can then retrieve the sample tube information through the API. def self.create!(parameters) - super.tap { |sample| Tube::Purpose.standard_sample_tube.create!.aliquots.create!(sample: sample) } + super.tap { |sample| Tube::Purpose.standard_sample_tube.create!.aliquots.create!(sample:) } end end diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 003818045f..1908e01b43 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -38,7 +38,7 @@ def find_by_id_or_name(id, name) return find(id) if id.present? raise StandardError, 'Must specify at least ID or name' if name.blank? - find_by(name: name) + find_by(name:) end # Temporary compatibility layer following AssetRefactor: diff --git a/app/models/asset_audit.rb b/app/models/asset_audit.rb index 4a5da9e51f..5379f57632 100644 --- a/app/models/asset_audit.rb +++ b/app/models/asset_audit.rb @@ -18,6 +18,6 @@ class AssetAudit < ApplicationRecord private def broadcast_event - BroadcastEvent::AssetAudit.create!(seed: self, user: User.find_by(login: created_by), created_at: created_at) + BroadcastEvent::AssetAudit.create!(seed: self, user: User.find_by(login: created_by), created_at:) end end diff --git a/app/models/asset_group.rb b/app/models/asset_group.rb index 86d1276b75..6e607f79a4 100644 --- a/app/models/asset_group.rb +++ b/app/models/asset_group.rb @@ -40,9 +40,7 @@ def unaccessioned_samples def self.find_or_create_asset_group(new_assets_name, study) # Is new name set or create group asset_group = nil - if new_assets_name.present? - asset_group = AssetGroup.create_with(study: study).find_or_create_by(name: new_assets_name) - end + asset_group = AssetGroup.create_with(study:).find_or_create_by(name: new_assets_name) if new_assets_name.present? asset_group end diff --git a/app/models/attributable/association.rb b/app/models/attributable/association.rb index 475ba4d744..9974444d2f 100644 --- a/app/models/attributable/association.rb +++ b/app/models/attributable/association.rb @@ -72,9 +72,9 @@ def selection_options(_) def to_field_info(*_args) FieldInfo.new( - display_name: display_name, + display_name:, key: assignable_attribute_name, - kind: kind, + kind:, selection: selection_options(nil) ) end diff --git a/app/models/attributable/attribute.rb b/app/models/attributable/attribute.rb index 58e0805956..bb00ecba4b 100644 --- a/app/models/attributable/attribute.rb +++ b/app/models/attributable/attribute.rb @@ -86,7 +86,7 @@ def configure(model) # rubocop:todo Metrics/CyclomaticComplexity model.with_options(conditions) do |object| # false.blank? == true, so we exclude booleans here, they handle themselves further down. object.validates_presence_of(name) if required? && !boolean? - object.with_options(allow_nil: optional?, allow_blank: allow_blank) do |required| + object.with_options(allow_nil: optional?, allow_blank:) do |required| required.validates_inclusion_of(name, in: [true, false]) if boolean? if integer? || float? required.validates name, numericality: { only_integer: integer?, greater_than_or_equal_to: minimum } @@ -174,10 +174,10 @@ def selection_options(validator_source) def to_field_info(validator_source = nil) options = { # TODO[xxx]: currently only working for metadata, the only place attributes are used - display_name: display_name, + display_name:, key: assignable_attribute_name, default_value: find_default(validator_source), - kind: kind, + kind:, required: required? } options.update(selection: selection_options(validator_source)) if selection? diff --git a/app/models/bait_library_layout.rb b/app/models/bait_library_layout.rb index 9c435856e8..345a103b5d 100644 --- a/app/models/bait_library_layout.rb +++ b/app/models/bait_library_layout.rb @@ -43,7 +43,7 @@ def layout_bait_libraries_on_plate # Bulk update the aliquots with the appropriate bait libraries bait_libraries_to_aliquot_ids.each do |bait_library_id, aliquot_ids| - Aliquot.where(id: aliquot_ids).update_all(bait_library_id: bait_library_id) # rubocop:disable Rails/SkipsModelValidations + Aliquot.where(id: aliquot_ids).update_all(bait_library_id:) # rubocop:disable Rails/SkipsModelValidations end end private :layout_bait_libraries_on_plate diff --git a/app/models/barcode.rb b/app/models/barcode.rb index 92576d6684..2579227fc7 100644 --- a/app/models/barcode.rb +++ b/app/models/barcode.rb @@ -154,7 +154,7 @@ def self.build_sequencescape22(attributes) def self.build_sanger_barcode(attributes, format:) # We need to symbolize our hash keys to allow them to get passed in to named arguments. safe_attributes = attributes.slice(:number, :prefix, :human_barcode, :machine_barcode).symbolize_keys - new(format: format, barcode: SBCF::SangerBarcode.new(**safe_attributes).human_barcode) + new(format:, barcode: SBCF::SangerBarcode.new(**safe_attributes).human_barcode) end # Extract barcode from user input diff --git a/app/models/barcode/barcodeable.rb b/app/models/barcode/barcodeable.rb index 65f8062236..f847fd0c3c 100644 --- a/app/models/barcode/barcodeable.rb +++ b/app/models/barcode/barcodeable.rb @@ -96,7 +96,7 @@ def foreign_barcode=(barcode) raise "Foreign Barcode: #{barcode} is already in use!" if Barcode.exists_for_format?(barcode_format, barcode) - barcodes << Barcode.new(format: barcode_format, barcode: barcode) + barcodes << Barcode.new(format: barcode_format, barcode:) end # ***** End getter and setter methods for foreign barcodes ***** diff --git a/app/models/batch.rb b/app/models/batch.rb index 27e9ba07ae..6acf134986 100644 --- a/app/models/batch.rb +++ b/app/models/batch.rb @@ -138,10 +138,10 @@ def fail(reason, comment, ignore_requests = false) raise StandardError, 'Can not fail batch without failing requests' if ignore_requests # create failures - failures.create(reason: reason, comment: comment, notify_remote: false) + failures.create(reason:, comment:, notify_remote: false) requests.each do |request| - request.failures.create(reason: reason, comment: comment, notify_remote: true) + request.failures.create(reason:, comment:, notify_remote: true) EventSender.send_fail_event(request, reason, comment, id) unless request.asset && request.asset.resource? end @@ -158,7 +158,7 @@ def fail_requests(requests_to_fail, reason, comment, fail_but_charge = false) # logger.debug "SENDING FAIL FOR REQUEST #{request.id}, BATCH #{id}, WITH REASON #{reason}" request.customer_accepts_responsibility! if fail_but_charge - request.failures.create(reason: reason, comment: comment, notify_remote: true) + request.failures.create(reason:, comment:, notify_remote: true) EventSender.send_fail_event(request, reason, comment, id) end update_batch_state(reason, comment) @@ -167,7 +167,7 @@ def fail_requests(requests_to_fail, reason, comment, fail_but_charge = false) # def update_batch_state(reason, comment) if requests.all?(&:terminated?) - failures.create(reason: reason, comment: comment, notify_remote: false) + failures.create(reason:, comment:, notify_remote: false) self.production_state = 'fail' save! end @@ -310,7 +310,7 @@ def verify_tube_layout(barcodes, user = nil) # rubocop:todo Metrics/AbcSize end end if errors.empty? - lab_events.create(description: 'Tube layout verified', user: user) + lab_events.create(description: 'Tube layout verified', user:) true else false @@ -331,7 +331,7 @@ def remove_request_ids(request_ids, reason = nil, comment = nil) Request .find(request_ids) .each do |request| - request.failures.create(reason: reason, comment: comment, notify_remote: true) + request.failures.create(reason:, comment:, notify_remote: true) detach_request(request) end update_batch_state(reason, comment) @@ -465,7 +465,7 @@ def robot_verified!(user_id) lab_events.create( description: 'Robot verified', message: 'Robot verification completed and source volumes updated.', - user_id: user_id + user_id: ) end @@ -586,12 +586,12 @@ def generate_target_assets_for_requests # rubocop:todo Metrics/AbcSize requests_to_update.concat(downstream_requests.map { |r| [r, target_asset.receptacle] }) end - request.update!(target_asset: target_asset) + request.update!(target_asset:) target_asset.parents << request.asset.labware end - requests_to_update.each { |request, asset| request.update!(asset: asset) } + requests_to_update.each { |request, asset| request.update!(asset:) } end # rubocop:enable Metrics/MethodLength end diff --git a/app/models/batch/state_machine_behaviour.rb b/app/models/batch/state_machine_behaviour.rb index c37e35caa9..316188f314 100644 --- a/app/models/batch/state_machine_behaviour.rb +++ b/app/models/batch/state_machine_behaviour.rb @@ -62,7 +62,7 @@ def complete_with_user!(user) def create_complete_batch_event_for(user) lab_events - .create!(batch: self, user: user, description: 'Complete') + .create!(batch: self, user:, description: 'Complete') .tap do |event| event.add_descriptor Descriptor.new(name: 'pipeline_id', value: pipeline.id) event.add_descriptor Descriptor.new(name: 'pipeline', value: pipeline.name) @@ -80,7 +80,7 @@ def release_with_user!(user) def create_release_batch_event_for(user) # rubocop:todo Metrics/AbcSize lab_events - .create!(batch: self, user: user, description: 'Released') + .create!(batch: self, user:, description: 'Released') .tap do |event| event.add_descriptor Descriptor.new(name: 'workflow_id', value: workflow.id) event.add_descriptor Descriptor.new(name: 'workflow', value: "Released from #{workflow.name}") diff --git a/app/models/batch_request.rb b/app/models/batch_request.rb index 53e8148865..7f1ed42a8f 100644 --- a/app/models/batch_request.rb +++ b/app/models/batch_request.rb @@ -12,7 +12,7 @@ class BatchRequest < ApplicationRecord belongs_to :request, inverse_of: :batch_request scope :ordered, -> { order(:position) } - scope :at_position, ->(position) { where(position: position) } + scope :at_position, ->(position) { where(position:) } # Ensure that any requests that are added have a position that is unique and incremental in the batch, # unless we're moving them around in the batch, in which case we assume it'll be valid. @@ -34,7 +34,7 @@ class BatchRequest < ApplicationRecord broadcast_with_warren def move_to_position!(position) - update!(sorting_requests_within_batch: true, position: position) + update!(sorting_requests_within_batch: true, position:) end private diff --git a/app/models/broadcast_event/qc_assay.rb b/app/models/broadcast_event/qc_assay.rb index e9aa752990..49413f3128 100644 --- a/app/models/broadcast_event/qc_assay.rb +++ b/app/models/broadcast_event/qc_assay.rb @@ -14,7 +14,7 @@ def self.generate_events(qc_assay) .distinct .pluck(:assay_type, :assay_version) .map do |assay_type, assay_version| - create!(seed: qc_assay, properties: { assay_type: assay_type, assay_version: assay_version }) + create!(seed: qc_assay, properties: { assay_type:, assay_version: }) end end diff --git a/app/models/bulk_submission.rb b/app/models/bulk_submission.rb index 755c184a92..cbcc2be48a 100644 --- a/app/models/bulk_submission.rb +++ b/app/models/bulk_submission.rb @@ -176,7 +176,7 @@ def process # rubocop:todo Metrics/CyclomaticComplexity submission = Submission.create!( name: submission_name, - user: user, + user:, orders: orders_processed, priority: max_priority(orders) ) @@ -355,11 +355,11 @@ def prepare_order(details) # rubocop:todo Metrics/CyclomaticComplexity # Set up the order attributes attributes = { - study: study, - project: project, - user: user, + study:, + project:, + user:, comments: details['comments'], - request_options: request_options, + request_options:, pre_cap_group: details['pre-capture group'] } diff --git a/app/models/bulk_transfer.rb b/app/models/bulk_transfer.rb index cce2cfc221..08b075259b 100644 --- a/app/models/bulk_transfer.rb +++ b/app/models/bulk_transfer.rb @@ -43,10 +43,10 @@ def build_transfers! ActiveRecord::Base.transaction do each_transfer do |source, destination, transfers| Transfer::BetweenPlates.create!( - source: source, - destination: destination, - user: user, - transfers: transfers, + source:, + destination:, + user:, + transfers:, bulk_transfer_id: id ) end diff --git a/app/models/cherrypick_request.rb b/app/models/cherrypick_request.rb index 34ae04ca0c..9463bb69dd 100644 --- a/app/models/cherrypick_request.rb +++ b/app/models/cherrypick_request.rb @@ -13,7 +13,7 @@ def on_started end def on_passed - target_asset.transfer_requests_as_target.where(submission_id: submission_id).find_each(&:pass!) + target_asset.transfer_requests_as_target.where(submission_id:).find_each(&:pass!) end def reduce_source_volume @@ -28,6 +28,6 @@ def reduce_source_volume # The transfer requests handle the actual transfer def transfer_aliquots - TransferRequest.create!(asset: asset, target_asset: target_asset, outer_request: self) + TransferRequest.create!(asset:, target_asset:, outer_request: self) end end diff --git a/app/models/cherrypick_task.rb b/app/models/cherrypick_task.rb index 13304cb801..1e5375cddb 100644 --- a/app/models/cherrypick_task.rb +++ b/app/models/cherrypick_task.rb @@ -23,10 +23,10 @@ class CherrypickTask < Task # rubocop:todo Metrics/ClassLength # def new_control_locator(batch_id, total_wells, num_control_wells, wells_to_leave_free: DEFAULT_WELLS_TO_LEAVE_FREE) CherrypickTask::ControlLocator.new( - batch_id: batch_id, - total_wells: total_wells, - num_control_wells: num_control_wells, - wells_to_leave_free: wells_to_leave_free + batch_id:, + total_wells:, + num_control_wells:, + wells_to_leave_free: ) end diff --git a/app/models/compound_aliquot.rb b/app/models/compound_aliquot.rb index 97f082d4dd..ccbbbd8ca4 100644 --- a/app/models/compound_aliquot.rb +++ b/app/models/compound_aliquot.rb @@ -59,8 +59,8 @@ def source_aliquots_have_same_project def aliquot_attributes { - tag_id: tag_id, - tag2_id: tag2_id, + tag_id:, + tag2_id:, library_type: default_library_type, study_id: default_compound_study.id, project_id: default_compound_project_id, diff --git a/app/models/event/labware_failed_event.rb b/app/models/event/labware_failed_event.rb index 00926664e9..c7fb8c7bf2 100644 --- a/app/models/event/labware_failed_event.rb +++ b/app/models/event/labware_failed_event.rb @@ -11,7 +11,7 @@ def self.create_for_asset!(asset, failure_id, created_by) message: "Labware failed for reason: #{failure_id}", content: Time.zone.today.to_s, family: 'labware_failure', - created_by: created_by + created_by: ) end end diff --git a/app/models/event/sample_logistics_qc_event.rb b/app/models/event/sample_logistics_qc_event.rb index be42944271..8c7daa49a4 100644 --- a/app/models/event/sample_logistics_qc_event.rb +++ b/app/models/event/sample_logistics_qc_event.rb @@ -12,9 +12,9 @@ def self.create_gel_qc_for_asset!(asset, result, user) def self.gel_qc_message(asset, message, family, user) create!( eventful: asset, - message: message, + message:, content: Date.today.to_s, - family: family, + family:, created_by: user ? user.login : nil ) end diff --git a/app/models/event/scanned_into_lab_event.rb b/app/models/event/scanned_into_lab_event.rb index d37c26e5ed..270d6ebba0 100644 --- a/app/models/event/scanned_into_lab_event.rb +++ b/app/models/event/scanned_into_lab_event.rb @@ -9,7 +9,7 @@ def self.create_for_asset!(asset, location_barcode, created_by) message: "Scanned into #{location_barcode}", content: Date.today.to_s, family: 'scanned_into_lab', - created_by: created_by + created_by: ) end diff --git a/app/models/event_sender.rb b/app/models/event_sender.rb index 1ff68d4d28..28a4d674fb 100644 --- a/app/models/event_sender.rb +++ b/app/models/event_sender.rb @@ -21,7 +21,7 @@ def self.send_state_event(state, request, reason, comment, batch_id, user = nil) end def self.send_request_update(request, family, message, options = nil) - hash = { eventful: request, family: family, message: message } + hash = { eventful: request, family:, message: } create!(hash.merge(options || {})) end @@ -29,7 +29,7 @@ def self.send_pick_event(well, purpose_name, message, options = nil) hash = { eventful: well, family: PlatesHelper.event_family_for_pick(purpose_name), - message: message, + message:, content: Date.today.to_s } create!(hash.merge(options || {})) diff --git a/app/models/field_info.rb b/app/models/field_info.rb index 8c1d40891c..b30465b20b 100644 --- a/app/models/field_info.rb +++ b/app/models/field_info.rb @@ -42,7 +42,7 @@ def parameters=(parameters) deprecate :parameters= => 'set selection directly' def parameters - { min: min, max: max, step: step } + { min:, max:, step: } end def value diff --git a/app/models/illumina_htp/requests/gbs_request.rb b/app/models/illumina_htp/requests/gbs_request.rb index 0cd3a89526..1ae49bee16 100644 --- a/app/models/illumina_htp/requests/gbs_request.rb +++ b/app/models/illumina_htp/requests/gbs_request.rb @@ -26,9 +26,9 @@ def aliquot_attributes { study_id: initial_study_id, project_id: initial_project_id, - library_type: library_type, - insert_size: insert_size, - primer_panel_id: primer_panel_id, + library_type:, + insert_size:, + primer_panel_id:, request_id: id } end diff --git a/app/models/illumina_htp/requests/heron_request.rb b/app/models/illumina_htp/requests/heron_request.rb index c02ad97e5e..75fb7ed19d 100644 --- a/app/models/illumina_htp/requests/heron_request.rb +++ b/app/models/illumina_htp/requests/heron_request.rb @@ -30,9 +30,9 @@ def aliquot_attributes { study_id: initial_study_id, project_id: initial_project_id, - library_type: library_type, - insert_size: insert_size, - primer_panel_id: primer_panel_id, + library_type:, + insert_size:, + primer_panel_id:, request_id: id } end diff --git a/app/models/illumina_htp/requests/heron_tailed_request.rb b/app/models/illumina_htp/requests/heron_tailed_request.rb index 1074322e88..ee8632cf00 100644 --- a/app/models/illumina_htp/requests/heron_tailed_request.rb +++ b/app/models/illumina_htp/requests/heron_tailed_request.rb @@ -42,9 +42,9 @@ def aliquot_attributes { study_id: initial_study_id, project_id: initial_project_id, - library_type: library_type, - insert_size: insert_size, - primer_panel_id: primer_panel_id, + library_type:, + insert_size:, + primer_panel_id:, library_id: asset_id, request_id: id } diff --git a/app/models/item.rb b/app/models/item.rb index 0be85c299b..69bb5f5f8e 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -33,7 +33,7 @@ class Item < ApplicationRecord before_validation :set_version, on: :create def set_version - things_with_same_name = self.class.where(name: name) + things_with_same_name = self.class.where(name:) if things_with_same_name.empty? increment(:version) else diff --git a/app/models/lab_event.rb b/app/models/lab_event.rb index 63b57f6f91..6169e9e3b5 100644 --- a/app/models/lab_event.rb +++ b/app/models/lab_event.rb @@ -35,10 +35,10 @@ def descriptor_value_for(name) end def add_new_descriptor(name, value) - add_descriptor Descriptor.new(name: name, value: value) + add_descriptor Descriptor.new(name:, value:) end def generate_broadcast_event - BroadcastEvent::LabEvent.create!(seed: self, user: user) + BroadcastEvent::LabEvent.create!(seed: self, user:) end end diff --git a/app/models/labware.rb b/app/models/labware.rb index e71d5c4cf9..212b5f58a8 100644 --- a/app/models/labware.rb +++ b/app/models/labware.rb @@ -118,7 +118,7 @@ def receptacle_proxy } scope :for_lab_searches_display, lambda { includes(:barcodes, requests_as_source: %i[pipeline batch]).order('requests.pipeline_id ASC') } - scope :named, ->(name) { where(name: name) } + scope :named, ->(name) { where(name:) } scope :with_purpose, ->(*purposes) { where(plate_purpose_id: purposes.flatten) } scope :include_scanned_into_lab_event, -> { includes(:scanned_into_lab_event) } scope :include_creation_batches, -> { includes(:creation_batches) } diff --git a/app/models/labwhere_reception.rb b/app/models/labwhere_reception.rb index f5f6c3593f..d2567f517e 100644 --- a/app/models/labwhere_reception.rb +++ b/app/models/labwhere_reception.rb @@ -49,8 +49,8 @@ def save # rubocop:todo Metrics/AbcSize begin scan = LabWhereClient::Scan.create( - location_barcode: location_barcode, - user_code: user_code, + location_barcode:, + user_code:, labware_barcodes: asset_barcodes ) @@ -71,9 +71,9 @@ def save # rubocop:todo Metrics/AbcSize asset.events.create_scanned_into_lab!(location_barcode, user.login) BroadcastEvent::LabwareReceived.create!( seed: asset, - user: user, + user:, properties: { - location_barcode: location_barcode + location_barcode: } ) end diff --git a/app/models/lib_pool_norm_tube_generator.rb b/app/models/lib_pool_norm_tube_generator.rb index 83dfb442db..d54d9d57e5 100644 --- a/app/models/lib_pool_norm_tube_generator.rb +++ b/app/models/lib_pool_norm_tube_generator.rb @@ -53,7 +53,7 @@ def create! # rubocop:todo Metrics/AbcSize @asset_group = AssetGroup.create!( assets: destination_tubes.map(&:receptacle), - study: study, + study:, name: "#{plate.human_barcode}_qc_completed_tubes" ) end @@ -71,14 +71,14 @@ def create! # rubocop:todo Metrics/AbcSize private def create_lib_pool_norm_tube(tube) - destination_tube = transfer_template.create!(user: user, source: tube).destination + destination_tube = transfer_template.create!(user:, source: tube).destination destination_tubes << destination_tube destination_tube end def pass_and_complete(tube) - StateChange.create!(user: user, target: tube, target_state: 'passed') - StateChange.create!(user: user, target: tube, target_state: 'qc_complete') + StateChange.create!(user:, target: tube, target_state: 'passed') + StateChange.create!(user:, target: tube, target_state: 'qc_complete') end def check_state diff --git a/app/models/library_creation_request.rb b/app/models/library_creation_request.rb index 59d52da323..57faf4e65e 100644 --- a/app/models/library_creation_request.rb +++ b/app/models/library_creation_request.rb @@ -46,8 +46,8 @@ def aliquot_attributes { study_id: initial_study_id, project_id: initial_project_id, - library_type: library_type, - insert_size: insert_size, + library_type:, + insert_size:, request_id: id } end diff --git a/app/models/location_report.rb b/app/models/location_report.rb index dc1c8177ec..ab725c1d14 100644 --- a/app/models/location_report.rb +++ b/app/models/location_report.rb @@ -177,12 +177,12 @@ def generate_study_cols_for_row(cur_study) def search_for_plates_by_selection params = { - faculty_sponsor_ids: faculty_sponsor_ids, - study_id: study_id, - start_date: start_date, - end_date: end_date, - plate_purpose_ids: plate_purpose_ids, - barcodes: barcodes + faculty_sponsor_ids:, + study_id:, + start_date:, + end_date:, + plate_purpose_ids:, + barcodes: } Plate.search_for_plates(params) end diff --git a/app/models/location_report/location_report_form.rb b/app/models/location_report/location_report_form.rb index 3d6405eb3f..fda732c781 100644 --- a/app/models/location_report/location_report_form.rb +++ b/app/models/location_report/location_report_form.rb @@ -35,16 +35,16 @@ def location_report @location_report || @location_report = LocationReport.new( - user: user, - name: name, - report_type: report_type, - location_barcode: location_barcode, - faculty_sponsor_ids: faculty_sponsor_ids, - study_id: study_id, + user:, + name:, + report_type:, + location_barcode:, + faculty_sponsor_ids:, + study_id:, start_date: start_date&.to_datetime, end_date: end_date&.to_datetime, - plate_purpose_ids: plate_purpose_ids, - barcodes: barcodes + plate_purpose_ids:, + barcodes: ) end diff --git a/app/models/lot.rb b/app/models/lot.rb index ce79be8410..e6eb025b62 100644 --- a/app/models/lot.rb +++ b/app/models/lot.rb @@ -34,7 +34,7 @@ def self.included(base) scope :include_lot_type, -> { includes(:lot_type) } scope :include_template, -> { includes(:template) } - scope :with_lot_number, ->(lot_number) { where(lot_number: lot_number) } + scope :with_lot_number, ->(lot_number) { where(lot_number:) } scope :with_qc_asset, ->(qc_asset) do diff --git a/app/models/messenger_creator.rb b/app/models/messenger_creator.rb index 2c279fb5c2..a1532eabfb 100644 --- a/app/models/messenger_creator.rb +++ b/app/models/messenger_creator.rb @@ -31,7 +31,7 @@ def each_target validate :template_exists? def create!(base) - finder.new(base).each_target { |target| Messenger.create!(target: target, root: root, template: template) } + finder.new(base).each_target { |target| Messenger.create!(target:, root:, template:) } end private diff --git a/app/models/metadata.rb b/app/models/metadata.rb index aa925c3289..07029b123a 100644 --- a/app/models/metadata.rb +++ b/app/models/metadata.rb @@ -23,7 +23,7 @@ def build_association(as_class, options) # rubocop:todo Metrics/MethodLength class_name = "#{name}::Metadata" default_options = { - class_name: class_name, + class_name:, dependent: :destroy, validate: true, autosave: true, diff --git a/app/models/metadata/builder_base.rb b/app/models/metadata/builder_base.rb index bc91d984ea..0ec0867791 100644 --- a/app/models/metadata/builder_base.rb +++ b/app/models/metadata/builder_base.rb @@ -41,6 +41,6 @@ def render_view(type, field, options = {}) ) locals[:group] = options[:grouping].downcase.gsub(/[^a-z0-9]+/, '_') if options[:grouping].present? locals = yield(locals) if block_given? - render(view.merge(locals: locals)) + render(view.merge(locals:)) end end diff --git a/app/models/metadata/form_builder.rb b/app/models/metadata/form_builder.rb index b6c19c8459..dee73ee0c0 100644 --- a/app/models/metadata/form_builder.rb +++ b/app/models/metadata/form_builder.rb @@ -59,7 +59,7 @@ def radio_select(method, choices, options = {}, html_options = {}) # rubocop:tod output << tag.div(class: %w[custom-control custom-radio custom-control-inline]) do value = option_value || label_text concat radio_button(method, value, class: 'custom-control-input', required: true) - concat label(method, label_text, class: 'custom-control-label', value: value) + concat label(method, label_text, class: 'custom-control-label', value:) end end end @@ -161,7 +161,7 @@ def finalize_related_fields partial: 'shared/metadata/related_fields', locals: { root: sanitized_object_name, - related: related, + related:, changing_fields: @changing } ) diff --git a/app/models/order.rb b/app/models/order.rb index f584aef0f9..6c9289e086 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -198,9 +198,9 @@ def duplicates_within(timespan) # rubocop:todo Metrics/AbcSize, Metrics/MethodLe matching_orders = Order .containing_samples(all_samples) - .where(template_name: template_name) + .where(template_name:) .includes(:submission, assets: :samples) - .where.not(orders: { id: id }) + .where.not(orders: { id: }) .where('orders.created_at > ?', Time.current - timespan) return false if matching_orders.empty? @@ -286,7 +286,7 @@ def subject_type end def generate_broadcast_event - BroadcastEvent::OrderMade.create!(seed: self, user: user) + BroadcastEvent::OrderMade.create!(seed: self, user:) end def study_is_active diff --git a/app/models/phi_x.rb b/app/models/phi_x.rb index 32046524f7..d99191a684 100644 --- a/app/models/phi_x.rb +++ b/app/models/phi_x.rb @@ -110,7 +110,7 @@ def self.default_study_option # # @return [String] The named tag option. def self.tag_option_for(i7_oligo:, i5_oligo:) - tag_options.deep_symbolize_keys.key(i7_oligo: i7_oligo, i5_oligo: i5_oligo)&.to_s || + tag_options.deep_symbolize_keys.key(i7_oligo:, i5_oligo:)&.to_s || "UNKNOWN i7:#{i7_oligo || '-'} i5:#{i5_oligo || '-'}" end @@ -124,6 +124,6 @@ def self.find_tag(tag_option, tag_type) oligo = tag_options.dig(tag_option.to_sym, tag_type) return nil if oligo.nil? - tag_group.tags.create_with(map_id: configuration[:tag_map_id]).find_or_create_by!(oligo: oligo) + tag_group.tags.create_with(map_id: configuration[:tag_map_id]).find_or_create_by!(oligo:) end end diff --git a/app/models/phi_x/spiked_buffer.rb b/app/models/phi_x/spiked_buffer.rb index 80604de92c..53f538e7dc 100644 --- a/app/models/phi_x/spiked_buffer.rb +++ b/app/models/phi_x/spiked_buffer.rb @@ -76,7 +76,7 @@ def parent_contains_phi_x def tags i7_oligo, i5_oligo = parent.aliquots.first.tags_combination - PhiX.tag_option_for(i7_oligo: i7_oligo, i5_oligo: i5_oligo) + PhiX.tag_option_for(i7_oligo:, i5_oligo:) end private @@ -89,7 +89,7 @@ def phi_x_sample # due to concerns that it will be set accidentally # But the option is here in the model to set it via study_id if needed in future def aliquot_attributes - study_id.present? ? { study_id: study_id } : {} + study_id.present? ? { study_id: } : {} end # Generates .number PhiX.stock_purpose tubes names @@ -112,7 +112,7 @@ def generate_spiked_buffers # rubocop:todo Metrics/AbcSize, Metrics/MethodLength receptacle.save! receptacle .transfer_requests_as_target - .build(asset: parent.receptacle, target_asset: receptacle, aliquot_attributes: aliquot_attributes) + .build(asset: parent.receptacle, target_asset: receptacle, aliquot_attributes:) .save! end parent.children << spiked_buffer diff --git a/app/models/phi_x/stock.rb b/app/models/phi_x/stock.rb index 4ce9ff644e..67c7e68c36 100644 --- a/app/models/phi_x/stock.rb +++ b/app/models/phi_x/stock.rb @@ -67,7 +67,7 @@ def generate_stocks # rubocop:todo Metrics/AbcSize tag: i7_tag, tag2: i5_tag, library: tube, - study_id: study_id + study_id: ) end end diff --git a/app/models/pick_list.rb b/app/models/pick_list.rb index b75994e132..d5a4b5656e 100644 --- a/app/models/pick_list.rb +++ b/app/models/pick_list.rb @@ -45,7 +45,7 @@ def pick_attributes=(picks) def pick_attributes orders.flat_map do |order| order.assets.map do |source_receptacle| - { source_receptacle: source_receptacle, study: order.study, project: order.project } + { source_receptacle:, study: order.study, project: order.project } end end end @@ -91,7 +91,7 @@ def queue_processing # Its listed as a private method, as it is intended as an implementation # detail, and I'm hoping that we'll be able to remove the need for it. def submission - super || build_submission(user: user) + super || build_submission(user:) end def request_type @@ -100,7 +100,7 @@ def request_type def build_order(pick_group, order_options) AutomatedOrder.new( - user: user, + user:, assets: pick_group.map(&:source_receptacle), request_types: [request_type_id], **order_options # Merge the order options into the arguments @@ -108,7 +108,7 @@ def build_order(pick_group, order_options) end def create_batch! - Batch.create!(requests: submission.requests.reload, pipeline: pipeline, user: user) + Batch.create!(requests: submission.requests.reload, pipeline:, user:) end def user diff --git a/app/models/pick_list/pick.rb b/app/models/pick_list/pick.rb index 5be067e87d..1f5764501c 100644 --- a/app/models/pick_list/pick.rb +++ b/app/models/pick_list/pick.rb @@ -12,7 +12,7 @@ class PickList::Pick # Used to help group compatible picks together into orders def order_options - { study: study, project: project } + { study:, project: } end def study diff --git a/app/models/pick_list/record_cache.rb b/app/models/pick_list/record_cache.rb index 2e4913cef3..5b07f9085e 100644 --- a/app/models/pick_list/record_cache.rb +++ b/app/models/pick_list/record_cache.rb @@ -41,7 +41,7 @@ def convert(entry) study_id, project_id = entry.values_at(:study_id, :project_id) other_keys = entry.except(*LABWARE_KEYS).to_hash source_receptacles.map do |source_receptacle| - other_keys.merge(source_receptacle: source_receptacle, study: study(study_id), project: project(project_id)) + other_keys.merge(source_receptacle:, study: study(study_id), project: project(project_id)) end end diff --git a/app/models/plate.rb b/app/models/plate.rb index 0655990c19..b9a650ec2c 100644 --- a/app/models/plate.rb +++ b/app/models/plate.rb @@ -63,7 +63,7 @@ def construct! # rubocop:todo Metrics/AbcSize # Warren::Message::Short keeps track of the class (Well) and id, and gets sent after # the transaction completes. This avoids us needing to instantiate wells, keeping the memory footprint # down. - ids.each { |id| Warren::Message::Short.new(class_name: 'Well', id: id).queue(Warren.handler) } + ids.each { |id| Warren::Message::Short.new(class_name: 'Well', id:).queue(Warren.handler) } end end end @@ -188,7 +188,7 @@ def submissions def iteration iter = siblings # assets sharing the same parent - .where(plate_purpose_id: plate_purpose_id, sti_type: sti_type) # of the same purpose and type + .where(plate_purpose_id:, sti_type:) # of the same purpose and type .where("#{self.class.table_name}.created_at <= ?", created_at) # created before or at the same time .count(:id) # count the siblings. @@ -426,7 +426,7 @@ def update_qc_values_with_parser(parser) unit_value: value, assay_type: parser.assay_type, assay_version: parser.assay_version, - qc_assay: qc_assay + qc_assay: ) end end diff --git a/app/models/plate/creator.rb b/app/models/plate/creator.rb index dce665ba56..f2cb945a20 100644 --- a/app/models/plate/creator.rb +++ b/app/models/plate/creator.rb @@ -81,8 +81,8 @@ def execute(source_plate_barcodes, barcode_printer, scanned_user, should_create_ LabelPrinter::PrintJob.new( barcode_printer.name, LabelPrinter::Label::PlateCreator, - plates: plates, - plate_purpose: plate_purpose, + plates:, + plate_purpose:, user_login: scanned_user.login ) @@ -131,7 +131,7 @@ def create_plates_from_tube_racks!( barcode_printer.name, LabelPrinter::Label::PlateCreator, plates: created_plates.pluck(:destinations).flatten.compact, - plate_purpose: plate_purpose, + plate_purpose:, user_login: scanned_user.login ) @@ -155,7 +155,7 @@ def create_asset_group(created_plates) # rubocop:todo Metrics/MethodLength ActiveRecord::Base.transaction do # TO DO: handle exceptions from this? - group = AssetGroup.create!(study: study, name: asset_group_name) + group = AssetGroup.create!(study:, name: asset_group_name) group.assets.concat(all_wells) end @@ -188,7 +188,7 @@ def asset_group_name end def tube_rack_to_plate_factories(tube_racks, plate_purpose) - tube_racks.map { |rack| ::Heron::Factories::PlateFromRack.new(tube_rack: rack, plate_purpose: plate_purpose) } + tube_racks.map { |rack| ::Heron::Factories::PlateFromRack.new(tube_rack: rack, plate_purpose:) } end def can_create_plates?(source_plate) @@ -239,7 +239,7 @@ def create_plates(source_plate_barcodes, current_user, creator_parameters = nil) # rubocop:enable Metrics/MethodLength def add_created_plates(source, destinations) - created_plates.push(source: source, destinations: destinations) + created_plates.push(source:, destinations:) end # rubocop:todo Metrics/MethodLength diff --git a/app/models/plate/fluidigm_behaviour.rb b/app/models/plate/fluidigm_behaviour.rb index aa38b1cdb2..ff1fab6694 100644 --- a/app/models/plate/fluidigm_behaviour.rb +++ b/app/models/plate/fluidigm_behaviour.rb @@ -61,7 +61,7 @@ def apply_fluidigm_data(fluidigm_file) # rubocop:todo Metrics/AbcSize assay_version: 'v0.1', value: gender_markers, units: 'bases', - qc_assay: qc_assay + qc_assay: }, { asset: sw, @@ -70,7 +70,7 @@ def apply_fluidigm_data(fluidigm_file) # rubocop:todo Metrics/AbcSize assay_version: 'v0.1', value: loci_passed, units: 'bases', - qc_assay: qc_assay + qc_assay: } ] ) diff --git a/app/models/plate/quad_creator.rb b/app/models/plate/quad_creator.rb index 46dc85f7af..e262039845 100644 --- a/app/models/plate/quad_creator.rb +++ b/app/models/plate/quad_creator.rb @@ -67,12 +67,12 @@ def indexed_target_wells end def creation - @creation ||= PooledPlateCreation.new(user: user, parents: @parents.values, child_purpose: target_purpose) + @creation ||= PooledPlateCreation.new(user:, parents: @parents.values, child_purpose: target_purpose) end def transfer_request_collection @transfer_request_collection ||= - TransferRequestCollection.new(user: user, transfer_requests_attributes: transfer_requests_attributes) + TransferRequestCollection.new(user:, transfer_requests_attributes:) end def transfer_requests_attributes @@ -99,7 +99,7 @@ def quadrant_metadata_collection quadrant_metadata["Quadrant #{quadrant_index + 1}"] = parent_barcodes[quadrant_name] || 'Empty' end @quadrant_metadata_collection ||= - CustomMetadatumCollection.new(user: user, asset: target_plate, metadata: quadrant_metadata) + CustomMetadatumCollection.new(user:, asset: target_plate, metadata: quadrant_metadata) end class << self diff --git a/app/models/plate/sample_tube_factory.rb b/app/models/plate/sample_tube_factory.rb index 34318d9b96..1d391a6742 100644 --- a/app/models/plate/sample_tube_factory.rb +++ b/app/models/plate/sample_tube_factory.rb @@ -15,7 +15,7 @@ def create_child_sample_tube(well) def create_sample_tubes_and_print_barcodes(barcode_printer) sample_tubes = create_sample_tubes print_job = - LabelPrinter::PrintJob.new(barcode_printer.name, LabelPrinter::Label::PlateToTubes, sample_tubes: sample_tubes) + LabelPrinter::PrintJob.new(barcode_printer.name, LabelPrinter::Label::PlateToTubes, sample_tubes:) print_job.execute sample_tubes diff --git a/app/models/plate_barcode.rb b/app/models/plate_barcode.rb index 6aa1a8e7cd..dfebbca72c 100644 --- a/app/models/plate_barcode.rb +++ b/app/models/plate_barcode.rb @@ -25,7 +25,7 @@ def self.create_barcode # Returns: # - Barcode instance, using Sequencescape22 format def self.create_barcode_with_text(text) - response = fetch_response("#{site}/barcodes/#{prefix}/new", { text: text }) + response = fetch_response("#{site}/barcodes/#{prefix}/new", { text: }) Barcode.build_sequencescape22(response) end @@ -36,8 +36,8 @@ def self.create_barcode_with_text(text) # Returns: # - Barcode instance, using Sequencescape22 format def self.create_child_barcodes(parent_barcode, count = 1) - response = fetch_response("#{site}/child-barcodes/#{prefix}/new", { barcode: parent_barcode, count: count }) - response[:barcodes_group][:barcodes].map! { |barcode| Barcode.build_sequencescape22(barcode: barcode) } + response = fetch_response("#{site}/child-barcodes/#{prefix}/new", { barcode: parent_barcode, count: }) + response[:barcodes_group][:barcodes].map! { |barcode| Barcode.build_sequencescape22(barcode:) } end # Obtain a record from Baracoda and retries the specified amount of time. If the number or retries is reached diff --git a/app/models/plate_creation.rb b/app/models/plate_creation.rb index 84cd06da7e..afe5658a84 100644 --- a/app/models/plate_creation.rb +++ b/app/models/plate_creation.rb @@ -34,7 +34,7 @@ def children private :children def create_children! - self.child = child_purpose.create!(barcode: barcode) + self.child = child_purpose.create!(barcode:) end private :create_children! end diff --git a/app/models/plate_volume.rb b/app/models/plate_volume.rb index 13323336e4..3f5ba6f7c1 100644 --- a/app/models/plate_volume.rb +++ b/app/models/plate_volume.rb @@ -51,7 +51,7 @@ def update_well_volumes units: 'ul', assay_type: ASSAY_TYPE, assay_version: ASSAY_VERSION, - qc_assay: qc_assay + qc_assay: ) end end diff --git a/app/models/pooling.rb b/app/models/pooling.rb index 09d6964a93..13d8cdebe3 100644 --- a/app/models/pooling.rb +++ b/app/models/pooling.rb @@ -34,7 +34,7 @@ def transfer # pass in a Request Null object. This will disable the attempt to detect an outer request. # We don't use nil as its *far* to easy to end up with nil by accident, so basing key behaviour # off it is risky. - TransferRequest.create!(asset: source_asset, target_asset: target_asset, outer_request: Request::None.new) + TransferRequest.create!(asset: source_asset, target_asset:, outer_request: Request::None.new) end message[:notice] = message[:notice] + success end @@ -72,7 +72,7 @@ def print_job barcode_printer, LabelPrinter::Label::MultiplexedTube, assets: target_assets, - count: count + count: ) end diff --git a/app/models/presenters/qc_report_presenter.rb b/app/models/presenters/qc_report_presenter.rb index fc9bec3d74..70c3d99d4f 100644 --- a/app/models/presenters/qc_report_presenter.rb +++ b/app/models/presenters/qc_report_presenter.rb @@ -51,7 +51,7 @@ def created_date end def state_description - I18n.t(qc_report.state, scope: 'qc_reports.state_descriptions', default: :default, queue_count: queue_count) + I18n.t(qc_report.state, scope: 'qc_reports.state_descriptions', default: :default, queue_count:) end def to_csv(io) diff --git a/app/models/product_criteria.rb b/app/models/product_criteria.rb index e97d571414..0ea9459fe8 100644 --- a/app/models/product_criteria.rb +++ b/app/models/product_criteria.rb @@ -19,7 +19,7 @@ class ProductCriteria < ApplicationRecord serialize :configuration - scope :for_stage, ->(stage) { where(stage: stage) } + scope :for_stage, ->(stage) { where(stage:) } scope :stock, -> { where(stage: STAGE_STOCK) } scope :older_than, ->(id) { where(['id < ?', id]) } diff --git a/app/models/project.rb b/app/models/project.rb index bb738822dd..8d09b27959 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -61,7 +61,7 @@ def self.states # Allow us to pass in nil or '' if we don't want to filter state. # State is required so we don't need to look up an actual null state - scope :in_state, ->(state) { state.present? ? where(state: state) : all } + scope :in_state, ->(state) { state.present? ? where(state:) : all } scope :approved, -> { where(approved: true) } scope :unapproved, -> { where(approved: false) } diff --git a/app/models/purpose.rb b/app/models/purpose.rb index e9150f1aeb..19ca280e42 100644 --- a/app/models/purpose.rb +++ b/app/models/purpose.rb @@ -85,7 +85,7 @@ def target_class end def prefix=(prefix) - self.barcode_prefix = BarcodePrefix.find_or_create_by(prefix: prefix) + self.barcode_prefix = BarcodePrefix.find_or_create_by(prefix:) end def set_default_barcode_prefix diff --git a/app/models/qc_file.rb b/app/models/qc_file.rb index 1a68de750c..d205f1fedb 100644 --- a/app/models/qc_file.rb +++ b/app/models/qc_file.rb @@ -11,7 +11,7 @@ def has_qc_files # rubocop:todo Metrics/MethodLength has_many :qc_files, foreign_key: :asset_id, dependent: :destroy def add_qc_file(file, filename = nil) - opts = { uploaded_data: { tempfile: file, filename: filename } } + opts = { uploaded_data: { tempfile: file, filename: } } opts[:filename] = filename unless filename.nil? qc_files.create!(opts) if file.present? end diff --git a/app/models/qc_report.rb b/app/models/qc_report.rb index d1121af7ce..5585535723 100644 --- a/app/models/qc_report.rb +++ b/app/models/qc_report.rb @@ -100,7 +100,7 @@ def generate_report # rubocop:todo Metrics/AbcSize assets.each do |asset| criteria = product_criteria.assess(asset, connected_wells[asset.id]) QcMetric.create!( - asset: asset, + asset:, qc_decision: criteria.qc_decision, metrics: criteria.metrics, qc_report: self diff --git a/app/models/qc_report/file.rb b/app/models/qc_report/file.rb index 93d9b0f739..c5a981de6e 100644 --- a/app/models/qc_report/file.rb +++ b/app/models/qc_report/file.rb @@ -65,7 +65,7 @@ def valid? # rubocop:todo Metrics/MethodLength # The report to which the file corresponds def qc_report - @qc_report ||= QcReport.find_by(report_identifier: report_identifier) + @qc_report ||= QcReport.find_by(report_identifier:) end # A hash of the header section @@ -134,7 +134,7 @@ def process_group(group) # rubocop:todo Metrics/AbcSize def process_line(line) qc_decision = (line[:qc_decision] || '').strip proceed = (line[:proceed] || '').strip - { qc_decision: qc_decision, proceed: proceed } + { qc_decision:, proceed: } end def invalid(message) diff --git a/app/models/qc_result.rb b/app/models/qc_result.rb index 2522bd113c..306ce1b388 100644 --- a/app/models/qc_result.rb +++ b/app/models/qc_result.rb @@ -28,7 +28,7 @@ class QcResult < ApplicationRecord validates :key, :value, :units, presence: true - scope :last_qc_result_for, ->(key) { where(key: key).order(created_at: :desc, id: :desc).limit(1) } + scope :last_qc_result_for, ->(key) { where(key:).order(created_at: :desc, id: :desc).limit(1) } scope :order_by_date, -> { order(created_at: :desc) } def self.by_key diff --git a/app/models/qc_result_factory.rb b/app/models/qc_result_factory.rb index d0c2a2632e..d2624947f4 100644 --- a/app/models/qc_result_factory.rb +++ b/app/models/qc_result_factory.rb @@ -23,11 +23,11 @@ def resources end def qc_assay - @qc_assay ||= QcAssay.new(lot_number: lot_number) + @qc_assay ||= QcAssay.new(lot_number:) end def build_resources(assets) - assets.each { |asset| resources << Resource.new(asset.merge(qc_assay: qc_assay)) } + assets.each { |asset| resources << Resource.new(asset.merge(qc_assay:)) } end def except_blank_wells @@ -61,14 +61,14 @@ def initialize(attributes = {}) @asset = build_asset @qc_result = QcResult.new( - asset: asset, - key: key, - value: value, - units: units, - cv: cv, - assay_type: assay_type, - assay_version: assay_version, - qc_assay: qc_assay + asset:, + key:, + value:, + units:, + cv:, + assay_type:, + assay_version:, + qc_assay: ) end diff --git a/app/models/qcable/statemachine.rb b/app/models/qcable/statemachine.rb index 5f47700c66..791f9cd6d9 100644 --- a/app/models/qcable/statemachine.rb +++ b/app/models/qcable/statemachine.rb @@ -47,7 +47,7 @@ def self.included(base) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength end # new version of combinable named_scope - scope :for_state, ->(state) { where(state: state) } + scope :for_state, ->(state) { where(state:) } scope :unavailable, -> { where(state: %i[created pending failed passed destroyed qc_in_progress exhausted]) } end diff --git a/app/models/qcable_creator.rb b/app/models/qcable_creator.rb index 24deab41b0..75c220a3f6 100644 --- a/app/models/qcable_creator.rb +++ b/app/models/qcable_creator.rb @@ -24,11 +24,11 @@ def qcables_by_count! end def qcables_by_barcode! - barcodes.split(',').collect { |barcode| lot.qcables.create!(qcable_creator: self, barcode: barcode) } + barcodes.split(',').collect { |barcode| lot.qcables.create!(qcable_creator: self, barcode:) } end # Creates using the supplied plate barcode we received from baracoda def qcables_by_supplied_barcode! - lot.qcables.create!(qcable_creator: self, supplied_barcode: supplied_barcode) + lot.qcables.create!(qcable_creator: self, supplied_barcode:) end end diff --git a/app/models/receptacle.rb b/app/models/receptacle.rb index 6f542bbef4..5298cc1e58 100644 --- a/app/models/receptacle.rb +++ b/app/models/receptacle.rb @@ -51,7 +51,7 @@ class Receptacle < Asset # rubocop:todo Metrics/ClassLength # to a barcode type and retire this delegate :two_dimensional_barcode, :two_dimensional_barcode=, to: :labware, allow_nil: true - scope :named, ->(name) { joins(:labware).where(labware: { name: name }) } + scope :named, ->(name) { joins(:labware).where(labware: { name: }) } # We accept not only an individual barcode but also an array of them. scope :with_barcode, @@ -254,13 +254,13 @@ def library_types def set_as_library(force: false) aliquots.each do |aliquot| - aliquot.set_library(force: force) + aliquot.set_library(force:) aliquot.save! end end def outer_request(submission_id) - transfer_requests_as_target.find_by(submission_id: submission_id).try(:outer_request) + transfer_requests_as_target.find_by(submission_id:).try(:outer_request) end # All studies related to this asset @@ -269,7 +269,7 @@ def related_studies end def attach_tag(tag, tag2 = nil) - tags = { tag: tag, tag2: tag2 }.compact + tags = { tag:, tag2: }.compact return if tags.empty? raise StandardError, 'Cannot tag an empty asset' if aliquots.empty? diff --git a/app/models/report_fail.rb b/app/models/report_fail.rb index 38466a5be5..343ec9210c 100644 --- a/app/models/report_fail.rb +++ b/app/models/report_fail.rb @@ -39,7 +39,7 @@ def save failed_labware.each do |labware| labware.events.create_labware_failed!(failure_id, user.login) - BroadcastEvent::LabwareFailed.create!(seed: labware, user: user, properties: { failure_reason: failure_id }) + BroadcastEvent::LabwareFailed.create!(seed: labware, user:, properties: { failure_reason: failure_id }) end valid? diff --git a/app/models/request.rb b/app/models/request.rb index b5e3cff493..79be045ba3 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -342,7 +342,7 @@ def self.for_study(study) end def self.number_expected_for_submission_id_and_request_type_id(submission_id, request_type_id) - Request.where(submission_id: submission_id, request_type_id: request_type_id) + Request.where(submission_id:, request_type_id:) end def self.accessioning_required? @@ -372,7 +372,7 @@ def project_id=(project_id) end def submission_plate_count - submission.requests.where(request_type_id: request_type_id).joins(:source_labware).distinct.count('labware.id') + submission.requests.where(request_type_id:).joins(:source_labware).distinct.count('labware.id') end def update_responsibilities! @@ -462,9 +462,7 @@ def next_request_type_id # CAUTION!: This may not behaves as expected. I'll be deprecating this soon. def next_requests_via_asset - if target_asset.present? - target_asset.requests.where(submission_id: submission_id, request_type_id: next_request_type_id) - end + target_asset.requests.where(submission_id:, request_type_id: next_request_type_id) if target_asset.present? end def next_requests_via_submission @@ -482,7 +480,7 @@ def previous_failed_requests? def add_comment(comment, user, title = nil) # Unscope comments to fix Rails 6 deprecation warnings. But I *think* this # essentially models the new behaviour in 6.1 So should be removable then - Comment.unscoped { comments.create(description: comment, user: user, title: title) } + Comment.unscoped { comments.create(description: comment, user:, title:) } end def return_pending_to_inbox! @@ -517,7 +515,7 @@ def cancelable? def update_priority priority = (self.priority + 1) % 4 - submission.update!(priority: priority) + submission.update!(priority:) end def priority diff --git a/app/models/request/library_creation.rb b/app/models/request/library_creation.rb index 98e4103006..c63c8473da 100644 --- a/app/models/request/library_creation.rb +++ b/app/models/request/library_creation.rb @@ -66,8 +66,8 @@ def aliquot_attributes { study_id: initial_study_id, project_id: initial_project_id, - library_type: library_type, - insert_size: insert_size, + library_type:, + insert_size:, request_id: id } end diff --git a/app/models/request/sample_compound_aliquot_transfer.rb b/app/models/request/sample_compound_aliquot_transfer.rb index 5d346a4bad..40f7970991 100644 --- a/app/models/request/sample_compound_aliquot_transfer.rb +++ b/app/models/request/sample_compound_aliquot_transfer.rb @@ -53,7 +53,7 @@ def aliquots_by_tags_combination # For a group of source aliquots, find or create a compound sample containing the component samples # Assign the compound sample to the target asset def transfer_into_compound_sample_aliquot(source_aliquots) - compound_aliquot = CompoundAliquot.new(request: self, source_aliquots: source_aliquots) + compound_aliquot = CompoundAliquot.new(request: self, source_aliquots:) unless compound_aliquot.valid? raise Request::SampleCompoundAliquotTransfer::Error, compound_aliquot.errors.full_messages end diff --git a/app/models/request/statemachine.rb b/app/models/request/statemachine.rb index 1273faa86d..e3281601fa 100644 --- a/app/models/request/statemachine.rb +++ b/app/models/request/statemachine.rb @@ -130,7 +130,7 @@ def destroy_aasm # rubocop:todo Metrics/MethodLength end end - scope :for_state, ->(state) { where(state: state) } + scope :for_state, ->(state) { where(state:) } scope :completed, -> { where(state: COMPLETED_STATE) } scope :pending, -> { where(state: %w[pending blocked]) } # block is a kind of substate of pending } diff --git a/app/models/request_factory.rb b/app/models/request_factory.rb index f8283e616e..8272d88455 100644 --- a/app/models/request_factory.rb +++ b/app/models/request_factory.rb @@ -15,11 +15,11 @@ def self.copy_request(request) def self.create_assets_requests(assets, study) request_type = RequestType.create_asset - assets.each { |asset| request_type.create!(study: study, asset: asset, state: 'passed') } + assets.each { |asset| request_type.create!(study:, asset:, state: 'passed') } end def self.create_external_multiplexed_library_creation_requests(sources, target, study) request_type = RequestType.external_multiplexed_library_creation - sources.each { |asset| request_type.create!(study: study, asset: asset, target_asset: target) } + sources.each { |asset| request_type.create!(study:, asset:, target_asset: target) } end end diff --git a/app/models/request_type/validation.rb b/app/models/request_type/validation.rb index cc1c8a22e4..867b677227 100644 --- a/app/models/request_type/validation.rb +++ b/app/models/request_type/validation.rb @@ -19,7 +19,7 @@ def create_validator(request_type) # rubocop:todo Metrics/MethodLength inclusion: { in: validator.valid_options, if: :"#{validator.request_option}_needs_checking?", - message: message, + message:, allow_blank: validator.allow_blank? } end diff --git a/app/models/robot.rb b/app/models/robot.rb index 5d8d96c4cb..1e86b62be2 100644 --- a/app/models/robot.rb +++ b/app/models/robot.rb @@ -60,9 +60,9 @@ def generation_behaviour end def generator(batch:, plate_barcode:, pick_number:) - picking_data = Robot::PickData.new(batch, max_beds: max_beds).picking_data_hash(plate_barcode)[pick_number] + picking_data = Robot::PickData.new(batch, max_beds:).picking_data_hash(plate_barcode)[pick_number] layout = verification_behaviour.layout_data_object(picking_data) - generation_behaviour.new(batch: batch, plate_barcode: plate_barcode, picking_data: picking_data, layout: layout) + generation_behaviour.new(batch:, plate_barcode:, picking_data:, layout:) end def self.default_for_verification diff --git a/app/models/robot/verification/base.rb b/app/models/robot/verification/base.rb index b541cff3c2..86a3f229f3 100644 --- a/app/models/robot/verification/base.rb +++ b/app/models/robot/verification/base.rb @@ -220,6 +220,6 @@ def valid_plates_on_robot?(beds, plates, bed_prefix, robot, _batch, expected_pla def cached_pick_data(batch, max_beds) @cached_pick_data ||= {} - @cached_pick_data[[batch, max_beds]] ||= Robot::PickData.new(batch, max_beds: max_beds) + @cached_pick_data[[batch, max_beds]] ||= Robot::PickData.new(batch, max_beds:) end end diff --git a/app/models/role.rb b/app/models/role.rb index 23fe1c4c79..c9450e5440 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -12,8 +12,8 @@ class Role < ApplicationRecord validates :name, presence: true scope :general_roles, -> { where(authorizable_type: nil) } - scope :named, ->(name) { where(name: name) } - scope :authorizing, ->(authorizable) { where(authorizable: authorizable) if authorizable } + scope :named, ->(name) { where(name:) } + scope :authorizing, ->(authorizable) { where(authorizable:) if authorizable } after_destroy :touch_authorizable diff --git a/app/models/role/user_role_helper.rb b/app/models/role/user_role_helper.rb index 6f112553d9..fa90b8225e 100644 --- a/app/models/role/user_role_helper.rb +++ b/app/models/role/user_role_helper.rb @@ -18,7 +18,7 @@ def role?(role_name, authorizable = nil) # Grants a user the role_name, in cases like # owner, authorizable should indicate the owned resource def grant_role(role_name, authorizable = nil) - roles << Role.find_or_create_by!(name: role_name, authorizable: authorizable) + roles << Role.find_or_create_by!(name: role_name, authorizable:) end def remove_role(role_name, authorizable = nil) diff --git a/app/models/sample.rb b/app/models/sample.rb index 18bbf6814f..71f7e707d7 100644 --- a/app/models/sample.rb +++ b/app/models/sample.rb @@ -411,7 +411,7 @@ def rename_to!(new_name) 'name LIKE :wild OR id IN (:sm_ids) OR id = :qid', wild: "%#{query}%", sm_ids: md, - query: query, + query:, qid: query.to_i ) } diff --git a/app/models/sample_manifest.rb b/app/models/sample_manifest.rb index 2418ab3fb2..ce4ff54eac 100644 --- a/app/models/sample_manifest.rb +++ b/app/models/sample_manifest.rb @@ -191,12 +191,12 @@ def create_sample_and_aliquot(sanger_sample_id, asset) def create_sample(sanger_sample_id) Sample - .create!(name: sanger_sample_id, sanger_sample_id: sanger_sample_id, sample_manifest: self) + .create!(name: sanger_sample_id, sanger_sample_id:, sample_manifest: self) .tap { |sample| sample.events.created_using_sample_manifest!(user) } end def created_broadcast_event - BroadcastEvent::SampleManifestCreated.create!(seed: self, user: user) + BroadcastEvent::SampleManifestCreated.create!(seed: self, user:) end def updated_broadcast_event(user_updating_manifest, updated_samples_ids) diff --git a/app/models/sample_manifest/core_behaviour.rb b/app/models/sample_manifest/core_behaviour.rb index 835edf32e5..9b62d7d30c 100644 --- a/app/models/sample_manifest/core_behaviour.rb +++ b/app/models/sample_manifest/core_behaviour.rb @@ -44,7 +44,7 @@ def generate_sample_and_aliquot(sanger_sample_id, receptacle) create_sample(sanger_sample_id).tap do |sample| tag_depth = tag_depth_for_sample(@manifest.pools, receptacle, sanger_sample_id) - receptacle.aliquots.create!(sample: sample, study: study, tag_depth: tag_depth) + receptacle.aliquots.create!(sample:, study:, tag_depth:) study.samples << sample end @@ -68,7 +68,7 @@ def tag_depth_for_sample(pools, receptacle, sanger_sample_id) module LibraryAssets def generate_sample_and_aliquot(sanger_sample_id, receptacle) create_sample(sanger_sample_id).tap do |sample| - receptacle.aliquots.create!(sample: sample, study: study, library: receptacle) + receptacle.aliquots.create!(sample:, study:, library: receptacle) study.samples << sample end end diff --git a/app/models/sample_manifest/generator.rb b/app/models/sample_manifest/generator.rb index e62e1edb24..ae16b4d7c7 100644 --- a/app/models/sample_manifest/generator.rb +++ b/app/models/sample_manifest/generator.rb @@ -41,8 +41,8 @@ def print_job LabelPrinter::PrintJob.new( params[:barcode_printer], LabelPrinter::Label::SampleManifestRedirect, - only_first_label: only_first_label, - sample_manifest: sample_manifest + only_first_label:, + sample_manifest: ) end @@ -97,10 +97,10 @@ def execute_print_job def attributes params.except(:template, :barcode_printer, :only_first_label).merge( - user: user, - asset_type: asset_type, - rows_per_well: rows_per_well, - invalid_wells: invalid_wells + user:, + asset_type:, + rows_per_well:, + invalid_wells: ) end diff --git a/app/models/sample_manifest/library_tube_behaviour.rb b/app/models/sample_manifest/library_tube_behaviour.rb index 1c1d5e30e8..84ea03123c 100644 --- a/app/models/sample_manifest/library_tube_behaviour.rb +++ b/app/models/sample_manifest/library_tube_behaviour.rb @@ -24,7 +24,7 @@ def generate def io_samples samples.map do |sample| { - sample: sample, + sample:, container: { barcode: sample.primary_receptacle.human_barcode }, diff --git a/app/models/sample_manifest/multiplexed_library_behaviour.rb b/app/models/sample_manifest/multiplexed_library_behaviour.rb index 3929604807..972f09ba71 100644 --- a/app/models/sample_manifest/multiplexed_library_behaviour.rb +++ b/app/models/sample_manifest/multiplexed_library_behaviour.rb @@ -26,7 +26,7 @@ def generate_mx_library def io_samples samples.map do |sample| { - sample: sample, + sample:, container: { barcode: sample.primary_receptacle.human_barcode }, diff --git a/app/models/sample_manifest/plate_behaviour.rb b/app/models/sample_manifest/plate_behaviour.rb index 70e2eaea54..b053d91e99 100644 --- a/app/models/sample_manifest/plate_behaviour.rb +++ b/app/models/sample_manifest/plate_behaviour.rb @@ -40,7 +40,7 @@ def io_samples samples.map do |sample| container = sample.primary_receptacle { - sample: sample, + sample:, container: { barcode: container.plate.human_barcode, position: container.map.description.sub(/^([^\d]+)(\d)$/, '\10\2') diff --git a/app/models/sample_manifest/sample_tube_behaviour.rb b/app/models/sample_manifest/sample_tube_behaviour.rb index 1ab84b0a9e..bf43090b4b 100644 --- a/app/models/sample_manifest/sample_tube_behaviour.rb +++ b/app/models/sample_manifest/sample_tube_behaviour.rb @@ -16,7 +16,7 @@ def generate end def io_samples - samples.map { |sample| { sample: sample, container: { barcode: sample.primary_receptacle.human_barcode } } } + samples.map { |sample| { sample:, container: { barcode: sample.primary_receptacle.human_barcode } } } end def acceptable_purposes diff --git a/app/models/sample_manifest/shared_tube_behaviour.rb b/app/models/sample_manifest/shared_tube_behaviour.rb index 1285e9a541..56443dd002 100644 --- a/app/models/sample_manifest/shared_tube_behaviour.rb +++ b/app/models/sample_manifest/shared_tube_behaviour.rb @@ -27,7 +27,7 @@ def generate_tubes(tube_purpose, number_of_tubes = count) # rubocop:todo Metrics tube = tube_purpose.create! sanger_sample_id = SangerSampleId.generate_sanger_sample_id!(study_abbreviation, sanger_ids.shift) SampleManifestAsset.create!( - sanger_sample_id: sanger_sample_id, + sanger_sample_id:, asset: tube.receptacle, sample_manifest: @manifest ) diff --git a/app/models/sample_manifest/uploader.rb b/app/models/sample_manifest/uploader.rb index b3229733ab..fadb3ba3b7 100644 --- a/app/models/sample_manifest/uploader.rb +++ b/app/models/sample_manifest/uploader.rb @@ -24,7 +24,7 @@ def initialize(file, configuration, user, override) @override = override @tag_group = create_tag_group @upload = - SampleManifestExcel::Upload::Base.new(file: file, column_list: self.configuration.columns.all, override: override) + SampleManifestExcel::Upload::Base.new(file:, column_list: self.configuration.columns.all, override:) end def run! diff --git a/app/models/sequencing_pipeline.rb b/app/models/sequencing_pipeline.rb index e6410ae10e..095e0bc15f 100644 --- a/app/models/sequencing_pipeline.rb +++ b/app/models/sequencing_pipeline.rb @@ -74,7 +74,7 @@ def detach_request_from_batch(batch, request) end def on_start_batch(batch, user) - BroadcastEvent::SequencingStart.create!(seed: batch, user: user, properties: {}, created_at: DateTime.now) + BroadcastEvent::SequencingStart.create!(seed: batch, user:, properties: {}, created_at: DateTime.now) end def post_release_batch(batch, _user) diff --git a/app/models/set_descriptors_task.rb b/app/models/set_descriptors_task.rb index 8c67042fd7..7eb585aacf 100644 --- a/app/models/set_descriptors_task.rb +++ b/app/models/set_descriptors_task.rb @@ -19,18 +19,18 @@ def can_process?(batch) def render_task(workflows_controller, params, user) Tasks::SetDescriptorsHandler::Handler.new( controller: workflows_controller, - params: params, + params:, task: self, - user: user + user: ).render end def do_task(workflows_controller, params, user) Tasks::SetDescriptorsHandler::Handler.new( controller: workflows_controller, - params: params, + params:, task: self, - user: user + user: ).perform end diff --git a/app/models/state_change.rb b/app/models/state_change.rb index 93157297f1..53aa097160 100644 --- a/app/models/state_change.rb +++ b/app/models/state_change.rb @@ -65,10 +65,10 @@ def state_changer def update_state_of_target state_changer.new( labware: target, - target_state: target_state, - user: user, - contents: contents, - customer_accepts_responsibility: customer_accepts_responsibility + target_state:, + user:, + contents:, + customer_accepts_responsibility: ).update_labware_state end end diff --git a/app/models/state_changer/mx_tube.rb b/app/models/state_changer/mx_tube.rb index cd6371bef5..5fb6b44da6 100644 --- a/app/models/state_changer/mx_tube.rb +++ b/app/models/state_changer/mx_tube.rb @@ -14,7 +14,7 @@ def associated_requests def generate_events_for(orders) orders.each do |order_id| - BroadcastEvent::PoolReleased.create!(seed: labware, user: user, properties: { order_id: order_id }) + BroadcastEvent::PoolReleased.create!(seed: labware, user:, properties: { order_id: }) end end diff --git a/app/models/state_changer/standard_plate.rb b/app/models/state_changer/standard_plate.rb index 179933fe84..6d1ea1069b 100644 --- a/app/models/state_changer/standard_plate.rb +++ b/app/models/state_changer/standard_plate.rb @@ -44,7 +44,7 @@ def pending_orders def generate_events_for(orders) orders.each do |order_id| - BroadcastEvent::LibraryStart.create!(seed: labware, user: user, properties: { order_id: order_id }) + BroadcastEvent::LibraryStart.create!(seed: labware, user:, properties: { order_id: }) end end diff --git a/app/models/stock_stamper.rb b/app/models/stock_stamper.rb index e0db550511..a72771d24c 100644 --- a/app/models/stock_stamper.rb +++ b/app/models/stock_stamper.rb @@ -40,7 +40,7 @@ def execute def generate_tecan_gwl_file_as_text picking_data = generate_tecan_data layout = Robot::Verification::SourceDestBeds.new.layout_data_object(picking_data) - @file_content = Robot::Generator::Tecan.new(picking_data: picking_data, layout: layout, total_volume: 0).as_text + @file_content = Robot::Generator::Tecan.new(picking_data:, layout:, total_volume: 0).as_text end def generate_tecan_data # rubocop:todo Metrics/AbcSize diff --git a/app/models/study.rb b/app/models/study.rb index abfb87248f..15bb2d513a 100644 --- a/app/models/study.rb +++ b/app/models/study.rb @@ -351,7 +351,7 @@ class Study < ApplicationRecord # rubocop:todo Metrics/ClassLength scope :with_remove_x_and_autosomes, -> { joins(:study_metadata).where(study_metadata: { remove_x_and_autosomes: Study::YES }) } - scope :by_state, ->(state) { where(state: state) } + scope :by_state, ->(state) { where(state:) } scope :by_user, ->(login) do diff --git a/app/models/study/poly_metadata_handler.rb b/app/models/study/poly_metadata_handler.rb index 7aa7c99f08..1dd1f7ebed 100644 --- a/app/models/study/poly_metadata_handler.rb +++ b/app/models/study/poly_metadata_handler.rb @@ -99,7 +99,7 @@ def handle_scrna_core_pbmc_donor_pooling_required_number_of_cells(key, value) if value.blank? poly_metadatum&.destroy! elsif poly_metadatum&.value != value - poly_metadatum ||= PolyMetadatum.new(key: key, metadatable: @study) + poly_metadatum ||= PolyMetadatum.new(key:, metadatable: @study) poly_metadatum.value = value poly_metadatum.save! end diff --git a/app/models/study_report.rb b/app/models/study_report.rb index 8fbd163aed..d5d001404e 100644 --- a/app/models/study_report.rb +++ b/app/models/study_report.rb @@ -54,7 +54,7 @@ def perform end def schedule_report - Delayed::Job.enqueue StudyReportJob.new(id), priority: priority + Delayed::Job.enqueue StudyReportJob.new(id), priority: end def priority diff --git a/app/models/study_report/well_details.rb b/app/models/study_report/well_details.rb index 2d61827754..f1a66bc6cc 100644 --- a/app/models/study_report/well_details.rb +++ b/app/models/study_report/well_details.rb @@ -41,8 +41,8 @@ def qc_report # rubocop:todo Metrics/AbcSize plate_barcode: plate.human_barcode, measured_volume: well_attribute.measured_volume, current_volume: well_attribute.current_volume, - gel_qc_date: gel_qc_date, - pico_date: pico_date, + gel_qc_date:, + pico_date:, qc_started_date: plate.qc_started_date, sequenom_stamp_date: plate.sequenom_stamp_date, quantity: well_attribute.quantity_in_micro_grams.try(:round, 3), diff --git a/app/models/submission/accession_behaviour.rb b/app/models/submission/accession_behaviour.rb index b3845f9b15..9dc0f42280 100644 --- a/app/models/submission/accession_behaviour.rb +++ b/app/models/submission/accession_behaviour.rb @@ -31,7 +31,7 @@ def check_data_release_and_accession_for_submission # rubocop:todo Metrics/AbcSi private def test_asset_group - AssetGroup.new(assets: assets) + AssetGroup.new(assets:) end def unaccessioned_samples diff --git a/app/models/submission/asset_group_behaviour.rb b/app/models/submission/asset_group_behaviour.rb index 2b6e9fb1b3..c4d3b6ff80 100644 --- a/app/models/submission/asset_group_behaviour.rb +++ b/app/models/submission/asset_group_behaviour.rb @@ -40,7 +40,7 @@ def create_our_asset_group group_name = asset_group_name group_name = uuid if asset_group_name.blank? - asset_group = study.asset_groups.create!(name: group_name, user: user, assets: assets) + asset_group = study.asset_groups.create!(name: group_name, user:, assets:) update!(asset_group_id: asset_group.id) end private :create_our_asset_group diff --git a/app/models/submission/flexible_request_graph.rb b/app/models/submission/flexible_request_graph.rb index a2106ca74f..8a4728e384 100644 --- a/app/models/submission/flexible_request_graph.rb +++ b/app/models/submission/flexible_request_graph.rb @@ -108,7 +108,7 @@ def build! # rubocop:todo Metrics/AbcSize source_asset_metrics_target_assets do |source_asset, qc_metrics, target_asset| chain .order - .create_request_of_type!(request_type, asset: source_asset, target_asset: target_asset) + .create_request_of_type!(request_type, asset: source_asset, target_asset:) .tap do |request| if source_asset&.labware.present? && target_asset&.labware.present? AssetLink.create_edge(source_asset.labware, target_asset.labware) @@ -117,9 +117,7 @@ def build! # rubocop:todo Metrics/AbcSize request.qc_metrics = qc_metrics.compact.uniq request.update_responsibilities! - if comments.present? - comments.each { |comment| request.comments.create!(user: user, description: comment) } - end + comments.each { |comment| request.comments.create!(user:, description: comment) } if comments.present? end end end @@ -195,7 +193,7 @@ def associate_built_requests! downstream_requests.each do |request| request.update!(initial_study: nil) if request.initial_study != study request.update!(initial_project: nil) if request.initial_project != project - comments.each { |comment| request.comments.create!(user: user, description: comment) } if comments.present? + comments.each { |comment| request.comments.create!(user:, description: comment) } if comments.present? end end diff --git a/app/models/submission/linear_request_graph.rb b/app/models/submission/linear_request_graph.rb index 0e2ca84894..7a9cd9d385 100644 --- a/app/models/submission/linear_request_graph.rb +++ b/app/models/submission/linear_request_graph.rb @@ -87,7 +87,7 @@ def create_request_chain!(request_type_and_multiplier_pairs, source_data_set, mu qc_metrics = source_data.qc_metric target_asset = target_assets[index] - create_request_of_type!(request_type, asset: source_asset, target_asset: target_asset).tap do |request| + create_request_of_type!(request_type, asset: source_asset, target_asset:).tap do |request| # TODO: AssetLink is supposed to disappear at some point in the future because it makes no real sense # given that the request graph describes this relationship. # JG: Its removal only really makes sense if we can walk the request graph in a timely manner. @@ -100,7 +100,7 @@ def create_request_chain!(request_type_and_multiplier_pairs, source_data_set, mu request.update_responsibilities! if comments.present? - comments.split("\n").each { |comment| request.comments.create!(user: user, description: comment) } + comments.split("\n").each { |comment| request.comments.create!(user:, description: comment) } end end end @@ -142,7 +142,7 @@ def associate_built_requests(assets) # rubocop:todo Metrics/AbcSize request.update!(initial_study: nil) if request.initial_study != study request.update!(initial_project: nil) if request.initial_project != project if comments.present? - comments.split("\n").each { |comment| request.comments.create!(user: user, description: comment) } + comments.split("\n").each { |comment| request.comments.create!(user:, description: comment) } end end end diff --git a/app/models/submission/submission_creator.rb b/app/models/submission/submission_creator.rb index d3efb68888..9c635b872c 100644 --- a/app/models/submission/submission_creator.rb +++ b/app/models/submission/submission_creator.rb @@ -101,7 +101,7 @@ def save # rubocop:todo Metrics/AbcSize submission.orders << new_order else - @submission = new_order.create_submission(user: order.user, priority: priority) + @submission = new_order.create_submission(user: order.user, priority:) end new_order.save! @@ -222,13 +222,13 @@ def create_order # rubocop:todo Metrics/AbcSize order_role = OrderRole.find_by(role: order_params.delete('order_role')) if order_params.present? new_order = template.new_order( - study: study, - project: project, + study:, + project:, user: @user, request_options: order_params, - comments: comments, + comments:, pre_cap_group: pre_capture_plex_group, - order_role: order_role + order_role: ) if order_params new_order.request_type_multiplier do |sequencing_request_type_id| @@ -243,7 +243,7 @@ def create_order # rubocop:todo Metrics/AbcSize # This is a legacy of the old controller... def find_samples_from_text(sample_text) names = sample_text.split(/\s+/) - samples = Sample.includes(:assets).where(['name IN (:names) OR sanger_sample_id IN (:names)', { names: names }]) + samples = Sample.includes(:assets).where(['name IN (:names) OR sanger_sample_id IN (:names)', { names: }]) name_set = Set.new(names) found_set = Set.new(samples.map { |s| [s.name, s.sanger_sample_id] }.flatten) diff --git a/app/models/submission_template.rb b/app/models/submission_template.rb index f0ff0b0879..8c3aed9c80 100644 --- a/app/models/submission_template.rb +++ b/app/models/submission_template.rb @@ -49,7 +49,7 @@ def supercede name, cloned.name = cloned.name, "Superceding #{cloned.name}" cloned.save! update!(superceded_by_id: cloned.id, superceded_at: Time.zone.now) - cloned.update!(name: name) + cloned.update!(name:) end end end diff --git a/app/models/supplier.rb b/app/models/supplier.rb index b226387918..b5922c2121 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -11,6 +11,6 @@ class Supplier < ApplicationRecord # Named scope for search by query string behaviour scope :for_search_query, ->(query) do - where(['suppliers.name IS NOT NULL AND (suppliers.name LIKE :like)', { like: "%#{query}%", query: query }]) + where(['suppliers.name IS NOT NULL AND (suppliers.name LIKE :like)', { like: "%#{query}%", query: }]) end end diff --git a/app/models/tag2_layout_template.rb b/app/models/tag2_layout_template.rb index da367e6bdb..be7d91f940 100644 --- a/app/models/tag2_layout_template.rb +++ b/app/models/tag2_layout_template.rb @@ -25,11 +25,11 @@ def stamp_to(_) def record_template_use(plate) plate.submissions.each do |submission| - Tag2Layout::TemplateSubmission.create!(submission: submission, tag2_layout_template: self) + Tag2Layout::TemplateSubmission.create!(submission:, tag2_layout_template: self) end end def default_attributes - { tag: tag } + { tag: } end end diff --git a/app/models/tag_group.rb b/app/models/tag_group.rb index dc9aa340fb..c66bac3a49 100644 --- a/app/models/tag_group.rb +++ b/app/models/tag_group.rb @@ -30,7 +30,7 @@ def adapter_type_name end def adapter_type_name=(name) - self.adapter_type = TagGroup::AdapterType.find_by!(name: name) + self.adapter_type = TagGroup::AdapterType.find_by!(name:) end # Returns a Hash that maps from the tag index in the group to the oligo sequence for the tag diff --git a/app/models/tag_group/form_object.rb b/app/models/tag_group/form_object.rb index ced34ead0e..b38479634b 100644 --- a/app/models/tag_group/form_object.rb +++ b/app/models/tag_group/form_object.rb @@ -65,7 +65,7 @@ def check_entered_oligos # rubocop:todo Metrics/AbcSize def persist! # rubocop:todo Metrics/AbcSize success = TagGroup.transaction do - @tag_group = TagGroup.new(name: name, adapter_type_id: adapter_type_id) + @tag_group = TagGroup.new(name:, adapter_type_id:) @tag_group.tags.build( parse_oligos_list.each_with_index.map { |oligo, i| { oligo: oligo.upcase, map_id: i + 1 } } ) diff --git a/app/models/tag_layout_template.rb b/app/models/tag_layout_template.rb index 274df968db..6fc2343458 100644 --- a/app/models/tag_layout_template.rb +++ b/app/models/tag_layout_template.rb @@ -36,11 +36,11 @@ def create!(attributes = {}, &block) end def tag_group_name=(name) - self.tag_group = TagGroup.find_by!(name: name) + self.tag_group = TagGroup.find_by!(name:) end def tag2_group_name=(name) - self.tag2_group = TagGroup.find_by!(name: name) + self.tag2_group = TagGroup.find_by!(name:) end private @@ -55,19 +55,19 @@ def walking_algorithm_class def tag_layout_attributes { - tag_group: tag_group, - tag2_group: tag2_group, - direction_algorithm: direction_algorithm, - walking_algorithm: walking_algorithm + tag_group:, + tag2_group:, + direction_algorithm:, + walking_algorithm: } end def record_template_use(plate, enforce_uniqueness) plate.submissions.each do |submission| TagLayout::TemplateSubmission.create!( - submission: submission, + submission:, tag_layout_template: self, - enforce_uniqueness: enforce_uniqueness + enforce_uniqueness: ) end end diff --git a/app/models/tag_set.rb b/app/models/tag_set.rb index 2650596d03..1b4eaf63cd 100644 --- a/app/models/tag_set.rb +++ b/app/models/tag_set.rb @@ -39,10 +39,10 @@ def tag_group_adapter_types_must_match end def tag_group_name=(name) - self.tag_group = TagGroup.find_by!(name: name) + self.tag_group = TagGroup.find_by!(name:) end def tag2_group_name=(name) - self.tag2_group = TagGroup.find_by!(name: name) + self.tag2_group = TagGroup.find_by!(name:) end end diff --git a/app/models/tag_substitution.rb b/app/models/tag_substitution.rb index 19ecfef63a..808d276231 100644 --- a/app/models/tag_substitution.rb +++ b/app/models/tag_substitution.rb @@ -119,7 +119,7 @@ def save # rubocop:todo Metrics/MethodLength # # @return [void] def template_asset=(asset) - @substitutions = asset.aliquots.includes(:sample).map { |aliquot| Substitution.new(aliquot: aliquot) } + @substitutions = asset.aliquots.includes(:sample).map { |aliquot| Substitution.new(aliquot:) } @name = asset.display_name end @@ -170,7 +170,7 @@ def apply_comments commented_assets.map do |asset_id| { commentable_id: asset_id, - commentable_type: commentable_type, + commentable_type:, user_id: @user&.id, description: comment_text, title: "Tag Substitution #{@ticket}" diff --git a/app/models/tag_substitution/substitution.rb b/app/models/tag_substitution/substitution.rb index 5fd6498292..82d39165b1 100644 --- a/app/models/tag_substitution/substitution.rb +++ b/app/models/tag_substitution/substitution.rb @@ -173,7 +173,7 @@ def substitute_tag2? end def find_matching_aliquots - attributes = { sample_id: sample_id, library_id: library_id } + attributes = { sample_id:, library_id: } attributes[:tag_id] = original_tag_id if original_tag_id attributes[:tag2_id] = original_tag2_id if original_tag2_id Aliquot.where(attributes).ids diff --git a/app/models/tasks/add_spiked_in_control_handler.rb b/app/models/tasks/add_spiked_in_control_handler.rb index 8805672f12..5179c9c3fd 100644 --- a/app/models/tasks/add_spiked_in_control_handler.rb +++ b/app/models/tasks/add_spiked_in_control_handler.rb @@ -52,10 +52,10 @@ def process_request(request) lane.direct_spiked_in_buffer = nil lane.direct_spiked_in_buffer = phi_x_tube if phi_x_tube LabEvent.create!( - batch: batch, + batch:, description: task.name, descriptors: descriptors_for(phi_x_tube), - user: user, + user:, eventful: request ) end diff --git a/app/models/tasks/base_handler.rb b/app/models/tasks/base_handler.rb index 0d273fba01..3f8afc2846 100644 --- a/app/models/tasks/base_handler.rb +++ b/app/models/tasks/base_handler.rb @@ -21,7 +21,7 @@ def initialize(controller:, params:, task:, user:) private def create_batch_events - event = batch.lab_events.build(description: 'Complete', user: user, batch: batch) + event = batch.lab_events.build(description: 'Complete', user:, batch:) event.add_descriptor Descriptor.new(name: 'task_id', value: task.id) event.add_descriptor Descriptor.new(name: 'task', value: task.name) event.save! diff --git a/app/models/tasks/cherrypick_handler.rb b/app/models/tasks/cherrypick_handler.rb index f01431917c..581ec8fa4a 100644 --- a/app/models/tasks/cherrypick_handler.rb +++ b/app/models/tasks/cherrypick_handler.rb @@ -162,7 +162,7 @@ def do_cherrypick_task(_task, params) # rubocop:todo Metrics/CyclomaticComplexit plate_purpose.create!( :do_not_create_wells, name: "Cherrypicked #{plate_barcode.barcode}", - size: size, + size:, sanger_barcode: plate_barcode ) { |new_plate| new_plate.fluidigm_barcode = fluidigm_plate if fluidigm_plate.present? } end diff --git a/app/models/tasks/set_descriptors_handler.rb b/app/models/tasks/set_descriptors_handler.rb index c4446d183c..5b46b95156 100644 --- a/app/models/tasks/set_descriptors_handler.rb +++ b/app/models/tasks/set_descriptors_handler.rb @@ -33,10 +33,10 @@ def params def process_request(request) LabEvent.create!( - batch: batch, + batch:, description: @task.name, descriptors: descriptors(request), - user: user, + user:, eventful: request ) diff --git a/app/models/transfer/between_plate_and_tubes.rb b/app/models/transfer/between_plate_and_tubes.rb index 683649687e..3945c1641b 100644 --- a/app/models/transfer/between_plate_and_tubes.rb +++ b/app/models/transfer/between_plate_and_tubes.rb @@ -92,7 +92,7 @@ def build_well_to_tube_transfers # rubocop:todo Metrics/MethodLength well_to_tubes.build( @transfers.map do |source, (destination, stock_wells)| tube_to_stock_wells[destination].concat(stock_wells) - { source: source, destination: destination } + { source:, destination: } end ).map(&:save!) diff --git a/app/models/tube.rb b/app/models/tube.rb index 56df111310..3bb36fbe62 100644 --- a/app/models/tube.rb +++ b/app/models/tube.rb @@ -94,7 +94,7 @@ def self.create_with_barcode!(*args, &block) # this is to control the order of barcode addition so that it gets set as the 'primary' barcode foreign_barcode = attributes.delete(:foreign_barcode) - tube = create!(attributes.merge(sanger_barcode: { prefix: prefix, number: barcode }), &block) + tube = create!(attributes.merge(sanger_barcode: { prefix:, number: barcode }), &block) tube.foreign_barcode = foreign_barcode if foreign_barcode tube.reload @@ -111,7 +111,7 @@ def extract_barcode(args, attributes) end def validate_barcode(barcode, prefix) - human = SBCF::SangerBarcode.new(prefix: prefix, number: barcode).human_barcode + human = SBCF::SangerBarcode.new(prefix:, number: barcode).human_barcode raise "Barcode: #{barcode} already used!" if Barcode.exists?(barcode: human) end diff --git a/app/models/user/authentication.rb b/app/models/user/authentication.rb index 2c156b1363..07b10cb09a 100644 --- a/app/models/user/authentication.rb +++ b/app/models/user/authentication.rb @@ -18,7 +18,7 @@ def update_profile_via_ldap # rubocop:todo Metrics/AbcSize filter = Net::LDAP::Filter.eq('uid', login) treebase = 'ou=people,dc=sanger,dc=ac,dc=uk' - ldap_profile = ldap.search(base: treebase, filter: filter)[0] + ldap_profile = ldap.search(base: treebase, filter:)[0] # If we have two or more records, something is off with LDAP @@ -43,7 +43,7 @@ def authenticate(login, password) when 'none' raise StandardError, 'Can only disable authentication in development' unless Rails.env.development? - User.find_by(login: login) + User.find_by(login:) else authenticated = authenticate_by_local(login, password) end @@ -61,8 +61,8 @@ def authenticate_with_ldap(login, password) # rubocop:todo Metrics/AbcSize, Metr encryption: :simple_tls, auth: { method: :simple, - username: username, - password: password + username:, + password: } ) begin @@ -83,7 +83,7 @@ def authenticate_with_ldap(login, password) # rubocop:todo Metrics/AbcSize, Metr end def register_or_update_via_ldap(login) - u = find_or_create_by(login: login) + u = find_or_create_by(login:) if u.nil? logger.error "Failed to find or create user #{login}" else @@ -95,7 +95,7 @@ def register_or_update_via_ldap(login) module Local def authenticate_by_local(login, password) - u = find_by(login: login) # need to get the salt + u = find_by(login:) # need to get the salt u && u.authenticated?(password) ? u : nil end end diff --git a/app/models/uuid.rb b/app/models/uuid.rb index 9289e1223e..573e1d15f3 100644 --- a/app/models/uuid.rb +++ b/app/models/uuid.rb @@ -75,11 +75,11 @@ def object scope :with_resource_type, ->(type) { where(resource_type: type.to_s) } scope :include_resource, -> { includes(:resource) } - scope :with_external_id, ->(external_id) { where(external_id: external_id) } + scope :with_external_id, ->(external_id) { where(external_id:) } scope :with_resource_by_type_and_id, ->(t, id) { where(resource_type: t, resource_id: id) } # Limits the query to resources of the given type if provided. Otherwise returns all - scope :limited_to_resource, ->(resource_type) { resource_type.nil? ? all : where(resource_type: resource_type) } + scope :limited_to_resource, ->(resource_type) { resource_type.nil? ? all : where(resource_type:) } before_validation do |record| record.external_id = Uuid.generate_uuid if record.new_record? && record.external_id.blank? @@ -102,7 +102,7 @@ def self.uuid?(value) end def self.find_uuid_instance!(resource_type, resource_id) - find_by!(resource_type: resource_type, resource_id: resource_id) + find_by!(resource_type:, resource_id:) end # Find the uuid corresponding id and system. @@ -111,7 +111,7 @@ def self.find_uuid_instance!(resource_type, resource_id) # @return [String, nil] the uuid if found. def self.find_uuid(resource_type, resource_id) - find_by(resource_type: resource_type, resource_id: resource_id).try(:external_id) + find_by(resource_type:, resource_id:).try(:external_id) end # Find an Uuid or create it if needed. @@ -121,7 +121,7 @@ def self.find_uuid(resource_type, resource_id) def self.find_uuid!(resource_type, resource_id) return unless resource_id # return nil for nil - find_uuid(resource_type, resource_id) || create!(resource_type: resource_type, resource_id: resource_id).external_id + find_uuid(resource_type, resource_id) || create!(resource_type:, resource_id:).external_id end # Given a list of internal ids, create uuids in bulk @@ -133,7 +133,7 @@ def self.generate_uuids!(resource_type, resource_ids) ids_missing_uuids = filter_uncreated_uuids(resource_type, resource_ids) uuids_to_create = - ids_missing_uuids.map { |id| create!(resource_type: resource_type, resource_id: id, external_id: generate_uuid) } + ids_missing_uuids.map { |id| create!(resource_type:, resource_id: id, external_id: generate_uuid) } # Uuid.import uuids_to_create unless uuids_to_create.empty? @@ -142,7 +142,7 @@ def self.generate_uuids!(resource_type, resource_ids) # ids is a string of internal_ids def self.filter_uncreated_uuids(resource_type, resource_ids) - existing_uuids = where(resource_type: resource_type, resource_id: resource_ids) + existing_uuids = where(resource_type:, resource_id: resource_ids) resource_ids - existing_uuids.pluck(:resource_id) end diff --git a/app/models/well.rb b/app/models/well.rb index 06d5b158cb..f8106b4ad5 100644 --- a/app/models/well.rb +++ b/app/models/well.rb @@ -199,7 +199,7 @@ def subject_type end def outer_request(submission_id) - outer_requests.order(id: :desc).find_by(submission_id: submission_id) + outer_requests.order(id: :desc).find_by(submission_id:) end def qc_results_by_key @@ -287,14 +287,14 @@ def update_gender_markers!(gender_markers, resource) # rubocop:todo Metrics/AbcS events.update_gender_markers!(resource) end - well_attribute.update!(gender_markers: gender_markers) + well_attribute.update!(gender_markers:) end # rubocop:enable Metrics/MethodLength def update_sequenom_count!(sequenom_count, resource) events.update_sequenom_count!(resource) unless well_attribute.sequenom_count == sequenom_count - well_attribute.update!(sequenom_count: sequenom_count) + well_attribute.update!(sequenom_count:) end # The sequenom pass value is either the string 'Unknown' or it is the combination of gender marker values. diff --git a/app/models/work_completion/labware_completion.rb b/app/models/work_completion/labware_completion.rb index afcd491f68..7b60a8ecb7 100644 --- a/app/models/work_completion/labware_completion.rb +++ b/app/models/work_completion/labware_completion.rb @@ -59,7 +59,7 @@ def fire_events seed: work_completion, user: work_completion.user, properties: { - order_id: order_id + order_id: } ) end diff --git a/app/models/work_order/factory.rb b/app/models/work_order/factory.rb index 713d5e1051..adb74da928 100644 --- a/app/models/work_order/factory.rb +++ b/app/models/work_order/factory.rb @@ -22,7 +22,7 @@ def create_work_orders! .group_by(&:asset_id) .map do |_asset_id, requests| state = requests.first.state - WorkOrder.create!(work_order_type: work_order_type, requests: requests, state: state) + WorkOrder.create!(work_order_type:, requests:, state:) end end diff --git a/app/resources/api/v2/plate_purpose_resource.rb b/app/resources/api/v2/plate_purpose_resource.rb index 138e929181..58edb41b51 100644 --- a/app/resources/api/v2/plate_purpose_resource.rb +++ b/app/resources/api/v2/plate_purpose_resource.rb @@ -60,7 +60,7 @@ class PlatePurposeResource < BaseResource # @param name [String] the name of the asset shape # @return [void] def asset_shape=(name) - @model.asset_shape = (AssetShape.find_by!(name: name) if name.present?) || AssetShape.default + @model.asset_shape = (AssetShape.find_by!(name:) if name.present?) || AssetShape.default end # Returns the name of the asset shape of the plate purpose. diff --git a/app/resources/api/v2/tube_rack_resource.rb b/app/resources/api/v2/tube_rack_resource.rb index 72004ae850..c94efcefcb 100644 --- a/app/resources/api/v2/tube_rack_resource.rb +++ b/app/resources/api/v2/tube_rack_resource.rb @@ -68,7 +68,7 @@ def tube_locations=(tube_locations) tube_locations.each do |coordinate, tube| tube_uuid = tube[:uuid] raise "No tube found for UUID '#{tube_uuid}'" unless tubes.key?(tube_uuid) - RackedTube.create(coordinate: coordinate, tube: tubes[tube_uuid], tube_rack: @model) + RackedTube.create(coordinate:, tube: tubes[tube_uuid], tube_rack: @model) end end diff --git a/app/sample_manifest_excel/sample_manifest_excel/download.rb b/app/sample_manifest_excel/sample_manifest_excel/download.rb index 99761de642..c0a75b28b1 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/download.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/download.rb @@ -19,14 +19,14 @@ def initialize(sample_manifest, column_list, range_list) return unless valid? @ranges_worksheet = - SequencescapeExcel::Worksheet::RangesWorksheet.new(ranges: range_list, workbook: workbook, password: password) + SequencescapeExcel::Worksheet::RangesWorksheet.new(ranges: range_list, workbook:, password:) @data_worksheet = Worksheet::DataWorksheet.new( - workbook: workbook, + workbook:, columns: column_list, - sample_manifest: sample_manifest, + sample_manifest:, ranges: range_list, - password: password + password: ) end diff --git a/app/sample_manifest_excel/sample_manifest_excel/test_download.rb b/app/sample_manifest_excel/sample_manifest_excel/test_download.rb index 5fa47cf8c2..b2be15ba03 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/test_download.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/test_download.rb @@ -10,7 +10,7 @@ class TestDownload attr_reader :worksheet def initialize(attributes = {}) - @worksheet = SampleManifestExcel::Worksheet::TestWorksheet.new(attributes.merge(workbook: workbook)) + @worksheet = SampleManifestExcel::Worksheet::TestWorksheet.new(attributes.merge(workbook:)) end end end diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/base.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/base.rb index f9618fc11f..e4c01c8380 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/base.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/base.rb @@ -64,8 +64,8 @@ def derive_sample_manifest return unless start_row.present? && sanger_sample_id_column.present? sanger_sample_id = data.cell(1, sanger_sample_id_column.number) - SampleManifestAsset.find_by(sanger_sample_id: sanger_sample_id)&.sample_manifest || - Sample.find_by(sanger_sample_id: sanger_sample_id)&.sample_manifest + SampleManifestAsset.find_by(sanger_sample_id:)&.sample_manifest || + Sample.find_by(sanger_sample_id:)&.sample_manifest end ## diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb index 797e90c0e8..58bce3f19a 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb @@ -113,10 +113,10 @@ def disable_match_expectation def update_downstream_aliquots substituter = TagSubstitution.new( - substitutions: substitutions, + substitutions:, comment: 'Manifest updated', disable_clash_detection: true, - disable_match_expectation: disable_match_expectation + disable_match_expectation: ) @downstream_aliquots_updated = substituter.save || log_error_and_return_false(substituter.errors.full_messages.join('; ')) diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/processor/tube_rack.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/processor/tube_rack.rb index 88b46feebd..01a8865377 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/processor/tube_rack.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/processor/tube_rack.rb @@ -58,7 +58,7 @@ def retrieve_tube_rack_barcodes_from_manifest # it has been processed before and should not be re-processed def check_if_tube_racks_present @tube_rack_barcodes_from_manifest.each do |barcode| - existing_barcode_record = Barcode.includes(:asset).find_by(barcode: barcode) + existing_barcode_record = Barcode.includes(:asset).find_by(barcode:) return true if !existing_barcode_record.nil? && !existing_barcode_record.asset.nil? end false @@ -180,7 +180,7 @@ def link_tubes_to_racks(rack_barcode_to_tube_rack) tube_rack_barcode = @tube_barcode_to_rack_barcode[tube_barcode] tube_rack = rack_barcode_to_tube_rack[tube_rack_barcode] tube_barcode_to_coordinate = @rack_barcode_to_scan_results[tube_rack_barcode] - RackedTube.create!(tube_rack: tube_rack, tube: tube, coordinate: tube_barcode_to_coordinate[tube_barcode]) + RackedTube.create!(tube_rack:, tube:, coordinate: tube_barcode_to_coordinate[tube_barcode]) end end diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/row.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/row.rb index 75e61c0f3f..2590f44b58 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/row.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/row.rb @@ -106,7 +106,7 @@ def changed? end def update_specialised_fields(tag_group) - specialised_fields.each { |specialised_field| specialised_field.update(tag_group: tag_group) } + specialised_fields.each { |specialised_field| specialised_field.update(tag_group:) } end def update_metadata_fields @@ -179,7 +179,7 @@ def validate_sample private def manifest_asset - @manifest_asset ||= cache.find_by(sanger_sample_id: sanger_sample_id) + @manifest_asset ||= cache.find_by(sanger_sample_id:) end def sanger_sample_id_exists? diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb index 1772a79cb7..4c65c2f855 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb @@ -38,7 +38,7 @@ def data_at(row_num) def create_rows(cache) [].tap do |rows| data.each_with_index do |r, i| - row = Row.new(number: i + data.start_row + 1, data: r, columns: columns, cache: cache) + row = Row.new(number: i + data.start_row + 1, data: r, columns:, cache:) rows << row unless row.empty? end end diff --git a/app/sample_manifest_excel/sample_manifest_excel/worksheet/data_worksheet.rb b/app/sample_manifest_excel/sample_manifest_excel/worksheet/data_worksheet.rb index 8122299ee2..a22e59e8f1 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/worksheet/data_worksheet.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/worksheet/data_worksheet.rb @@ -88,7 +88,7 @@ def create_row(detail) (sample_manifest.invalid_wells&.include?(detail.fetch(:position, nil)) ? [:disabled] : column.style) style = find_or_create_style(style_name)&.reference - row.add_cell column.attribute_value(detail), type: column.type, style: style + row.add_cell column.attribute_value(detail), type: column.type, style: end end end diff --git a/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb b/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb index 42ae1cfbe6..deeb1ae204 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb @@ -87,19 +87,19 @@ def create_sample_manifest # rubocop:todo Metrics/MethodLength when /plate/ FactoryBot.create( :pending_plate_sample_manifest, - num_plates: num_plates, - num_filled_wells_per_plate: num_filled_wells_per_plate, - num_rows_per_well: num_rows_per_well, - study: study + num_plates:, + num_filled_wells_per_plate:, + num_rows_per_well:, + study: ) when /tube_library/, /tube_chromium_library/ - FactoryBot.create(:sample_manifest, asset_type: 'library', study: study) + FactoryBot.create(:sample_manifest, asset_type: 'library', study:) when /tube_multiplexed_library/ - FactoryBot.create(:sample_manifest, asset_type: 'multiplexed_library', study: study) + FactoryBot.create(:sample_manifest, asset_type: 'multiplexed_library', study:) when /tube_rack/ - FactoryBot.create(:tube_rack_manifest, asset_type: 'tube_rack', study: study) + FactoryBot.create(:tube_rack_manifest, asset_type: 'tube_rack', study:) else - FactoryBot.create(:sample_manifest, asset_type: '1dtube', study: study) + FactoryBot.create(:sample_manifest, asset_type: '1dtube', study:) end end @@ -272,7 +272,7 @@ def create_tube_requests assets.each do |asset| FactoryBot.create( :external_multiplexed_library_tube_creation_request, - asset: asset, + asset:, target_asset: multiplexed_library_tube ) end diff --git a/app/sequencescape_excel/sequencescape_excel/column.rb b/app/sequencescape_excel/sequencescape_excel/column.rb index 01306be6bd..201d824b2a 100644 --- a/app/sequencescape_excel/sequencescape_excel/column.rb +++ b/app/sequencescape_excel/sequencescape_excel/column.rb @@ -118,13 +118,13 @@ def updated? # Update the column validation using the passed worksheet and found range. # Update the conditional formatting based on a range and worksheet. def update(first_row, last_row, ranges, worksheet) - self.range = { first_column: number, first_row: first_row, last_row: last_row } + self.range = { first_column: number, first_row:, last_row: } range = ranges.find_by(range_name) || NullRange.new - validation.update(range: range, reference: self.range.reference, worksheet: worksheet) + validation.update(range:, reference: self.range.reference, worksheet:) conditional_formattings.update( - self.range.references.merge(absolute_reference: range.absolute_reference, worksheet: worksheet) + self.range.references.merge(absolute_reference: range.absolute_reference, worksheet:) ) @updated = true diff --git a/app/sequencescape_excel/sequencescape_excel/conditional_formatting_default.rb b/app/sequencescape_excel/sequencescape_excel/conditional_formatting_default.rb index 19f23f2623..c2ebb0e477 100644 --- a/app/sequencescape_excel/sequencescape_excel/conditional_formatting_default.rb +++ b/app/sequencescape_excel/sequencescape_excel/conditional_formatting_default.rb @@ -23,12 +23,12 @@ def expression? def combine(other = nil) (other || {}) - .merge(style: style, options: options) + .merge(style:, options:) .with_indifferent_access .tap do |cf| if expression? cf[:formula] ||= {} - cf[:formula].merge!(type: type) + cf[:formula].merge!(type:) end end end diff --git a/app/sequencescape_excel/sequencescape_excel/formula.rb b/app/sequencescape_excel/sequencescape_excel/formula.rb index d1cd7427da..4cd48ffd15 100644 --- a/app/sequencescape_excel/sequencescape_excel/formula.rb +++ b/app/sequencescape_excel/sequencescape_excel/formula.rb @@ -54,11 +54,11 @@ def to_s def to_h { - type: type, - first_cell_reference: first_cell_reference, - absolute_reference: absolute_reference, - operator: operator, - operand: operand + type:, + first_cell_reference:, + absolute_reference:, + operator:, + operand: } end diff --git a/app/sequencescape_excel/sequencescape_excel/range.rb b/app/sequencescape_excel/sequencescape_excel/range.rb index 41b3adfcf9..46a56ec5ff 100644 --- a/app/sequencescape_excel/sequencescape_excel/range.rb +++ b/app/sequencescape_excel/sequencescape_excel/range.rb @@ -137,10 +137,10 @@ def static? # classes of the module. def references { - first_cell_reference: first_cell_reference, - reference: reference, - fixed_reference: fixed_reference, - absolute_reference: absolute_reference + first_cell_reference:, + reference:, + fixed_reference:, + absolute_reference: } end diff --git a/app/sequencescape_excel/sequencescape_excel/range_list.rb b/app/sequencescape_excel/sequencescape_excel/range_list.rb index 99312e88e9..1f1c7318d8 100644 --- a/app/sequencescape_excel/sequencescape_excel/range_list.rb +++ b/app/sequencescape_excel/sequencescape_excel/range_list.rb @@ -54,7 +54,7 @@ def <=>(other) def create(ranges_data) {}.tap do |ranges| ranges_data.each_with_index do |(name, attributes), i| - attributes = attributes.merge(name: name, first_row: i + 1) + attributes = attributes.merge(name:, first_row: i + 1) ranges[name] = SequencescapeExcel::Range.new(attributes) end end diff --git a/app/sequencescape_excel/sequencescape_excel/specialised_field/chromium_tag_well.rb b/app/sequencescape_excel/sequencescape_excel/specialised_field/chromium_tag_well.rb index 37645c2e4b..e44096aa41 100644 --- a/app/sequencescape_excel/sequencescape_excel/specialised_field/chromium_tag_well.rb +++ b/app/sequencescape_excel/sequencescape_excel/specialised_field/chromium_tag_well.rb @@ -21,7 +21,7 @@ def update(_attributes = {}) if asset.aliquots.one? tags.each { |tag| tag.multitag!(asset) } elsif aliquot_count == TAGS_PER_WELL - tags.zip(aliquots).each { |tag, aliquot| aliquot.assign_attributes(tag: tag) } + tags.zip(aliquots).each { |tag, aliquot| aliquot.assign_attributes(tag:) } else # We should never end up here, as our validation should handle this # However if that fails, something has gone wrong, and we shouldn't proceed diff --git a/app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb b/app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb index bfc58042a3..a754b0d569 100644 --- a/app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb +++ b/app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb @@ -28,7 +28,7 @@ def update(_attributes = {}) raise StandardError, 'Tag aliquot mismatch' unless asset.aliquots.one? # For dual index tags, tag is a i7 oligo and tag2 is a i5 oligo - asset.aliquots.first.update(tag: tag, tag2: tag2) + asset.aliquots.first.update(tag:, tag2:) end def link(other_fields) @@ -64,7 +64,7 @@ def well_index # i7 tag def tag - Tag.find_by(tag_group_id: tag_group_id, map_id: well_index) + Tag.find_by(tag_group_id:, map_id: well_index) end # i5 tag diff --git a/app/sequencescape_excel/sequencescape_excel/specialised_field/volume.rb b/app/sequencescape_excel/sequencescape_excel/specialised_field/volume.rb index 16d7a53712..43cc474b92 100644 --- a/app/sequencescape_excel/sequencescape_excel/specialised_field/volume.rb +++ b/app/sequencescape_excel/sequencescape_excel/specialised_field/volume.rb @@ -19,7 +19,7 @@ def create_qc_record ActiveRecord::Base.transaction do qc_assay = sample_manifest_asset.sample_manifest.find_or_create_qc_assay! asset.qc_results.build( - qc_assay: qc_assay, + qc_assay:, key: 'volume', value: value.to_f, assay_type: 'customer_supplied', diff --git a/app/sequencescape_excel/sequencescape_excel/validation.rb b/app/sequencescape_excel/sequencescape_excel/validation.rb index ad0b7e0843..b49375bde6 100644 --- a/app/sequencescape_excel/sequencescape_excel/validation.rb +++ b/app/sequencescape_excel/sequencescape_excel/validation.rb @@ -85,7 +85,7 @@ def reference_start end def sanitized_options - options.merge(formula1: formula1) + options.merge(formula1:) end end end diff --git a/app/sequencescape_excel/sequencescape_excel/worksheet/base.rb b/app/sequencescape_excel/sequencescape_excel/worksheet/base.rb index 0a8944b244..bc6f52b799 100644 --- a/app/sequencescape_excel/sequencescape_excel/worksheet/base.rb +++ b/app/sequencescape_excel/sequencescape_excel/worksheet/base.rb @@ -22,7 +22,7 @@ def initialize(attributes = {}) # Adds row to a worksheet with particular value, style and type for each cell def add_row(values = [], style = nil, types = nil) - axlsx_worksheet.add_row values, types: types || ([:string] * values.length), style: style + axlsx_worksheet.add_row values, types: types || ([:string] * values.length), style: end # Adds n empty rows @@ -50,7 +50,7 @@ def protect # Adds axlsx worksheet to a workbook, to a particular place. def insert_axlsx_worksheet(name, index = 0) - @axlsx_worksheet ||= workbook.insert_worksheet(index, name: name) # rubocop:disable Naming/MemoizedInstanceVariableName + @axlsx_worksheet ||= workbook.insert_worksheet(index, name:) # rubocop:disable Naming/MemoizedInstanceVariableName end # Creates a worksheet, empty one in this case diff --git a/app/uat_actions/uat_actions.rb b/app/uat_actions/uat_actions.rb index 07a3e587a9..e35a68821e 100644 --- a/app/uat_actions/uat_actions.rb +++ b/app/uat_actions/uat_actions.rb @@ -97,7 +97,7 @@ def form_field(attribute, type, options = {}) @form_fields ||= [] attr_accessor attribute - @form_fields << UatActions::FormField.new(options.merge(attribute: attribute, type: type)) + @form_fields << UatActions::FormField.new(options.merge(attribute:, type:)) end def form_fields diff --git a/app/uat_actions/uat_actions/generate_plate_concentrations.rb b/app/uat_actions/uat_actions/generate_plate_concentrations.rb index 10e138b9a5..918fe0772e 100644 --- a/app/uat_actions/uat_actions/generate_plate_concentrations.rb +++ b/app/uat_actions/uat_actions/generate_plate_concentrations.rb @@ -103,16 +103,16 @@ def construct_qc_assay QcResult.create!( asset: well, - key: key, + key:, value: create_random_concentration, units: conc_units, assay_type: 'UAT_Testing', assay_version: 'Binning', - qc_assay: qc_assay + qc_assay: ) num_wells_written += 1 end qc_assay_success = qc_assay.save - { qc_assay_success: qc_assay_success, num_wells_written: num_wells_written } + { qc_assay_success:, num_wells_written: } end end diff --git a/app/uat_actions/uat_actions/generate_plates.rb b/app/uat_actions/uat_actions/generate_plates.rb index 96ddd1329a..bde35373ab 100644 --- a/app/uat_actions/uat_actions/generate_plates.rb +++ b/app/uat_actions/uat_actions/generate_plates.rb @@ -144,9 +144,9 @@ def save_sample(sample, well, sample_index) sample.save!(validate: false) if num_samples_per_well > 1 - well.aliquots.create!(sample: sample, study: study, tag_depth: sample_index) + well.aliquots.create!(sample:, study:, tag_depth: sample_index) else - well.aliquots.create!(sample: sample, study: study) + well.aliquots.create!(sample:, study:) end end diff --git a/app/uat_actions/uat_actions/generate_primer_panel.rb b/app/uat_actions/uat_actions/generate_primer_panel.rb index b2539ac3d8..4cf95921f4 100644 --- a/app/uat_actions/uat_actions/generate_primer_panel.rb +++ b/app/uat_actions/uat_actions/generate_primer_panel.rb @@ -66,13 +66,13 @@ def perform # Any helper methods def existing_primer_panel - @existing_primer_panel ||= PrimerPanel.find_by(name: name) + @existing_primer_panel ||= PrimerPanel.find_by(name:) end def primer_panel_params { - name: name, - snp_count: snp_count, + name:, + snp_count:, programs: { 'pcr 1' => { 'name' => pcr_1_name, diff --git a/app/uat_actions/uat_actions/generate_project.rb b/app/uat_actions/uat_actions/generate_project.rb index 6bdd0565be..b601f23182 100644 --- a/app/uat_actions/uat_actions/generate_project.rb +++ b/app/uat_actions/uat_actions/generate_project.rb @@ -26,7 +26,7 @@ def create_project approved: true, state: 'active', project_metadata_attributes: { - project_cost_code: project_cost_code, + project_cost_code:, project_funding_model: 'Internal' } ).find_or_create_by!(name: project_name) diff --git a/app/uat_actions/uat_actions/generate_qc_results.rb b/app/uat_actions/uat_actions/generate_qc_results.rb index 9499ec8db2..a5041e2028 100644 --- a/app/uat_actions/uat_actions/generate_qc_results.rb +++ b/app/uat_actions/uat_actions/generate_qc_results.rb @@ -114,7 +114,7 @@ def construct_qc_assay units: resolved_units, assay_type: 'UAT_Testing', assay_version: 'Binning', - qc_assay: qc_assay + qc_assay: ) end report['number_results_written'] = qc_assay.qc_results.length diff --git a/app/uat_actions/uat_actions/generate_sample_manifest.rb b/app/uat_actions/uat_actions/generate_sample_manifest.rb index d28ed4020f..eadb26db0c 100644 --- a/app/uat_actions/uat_actions/generate_sample_manifest.rb +++ b/app/uat_actions/uat_actions/generate_sample_manifest.rb @@ -60,7 +60,7 @@ def perform end def create_sample_manifest - SampleManifest.create!(study: study, supplier: supplier, asset_type: asset_type, count: count, purpose: purpose) + SampleManifest.create!(study:, supplier:, asset_type:, count:, purpose:) end def generate_manifest(sample_manifest) @@ -73,7 +73,7 @@ def create_samples(sample_manifest) raise 'Manifest for plates is not supported yet' unless asset_type == '1dtube' create_sample("Sample_#{asset.human_barcode}_1", sample_manifest).tap do |sample| - asset.aliquots.create!(sample: sample, study: study) + asset.aliquots.create!(sample:, study:) study.samples << sample end end @@ -117,7 +117,7 @@ def create_sample(sample_name, sample_manifest) donor_id: "#{sample_name}_donor", sample_common_name: 'human' }, - sample_manifest: sample_manifest + sample_manifest: ) end diff --git a/app/uat_actions/uat_actions/generate_tag_group.rb b/app/uat_actions/uat_actions/generate_tag_group.rb index 8c0f0d206a..b884b9bc36 100644 --- a/app/uat_actions/uat_actions/generate_tag_group.rb +++ b/app/uat_actions/uat_actions/generate_tag_group.rb @@ -70,13 +70,13 @@ def perform end def create_tag_group(name, adapter_type) - tag_group = TagGroup.create!(name: name, adapter_type_id: adapter_type&.id) + tag_group = TagGroup.create!(name:, adapter_type_id: adapter_type&.id) tag_group.tags.build( OligoEnumerator .new(size.to_i, tag_sequence_offset.to_i) .each_with_index - .map { |oligo, map_id| { oligo: oligo, map_id: map_id + 1 } } + .map { |oligo, map_id| { oligo:, map_id: map_id + 1 } } ) tag_group.save end @@ -90,7 +90,7 @@ def existing_tags # Any helper methods def existing_tag_group - @tag_group ||= TagGroup.find_by(name: name) + @tag_group ||= TagGroup.find_by(name:) end # diff --git a/app/uat_actions/uat_actions/generate_tag_layout_template.rb b/app/uat_actions/uat_actions/generate_tag_layout_template.rb index bf5559666d..318039a2c1 100644 --- a/app/uat_actions/uat_actions/generate_tag_layout_template.rb +++ b/app/uat_actions/uat_actions/generate_tag_layout_template.rb @@ -54,10 +54,10 @@ def perform walk_algorithm = walking_by_algorithm.presence || 'TagLayout::WalkWellsOfPlate' tlt_parameters = { - name: name, + name:, tag_group_id: tag_group.id, tag2_group_id: tag2_group&.id, - direction_algorithm: direction_algorithm, + direction_algorithm:, walking_algorithm: walk_algorithm } @@ -72,7 +72,7 @@ def user end def existing_tag_layout_template - @existing_tag_layout_template ||= TagLayoutTemplate.find_by(name: name) + @existing_tag_layout_template ||= TagLayoutTemplate.find_by(name:) end def tag_group diff --git a/app/uat_actions/uat_actions/generate_tag_plates.rb b/app/uat_actions/uat_actions/generate_tag_plates.rb index 51efe3c91d..4442a8a02d 100644 --- a/app/uat_actions/uat_actions/generate_tag_plates.rb +++ b/app/uat_actions/uat_actions/generate_tag_plates.rb @@ -36,7 +36,7 @@ def self.default end def perform - qcc = QcableCreator.create!(lot: lot, user: user, count: plate_count.to_i) + qcc = QcableCreator.create!(lot:, user:, count: plate_count.to_i) qcc.qcables.each_with_index do |qcable, index| qcable.update!(state: 'available') report["tag_plate_#{index}"] = qcable.asset.machine_barcode @@ -54,7 +54,7 @@ def lot lot_type.lots.create!( lot_number: "UAT#{Time.current.to_f}", template: tag_layout_template, - user: user, + user:, received_at: Time.current ) end diff --git a/app/uat_actions/uat_actions/generate_tagged_plates.rb b/app/uat_actions/uat_actions/generate_tagged_plates.rb index 790f587fdc..e38784ca50 100644 --- a/app/uat_actions/uat_actions/generate_tagged_plates.rb +++ b/app/uat_actions/uat_actions/generate_tagged_plates.rb @@ -72,12 +72,12 @@ def self.default def perform super do |plate| TagLayout.create!( - user: user, - plate: plate, - direction: direction, - walking_by: walking_by, - tag_group: tag_group, - tag2_group: tag2_group + user:, + plate:, + direction:, + walking_by:, + tag_group:, + tag2_group: ) end end diff --git a/app/uat_actions/uat_actions/generate_tube_racks.rb b/app/uat_actions/uat_actions/generate_tube_racks.rb index 7f8a8842d8..31e6518b46 100644 --- a/app/uat_actions/uat_actions/generate_tube_racks.rb +++ b/app/uat_actions/uat_actions/generate_tube_racks.rb @@ -28,7 +28,7 @@ def perform # rubocop:todo Metrics/AbcSize, Metrics/MethodLength purpose = Purpose.find_by(name: 'TR Stock 96') rack_count.to_i.times do |i| TubeRack - .create!(size: 96, purpose: purpose) + .create!(size: 96, purpose:) .tap do |rack| Barcode.create!( asset: rack, @@ -58,7 +58,7 @@ def construct_tubes(rack) supplier_name: sample_name } ), - study: study + study: ) racked_tube = RackedTube.create!(tube_rack_id: rack.id, tube_id: tube.id, coordinate: i) diff --git a/app/uat_actions/uat_actions/generate_tubes.rb b/app/uat_actions/uat_actions/generate_tubes.rb index b5bc0e4ce6..6f8ee82d88 100644 --- a/app/uat_actions/uat_actions/generate_tubes.rb +++ b/app/uat_actions/uat_actions/generate_tubes.rb @@ -49,7 +49,7 @@ def perform supplier_name: sample_name } ), - study: study + study: ) add_foreign_barcode_if_selected(tube) diff --git a/app/uat_actions/uat_actions/static_records.rb b/app/uat_actions/uat_actions/static_records.rb index a5a4f63e62..514c820c62 100644 --- a/app/uat_actions/uat_actions/static_records.rb +++ b/app/uat_actions/uat_actions/static_records.rb @@ -26,14 +26,14 @@ def self.study state: 'active', study_metadata_attributes: { data_access_group: 'dag', - study_type: study_type, - faculty_sponsor: faculty_sponsor, - data_release_study_type: data_release_study_type, + study_type:, + faculty_sponsor:, + data_release_study_type:, study_description: 'A study generated for UAT', contaminated_human_dna: 'No', contains_human_dna: 'No', commercially_available: 'No', - program: program + program: } ).find_or_create_by!(name: 'UAT Study') end @@ -53,7 +53,7 @@ def self.project project_metadata_attributes: { project_cost_code: 'FAKE1', project_funding_model: 'Internal', - budget_division: budget_division + budget_division: } ).find_or_create_by!(name: 'UAT Project') end diff --git a/app/uat_actions/uat_actions/test_submission.rb b/app/uat_actions/uat_actions/test_submission.rb index 0aafe6fbe6..11b5d6b55f 100644 --- a/app/uat_actions/uat_actions/test_submission.rb +++ b/app/uat_actions/uat_actions/test_submission.rb @@ -122,10 +122,10 @@ def self.compatible_submission_templates def perform # rubocop:todo Metrics/AbcSize order = submission_template.create_with_submission!( - study: study, - project: project, - user: user, - assets: assets, + study:, + project:, + user:, + assets:, request_options: order_request_options ) report['plate_barcode_0'] = labware.human_barcode diff --git a/app/uat_actions/uat_actions/tube_submission.rb b/app/uat_actions/uat_actions/tube_submission.rb index 35e7e506c9..cacecda507 100644 --- a/app/uat_actions/uat_actions/tube_submission.rb +++ b/app/uat_actions/uat_actions/tube_submission.rb @@ -60,10 +60,10 @@ def self.compatible_submission_templates def perform order = submission_template.create_with_submission!( - study: study, - project: project, - user: user, - assets: assets, + study:, + project:, + user:, + assets:, request_options: order_request_options ) fill_report(order) diff --git a/config/initializers/api_routing.rb b/config/initializers/api_routing.rb index 26c900b4d5..124889b59e 100644 --- a/config/initializers/api_routing.rb +++ b/config/initializers/api_routing.rb @@ -17,7 +17,7 @@ def model(*entities, &block) entities.push({ only: exposed_actions, name_prefix: 'api_' }.merge(options)) original_block = block - block = !block_given? ? original_block : ->(r) { r.with_options(read_only: read_only, &original_block) } + block = !block_given? ? original_block : ->(r) { r.with_options(read_only:, &original_block) } resources(*entities, &block) end end diff --git a/db/migrate/20180328130539_populate_existing_purposes_with_prefix_data.rb b/db/migrate/20180328130539_populate_existing_purposes_with_prefix_data.rb index 30fa59a4ee..770fc54875 100644 --- a/db/migrate/20180328130539_populate_existing_purposes_with_prefix_data.rb +++ b/db/migrate/20180328130539_populate_existing_purposes_with_prefix_data.rb @@ -50,7 +50,7 @@ def up Purpose .where(target_type: asset_class) .find_each do |purpose| - purpose.barcode_prefix_id = BarcodePrefix.find_by(prefix: prefix).id + purpose.barcode_prefix_id = BarcodePrefix.find_by(prefix:).id purpose.save! end end diff --git a/db/migrate/20180329080953_remove_redundant_plate_classes.rb b/db/migrate/20180329080953_remove_redundant_plate_classes.rb index b8cdc493f8..e1fcececb8 100644 --- a/db/migrate/20180329080953_remove_redundant_plate_classes.rb +++ b/db/migrate/20180329080953_remove_redundant_plate_classes.rb @@ -35,7 +35,7 @@ def down Purpose .where(target_type: new_type) .joins('LEFT JOIN barcode_prefixes ON barcode_prefixes.id = plate_purposes.barcode_prefix_id') - .where(barcode_prefixes: { prefix: prefix }) + .where(barcode_prefixes: { prefix: }) .find_each do |purpose| purpose.target_type = original purpose.save diff --git a/db/migrate/20180420144414_migrate_sanger_barcodes_to_new_tables.rb b/db/migrate/20180420144414_migrate_sanger_barcodes_to_new_tables.rb index b8f4647492..76be18f564 100644 --- a/db/migrate/20180420144414_migrate_sanger_barcodes_to_new_tables.rb +++ b/db/migrate/20180420144414_migrate_sanger_barcodes_to_new_tables.rb @@ -18,8 +18,8 @@ def up # rubocop:disable Metrics/AbcSize barcodes_hash = barcodes.map do |asset_id, number, prefix_id| { - asset_id: asset_id, - barcode: SBCF::SangerBarcode.new(number: number, prefix: @prefixes[prefix_id]).human_barcode, + asset_id:, + barcode: SBCF::SangerBarcode.new(number:, prefix: @prefixes[prefix_id]).human_barcode, format: 0 } end diff --git a/db/migrate/20180420151252_migrate_other_barcodes_to_new_tables.rb b/db/migrate/20180420151252_migrate_other_barcodes_to_new_tables.rb index efc891f356..f723fc470e 100644 --- a/db/migrate/20180420151252_migrate_other_barcodes_to_new_tables.rb +++ b/db/migrate/20180420151252_migrate_other_barcodes_to_new_tables.rb @@ -14,7 +14,7 @@ def up # rubocop:disable Metrics/AbcSize barcodes = batch.pluck(:plate_id, :infinium_barcode) say "From #{barcodes.first.first} to #{barcodes.last.first}" say 'Building hashes' - barcodes_hash = barcodes.map { |asset_id, barcode| { asset_id: asset_id, barcode: barcode, format: 1 } } + barcodes_hash = barcodes.map { |asset_id, barcode| { asset_id:, barcode:, format: 1 } } say 'Importing' Barcode.import(barcodes_hash) say 'Imported' @@ -29,7 +29,7 @@ def up # rubocop:disable Metrics/AbcSize barcodes = batch.pluck(:plate_id, :fluidigm_barcode) say "From #{barcodes.first.first} to #{barcodes.last.first}" say 'Building hashes' - barcodes_hash = barcodes.map { |asset_id, barcode| { asset_id: asset_id, barcode: barcode, format: 2 } } + barcodes_hash = barcodes.map { |asset_id, barcode| { asset_id:, barcode:, format: 2 } } say 'Importing' Barcode.import(barcodes_hash) say 'Imported' diff --git a/db/migrate/20190522123113_migrate_plate_type_to_new_column.rb b/db/migrate/20190522123113_migrate_plate_type_to_new_column.rb index 2d5369599f..1db2be9ee6 100644 --- a/db/migrate/20190522123113_migrate_plate_type_to_new_column.rb +++ b/db/migrate/20190522123113_migrate_plate_type_to_new_column.rb @@ -31,7 +31,7 @@ def up .find_each do |asset| labware_type_id = LabwareType.id_for(asset.labware_type) say "Updating #{asset.id} => #{asset.labware_type} (#{labware_type_id})" - asset.update(labware_type_id: labware_type_id) + asset.update(labware_type_id:) end end end diff --git a/db/migrate/20190620094528_migrate_legacy_pipeline_classes.rb b/db/migrate/20190620094528_migrate_legacy_pipeline_classes.rb index 50b6d75348..d934f19d9c 100644 --- a/db/migrate/20190620094528_migrate_legacy_pipeline_classes.rb +++ b/db/migrate/20190620094528_migrate_legacy_pipeline_classes.rb @@ -30,10 +30,10 @@ def down ['Strip Tube Creation', 'StripTubeCreationPipeline'], ['HiSeq X PE (spiked in controls) from strip-tubes', 'UnrepeatableSequencingPipeline'] ].each do |name, sti_type| - pipeline = Pipeline.find_by(name: name) + pipeline = Pipeline.find_by(name:) next if pipeline.nil? - pipeline.update!(sti_type: sti_type) + pipeline.update!(sti_type:) end end end diff --git a/db/migrate/20211214094820_migrate_removed_pipelines_to_legacy_class.rb b/db/migrate/20211214094820_migrate_removed_pipelines_to_legacy_class.rb index 1600c56a4c..cff90c0429 100644 --- a/db/migrate/20211214094820_migrate_removed_pipelines_to_legacy_class.rb +++ b/db/migrate/20211214094820_migrate_removed_pipelines_to_legacy_class.rb @@ -32,10 +32,10 @@ def down %w[Genotyping GenotypingPipeline], ['Cherrypicking for Pulldown', 'CherrypickForPulldownPipeline'] ].each do |name, sti_type| - pipeline = Pipeline.find_by(name: name) + pipeline = Pipeline.find_by(name:) next if pipeline.nil? - pipeline.update!(sti_type: sti_type) + pipeline.update!(sti_type:) end end end diff --git a/db/migrate/20220428085815_remove_flexible_cherrypick_pipeline.rb b/db/migrate/20220428085815_remove_flexible_cherrypick_pipeline.rb index 30365a9b26..b03778f3c8 100644 --- a/db/migrate/20220428085815_remove_flexible_cherrypick_pipeline.rb +++ b/db/migrate/20220428085815_remove_flexible_cherrypick_pipeline.rb @@ -12,10 +12,10 @@ def down # The following code makes assumptions about names, and mimic the production # state when the migration was written. [['Flexible Cherrypick', 'FlexibleCherrypickPipeline']].each do |name, sti_type| - pipeline = Pipeline.find_by(name: name) + pipeline = Pipeline.find_by(name:) next if pipeline.nil? - pipeline.update!(sti_type: sti_type, active: true) + pipeline.update!(sti_type:, active: true) end end end diff --git a/db/migrate/20230512102847_add_missing_insdc_countries.rb b/db/migrate/20230512102847_add_missing_insdc_countries.rb index 8d2f6ae50b..9ac73c02ad 100644 --- a/db/migrate/20230512102847_add_missing_insdc_countries.rb +++ b/db/migrate/20230512102847_add_missing_insdc_countries.rb @@ -12,6 +12,6 @@ def change 'missing: data agreement established pre-2023', 'missing: endangered species', 'missing: human-identifiable' - ].each { |name| Insdc::Country.find_or_create_by(name: name, sort_priority: -2, validation_state: 0) } + ].each { |name| Insdc::Country.find_or_create_by(name:, sort_priority: -2, validation_state: 0) } end end diff --git a/db/seeds/0001_tube_purposes.rb b/db/seeds/0001_tube_purposes.rb index cd647fc583..4fd87963e0 100644 --- a/db/seeds/0001_tube_purposes.rb +++ b/db/seeds/0001_tube_purposes.rb @@ -11,6 +11,6 @@ 'Stock library' => %w[Tube::Purpose StockLibraryTube], 'Legacy MX tube' => %w[IlluminaHtp::MxTubePurpose MultiplexedLibraryTube] }.each do |name, (type, asset_type)| - type.constantize.create!(name: name, barcode_printer_type: barcode_printer_type, target_type: asset_type) + type.constantize.create!(name:, barcode_printer_type:, target_type: asset_type) end end diff --git a/db/seeds/0001_workflows.rb b/db/seeds/0001_workflows.rb index df7018adff..fc092c1522 100644 --- a/db/seeds/0001_workflows.rb +++ b/db/seeds/0001_workflows.rb @@ -31,7 +31,7 @@ REQUEST_INFORMATION_TYPES = RequestInformationType.all.index_by { |t| t.key }.freeze def create_request_information_types(pipeline, *keys) PipelineRequestInformationType.create!( - keys.map { |k| { pipeline: pipeline, request_information_type: REQUEST_INFORMATION_TYPES[k] } } + keys.map { |k| { pipeline:, request_information_type: REQUEST_INFORMATION_TYPES[k] } } ) end @@ -175,20 +175,20 @@ def create_request_information_types(pipeline, *keys) per_item: false, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(key: 'read_length') ) PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(key: 'library_type') ) PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -235,13 +235,13 @@ def create_request_information_types(pipeline, *keys) per_item: false, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -288,13 +288,13 @@ def create_request_information_types(pipeline, *keys) per_item: false, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -368,13 +368,13 @@ def create_request_information_types(pipeline, *keys) per_item: false, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -424,13 +424,13 @@ def create_request_information_types(pipeline, *keys) per_item: false, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -540,13 +540,13 @@ def create_request_information_types(pipeline, *keys) per_item: true, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -585,7 +585,7 @@ def create_request_information_types(pipeline, *keys) per_item: true, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap { |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') } @@ -634,13 +634,13 @@ def create_request_information_types(pipeline, *keys) per_item: true, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -689,13 +689,13 @@ def create_request_information_types(pipeline, *keys) per_item: true, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -741,13 +741,13 @@ def create_request_information_types(pipeline, *keys) per_item: true, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -792,13 +792,13 @@ def create_request_information_types(pipeline, *keys) per_item: false, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -838,13 +838,13 @@ def create_request_information_types(pipeline, *keys) per_item: true, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -911,13 +911,13 @@ def create_request_information_types(pipeline, *keys) per_item: true, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline: pipeline, + pipeline:, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -941,7 +941,7 @@ def create_request_information_types(pipeline, *keys) [ { class: PlateTemplateTask, name: 'Select Plate Template', sorted: 1, batched: true, lab_activity: true }, { class: CherrypickTask, name: 'Approve Plate Layout', sorted: 2, batched: true, lab_activity: true } - ].each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + ].each { |details| details.delete(:class).create!(details.merge(workflow:)) } end end @@ -1006,9 +1006,9 @@ def create_request_information_types(pipeline, *keys) workflow.item_limit = 1 end .tap do |workflow| - t1 = SetDescriptorsTask.create!(name: 'Specify Dilution Volume', sorted: 0, workflow: workflow) + t1 = SetDescriptorsTask.create!(name: 'Specify Dilution Volume', sorted: 0, workflow:) Descriptor.create!(kind: 'Text', sorter: 1, name: 'Concentration', task: t1) - t2 = SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 0, workflow: workflow) + t2 = SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 0, workflow:) Descriptor.create!(kind: 'Text', sorter: 1, name: 'Chip barcode', task: t2) Descriptor.create!(kind: 'Text', sorter: 2, name: 'Cartridge barcode', task: t2) Descriptor.create!(kind: 'Text', sorter: 4, name: 'Machine name', task: t2) @@ -1232,7 +1232,7 @@ def create_request_information_types(pipeline, *keys) lab_activity: true } ].select { |task| type == '(spiked in controls)' || task[:name] != 'Add Spiked in Control' } - .each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + .each { |details| details.delete(:class).create!(details.merge(workflow:)) } end pipeline.request_types = v4_requests_types_pe end @@ -1275,7 +1275,7 @@ def create_request_information_types(pipeline, *keys) lab_activity: true } ].select { |task| type == '(spiked in controls)' || task[:name] != 'Add Spiked in Control' } - .each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + .each { |details| details.delete(:class).create!(details.merge(workflow:)) } end pipeline.request_types = v4_requests_types_se end @@ -1326,7 +1326,7 @@ def create_request_information_types(pipeline, *keys) lab_activity: true } ].select { |task| type == '(spiked in controls)' || task[:name] != 'Add Spiked in Control' } - .each { |details| details.delete(:class).create!(details.merge(workflow: workflow)) } + .each { |details| details.delete(:class).create!(details.merge(workflow:)) } end pipeline.request_types = x10_requests_types end @@ -1364,8 +1364,8 @@ def create_request_information_types(pipeline, *keys) end def build_4000_tasks_for(workflow, paired_only = false) # rubocop:todo Metrics/MethodLength - AddSpikedInControlTask.create!(name: 'Add Spiked in control', sorted: 0, workflow: workflow) - SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 1, workflow: workflow) do |task| + AddSpikedInControlTask.create!(name: 'Add Spiked in control', sorted: 0, workflow:) + SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 1, workflow:) do |task| task.descriptors.build( [ { kind: 'Text', sorter: 1, name: 'Chip Barcode', required: true }, @@ -1379,7 +1379,7 @@ def build_4000_tasks_for(workflow, paired_only = false) # rubocop:todo Metrics/M ) end - SetDescriptorsTask.create!(name: 'Read 1 Lin/block/hyb/load', sorted: 2, workflow: workflow) do |task| + SetDescriptorsTask.create!(name: 'Read 1 Lin/block/hyb/load', sorted: 2, workflow:) do |task| task.descriptors.build( [ { kind: 'Text', sorter: 1, name: 'Chip Barcode', required: true }, @@ -1400,7 +1400,7 @@ def build_4000_tasks_for(workflow, paired_only = false) # rubocop:todo Metrics/M ) end - SetDescriptorsTask.create!(name: 'Read 2 Lin/block/hyb/load', sorted: 2, workflow: workflow) do |task| + SetDescriptorsTask.create!(name: 'Read 2 Lin/block/hyb/load', sorted: 2, workflow:) do |task| if paired_only task.descriptors.build( [ @@ -1479,7 +1479,7 @@ def add_4000_information_types_to(pipeline) if read_lengths.present? RequestType::Validator.create!( - request_type: request_type, + request_type:, request_option: 'read_length', valid_options: read_lengths ) diff --git a/db/seeds/0010_budget_division.rb b/db/seeds/0010_budget_division.rb index 3d0a1c3bdc..932143a57b 100644 --- a/db/seeds/0010_budget_division.rb +++ b/db/seeds/0010_budget_division.rb @@ -2,4 +2,4 @@ budget_divisions = ['Unallocated', 'Pathogen (including malaria)', 'Human variation'] -budget_divisions.each { |name| BudgetDivision.create!(name: name) } +budget_divisions.each { |name| BudgetDivision.create!(name:) } diff --git a/db/seeds/0013_reference_genome.rb b/db/seeds/0013_reference_genome.rb index baf13c1588..b0fec099ef 100644 --- a/db/seeds/0013_reference_genome.rb +++ b/db/seeds/0013_reference_genome.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -['', 'Not suitable for alignment'].each { |name| ReferenceGenome.create!(name: name) } +['', 'Not suitable for alignment'].each { |name| ReferenceGenome.create!(name:) } diff --git a/db/seeds/0015_tags.rb b/db/seeds/0015_tags.rb index 7f6822ddb7..14eb659d01 100644 --- a/db/seeds/0015_tags.rb +++ b/db/seeds/0015_tags.rb @@ -551,6 +551,6 @@ tag_options = tags.flat_map do |tag_group_name, tags_in_group| tag_group_id = groups[tag_group_name] - tags_in_group.map { |m, o| { map_id: m, oligo: o, tag_group_id: tag_group_id } } + tags_in_group.map { |m, o| { map_id: m, oligo: o, tag_group_id: } } end Tag.import(tag_options) diff --git a/db/seeds/0016_tag_layout_templates.rb b/db/seeds/0016_tag_layout_templates.rb index bc4c58ffac..a1a2337959 100644 --- a/db/seeds/0016_tag_layout_templates.rb +++ b/db/seeds/0016_tag_layout_templates.rb @@ -5,25 +5,25 @@ TagGroup.find_each do |tag_group| TagLayoutTemplate.create!( name: "#{tag_group.name} in column major order", - tag_group: tag_group, + tag_group:, direction_algorithm: 'TagLayout::InColumns', walking_algorithm: 'TagLayout::WalkWellsByPools' ) TagLayoutTemplate.create!( name: "#{tag_group.name} in row major order", - tag_group: tag_group, + tag_group:, direction_algorithm: 'TagLayout::InRows', walking_algorithm: 'TagLayout::WalkWellsByPools' ) TagLayoutTemplate.create!( name: "#{tag_group.name} in inverted column major order", - tag_group: tag_group, + tag_group:, direction_algorithm: 'TagLayout::InInverseColumns', walking_algorithm: 'TagLayout::WalkWellsByPools' ) TagLayoutTemplate.create!( name: "#{tag_group.name} in inverted row major order", - tag_group: tag_group, + tag_group:, direction_algorithm: 'TagLayout::InInverseRows', walking_algorithm: 'TagLayout::WalkWellsByPools' ) @@ -58,12 +58,12 @@ 'TruSeq small RNA index tags - 6 mer tags', 'TruSeq mRNA Adapter Index Sequences' ].each do |name| - next if TagGroup.find_by(name: name).nil? + next if TagGroup.find_by(name:).nil? TagLayoutTemplate.create!( name: "Illumina C - #{name}", walking_algorithm: 'TagLayout::WalkWellsOfPlate', - tag_group: TagGroup.find_by(name: name), + tag_group: TagGroup.find_by(name:), direction_algorithm: 'TagLayout::InColumns' ) end diff --git a/db/seeds/0017_bait_libraries.rb b/db/seeds/0017_bait_libraries.rb index a9d76e8b7d..752f9a0893 100644 --- a/db/seeds/0017_bait_libraries.rb +++ b/db/seeds/0017_bait_libraries.rb @@ -3,7 +3,7 @@ # Generate a few bait libraries. { 'Standard' => 'standard', 'Custom - Pipeline' => 'custom', 'Custom - Customer' => 'custom' }.each do |name, category| - BaitLibraryType.create!(name: name, category: category) + BaitLibraryType.create!(name:, category:) end BaitLibrary::Supplier diff --git a/db/seeds/0019_plate_creators.rb b/db/seeds/0019_plate_creators.rb index 2a0541d2f6..a109b32346 100644 --- a/db/seeds/0019_plate_creators.rb +++ b/db/seeds/0019_plate_creators.rb @@ -42,8 +42,8 @@ # Additional plate purposes required ['Pico dilution', 'Working dilution'].each do |name| - plate_purpose = PlatePurpose.find_by!(name: name) - Plate::Creator.create!(name: name, plate_purposes: [plate_purpose]) + plate_purpose = PlatePurpose.find_by!(name:) + Plate::Creator.create!(name:, plate_purposes: [plate_purpose]) end plate_purpose = PlatePurpose.find_by!(name: 'Pre-Extracted Plate') @@ -64,7 +64,7 @@ # Valid options: Dilution Factors: [['Working dilution', [12.5, 20.0, 15.0, 50.0]], ['Pico dilution', [4.0]]].each do |name, values| - c = Plate::Creator.find_by!(name: name) + c = Plate::Creator.find_by!(name:) c.update!(valid_options: { valid_dilution_factors: values }) end Plate::Creator.find_each do |c| diff --git a/db/seeds/3000_library_types_setup.rb b/db/seeds/3000_library_types_setup.rb index ded537a208..d308724714 100644 --- a/db/seeds/3000_library_types_setup.rb +++ b/db/seeds/3000_library_types_setup.rb @@ -154,7 +154,7 @@ def self.existing_defaults_for(request_type) 'Pre-quality controlled', 'DSN_RNAseq', 'RNA-seq dUTP' - ].map { |name| { name: name } } + ].map { |name| { name: } } ) RequestType.find_each do |request_type| @@ -165,13 +165,13 @@ def self.existing_defaults_for(request_type) if library_types.present? library_types.each do |library_type| LibraryTypesRequestType.create!( - request_type: request_type, - library_type: library_type, + request_type:, + library_type:, is_default: library_type.name == SetupLibraryTypes.existing_defaults_for(request_type) ) end RequestType::Validator.create!( - request_type: request_type, + request_type:, request_option: 'library_type', valid_options: RequestType::Validator::LibraryTypeValidator.new(request_type.id) ) @@ -199,7 +199,7 @@ def self.existing_defaults_for(request_type) if read_lengths.present? RequestType::Validator.create!( - request_type: request_type, + request_type:, request_option: 'read_length', valid_options: read_lengths ) @@ -228,23 +228,23 @@ def self.existing_defaults_for(request_type) 'Nextera single index pre quality controlled', 'Nextera dual index pre quality controlled', 'Bisulphate pre quality controlled' - ].map { |name| { name: name } } + ].map { |name| { name: } } ) %i[illumina_c_multiplexed_library_creation illumina_c_library_creation].each do |request_class_symbol| request_type = RequestType.find_by!(key: request_class_symbol.to_s) library_types.each do |library_type| - LibraryTypesRequestType.create!(request_type: request_type, library_type: library_type, is_default: false) + LibraryTypesRequestType.create!(request_type:, library_type:, is_default: false) end end libs_ribozero = - ['Ribozero RNA-seq (Bacterial)', 'Ribozero RNA-seq (HMR)'].map { |name| LibraryType.find_or_create_by!(name: name) } + ['Ribozero RNA-seq (Bacterial)', 'Ribozero RNA-seq (HMR)'].map { |name| LibraryType.find_or_create_by!(name:) } libs_ribozero.each do |lib| %i[illumina_c_pcr illumina_c_pcr_no_pool].each do |request_class_symbol| request_type = RequestType.find_by(key: request_class_symbol.to_s) - LibraryTypesRequestType.create!(request_type: request_type, library_type: lib, is_default: false) + LibraryTypesRequestType.create!(request_type:, library_type: lib, is_default: false) end end diff --git a/db/seeds/9999_tag_qc_setup.rb b/db/seeds/9999_tag_qc_setup.rb index db25d5e2e0..583f6a87f5 100644 --- a/db/seeds/9999_tag_qc_setup.rb +++ b/db/seeds/9999_tag_qc_setup.rb @@ -48,9 +48,9 @@ workflow.item_limit = 1 end .tap do |workflow| - t1 = SetDescriptorsTask.create!(name: 'Specify Dilution Volume', sorted: 0, workflow: workflow) + t1 = SetDescriptorsTask.create!(name: 'Specify Dilution Volume', sorted: 0, workflow:) Descriptor.create!(kind: 'Text', sorter: 1, name: 'Concentration', task: t1) - t2 = SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 0, workflow: workflow) + t2 = SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 0, workflow:) Descriptor.create!(kind: 'Text', sorter: 1, name: 'Chip barcode', task: t2) Descriptor.create!(kind: 'Text', sorter: 2, name: 'Cartridge barcode', task: t2) Descriptor.create!(kind: 'Text', sorter: 4, name: 'Machine name', task: t2) diff --git a/features/support/accession_service.rb b/features/support/accession_service.rb index 086b6f2f20..b60b7f6786 100644 --- a/features/support/accession_service.rb +++ b/features/support/accession_service.rb @@ -38,7 +38,7 @@ def self.install_hooks(target, tags) # rubocop:todo Metrics/AbcSize .to_return do |_request| response = FakeAccessionService.instance.next! status = response.nil? ? 500 : 200 - { headers: { 'Content-Type' => 'text/xml' }, body: response, status: status } + { headers: { 'Content-Type' => 'text/xml' }, body: response, status: } end end end diff --git a/features/support/barcode_service.rb b/features/support/barcode_service.rb index aa830d262b..3d3bef0e23 100644 --- a/features/support/barcode_service.rb +++ b/features/support/barcode_service.rb @@ -30,7 +30,7 @@ def clear end def barcode(barcode, format = nil) - barcodes.push({ barcode: barcode, format: format }) + barcodes.push({ barcode:, format: }) end def next_barcode! @@ -64,7 +64,7 @@ def mock_child_barcodes(parent_barcode, count) end WebMock .stub_request(:post, "#{plate_barcode_url}/child-barcodes/#{configatron.plate_barcode_prefix}/new") - .with(body: { barcode: parent_barcode, count: count }) + .with(body: { barcode: parent_barcode, count: }) .to_return do { headers: { diff --git a/features/support/capybara.rb b/features/support/capybara.rb index 2379940c1d..37d246acd6 100644 --- a/features/support/capybara.rb +++ b/features/support/capybara.rb @@ -15,14 +15,14 @@ options.add_argument('--headless=old') options.add_argument('--disable-gpu') options.add_argument('--disable-search-engine-choice-screen') - Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) + Capybara::Selenium::Driver.new(app, browser: :chrome, options:) end Capybara.register_driver :chrome do |app| options = Selenium::WebDriver::Chrome::Options.new options.add_preference('download.default_directory', DownloadHelpers::PATH.to_s) - Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) + Capybara::Selenium::Driver.new(app, browser: :chrome, options:) end Capybara.default_max_wait_time = 10 diff --git a/features/support/parameter_types.rb b/features/support/parameter_types.rb index a5755c89a2..7bfb0d9f72 100644 --- a/features/support/parameter_types.rb +++ b/features/support/parameter_types.rb @@ -14,14 +14,14 @@ name: 'plate_name', regexp: /the plate "([^"]+)"/, type: Plate, - transformer: ->(name) { Plate.find_by!(name: name) } + transformer: ->(name) { Plate.find_by!(name:) } ) ParameterType( name: 'asset_name', regexp: /the (plate|tube|sample tube|labware) "([^"]+)"/, type: Asset, - transformer: ->(_, name) { Labware.find_by!(name: name) } + transformer: ->(_, name) { Labware.find_by!(name:) } ) ParameterType( @@ -42,7 +42,7 @@ name: 'submitted_to', regexp: /submitted to "([^"]+)"/, type: SubmissionTemplate, - transformer: ->(name) { SubmissionTemplate.find_by!(name: name) } + transformer: ->(name) { SubmissionTemplate.find_by!(name:) } ) ParameterType( @@ -64,7 +64,7 @@ name: 'tag_layout_template', regexp: /tag layout template "([^"]+)"/, type: TagLayoutTemplate, - transformer: ->(name) { TagLayoutTemplate.find_by!(name: name) } + transformer: ->(name) { TagLayoutTemplate.find_by!(name:) } ) ParameterType( @@ -78,7 +78,7 @@ name: 'study_name', regexp: /the study "([^"]+)"/, type: Study, - transformer: ->(name) { Study.find_by!(name: name) } + transformer: ->(name) { Study.find_by!(name:) } ) ParameterType( @@ -115,5 +115,5 @@ name: 'asset_group', regexp: /the asset group "([^"]+)"/, type: AssetGroup, - transformer: ->(name) { AssetGroup.find_by!(name: name) } + transformer: ->(name) { AssetGroup.find_by!(name:) } ) diff --git a/features/support/paths.rb b/features/support/paths.rb index e77c5f2bb2..6cdd938d6d 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -4,7 +4,7 @@ module NavigationHelpers # Finds the specified page for the given model with the specified name. def page_for_model(model, page, name) - object = model.find_by!(name: name) + object = model.find_by!(name:) routing_method = "#{model.name.underscore}_path" routing_method = "#{page}_#{routing_method}" unless page == 'show' send(routing_method.to_sym, object) @@ -106,7 +106,7 @@ def path_to(page_name) # rubocop:todo Metrics/AbcSize study_reports_path when /the profile page for "([^"]+)"/ login = $1 - user = User.find_by!(login: login) + user = User.find_by!(login:) profile_path(user) when /the plate purpose homepage/ admin_plate_purposes_path diff --git a/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb b/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb index c8e663a79f..cee9022934 100644 --- a/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb +++ b/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb @@ -6,12 +6,12 @@ library_tube = FactoryBot.create :empty_library_tube request_type = RequestType.find_by(name: 'Illumina-B Paired end sequencing') request = - FactoryBot.create :request, + FactoryBot.create(:request, asset: library_tube, target_asset: lane, state: 'pending', - project: project, - request_type: request_type + project:, + request_type:) project.update!(enforce_quotas: true) end diff --git a/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb b/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb index 593a57b44a..17a3d02fa0 100644 --- a/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb +++ b/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb @@ -8,9 +8,9 @@ FactoryBot.create( :request, id: request_id, - study: study, - project: project, - request_type: request_type, + study:, + project:, + request_type:, asset: FactoryBot.create(:sample_tube) ) end diff --git a/features/support/step_definitions/11803383_bug_NPG_batch_state_released_steps.rb b/features/support/step_definitions/11803383_bug_NPG_batch_state_released_steps.rb index a91894fffd..3696395990 100644 --- a/features/support/step_definitions/11803383_bug_NPG_batch_state_released_steps.rb +++ b/features/support/step_definitions/11803383_bug_NPG_batch_state_released_steps.rb @@ -11,8 +11,8 @@ request_type: pipeline.request_types.last, state: 'started' - batch = FactoryBot.create :batch, state: 'started', qc_state: 'qc_manual', pipeline: pipeline - FactoryBot.create :batch_request, request: request, batch: batch, position: 1 + batch = FactoryBot.create(:batch, state: 'started', qc_state: 'qc_manual', pipeline:) + FactoryBot.create :batch_request, request:, batch:, position: 1 end When /^I (POST|PUT) following XML to pass QC state on the last asset:$/ do |action, xml| diff --git a/features/support/step_definitions/269135815_add_bait_library_editor_to_admin_view.rb b/features/support/step_definitions/269135815_add_bait_library_editor_to_admin_view.rb index ed41263014..ff322fbda0 100644 --- a/features/support/step_definitions/269135815_add_bait_library_editor_to_admin_view.rb +++ b/features/support/step_definitions/269135815_add_bait_library_editor_to_admin_view.rb @@ -14,7 +14,7 @@ Given /^I have a bait library called "([^"]*)"$/ do |name| BaitLibrary.create!( - name: name, + name:, bait_library_type: BaitLibraryType.find_by(visible: true), bait_library_supplier: BaitLibrary::Supplier.find_by(visible: true), target_species: 'Dragon' @@ -22,28 +22,28 @@ end Then /^the supplier_identifier for "([^"]*)" should be nil$/ do |name| - assert BaitLibrary.find_by(name: name).supplier_identifier.nil? + assert BaitLibrary.find_by(name:).supplier_identifier.nil? end Given /^I have a bait library type called "([^"]*)"$/ do |name| - BaitLibraryType.create!(name: name, category: 'standard') + BaitLibraryType.create!(name:, category: 'standard') end Given /^I have a supplier called "([^"]*)"$/ do |name| - BaitLibrary::Supplier.create!(name: name) + BaitLibrary::Supplier.create!(name:) end Then /^the "([^"]*)" called "([^"]*)" should exist$/ do |class_name, name| - matching = class_name.constantize.find_by(name: name) + matching = class_name.constantize.find_by(name:) assert matching end Given /^the last bait library has type "([^"]*)"$/ do |name| - BaitLibrary.last.update(bait_library_type: BaitLibraryType.create!(name: name, category: 'standard')) + BaitLibrary.last.update(bait_library_type: BaitLibraryType.create!(name:, category: 'standard')) end Given /^the last bait library has supplier "([^"]*)"$/ do |name| - BaitLibrary.last.update(bait_library_supplier: BaitLibrary::Supplier.create!(name: name)) + BaitLibrary.last.update(bait_library_supplier: BaitLibrary::Supplier.create!(name:)) end Given /^the last bait library is hidden$/ do diff --git a/features/support/step_definitions/35177179_updating_released_samples_steps.rb b/features/support/step_definitions/35177179_updating_released_samples_steps.rb index 6b71b20e6b..1a372ae3ca 100644 --- a/features/support/step_definitions/35177179_updating_released_samples_steps.rb +++ b/features/support/step_definitions/35177179_updating_released_samples_steps.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true Given /^the sample name "([^"]*)" has previously been released$/ do |name| - Sample.find_by(name: name).release + Sample.find_by(name:).release end When /^ignoring "([^"]+)" the XML submission for the sample "([^"]*)" should be:$/ do |key_regexp, name, serialized_xml| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find sample with name #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find sample with name #{name.inspect}" accession_service = sample.accession_service accessionable_sample = Accessionable::Sample.new(sample) submission = Accessionable::Submission.new(accession_service, User.find_by(login: 'me'), accessionable_sample) diff --git a/features/support/step_definitions/3550676_search_functionality_steps.rb b/features/support/step_definitions/3550676_search_functionality_steps.rb index b70bdaef65..a164931617 100644 --- a/features/support/step_definitions/3550676_search_functionality_steps.rb +++ b/features/support/step_definitions/3550676_search_functionality_steps.rb @@ -4,7 +4,7 @@ sample = Sample.find_by(name: sample_name) or raise StandardError, "Could not find a sample named '#{sample_name}'" FactoryBot .create(:empty_sample_tube, name: sample_tube_name) - .tap { |sample_tube| sample_tube.aliquots.create!(sample: sample) } + .tap { |sample_tube| sample_tube.aliquots.create!(sample:) } end Then /^the search results I should see are:$/ do |table| diff --git a/features/support/step_definitions/3871492_links_from_study_workflow_view_steps.rb b/features/support/step_definitions/3871492_links_from_study_workflow_view_steps.rb index 499b61141e..3cc83bf7f5 100644 --- a/features/support/step_definitions/3871492_links_from_study_workflow_view_steps.rb +++ b/features/support/step_definitions/3871492_links_from_study_workflow_view_steps.rb @@ -3,7 +3,7 @@ Given /^study "([^"]+)" has a registered sample "([^"]+)"$/ do |study_name, sample_name| study = Study.find_by!(name: study_name) sample = study.samples.create!(name: sample_name) - st = SampleTube.create!.tap { |sample_tube| sample_tube.aliquots.create!(sample: sample, study: study) } + st = SampleTube.create!.tap { |sample_tube| sample_tube.aliquots.create!(sample:, study:) } - FactoryHelp.submission(study: study, assets: [st], state: 'ready') + FactoryHelp.submission(study:, assets: [st], state: 'ready') end diff --git a/features/support/step_definitions/3958121_sample_update_filters_properties_steps.rb b/features/support/step_definitions/3958121_sample_update_filters_properties_steps.rb index b51dfb7796..7b692e26f7 100644 --- a/features/support/step_definitions/3958121_sample_update_filters_properties_steps.rb +++ b/features/support/step_definitions/3958121_sample_update_filters_properties_steps.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Given /^I am the owner of sample "([^"]+)"$/ do |name| - sample = Sample.find_by!(name: name) + sample = Sample.find_by!(name:) @current_user.grant_owner(sample) end diff --git a/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb b/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb index 1958f2a060..5cec2259fc 100644 --- a/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb +++ b/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb @@ -8,11 +8,11 @@ def create_request(request_type, study, project, asset, target_asset, additional FactoryBot.create( :request_with_submission, additional_options.merge( - study: study, - project: project, - asset: asset, - target_asset: target_asset, - request_type: request_type + study:, + project:, + asset:, + target_asset:, + request_type: ) ) request.id = additional_options[:id] if additional_options.key?(:id) # Force ID hack! @@ -97,7 +97,7 @@ def create_request(request_type, study, project, asset, target_asset, additional tube_name = "#{group_name}, sample tube #{i}" FactoryBot.create(:sample_tube, name: tube_name, sample_attributes: { name: sample_name }) end - FactoryBot.create(:asset_group, name: group_name, study: study, assets: assets.map(&:receptacle)) + FactoryBot.create(:asset_group, name: group_name, study:, assets: assets.map(&:receptacle)) end Then /^I should see the following request information:$/ do |expected| diff --git a/features/support/step_definitions/4759010_bug_on_reset_batches_steps.rb b/features/support/step_definitions/4759010_bug_on_reset_batches_steps.rb index cb72340e4e..e73b8547b4 100644 --- a/features/support/step_definitions/4759010_bug_on_reset_batches_steps.rb +++ b/features/support/step_definitions/4759010_bug_on_reset_batches_steps.rb @@ -8,12 +8,12 @@ Given /^a batch in "Illumina-B MX Library Preparation" has been setup for feature 4759010$/ do pipeline = Pipeline.find_by(name: 'Illumina-B MX Library Preparation') or raise StandardError, "Cannot find pipeline 'Illumina-B MX Library Preparation'" - batch = FactoryBot.create :batch, pipeline: pipeline, state: 'pending' + batch = FactoryBot.create :batch, pipeline:, state: 'pending' asset_group = FactoryBot.create(:asset_group) submission = FactoryHelp.submission( - asset_group: asset_group, + asset_group:, request_options: { read_length: 76, fragment_size_required_from: 1, diff --git a/features/support/step_definitions/5070230_requesting_additional_hiseq_sequencing_steps.rb b/features/support/step_definitions/5070230_requesting_additional_hiseq_sequencing_steps.rb index 7b8c94b853..cb152739ff 100644 --- a/features/support/step_definitions/5070230_requesting_additional_hiseq_sequencing_steps.rb +++ b/features/support/step_definitions/5070230_requesting_additional_hiseq_sequencing_steps.rb @@ -3,9 +3,9 @@ Given 'I have already made a request for library tube {string} within {study_name}' do |library_tube_name, study| library_tube = LibraryTube.find_by!(name: library_tube_name) library_type = LibraryType.find_by(name: 'Standard') || FactoryBot.create(:library_type, name: 'Standard') - FactoryBot.create(:library_creation_request_type, :with_library_types, library_type: library_type).create!( + FactoryBot.create(:library_creation_request_type, :with_library_types, library_type:).create!( asset: library_tube, - study: study, + study:, request_metadata_attributes: { fragment_size_required_from: 111, fragment_size_required_to: 222, diff --git a/features/support/step_definitions/5158172_gel_hide_blank_wells_steps.rb b/features/support/step_definitions/5158172_gel_hide_blank_wells_steps.rb index 9f3ee65df0..cdfdfccf17 100644 --- a/features/support/step_definitions/5158172_gel_hide_blank_wells_steps.rb +++ b/features/support/step_definitions/5158172_gel_hide_blank_wells_steps.rb @@ -18,7 +18,7 @@ # This may be forcing the name of the sample so we cannot check validation here. sample = Sample.new(name: sample_name) sample.save(validate: false) - well.aliquots.create!(sample: sample) + well.aliquots.create!(sample:) end Given /^well "([^"]*)" on plate "([^"]*)" has an empty supplier sample name$/ do |well_position, plate_barcode| diff --git a/features/support/step_definitions/5197615_external_release_flag_steps.rb b/features/support/step_definitions/5197615_external_release_flag_steps.rb index 5b0da6baf5..4f1503ad48 100644 --- a/features/support/step_definitions/5197615_external_release_flag_steps.rb +++ b/features/support/step_definitions/5197615_external_release_flag_steps.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true Given /^an unreleasable lane named "([^"]*)" exists$/ do |name| - FactoryBot.create(:lane, name: name, external_release: false) + FactoryBot.create(:lane, name:, external_release: false) end Given /^a releasable lane named "([^"]*)" exists$/ do |name| - FactoryBot.create(:lane, name: name, external_release: true) + FactoryBot.create(:lane, name:, external_release: true) end diff --git a/features/support/step_definitions/5393882_spiked_in_control_steps.rb b/features/support/step_definitions/5393882_spiked_in_control_steps.rb index 39bc795ae2..70fabf2eb6 100644 --- a/features/support/step_definitions/5393882_spiked_in_control_steps.rb +++ b/features/support/step_definitions/5393882_spiked_in_control_steps.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Given /^I have a hybridization spiked buffer called "([^"]+)"$/ do |name| - buffer = FactoryBot.create(:spiked_buffer, name: name) + buffer = FactoryBot.create(:spiked_buffer, name:) buffer.parents << FactoryBot.create(:phi_x_stock_tube, name: 'indexed phiX') end @@ -17,6 +17,6 @@ end Then /^(.+) asset (?:called|named) "([^"]+)"(.*)$/ do |pre, name, post| - asset = Labware.find_by(name: name) or raise StandardError, "Cannot find asset #{name.inspect}" + asset = Labware.find_by(name:) or raise StandardError, "Cannot find asset #{name.inspect}" step "#{pre} asset \"#{asset.id}\"#{post}" end diff --git a/features/support/step_definitions/5397680_sequenome_plate_details_steps.rb b/features/support/step_definitions/5397680_sequenome_plate_details_steps.rb index 6a71a1c27b..ea0bd53f95 100644 --- a/features/support/step_definitions/5397680_sequenome_plate_details_steps.rb +++ b/features/support/step_definitions/5397680_sequenome_plate_details_steps.rb @@ -10,7 +10,7 @@ sample = FactoryBot.create :sample_with_gender, name: "#{plate_barcode}_x" - 1.upto(number_of_wells.to_i) { |i| new_plate.wells.create!(map_id: i).aliquots.create!(sample: sample) } + 1.upto(number_of_wells.to_i) { |i| new_plate.wells.create!(map_id: i).aliquots.create!(sample:) } end Given(/^plate "([^"]*)" has (\d+) blank samples$/) do |plate_barcode, number_of_blanks| @@ -22,7 +22,7 @@ well.aliquots.clear well.aliquots.create!( sample: Sample.create!(name: "#{plate_barcode}_#{index}", empty_supplier_sample_name: true), - study: study + study: ) end end diff --git a/features/support/step_definitions/5781572_external_data_release_interactions_steps.rb b/features/support/step_definitions/5781572_external_data_release_interactions_steps.rb index 91547d10d1..88d306a599 100644 --- a/features/support/step_definitions/5781572_external_data_release_interactions_steps.rb +++ b/features/support/step_definitions/5781572_external_data_release_interactions_steps.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true Given /^a state "([^"]*)" to lane named "([^"]*)"$/ do |status, name| - FactoryBot.create(:lane, name: name, qc_state: status) + FactoryBot.create(:lane, name:, qc_state: status) end Given /^an unreleasable lane named "([^"]*)"$/ do |name| - lane = Lane.joins(:labware).find_by(labware: { name: name }) + lane = Lane.joins(:labware).find_by(labware: { name: }) lane.external_release = false lane.save end Given /^an releasable lane named "([^"]*)"$/ do |name| - lane = Lane.joins(:labware).find_by(labware: { name: name }) + lane = Lane.joins(:labware).find_by(labware: { name: }) lane.external_release = true lane.save end diff --git a/features/support/step_definitions/6040471_truncate_sample_name_barcode_steps.rb b/features/support/step_definitions/6040471_truncate_sample_name_barcode_steps.rb index 08b8f059fc..5306109ce2 100644 --- a/features/support/step_definitions/6040471_truncate_sample_name_barcode_steps.rb +++ b/features/support/step_definitions/6040471_truncate_sample_name_barcode_steps.rb @@ -39,5 +39,5 @@ Given /^the asset "([^"]*)" has a sanger_sample_id of "([^"]*)"$/ do |asset_id, sanger_sample_id| asset = Labware.find(asset_id).receptacle asset.aliquots.clear - asset.aliquots.create!(sample: Sample.create!(name: 'Sample_123456', sanger_sample_id: sanger_sample_id)) + asset.aliquots.create!(sample: Sample.create!(name: 'Sample_123456', sanger_sample_id:)) end diff --git a/features/support/step_definitions/6218053_display_concentration_inbox_pipeline_steps.rb b/features/support/step_definitions/6218053_display_concentration_inbox_pipeline_steps.rb index d6192a9ad4..a2cd1b41e0 100644 --- a/features/support/step_definitions/6218053_display_concentration_inbox_pipeline_steps.rb +++ b/features/support/step_definitions/6218053_display_concentration_inbox_pipeline_steps.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true Given /^Pipeline "([^"]*)" and a setup for 6218053$/ do |name| - pipeline = Pipeline.find_by(name: name) or raise StandardError, "Cannot find pipeline '#{name}'" + pipeline = Pipeline.find_by(name:) or raise StandardError, "Cannot find pipeline '#{name}'" asset_type = pipeline_name_to_asset_type(name) request_type = pipeline.request_types.detect { |rt| !rt.deprecated } metadata = FactoryBot.create :"request_metadata_for_#{request_type.key}" request = FactoryBot.create :request_with_submission, - request_type: request_type, + request_type:, asset: FactoryBot.create(asset_type), request_metadata: metadata request.asset.save! diff --git a/features/support/step_definitions/641709_create_duplicate_SE_pipeline_with_no_controls_steps.rb b/features/support/step_definitions/641709_create_duplicate_SE_pipeline_with_no_controls_steps.rb index bf6b88c5a2..5979ff4eb5 100644 --- a/features/support/step_definitions/641709_create_duplicate_SE_pipeline_with_no_controls_steps.rb +++ b/features/support/step_definitions/641709_create_duplicate_SE_pipeline_with_no_controls_steps.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Given /^Pipeline "([^"]*)" and a setup for 641709$/ do |name| - pipeline = Pipeline.find_by(name: name) or raise StandardError, "Cannot find pipeline '#{name}'" + pipeline = Pipeline.find_by(name:) or raise StandardError, "Cannot find pipeline '#{name}'" pipeline.workflow.item_limit.times { step("I have a request for \"#{name}\"") } end diff --git a/features/support/step_definitions/65192392_tag_qc_steps.rb b/features/support/step_definitions/65192392_tag_qc_steps.rb index b4dc423899..7c50c5999e 100644 --- a/features/support/step_definitions/65192392_tag_qc_steps.rb +++ b/features/support/step_definitions/65192392_tag_qc_steps.rb @@ -2,7 +2,7 @@ Given /^I have a lot type for testing called "(.*?)"$/ do |name| LotType.create!( - name: name, + name:, target_purpose: QcablePlatePurpose.find_by(name: 'Tag Plate'), template_class: 'TagLayoutTemplate' ) @@ -10,14 +10,14 @@ Given /^I have a reporter lot type for testing called "(.*?)"$/ do |name| LotType.create!( - name: name, + name:, target_purpose: QcablePlatePurpose.find_by(name: 'Reporter Plate'), template_class: 'PlateTemplate' ) end Given /^the UUID for the lot type "(.*?)" is "(.*?)"$/ do |name, uuid| - set_uuid_for(LotType.find_by(name: name), uuid) + set_uuid_for(LotType.find_by(name:), uuid) end Given /^the lot exists with the attributes:$/ do |table| @@ -33,20 +33,20 @@ end Given /^the UUID for the lot with lot number "(.*?)" is "(.*?)"$/ do |lot_number, uuid| - set_uuid_for(Lot.find_by(lot_number: lot_number), uuid) + set_uuid_for(Lot.find_by(lot_number:), uuid) end Given /^lot "(.*?)" has (\d+) created qcables$/ do |lot_number, qcable_count| - lot = Lot.find_by(lot_number: lot_number) - QcableCreator.create!(lot: lot, user: User.last, count: qcable_count.to_i) + lot = Lot.find_by(lot_number:) + QcableCreator.create!(lot:, user: User.last, count: qcable_count.to_i) end Then /^the qcables in lot "(.*?)" should be "(.*?)"$/ do |lot_number, target_state| - Lot.find_by(lot_number: lot_number).qcables.each { |qcable| assert_equal target_state, qcable.state } + Lot.find_by(lot_number:).qcables.each { |qcable| assert_equal target_state, qcable.state } end Given /^all qcables in lot "(.*?)" are "(.*?)"$/ do |lot_number, state| - Lot.find_by(lot_number: lot_number).qcables.each { |qcable| qcable.update!(state: state) } + Lot.find_by(lot_number:).qcables.each { |qcable| qcable.update!(state:) } end Given /^I am set up for testing qcable ordering$/ do @@ -54,19 +54,19 @@ user = User.last 9.times { |pos| step "the Baracoda barcode service returns \"SQPD-100000#{pos + 1}\"" } step 'a robot exists' - qccreate = QcableCreator.create!(lot: lot, user: user, count: 6) + qccreate = QcableCreator.create!(lot:, user:, count: 6) step 'all of this is happening at exactly "23-Oct-2010 23:00:00+01:00"' sqc_a = Stamp::StampQcable.new(bed: '1', order: 1, qcable: qccreate.qcables[0]) sqc_b = Stamp::StampQcable.new(bed: '2', order: 2, qcable: qccreate.qcables[4]) - stamp_a = Stamp.create!(user: user, tip_lot: '1234556', stamp_qcables: [sqc_a, sqc_b], lot: lot, robot: Robot.last) + stamp_a = Stamp.create!(user:, tip_lot: '1234556', stamp_qcables: [sqc_a, sqc_b], lot:, robot: Robot.last) step 'all of this is happening at exactly "23-Oct-2010 23:20:00+01:00"' sqc_c = Stamp::StampQcable.new(bed: '5', order: 1, qcable: qccreate.qcables[3]) sqc_d = Stamp::StampQcable.new(bed: '3', order: 2, qcable: qccreate.qcables[2]) - stamp_b = Stamp.create!(user: user, tip_lot: '1234556', stamp_qcables: [sqc_c, sqc_d], lot: lot, robot: Robot.last) + stamp_b = Stamp.create!(user:, tip_lot: '1234556', stamp_qcables: [sqc_c, sqc_d], lot:, robot: Robot.last) end Given /^I have a qcable$/ do @@ -74,7 +74,7 @@ user = User.last step 'the UUID of the next plate created will be "55555555-6666-7777-8888-000000000004"' step 'the Baracoda barcode service returns "SQPD-1000001"' - QcableCreator.create!(lot: lot, user: user, count: 1) + QcableCreator.create!(lot:, user:, count: 1) end Given /^I have two qcables$/ do @@ -82,11 +82,11 @@ user = User.last step 'the Baracoda barcode service returns "SQPD-1000001"' step 'the Baracoda barcode service returns "SQPD-1000002"' - QcableCreator.create!(lot: lot, user: user, count: 2) + QcableCreator.create!(lot:, user:, count: 2) end Given /^I have a robot for testing called "(.*?)"$/ do |name| - Robot.create!(name: name, location: 'Somewhere', barcode: 123) do |robot| + Robot.create!(name:, location: 'Somewhere', barcode: 123) do |robot| robot.robot_properties.build( [ { name: 'Max Number of plates', key: 'max_plates', value: '3' }, @@ -104,15 +104,15 @@ user = User.last step 'the Baracoda barcode service returns "SQPD-1000001"' step 'the Baracoda barcode service returns "SQPD-1000002"' - qca = QcableCreator.create!(lot: lot, user: user, count: 1) - qcb = QcableCreator.create!(lot: lot_b, user: user, count: 1) + qca = QcableCreator.create!(lot:, user:, count: 1) + qcb = QcableCreator.create!(lot: lot_b, user:, count: 1) tag_plate = qca.qcables.first.asset reporter_plate = qcb.qcables.first.asset tag_plate.update!(plate_purpose: PlatePurpose.find_by(name: 'Tag PCR')) Transfer::BetweenPlates.create!( - user: user, + user:, source: reporter_plate, destination: tag_plate, transfers: { @@ -120,7 +120,7 @@ } ) stc = - SpecificTubeCreation.create!(parent: tag_plate, child_purposes: [Tube::Purpose.find_by(name: 'Tag MX')], user: user) + SpecificTubeCreation.create!(parent: tag_plate, child_purposes: [Tube::Purpose.find_by(name: 'Tag MX')], user:) batch = Batch .new(pipeline: Pipeline.find_by(name: 'MiSeq sequencing')) @@ -128,7 +128,7 @@ batch.id = 12_345 batch.save! end - FactoryBot.create :request_without_submission, asset: stc.children.first, batch: batch + FactoryBot.create :request_without_submission, asset: stc.children.first, batch: # Batch.find(12345).batch_requests.create!(:request=>Request.create!(:asset=>stc.children.first),:position=>1) end Given /^the library is testing a reporter$/ do diff --git a/features/support/step_definitions/6679401_batch_request_recycling_broken_steps.rb b/features/support/step_definitions/6679401_batch_request_recycling_broken_steps.rb index 3ab8138ca3..a73887c64a 100644 --- a/features/support/step_definitions/6679401_batch_request_recycling_broken_steps.rb +++ b/features/support/step_definitions/6679401_batch_request_recycling_broken_steps.rb @@ -9,7 +9,7 @@ .create!(name: group_name) .tap do |asset_group| asset_group.assets << (1..count.to_i).map do |index| - FactoryBot.create(:well, plate: plate, map: Map.map_96wells[index - 1]) + FactoryBot.create(:well, plate:, map: Map.map_96wells[index - 1]) end end end @@ -29,7 +29,7 @@ end Given /^the plate template "([^"]+)" exists$/ do |name| - FactoryBot.create(:plate_template, name: name) + FactoryBot.create(:plate_template, name:) end # This is a complete hack to get this to work: it knows where the wells are and goes to get them. It knows @@ -51,7 +51,7 @@ ######################################################################################################### # rubocop:todo Metrics/MethodLength def build_batch_for(name, count) # rubocop:todo Metrics/AbcSize - pipeline = Pipeline.find_by(name: name) or raise StandardError, "Cannot find pipeline #{name.inspect}" + pipeline = Pipeline.find_by(name:) or raise StandardError, "Cannot find pipeline #{name.inspect}" submission_details = yield(pipeline) user = FactoryBot.create(:user) @@ -73,9 +73,9 @@ def build_batch_for(name, count) # rubocop:todo Metrics/AbcSize :linear_submission, study: FactoryBot.create(:study), project: FactoryBot.create(:project), - user: user, + user:, # Setup the assets so that they have samples and they are scanned into the correct lab. - assets: assets, + assets:, request_types: [rt_id], # Request parameter options request_options: submission_details[:request_options] @@ -91,12 +91,12 @@ def build_batch_for(name, count) # rubocop:todo Metrics/AbcSize raise StandardError, "Pipeline has #{requests.size} requests waiting rather than #{count}" end - batch = Batch.create!(pipeline: pipeline, user: user, requests: requests) + batch = Batch.create!(pipeline:, user:, requests:) end # rubocop:enable Metrics/MethodLength def requests_for_pipeline(name, count) - pipeline = Pipeline.find_by(name: name) or raise StandardError, "Cannot find pipeline #{name.inspect}" + pipeline = Pipeline.find_by(name:) or raise StandardError, "Cannot find pipeline #{name.inspect}" requests_in_inbox = pipeline.requests.ready_in_storage.full_inbox.all # There should be requests in the inbox and they should be clones of original requests. diff --git a/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb b/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb index 920df971a4..374b5b986e 100644 --- a/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb +++ b/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb @@ -39,7 +39,7 @@ plate = FactoryBot.create :plate, barcode: plate_barcode well_details.hashes.each do |well_detail| well = - Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate: plate) + Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate:) well.well_attribute.update!( concentration: well_detail[:measured_concentration], measured_volume: well_detail[:measured_volume] diff --git a/features/support/step_definitions/aliquot_steps.rb b/features/support/step_definitions/aliquot_steps.rb index 85b52fafc4..fa61b0523d 100644 --- a/features/support/step_definitions/aliquot_steps.rb +++ b/features/support/step_definitions/aliquot_steps.rb @@ -21,7 +21,7 @@ def assert_equal_aliquots(expected, received) end Given /^the aliquots in the library tube called "([^"]+)" have been modified$/ do |name| - tube = LibraryTube.find_by(name: name) or raise "Can't find library tube named #{name.inspect}" + tube = LibraryTube.find_by(name:) or raise "Can't find library tube named #{name.inspect}" tube.aliquots.each do |a| a.updated_at = Time.zone.now a.save(validate: false) diff --git a/features/support/step_definitions/api_steps.rb b/features/support/step_definitions/api_steps.rb index 94254d3454..11c997ce8b 100644 --- a/features/support/step_definitions/api_steps.rb +++ b/features/support/step_definitions/api_steps.rb @@ -64,7 +64,7 @@ def assert_json_equal(expected, received, &block) end Given /^the WTSI single sign-on service recognises "([^"]+)" as "([^"]+)"$/ do |key, login| - User.find_or_create_by(login: login).update!(api_key: key) + User.find_or_create_by(login:).update!(api_key: key) end Given /^the WTSI single sign-on service does not recognise "([^"]+)"$/ do |cookie| @@ -119,7 +119,7 @@ def api_request(action, path, body) # rubocop:todo Metrics/AbcSize end Given /^I have a "(.*?)" authorised user with the key "(.*?)"$/ do |permission, key| - ApiApplication.new(name: 'test_api', key: key, privilege: permission, contact: 'none').save(validate: false) + ApiApplication.new(name: 'test_api', key:, privilege: permission, contact: 'none').save(validate: false) end When /^I retrieve the JSON for all (studies|samples|requests)$/ do |model| @@ -127,18 +127,18 @@ def api_request(action, path, body) # rubocop:todo Metrics/AbcSize end When /^I retrieve the JSON for all requests related to the (sample|library) tube "([^"]+)"$/ do |tube_type, name| - tube = "#{tube_type}_tube".classify.constantize.find_by(name: name) or + tube = "#{tube_type}_tube".classify.constantize.find_by(name:) or raise StandardError, "Cannot find #{tube_type} tube called #{name.inspect}" visit(url_for(controller: 'api/requests', action: 'index', "#{tube_type}_tube_id": tube.id, format: :json)) end When /^I retrieve the JSON for the (sample|study) "([^"]+)"$/ do |model, name| - object = model.classify.constantize.find_by(name: name) or raise "Cannot find #{model} #{name.inspect}" + object = model.classify.constantize.find_by(name:) or raise "Cannot find #{model} #{name.inspect}" visit(url_for(controller: "api/#{model.pluralize}", action: 'show', id: object, format: :json)) end When /^I retrieve the JSON for the last request in the study "([^"]+)"$/ do |name| - study = Study.find_by(name: name) or raise StandardError, "Cannot find the study #{name.inspect}" + study = Study.find_by(name:) or raise StandardError, "Cannot find the study #{name.inspect}" raise StandardError, "It appears there are no requests for study #{name.inspect}" if study.requests.empty? visit(url_for(controller: 'api/requests', action: 'show', id: study.requests.last, format: :json)) @@ -283,11 +283,11 @@ def decode_json(json, source) end Given /^the sample "([^"]+)" is in (\d+) sample tubes? with sequential IDs starting at (\d+)$/ do |name, count, base_id| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find the sample #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find the sample #{name.inspect}" (1..count.to_i).each do |index| FactoryBot .create(:empty_sample_tube, name: "#{name} sample tube #{index}", id: (base_id.to_i + index - 1)) - .tap { |sample_tube| sample_tube.aliquots.create!(sample: sample) } + .tap { |sample_tube| sample_tube.aliquots.create!(sample:) } end end diff --git a/features/support/step_definitions/asset_steps.rb b/features/support/step_definitions/asset_steps.rb index 92c452cf92..3592b5dad5 100644 --- a/features/support/step_definitions/asset_steps.rb +++ b/features/support/step_definitions/asset_steps.rb @@ -1,34 +1,34 @@ # frozen_string_literal: true Given /^the barcode for the sample tube "([^"]+)" is "([^"]+)"$/ do |name, barcode| - sample_tube = SampleTube.find_by!(name: name) - sample_tube.primary_barcode.update!(barcode: barcode) + sample_tube = SampleTube.find_by!(name:) + sample_tube.primary_barcode.update!(barcode:) end Given /^the barcode for the asset "([^"]+)" is "([^"]+)"$/ do |name, barcode| - Barcode.find_by(barcode: barcode)&.destroy - asset = Labware.find_by!(name: name) + Barcode.find_by(barcode:)&.destroy + asset = Labware.find_by!(name:) if asset.primary_barcode - asset.primary_barcode.update!(barcode: barcode) + asset.primary_barcode.update!(barcode:) else - asset.barcodes << FactoryBot.create(:sanger_ean13_tube, barcode: barcode) + asset.barcodes << FactoryBot.create(:sanger_ean13_tube, barcode:) end end Given /^tube "([^"]*)" has a public name of "([^"]*)"$/ do |name, public_name| - Labware.find_by(name: name).update!(public_name: public_name) + Labware.find_by(name:).update!(public_name:) end Given /^(?:I have )?a phiX tube called "([^"]+)"$/ do |name| - FactoryBot.create(:sample_tube, name: name, study: nil, project: nil) + FactoryBot.create(:sample_tube, name:, study: nil, project: nil) end Given /^(?:I have )?a (sample|library) tube called "([^"]+)"$/ do |tube_type, name| - FactoryBot.create(:"#{tube_type}_tube", name: name) + FactoryBot.create(:"#{tube_type}_tube", name:) end Given 'I have an empty library tube called {string}' do |name| - FactoryBot.create(:empty_library_tube, name: name) + FactoryBot.create(:empty_library_tube, name:) end Then 'the name of {uuid} should be {string}' do |asset, name| @@ -41,6 +41,6 @@ AssetLink.create_edge(source_plate, target_plate) target_plate.wells.each do |target_well| source_well = source_plate.wells.located_at(target_well.map_description).first - Well::Link.create!(target_well: target_well, source_well: source_well, type: 'stock') + Well::Link.create!(target_well:, source_well:, type: 'stock') end end diff --git a/features/support/step_definitions/authentication_steps.rb b/features/support/step_definitions/authentication_steps.rb index edd9bb252c..c97a12f2ef 100644 --- a/features/support/step_definitions/authentication_steps.rb +++ b/features/support/step_definitions/authentication_steps.rb @@ -12,7 +12,7 @@ @current_user = FactoryBot.create( :user, - login: login, + login:, first_name: 'John', last_name: 'Doe', password: 'generic', @@ -33,11 +33,11 @@ end Then /^I should be logged in as "([^"]*)"$/ do |login| - user = User.find_by(login: login) + user = User.find_by(login:) assert @current_user == user end Given /^user "([^"]*)" has nil first and last names$/ do |login| - user = User.find_by(login: login) + user = User.find_by(login:) user.update!(last_name: nil, first_name: nil) end diff --git a/features/support/step_definitions/bait_library_steps.rb b/features/support/step_definitions/bait_library_steps.rb index 2bd0559590..687c3686e0 100644 --- a/features/support/step_definitions/bait_library_steps.rb +++ b/features/support/step_definitions/bait_library_steps.rb @@ -5,7 +5,7 @@ end Then 'the bait library for {well_range} of {plate_name} should be {string}' do |range, plate, name| - bait_library = BaitLibrary.find_by(name: name) or raise StandardError, "Cannot find bait library #{name.inspect}" + bait_library = BaitLibrary.find_by(name:) or raise StandardError, "Cannot find bait library #{name.inspect}" bait_libraries = plate.wells.select(&range.method(:include?)).map(&:aliquots).flatten.map(&:bait_library).uniq assert_equal([bait_library], bait_libraries, 'The bait libraries do not match what was expected') end diff --git a/features/support/step_definitions/barcode_steps.rb b/features/support/step_definitions/barcode_steps.rb index 3ef23f0ee0..9b7423207d 100644 --- a/features/support/step_definitions/barcode_steps.rb +++ b/features/support/step_definitions/barcode_steps.rb @@ -31,7 +31,7 @@ Given /^the "([^"]+)" barcode printer "([^"]+)" exists$/ do |type_name, name| printer_type = BarcodePrinterType.find_by!(name: type_name) - BarcodePrinter.create!(name: name, barcode_printer_type: printer_type, active: true) + BarcodePrinter.create!(name:, barcode_printer_type: printer_type, active: true) end Given '{asset_id} has a barcode of {string}' do |barcoded, barcode| diff --git a/features/support/step_definitions/batch_steps.rb b/features/support/step_definitions/batch_steps.rb index 1dd53f6781..624e1fd573 100644 --- a/features/support/step_definitions/batch_steps.rb +++ b/features/support/step_definitions/batch_steps.rb @@ -17,13 +17,13 @@ Given /^the last batch is for the "([^"]+)" pipeline$/ do |name| batch = Batch.last or raise StandardError, 'There appear to be no batches' - pipeline = Pipeline.find_by(name: name) or raise StandardError, "Unable to find the pipeline #{name}" + pipeline = Pipeline.find_by(name:) or raise StandardError, "Unable to find the pipeline #{name}" pipeline.batches << batch end Given /^"([^"]+)" is the owner of batch with ID (\d+)$/ do |login, id| - user = User.find_by(login: login) or raise StandardError, "Cannot find user login #{login.inspect}" - Batch.find(id).update!(user: user) + user = User.find_by(login:) or raise StandardError, "Cannot find user login #{login.inspect}" + Batch.find(id).update!(user:) end When /^the batch is started$/ do diff --git a/features/support/step_definitions/bulk_submission_steps.rb b/features/support/step_definitions/bulk_submission_steps.rb index 83d6399dee..e8ad0987e4 100644 --- a/features/support/step_definitions/bulk_submission_steps.rb +++ b/features/support/step_definitions/bulk_submission_steps.rb @@ -21,12 +21,12 @@ def upload_custom_row_submission plate = FactoryBot.create :plate, name: asset_name plate.wells.construct! well = plate.wells.first - well.aliquots.create!(sample: sample) + well.aliquots.create!(sample:) end When /^the plate '(.*)' has a barcode '(.*)'$/ do |name, barcode| bc = SBCF::SangerBarcode.new(prefix: 'DN', number: barcode).human_barcode - Plate.find_by(name: name).primary_barcode.update(barcode: bc) + Plate.find_by(name:).primary_barcode.update(barcode: bc) end When /^the sample '(.*)' belongs to study '(.*)'$/ do |sample_name, study_name| diff --git a/features/support/step_definitions/custom_metadatum_collection_steps.rb b/features/support/step_definitions/custom_metadatum_collection_steps.rb index e44fd42968..6002a6b34d 100644 --- a/features/support/step_definitions/custom_metadatum_collection_steps.rb +++ b/features/support/step_definitions/custom_metadatum_collection_steps.rb @@ -5,7 +5,7 @@ FactoryBot.build(:custom_metadatum, key: 'Key1', value: 'Value1'), FactoryBot.build(:custom_metadatum, key: 'Key2', value: 'Value2') ] - FactoryBot.create(:custom_metadatum_collection, id: id, custom_metadata: metadata) + FactoryBot.create(:custom_metadatum_collection, id:, custom_metadata: metadata) end Given(/^the UUID for the custom metadatum collection with ID (\d+) is "(.*?)"$/) do |id, uuid| diff --git a/features/support/step_definitions/custom_text_steps.rb b/features/support/step_definitions/custom_text_steps.rb index b036d036e5..efa0b8d1dd 100644 --- a/features/support/step_definitions/custom_text_steps.rb +++ b/features/support/step_definitions/custom_text_steps.rb @@ -9,7 +9,7 @@ end Given /^there is a CustomText with identifier: "([^"]*)", differential: "([^"]*)"$/ do |identifier, differential| - @current_custom_text = CustomText.find_by(identifier: identifier, differential: differential) + @current_custom_text = CustomText.find_by(identifier:, differential:) assert_not_nil @current_custom_text end diff --git a/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb b/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb index a6c3c0338d..b6c03e0327 100644 --- a/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb +++ b/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true Given(/^Pipeline "([^"]*)" and a setup for submitted at$/) do |name| - pipeline = Pipeline.find_by(name: name) or raise StandardError, "Cannot find pipeline '#{name}'" + pipeline = Pipeline.find_by(name:) or raise StandardError, "Cannot find pipeline '#{name}'" asset_type = pipeline_name_to_asset_type(name) request_type = pipeline.request_types.detect { |rt| !rt.deprecated } metadata = FactoryBot.create :"request_metadata_for_#{request_type.key}" asset = FactoryBot.create(asset_type) request = - FactoryBot.create :request_with_submission, request_type: request_type, asset: asset, request_metadata: metadata + FactoryBot.create :request_with_submission, request_type:, asset:, request_metadata: metadata request.asset.plate = FactoryBot.create(:plate) if request.asset.plate.nil? if request.asset.is_a?(Well) request.asset.save! diff --git a/features/support/step_definitions/genotyping_steps.rb b/features/support/step_definitions/genotyping_steps.rb index 2fa8b88349..95020b45f7 100644 --- a/features/support/step_definitions/genotyping_steps.rb +++ b/features/support/step_definitions/genotyping_steps.rb @@ -25,16 +25,16 @@ study = Study.find_by(name: study_name) purpose = Purpose.find_by(name: purpose_name) sanger_barcode = Barcode.build_sequencescape22({ barcode: plate_barcode }) - plate = FactoryBot.create(:plate, purpose: purpose, sanger_barcode: sanger_barcode) + plate = FactoryBot.create(:plate, purpose:, sanger_barcode:) asset_group = study.asset_groups.find_by(name: asset_group_name) || study.asset_groups.create!(name: asset_group_name) asset_group.assets << (1..number_of_samples.to_i).map do |index| FactoryBot - .create(:well, plate: plate, map_id: index) + .create(:well, plate:, map_id: index) .tap do |well| well.aliquots.create!( sample: FactoryBot.create(:sample, name: "Sample_#{plate_barcode}_#{index}"), - study: study + study: ) end end @@ -101,7 +101,7 @@ wells = plate.wells.in_column_major_order.to_a submission_template = SubmissionTemplate.find_by(name: submission_template_name) - order = submission_template.create_with_submission!(study: study, project: project, user: User.last, assets: wells) + order = submission_template.create_with_submission!(study:, project:, user: User.last, assets: wells) order.submission.built! step('1 pending delayed jobs are processed') end @@ -114,8 +114,8 @@ submission_template = SubmissionTemplate.find_by(name: 'Cherrypick') order = submission_template.create_with_submission!( - study: study, - project: project, + study:, + project:, user: User.last, assets: asset_group.assets ) diff --git a/features/support/step_definitions/order_steps.rb b/features/support/step_definitions/order_steps.rb index 517947112b..814471d6af 100644 --- a/features/support/step_definitions/order_steps.rb +++ b/features/support/step_definitions/order_steps.rb @@ -5,7 +5,7 @@ end Given /^I have an order created with the following details based on the template "([^"]+)":$/ do |name, details| - template = SubmissionTemplate.find_by(name: name) or + template = SubmissionTemplate.find_by(name:) or raise StandardError, "Cannot find submission template #{name.inspect}" order_attributes = details.rows_hash.map do |k, v| @@ -25,15 +25,15 @@ [k.to_sym, v] end user = User.find_by(login: 'abc123') || FactoryBot.create(:user, login: 'abc123') - order = template.create_order!({ user: user }.merge(order_attributes.to_h)) + order = template.create_order!({ user: }.merge(order_attributes.to_h)) end Given /^an order template called "([^"]+)" with UUID "([^"]+)"$/ do |name, uuid_value| - set_uuid_for(FactoryBot.create(:submission_template, name: name), uuid_value) + set_uuid_for(FactoryBot.create(:submission_template, name:), uuid_value) end Given /^the UUID for the order template "([^"]+)" is "([^"]+)"$/ do |name, uuid_value| - object = SubmissionTemplate.find_by!(name: name) + object = SubmissionTemplate.find_by!(name:) set_uuid_for(object, uuid_value) end diff --git a/features/support/step_definitions/pipeline_steps.rb b/features/support/step_definitions/pipeline_steps.rb index 21ae5db7b2..3bbc666198 100644 --- a/features/support/step_definitions/pipeline_steps.rb +++ b/features/support/step_definitions/pipeline_steps.rb @@ -2,7 +2,7 @@ Given /^I have a pipeline called "([^"]*)"$/ do |name| request_type = FactoryBot.create :request_type - pipeline = FactoryBot.create :pipeline, name: name, request_types: [request_type] + pipeline = FactoryBot.create :pipeline, name:, request_types: [request_type] pipeline.workflow.update!(item_limit: 8) task = FactoryBot.create :task, name: 'Task1', workflow: pipeline.workflow end @@ -12,11 +12,11 @@ end Given /^I have a "([^"]*)" batch in "([^"]*)"$/ do |state, pipeline| - @batch = FactoryBot.create :batch, pipeline: Pipeline.find_by(name: pipeline), state: state, production_state: nil + @batch = FactoryBot.create :batch, pipeline: Pipeline.find_by(name: pipeline), state:, production_state: nil end Given /^I have a control called "([^"]*)" for "([^"]*)"$/ do |name, pipeline_name| - control = FactoryBot.create :control, name: name, pipeline: Pipeline.find_by(name: pipeline_name) + control = FactoryBot.create :control, name:, pipeline: Pipeline.find_by(name: pipeline_name) end def pipeline_name_to_asset_type(pipeline_name) @@ -34,7 +34,7 @@ def create_request_for_pipeline(pipeline_name, options = {}) # rubocop:todo Metr options.merge( request_type: pipeline.request_types.last, asset: FactoryBot.create(pipeline_name_to_asset_type(pipeline_name)), - request_metadata: request_metadata + request_metadata: ) FactoryBot .create(:request_with_submission, request_parameters) @@ -53,7 +53,7 @@ def create_request_for_pipeline(pipeline_name, options = {}) # rubocop:todo Metr end Then /^the requests from "([^"]+)" batches should not be in the inbox$/ do |name| - pipeline = Pipeline.find_by(name: name) or raise StandardError, "Cannot find pipeline #{name.inspect}" + pipeline = Pipeline.find_by(name:) or raise StandardError, "Cannot find pipeline #{name.inspect}" raise StandardError, "There are no batches in #{name.inspect}" if pipeline.batches.empty? pipeline.batches.each do |batch| @@ -62,7 +62,7 @@ def create_request_for_pipeline(pipeline_name, options = {}) # rubocop:todo Metr end Given /^the maximum batch size for the pipeline "([^"]+)" is (\d+)$/ do |name, max_size| - pipeline = Pipeline.find_by(name: name) or raise StandardError, "Cannot find pipeline #{name.inspect}" + pipeline = Pipeline.find_by(name:) or raise StandardError, "Cannot find pipeline #{name.inspect}" pipeline.update!(max_size: max_size.to_i) end @@ -75,5 +75,5 @@ def create_request_for_pipeline(pipeline_name, options = {}) # rubocop:todo Metr end Given /^the last request is in the "([^"]+)" state$/ do |state| - Request.last.update!(state: state) + Request.last.update!(state:) end diff --git a/features/support/step_definitions/plate_steps.rb b/features/support/step_definitions/plate_steps.rb index 4ce301e7ea..fb9413dae9 100644 --- a/features/support/step_definitions/plate_steps.rb +++ b/features/support/step_definitions/plate_steps.rb @@ -2,7 +2,7 @@ Given /^plate "([^"]*)" has "([^"]*)" wells$/ do |plate_barcode, number_of_wells| plate = Plate.find_from_barcode(plate_barcode) - 1.upto(number_of_wells.to_i) { |i| Well.create!(plate: plate, map_id: i) } + 1.upto(number_of_wells.to_i) { |i| Well.create!(plate:, map_id: i) } end Then /^plate with barcode "([^"]*)" should exist$/ do |plate_barcode| @@ -27,11 +27,11 @@ Given /^plate with barcode "([^"]*)" has a well$/ do |plate_barcode| plate = Plate.find_from_barcode(plate_barcode) map = plate.maps.first - FactoryBot.create(:untagged_well, plate: plate, map: map) + FactoryBot.create(:untagged_well, plate:, map:) end Given 'a tube named {string} with barcode {string} exists' do |name, machine_barcode| - FactoryBot.create :tube, name: name, sanger_barcode: { machine_barcode: machine_barcode } + FactoryBot.create :tube, name:, sanger_barcode: { machine_barcode: } end Given /^a plate with barcode "([^"]*)" exists$/ do |machine_barcode| @@ -39,7 +39,7 @@ FactoryBot.create :plate, sanger_barcode: Barcode.build_sequencescape22({ barcode: machine_barcode }) else FactoryBot.create :plate, - sanger_barcode: Barcode.build_sanger_code39({ machine_barcode: machine_barcode, format: 'DN' }) + sanger_barcode: Barcode.build_sanger_code39({ machine_barcode:, format: 'DN' }) end end @@ -47,7 +47,7 @@ Given /^a "([^"]*)" plate purpose and of type "([^"]*)" with barcode "([^"]*)" exists$/ do |plate_purpose_name, plate_type, machine_barcode| # rubocop:enable Layout/LineLength plate_type.constantize.create!( - sanger_barcode: Barcode.build_sanger_code39({ machine_barcode: machine_barcode, format: 'DN' }), + sanger_barcode: Barcode.build_sanger_code39({ machine_barcode:, format: 'DN' }), plate_purpose: PlatePurpose.find_by(name: plate_purpose_name), name: machine_barcode ) @@ -58,7 +58,7 @@ end Given /^the plate with ID (\d+) has a plate purpose of "([^"]+)"$/ do |id, name| - purpose = PlatePurpose.find_by(name: name) or raise StandardError, "Cannot find plate purpose #{name.inspect}" + purpose = PlatePurpose.find_by(name:) or raise StandardError, "Cannot find plate purpose #{name.inspect}" Plate.find(id).update!(plate_purpose: purpose) end @@ -74,7 +74,7 @@ else FactoryBot.create( :plate, - sanger_barcode: Barcode.build_sanger_code39({ machine_barcode: machine_barcode }), + sanger_barcode: Barcode.build_sanger_code39({ machine_barcode: }), well_count: 8, plate_purpose: Purpose.find_by(name: plate_purpose_name) ) @@ -87,7 +87,7 @@ :plate, name: 'A_TEST_STOCK_PLATE', well_count: 8, - sanger_barcode: Barcode.build_sanger_code39({ machine_barcode: machine_barcode }), + sanger_barcode: Barcode.build_sanger_code39({ machine_barcode: }), plate_purpose: PlatePurpose.find_by(name: 'Stock Plate') ) end @@ -105,13 +105,13 @@ plate = Plate.find(plate_id) map = Map.where_description(position).where_plate_size(plate.size).where_plate_shape(plate.asset_shape).first or raise StandardError, "Could not find position #{position}" - Well.find(well_id).update!(plate: plate, map: map) + Well.find(well_id).update!(plate:, map:) end Given /^well "([^"]*)" is holded by plate "([^"]*)"$/ do |well_uuid, plate_uuid| well = Uuid.find_by(external_id: well_uuid).resource plate = Uuid.find_by(external_id: plate_uuid).resource - well.update!(plate: plate, map: Map.find_by(description: 'A1', asset_size: plate.size)) + well.update!(plate:, map: Map.find_by(description: 'A1', asset_size: plate.size)) Plate.find(plate_id).primary_barcode.update!(barcode: 'DN1S') end @@ -120,13 +120,13 @@ end Given /^a "([^"]+)" plate called "([^"]+)" exists$/ do |name, plate_name| - plate_purpose = PlatePurpose.find_by!(name: name) + plate_purpose = PlatePurpose.find_by!(name:) plate_purpose.create!(name: plate_name) end Given(/^a plate called "([^"]*)" exists with purpose "([^"]*)"$/) do |name, purpose_name| purpose = Purpose.find_by(name: purpose_name) || FactoryBot.create(:plate_purpose, name: purpose_name) - FactoryBot.create(:plate, name: name, purpose: purpose, well_count: 8) + FactoryBot.create(:plate, name:, purpose:, well_count: 8) end Given( @@ -136,21 +136,21 @@ FactoryBot.create( :full_plate, well_factory: :untagged_well, - name: name, - purpose: purpose, - barcode: barcode, + name:, + purpose:, + barcode:, well_count: 16 ) end Given /^a "([^"]+)" plate called "([^"]+)" exists with barcode "([^"]+)"$/ do |name, plate_name, barcode| - plate_purpose = PlatePurpose.find_by!(name: name) + plate_purpose = PlatePurpose.find_by!(name:) step("the Baracoda barcode service returns \"#{barcode}\"") - plate_purpose.create!(name: plate_name, barcode: barcode) + plate_purpose.create!(name: plate_name, barcode:) end Given /^a "([^"]+)" plate called "([^"]+)" exists as a child of "([^"]+)"$/ do |name, plate_name, parent_name| - plate_purpose = PlatePurpose.find_by(name: name) or raise StandardError, "Cannot find plate purpose #{name.inspect}" + plate_purpose = PlatePurpose.find_by(name:) or raise StandardError, "Cannot find plate purpose #{name.inspect}" parent = Plate.find_by(name: parent_name) or raise StandardError, "Cannot find parent plate #{parent_name.inspect}" AssetLink.create!(ancestor: parent, descendant: plate_purpose.create!(name: plate_name)) end @@ -175,7 +175,7 @@ Given /^the plate "([^"]*)" is (passed|started|pending|failed) by "([^"]*)"$/ do |plate_name, state, user_name| plate = Plate.find_by(name: plate_name) user = User.find_by(login: user_name) - StateChange.create!(user: user, target: plate, target_state: state) + StateChange.create!(user:, target: plate, target_state: state) end # rubocop:todo Layout/LineLength @@ -188,7 +188,7 @@ :transfer_request, asset: source.wells.in_row_major_order[i], target_asset: destination.wells.in_row_major_order[i], - state: state + state: ) Well::Link.create!( source_well: source.wells.in_row_major_order[i], @@ -214,7 +214,7 @@ plate = Uuid.find_by(external_id: uuid).resource well_details.hashes.each do |well_detail| well = - Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate: plate) + Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate:) well.well_attribute.update!( concentration: well_detail[:measured_concentration], measured_volume: well_detail[:measured_volume] diff --git a/features/support/step_definitions/project_steps.rb b/features/support/step_definitions/project_steps.rb index 32cef3cfd2..d58d71c417 100644 --- a/features/support/step_definitions/project_steps.rb +++ b/features/support/step_definitions/project_steps.rb @@ -17,7 +17,7 @@ end Given /^project "([^"]*)" has enforced quotas$/ do |name| - project = Project.find_by(name: name) or raise StandardError, "Cannot find project with name #{name.inspect}" + project = Project.find_by(name:) or raise StandardError, "Cannot find project with name #{name.inspect}" project.update!(enforce_quotas: true) end @@ -32,5 +32,5 @@ budget_division = BudgetDivision.find_by(name: budget_division_name) or raise StandardError, "Cannot find budget division #{budget_division_name.inspect}" - project.update!(project_metadata_attributes: { budget_division: budget_division }) + project.update!(project_metadata_attributes: { budget_division: }) end diff --git a/features/support/step_definitions/pulldown_steps.rb b/features/support/step_definitions/pulldown_steps.rb index 8c2e4f2ffb..5e0954d8b8 100644 --- a/features/support/step_definitions/pulldown_steps.rb +++ b/features/support/step_definitions/pulldown_steps.rb @@ -9,8 +9,8 @@ def create_submission_of_assets(template, assets, request_options = {}) user: FactoryBot.create(:user), study: FactoryBot.create(:study), project: FactoryBot.create(:project), - assets: assets, - request_options: request_options + assets:, + request_options: ).submission submission.built! Delayed::Worker.delay_jobs = true @@ -35,7 +35,7 @@ def create_submission_of_assets(template, assets, request_options = {}) plate .wells .select(&range.method(:include?)) - .each { |well| FactoryBot.create :transfer_request, submission: submission, target_asset: well } + .each { |well| FactoryBot.create :transfer_request, submission:, target_asset: well } end Given '{well_range} of {plate_name} have been failed' do |range, plate| @@ -77,7 +77,7 @@ def create_submission_of_assets(template, assets, request_options = {}) def work_pipeline_for(submissions, name, template = nil) # rubocop:todo Metrics/CyclomaticComplexity raise StandardError, 'No submissions to process' if submissions.empty? - final_plate_type = PlatePurpose.find_by(name: name) or raise StandardError, "Cannot find #{name.inspect} plate type" + final_plate_type = PlatePurpose.find_by(name:) or raise StandardError, "Cannot find #{name.inspect} plate type" template ||= TransferTemplate.find_by(name: 'Pool wells based on submission') or raise StandardError, 'Cannot find pooling transfer template' @@ -119,11 +119,11 @@ def work_pipeline_for(submissions, name, template = nil) # rubocop:todo Metrics/ # rubocop:todo Layout/LineLength Given 'all of the wells on {plate_name} are in an asset group called {string} owned by {study_name}' do |plate, name, study| # rubocop:enable Layout/LineLength - AssetGroup.create!(study: study, name: name, assets: plate.wells) + AssetGroup.create!(study:, name:, assets: plate.wells) end Then /^all "([^"]+)" requests should have the following details:$/ do |name, table| - request_type = RequestType.find_by(name: name) or raise StandardError, "Could not find request type #{name.inspect}" + request_type = RequestType.find_by(name:) or raise StandardError, "Could not find request type #{name.inspect}" raise StandardError, "No requests of type #{name.inspect}" if request_type.requests.empty? results = @@ -156,7 +156,7 @@ def work_pipeline_for(submissions, name, template = nil) # rubocop:todo Metrics/ Given '{plate_name} will pool into 1 tube' do |plate| well_count = plate.wells.count - stock_plate = FactoryBot.create :full_stock_plate, well_count: well_count + stock_plate = FactoryBot.create(:full_stock_plate, well_count:) stock_wells = stock_plate.wells submission = Submission.create!(user: FactoryBot.create(:user)) @@ -168,8 +168,8 @@ def work_pipeline_for(submissions, name, template = nil) # rubocop:todo Metrics/ .readonly(false) .each_with_index do |well, i| stock_well = stock_wells[i] - FactoryBot.create(:library_creation_request, asset: stock_well, target_asset: well, submission: submission) - FactoryBot.create(:transfer_request, asset: stock_well, target_asset: well, submission: submission) + FactoryBot.create(:library_creation_request, asset: stock_well, target_asset: well, submission:) + FactoryBot.create(:transfer_request, asset: stock_well, target_asset: well, submission:) well.stock_wells.attach!([stock_well]) end end diff --git a/features/support/step_definitions/reference_genome_steps.rb b/features/support/step_definitions/reference_genome_steps.rb index ac9d4d1d39..da24713ed2 100644 --- a/features/support/step_definitions/reference_genome_steps.rb +++ b/features/support/step_definitions/reference_genome_steps.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Given /^the reference genome "([^"]*)" exists$/ do |name| - FactoryBot.create :reference_genome, name: name + FactoryBot.create :reference_genome, name: end Given /^a reference genome table$/ do diff --git a/features/support/step_definitions/request_steps.rb b/features/support/step_definitions/request_steps.rb index 9b6ae066ab..88c65dd469 100644 --- a/features/support/step_definitions/request_steps.rb +++ b/features/support/step_definitions/request_steps.rb @@ -2,7 +2,7 @@ Given /^user "([^"]*)" owns all requests$/ do |user_name| user = FactoryBot.create :user, login: user_name - Request.find_each { |request| request.update!(user: user) } + Request.find_each { |request| request.update!(user:) } end Given /^all requests have a priority flag$/ do diff --git a/features/support/step_definitions/robot_verification_steps.rb b/features/support/step_definitions/robot_verification_steps.rb index 4956369bdb..c974a84895 100644 --- a/features/support/step_definitions/robot_verification_steps.rb +++ b/features/support/step_definitions/robot_verification_steps.rb @@ -90,7 +90,7 @@ end Given /^user "([^"]*)" has a user barcode of "([^"]*)"$/ do |login, user_barcode| - user = User.find_by(login: login) + user = User.find_by(login:) user.update!(barcode: user_barcode) end diff --git a/features/support/step_definitions/role_steps.rb b/features/support/step_definitions/role_steps.rb index cd667c2d99..c6d7d4c049 100644 --- a/features/support/step_definitions/role_steps.rb +++ b/features/support/step_definitions/role_steps.rb @@ -13,6 +13,6 @@ end Given /^user "([^"]+)" is an administrator$/ do |login| - user = User.find_by(login: login) or raise StandardError, "Cannot find user with login #{login.inspect}" + user = User.find_by(login:) or raise StandardError, "Cannot find user with login #{login.inspect}" user.roles.create!(name: 'administrator') end diff --git a/features/support/step_definitions/sample_manifest_steps.rb b/features/support/step_definitions/sample_manifest_steps.rb index bb9e80dd17..425797c4af 100644 --- a/features/support/step_definitions/sample_manifest_steps.rb +++ b/features/support/step_definitions/sample_manifest_steps.rb @@ -5,7 +5,7 @@ end Given /^the library type "([^"]+)" exists$/ do |name| - LibraryType.find_or_create_by(name: name) + LibraryType.find_or_create_by(name:) end Given /^the study "(.*)" has a abbreviation$/ do |study_name| @@ -71,7 +71,7 @@ def instance.next! Then /^the samples table should look like:$/ do |table| table.hashes.each do |expected_data| sanger_sample_id = expected_data[:sanger_sample_id] - sample = Sample.find_by(sanger_sample_id: sanger_sample_id) + sample = Sample.find_by(sanger_sample_id:) if expected_data.fetch(:empty_supplier_sample_name, expected_data[:sample_absent]) == 'true' assert_nil sample, "#{sanger_sample_id} exists but should not be created" @@ -113,7 +113,7 @@ def instance.next! Then /^the sample accession numbers should be:$/ do |table| table.hashes.each do |expected_data| sanger_sample_id = expected_data[:sanger_sample_id] - sample = Sample.find_by!(sanger_sample_id: sanger_sample_id) + sample = Sample.find_by!(sanger_sample_id:) assert_equal(expected_data[:accession_number], sample.sample_metadata.sample_ebi_accession_number) end end @@ -121,7 +121,7 @@ def instance.next! Then /^the sample reference genomes should be:$/ do |table| table.hashes.each do |expected_data| sanger_sample_id = expected_data[:sanger_sample_id] - sample = Sample.find_by(sanger_sample_id: sanger_sample_id) or + sample = Sample.find_by(sanger_sample_id:) or raise StandardError, "Could not find sample #{sanger_sample_id}" assert_equal(expected_data[:reference_genome], sample.sample_metadata.reference_genome.name) end @@ -172,7 +172,7 @@ def instance.next! study = Study.find_by!(name: study_name) supplier = Supplier.find_by!(name: 'Test supplier name') sample_manifest = - FactoryBot.create :sample_manifest, study: study, supplier: supplier, user: User.find_by(first_name: 'john') + FactoryBot.create :sample_manifest, study:, supplier:, user: User.find_by(first_name: 'john') sample_manifest.generate Delayed::Worker.new.work_off visit(url_for(sample_manifest)) @@ -223,14 +223,14 @@ def instance.next! When /^the sample manifest with ID (\d+) is owned by study "([^"]+)"$/ do |id, name| manifest = SampleManifest.find(id) - study = Study.find_by(name: name) or raise StandardError, "Cannot find study #{name.inspect}" - manifest.update!(study: study) + study = Study.find_by(name:) or raise StandardError, "Cannot find study #{name.inspect}" + manifest.update!(study:) end When /^the sample manifest with ID (\d+) is supplied by "([^"]+)"$/ do |id, name| manifest = SampleManifest.find(id) - supplier = Supplier.find_by(name: name) or raise StandardError, "Cannot find supplier #{name.inspect}" - manifest.update!(supplier: supplier) + supplier = Supplier.find_by(name:) or raise StandardError, "Cannot find supplier #{name.inspect}" + manifest.update!(supplier:) end Given /^the sample manifest with ID (\d+) is for (\d+) sample tube$/ do |id, count| diff --git a/features/support/step_definitions/sample_metadata_steps.rb b/features/support/step_definitions/sample_metadata_steps.rb index bb9821f41d..fe8dec4b3f 100644 --- a/features/support/step_definitions/sample_metadata_steps.rb +++ b/features/support/step_definitions/sample_metadata_steps.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Given /^the fields of the sample_metadata for the sample called "([^"]+)" are prepopulated$/ do |name| - sample = Sample.find_by!(name: name) + sample = Sample.find_by!(name:) sample.update!(sample_metadata_attributes: FactoryBot.attributes_for(:sample_metadata_for_api)) end diff --git a/features/support/step_definitions/samples_steps.rb b/features/support/step_definitions/samples_steps.rb index 519e1e715d..e0918df5ce 100644 --- a/features/support/step_definitions/samples_steps.rb +++ b/features/support/step_definitions/samples_steps.rb @@ -1,37 +1,37 @@ # frozen_string_literal: true Given /^the sample "([^"]+)" has the Taxon ID "([^"]+)"$/ do |name, id| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find sample with name #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find sample with name #{name.inspect}" sample.sample_metadata.sample_taxon_id = id sample.save! end Given /^the sample "([^"]+)" has the common name "([^"]*)"$/ do |name, common_name| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find sample with name #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find sample with name #{name.inspect}" sample.sample_metadata.sample_common_name = common_name sample.save! end Given /^the sample "([^"]+)" has the gender "([^"]*)"$/ do |name, gender| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find sample with name #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find sample with name #{name.inspect}" sample.sample_metadata.gender = gender sample.save! end Given /^the sample "([^"]+)" has the donor id "([^"]*)"$/ do |name, donor_id| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find sample with name #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find sample with name #{name.inspect}" sample.sample_metadata.donor_id = donor_id sample.save! end Given /^the sample "([^"]+)" has the phenotype "([^"]*)"$/ do |name, phenotype| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find sample with name #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find sample with name #{name.inspect}" sample.sample_metadata.phenotype = phenotype sample.save! end Given /^the reference genome for sample "([^"]+)" is "([^"]+)"$/ do |name, value| - sample = Sample.find_by!(name: name) + sample = Sample.find_by!(name:) ref_genome = ReferenceGenome.find_or_create_by!(name: value) sample.sample_metadata.reference_genome = ref_genome sample.save! @@ -45,7 +45,7 @@ end Then /^the reference genome for the sample "([^"]+)" should be "([^"]+)"$/ do |name, genome| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find sample with name #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find sample with name #{name.inspect}" assert_equal(genome, sample.sample_metadata.reference_genome.name) end @@ -100,26 +100,26 @@ end Then /^the sample "([^"]+)" should exist$/ do |name| - assert_not_nil(Sample.find_by(name: name), "The sample #{name.inspect} does not exist") + assert_not_nil(Sample.find_by(name:), "The sample #{name.inspect} does not exist") end Then /^the sample "([^"]+)" should have an associated sample tube$/ do |name| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find sample with name #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find sample with name #{name.inspect}" assert(!sample.assets.empty?, 'No associated sample tubes') end When /^I get the XML for the sample "([^"]+)"$/ do |name| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find sample with name #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find sample with name #{name.inspect}" visit(url_for(controller: 'samples', action: 'show', id: sample, format: :xml)) end Given /^I have a sample called "([^"]*)" with metadata$/ do |name| - sample = FactoryBot.create :sample, name: name + sample = FactoryBot.create :sample, name: end Given /^the sample "([^"]*)" has a supplier name of "([^"]*)"$/ do |sample_name, supplier_name| sample = Sample.find_by(name: sample_name) - sample.sample_metadata.update!(supplier_name: supplier_name) + sample.sample_metadata.update!(supplier_name:) end Given /^the sample "([^"]+)" is in the (sample tube|well) "([^"]+)"$/ do |sample_name, _asset_type, asset_name| @@ -127,11 +127,11 @@ asset = Labware.find_by(name: asset_name).receptacle or raise StandardError, "Cannot find sample tube #{asset_name.inspect}" asset.aliquots.clear - asset.aliquots.create!(sample: sample) + asset.aliquots.create!(sample:) end Given(/^the sample "([^"]+)" has the accession number "([^"]+)"$/) do |name, value| - sample = Sample.find_by!(name: name) + sample = Sample.find_by!(name:) sample.sample_metadata.sample_ebi_accession_number = value.presence sample.save! end @@ -159,7 +159,7 @@ Given /^sample "([^"]*)" came from a sample manifest$/ do |sample_name| sample = Sample.find_by(name: sample_name) sample_manifest = FactoryBot.create(:sample_manifest, id: 1) - sample.update!(sample_manifest: sample_manifest) + sample.update!(sample_manifest:) end Given /^a sample named "([^"]+)" exists for accession/ do |sample_name| @@ -188,37 +188,37 @@ end Given /^the sample called "([^"]+)" is (#{Sample::GENDERS.join('|')})$/ do |name, gender| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find the sample #{name.inspect}" - sample.update!(sample_metadata_attributes: { gender: gender }) + sample = Sample.find_by(name:) or raise StandardError, "Cannot find the sample #{name.inspect}" + sample.update!(sample_metadata_attributes: { gender: }) end Given /^the GC content of the sample called "([^"]+)" is (#{Sample::GC_CONTENTS.join('|')})$/ do |name, gc_content| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find the sample #{name.inspect}" - sample.update!(sample_metadata_attributes: { gc_content: gc_content }) + sample = Sample.find_by(name:) or raise StandardError, "Cannot find the sample #{name.inspect}" + sample.update!(sample_metadata_attributes: { gc_content: }) end Given /^the DNA source of the sample called "([^"]+)" is (#{Sample::DNA_SOURCES.join('|')})$/ do |name, source| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find the sample #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find the sample #{name.inspect}" sample.update!(sample_metadata_attributes: { dna_source: source }) end Given /^the SRA status of the sample called "([^"]+)" is (#{Sample::SRA_HOLD_VALUES.join('|')})$/ do |name, sra_status| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find the sample #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find the sample #{name.inspect}" sample.update!(sample_metadata_attributes: { sample_sra_hold: sra_status }) end Given /^the sample called "([^"]+)" is (#{Sample::AGE_REGEXP}) old$/o do |name, age| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find the sample #{name.inspect}" - sample.update!(sample_metadata_attributes: { age: age }) + sample = Sample.find_by(name:) or raise StandardError, "Cannot find the sample #{name.inspect}" + sample.update!(sample_metadata_attributes: { age: }) end Given /^the dosage of the sample called "([^"]+)" is (#{Sample::DOSE_REGEXP})/o do |name, dose| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find the sample #{name.inspect}" - sample.update!(sample_metadata_attributes: { dose: dose }) + sample = Sample.find_by(name:) or raise StandardError, "Cannot find the sample #{name.inspect}" + sample.update!(sample_metadata_attributes: { dose: }) end Given /^the description of the sample called "([^"]+)" contains quotes/ do |name| - sample = Sample.find_by(name: name) or raise StandardError, "Cannot find the sample #{name.inspect}" + sample = Sample.find_by(name:) or raise StandardError, "Cannot find the sample #{name.inspect}" sample.update!(sample_metadata_attributes: { sample_description: 'something "with" quotes' }) end diff --git a/features/support/step_definitions/study_report_steps.rb b/features/support/step_definitions/study_report_steps.rb index 6494af4a57..5f1238b424 100644 --- a/features/support/step_definitions/study_report_steps.rb +++ b/features/support/step_definitions/study_report_steps.rb @@ -6,12 +6,12 @@ Given /^there is (\d+) pending report for study "([^"]*)"$/ do |num_reports, study_name| study = Study.find_by(name: study_name) or raise StandardError, "Cannot find study #{study_name.inspect}" - 1.upto(num_reports.to_i) { FactoryBot.create :pending_study_report, study: study, user: @current_user } + 1.upto(num_reports.to_i) { FactoryBot.create :pending_study_report, study:, user: @current_user } end Given /^there is (\d+) completed report for study "([^"]*)"$/ do |num_reports, study_name| study = Study.find_by(name: study_name) or raise StandardError, "Cannot find study #{study_name.inspect}" - 1.upto(num_reports.to_i) { FactoryBot.create :completed_study_report, study: study, user: @current_user } + 1.upto(num_reports.to_i) { FactoryBot.create :completed_study_report, study:, user: @current_user } end Then /^I should see the report for "([^"]*)":$/ do |study_name, expected_results_table| diff --git a/features/support/step_definitions/study_steps.rb b/features/support/step_definitions/study_steps.rb index a6aea75424..a580958910 100644 --- a/features/support/step_definitions/study_steps.rb +++ b/features/support/step_definitions/study_steps.rb @@ -22,7 +22,7 @@ Given /^study "([^"]*)" has assets registered$/ do |study| proj = Study.find_by(name: study) user = User.find_by login: 'user' - new_sample_group = FactoryBot.create :asset_group, name: 'new_asset_group', user: user, study: proj + new_sample_group = FactoryBot.create :asset_group, name: 'new_asset_group', user:, study: proj end Given /^the following user records$/ do |table| @@ -43,7 +43,7 @@ created_at: Time.zone.now, updated_at: Time.zone.now end - usr = User.find_by(login: login) + usr = User.find_by(login:) usr.roles << role usr.save end @@ -64,7 +64,7 @@ def given_fixed_study_metadata(attribute, value, regexp) Given(regexp) do |name| - study = Study.find_by(name: name) or raise StandardError, "There appears to be no study named '#{name}'" + study = Study.find_by(name:) or raise StandardError, "There appears to be no study named '#{name}'" study.study_metadata.send(:"#{attribute}=", value) study.save! end @@ -94,7 +94,7 @@ def given_fixed_study_metadata(attribute, value, regexp) def given_study_metadata(attribute, regexp) Given(regexp) do |name, value| - study = Study.find_by(name: name) or raise StandardError, "There appears to be no study named '#{name}'" + study = Study.find_by(name:) or raise StandardError, "There appears to be no study named '#{name}'" study.study_metadata.send(:"#{attribute}=", value.presence) study.save! end @@ -112,28 +112,28 @@ def given_study_metadata(attribute, regexp) end Given(/^the study "([^"]+)" is a "([^"]*)" study$/) do |name, value| - study = Study.find_by!(name: name) + study = Study.find_by!(name:) study_type = StudyType.find_by!(name: value) study.study_metadata.study_type = study_type study.save! end Given(/^the study "([^"]+)" is a "([^"]+)" study for data release$/) do |name, value| - study = Study.find_by!(name: name) + study = Study.find_by!(name:) study_type_dr = DataReleaseStudyType.find_by!(name: value) study.study_metadata.data_release_study_type = study_type_dr study.save! end Given(/^the faculty sponsor for study "([^"]+)" is "([^"]+)"$/) do |name, value| - study = Study.find_by!(name: name) + study = Study.find_by!(name:) faculty_sponsor = FacultySponsor.create!(name: value) study.study_metadata.faculty_sponsor = faculty_sponsor study.save! end Given(/^the reference genome for study "([^"]+)" is "([^"]+)"$/) do |name, value| - study = Study.find_by!(name: name) + study = Study.find_by!(name:) ref_genome = ReferenceGenome.find_or_create_by!(name: value) study.study_metadata.reference_genome = ref_genome study.save! @@ -148,14 +148,14 @@ def given_study_metadata(attribute, regexp) given_study_metadata(:ega_policy_accession_number, /^the EGA policy accession number for study "([^"]+)" is "([^"]+)"$/) Given /^the (abstract|description|title) of study "([^"]+)" is "([^"]*)"$/ do |attribute, name, description| - study = Study.find_by(name: name) or raise StandardError, "There appears to be no study named '#{name}'" + study = Study.find_by(name:) or raise StandardError, "There appears to be no study named '#{name}'" attribute = 'study_title' if attribute == 'title' # Got to love consistency study.study_metadata.send(:"study_#{attribute}=", description) study.save! end Given /^the study "([^"]+)" is delayed for (3|6|9|12) months because "([^"]+)"$/ do |name, period, reason| - study = Study.find_by(name: name) or raise StandardError, "There appears to be no study named '#{name}'" + study = Study.find_by(name:) or raise StandardError, "There appears to be no study named '#{name}'" study.update!( study_metadata_attributes: { data_release_timing: 'delayed', @@ -176,13 +176,13 @@ def given_study_metadata(attribute, regexp) proj = Study.find_by(name: study) user = User.find_by login: 'user' - id_asset_group = FactoryBot.create :asset_group, user: user, study: proj + id_asset_group = FactoryBot.create :asset_group, user:, study: proj id_asset = FactoryBot.create :sample_tube, name: 'Cucumberirbattle', barcode: 'barcode', closed: '0' id_aga = FactoryBot.create :asset_group_asset, asset_id: id_asset.id, asset_group_id: id_asset_group.id end Given /^study "([^"]*)" has an accession number$/ do |name| - study = Study.find_by(name: name) or raise StandardError, "Cannot find study with name '#{name}'" + study = Study.find_by(name:) or raise StandardError, "Cannot find study with name '#{name}'" study.study_metadata.study_ebi_accession_number = 9999 study.study_metadata.data_release_strategy ||= 'managed' study.save! @@ -228,7 +228,7 @@ def assign_asset_to_study(asset, study_name) assert_not_nil study.abbreviation.match(Regexp.new(abbreviation_regex)) end When /^I get the XML accession for the study *"([^"]+)"$/ do |name| - study = Study.find_by(name: name) or raise StandardError, "Cannot find sample with name #{name.inspect}" + study = Study.find_by(name:) or raise StandardError, "Cannot find sample with name #{name.inspect}" visit(url_for(controller: 'studies', action: 'show_accession', id: study.id, format: :xml)) end diff --git a/features/support/step_definitions/submission_steps.rb b/features/support/step_definitions/submission_steps.rb index 861170bc82..035bc9df6c 100644 --- a/features/support/step_definitions/submission_steps.rb +++ b/features/support/step_definitions/submission_steps.rb @@ -9,7 +9,7 @@ When /^the state of the submission with UUID "([^"]+)" is "([^"]+)"$/ do |uuid, state| submission = Uuid.with_external_id(uuid).first.try(:resource) or raise StandardError, "Could not find submission with UUID #{uuid.inspect}" - submission.update!(state: state) + submission.update!(state:) end Then /^there should be no submissions to be processed$/ do @@ -88,14 +88,14 @@ end Given /^the request type "([^"]+)" exists$/ do |name| - FactoryBot.create(:request_type, name: name) + FactoryBot.create(:request_type, name:) end def submission_in_state(state, attributes = {}) study = Study.first or raise StandardError, 'There are no studies!' submission = FactoryHelp.submission( - { asset_group_name: 'Faked to prevent empty asset errors' }.merge(attributes).merge(study: study) + { asset_group_name: 'Faked to prevent empty asset errors' }.merge(attributes).merge(study:) ) submission.state = state submission.save(validate: false) @@ -106,7 +106,7 @@ def submission_in_state(state, attributes = {}) end Given /^I have a submission in the "failed" state with message "([^"]+)"$/ do |message| - submission_in_state('failed', message: message) + submission_in_state('failed', message:) end # These are the sensible default values for requests, which later get bound to the request types @@ -140,7 +140,7 @@ def submission_in_state(state, attributes = {}) }.freeze def with_request_type_scope(name, &block) - request_type = RequestType.find_by(name: name) or raise StandardError, "Cannot find request type #{name.inspect}" + request_type = RequestType.find_by(name:) or raise StandardError, "Cannot find request type #{name.inspect}" with_scope("#request_type_options_for_#{request_type.id}", &block) end @@ -177,7 +177,7 @@ def with_request_type_scope(name, &block) study: Study.find_by(name: params['Study']), asset_group: AssetGroup.find_by(name: params['Asset Group']), user: @current_user, - request_options: request_options + request_options: ) .submission .built! @@ -185,7 +185,7 @@ def with_request_type_scope(name, &block) # step(%Q{1 pending delayed jobs are processed}) end Then /^the last submission should have a priority of (\d+)$/ do |priority| - Submission.last.update!(priority: priority) + Submission.last.update!(priority:) end Given /^all the requests in the last submission are cancelled$/ do diff --git a/features/support/step_definitions/tag_layout_steps.rb b/features/support/step_definitions/tag_layout_steps.rb index b2c4798335..f0be615cf6 100644 --- a/features/support/step_definitions/tag_layout_steps.rb +++ b/features/support/step_definitions/tag_layout_steps.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true Given /^the ((?:entire plate |inverted )?tag layout template) "([^"]+)" exists$/ do |style, name| - FactoryBot.create(style.tr(' ', '_'), name: name) + FactoryBot.create(style.tr(' ', '_'), name:) end Given /^the tag 2 layout template "([^"]+)" exists$/ do |name| - FactoryBot.create(:tag2_layout_template, name: name, oligo: 'AAA') + FactoryBot.create(:tag2_layout_template, name:, oligo: 'AAA') end TAG_LAYOUT_TEMPLATE_REGEXP = 'tag layout template "[^\"]+"' @@ -53,7 +53,7 @@ def plate_view_of_oligos(label, mapping) # rubocop:todo Metrics/AbcSize end def check_tag_layout(name, well_range, expected_wells_to_oligos) # rubocop:todo Metrics/MethodLength - plate = Plate.find_by(name: name) or raise StandardError, "Cannot find plate #{name.inspect}" + plate = Plate.find_by(name:) or raise StandardError, "Cannot find plate #{name.inspect}" wells_to_oligos = plate .wells @@ -70,7 +70,7 @@ def check_tag_layout(name, well_range, expected_wells_to_oligos) # rubocop:todo end end def check_tag2_layout(name, well_range, expected_wells_to_oligos) # rubocop:todo Metrics/MethodLength - plate = Plate.find_by(name: name) or raise StandardError, "Cannot find plate #{name.inspect}" + plate = Plate.find_by(name:) or raise StandardError, "Cannot find plate #{name.inspect}" wells_to_oligos = plate .wells @@ -126,11 +126,11 @@ def pool_by_strategy(source, destination, pooling_strategy) # rubocop:todo Metri wells_for_source .zip(wells_for_destination) .each do |w| - TransferRequest.create!(asset: w.first, target_asset: w.last, submission_id: submission_id) + TransferRequest.create!(asset: w.first, target_asset: w.last, submission_id:) FactoryBot.create :request_without_submission, asset: w.first, target_asset: w.last, - submission_id: submission_id + submission_id: end end end @@ -149,7 +149,7 @@ def pool_by_strategy(source, destination, pooling_strategy) # rubocop:todo Metri end Given /^the tag group "(.*?)" exists$/ do |name| - TagGroup.create!(name: name) + TagGroup.create!(name:) end Given /^the tag group "(.*?)" has (\d+) tags$/ do |group, count| diff --git a/features/support/step_definitions/transfer_steps.rb b/features/support/step_definitions/transfer_steps.rb index 28d588c6a8..b27533da51 100644 --- a/features/support/step_definitions/transfer_steps.rb +++ b/features/support/step_definitions/transfer_steps.rb @@ -13,7 +13,7 @@ def transfer_model(name) end Given /^the transfer (between plates|from plate to tube) exists with ID (\d+)$/ do |name, id| - FactoryBot.create(:"transfer_#{name.gsub(/\s+/, '_')}", id: id) + FactoryBot.create(:"transfer_#{name.gsub(/\s+/, '_')}", id:) end # rubocop:todo Layout/LineLength @@ -23,7 +23,7 @@ def transfer_model(name) end Given /^the ((?:pooling ||multiplex )?transfer template) called "([^"]+)" exists$/ do |type, name| - FactoryBot.create(type.gsub(/\s/, '_').to_sym, name: name) + FactoryBot.create(type.gsub(/\s/, '_').to_sym, name:) end Then 'the transfers from {plate_name} to {plate_name} should be:' do |source, destination, table| @@ -42,16 +42,16 @@ def transfer_model(name) end Given /^a transfer plate exists with ID (\d+)$/ do |id| - FactoryBot.create(:transfer_plate, id: id) + FactoryBot.create(:transfer_plate, id:) end Given /^a transfer plate called "([^"]+)" exists$/ do |name| - FactoryBot.create(:transfer_plate, name: name) + FactoryBot.create(:transfer_plate, name:) end Given /^the plate "(.*?)" has additional wells$/ do |name| Plate - .find_by(name: name) + .find_by(name:) .tap do |plate| plate.wells << %w[C1 D1].map do |location| map = @@ -60,19 +60,19 @@ def transfer_model(name) .where_plate_size(plate.size) .where_plate_shape(AssetShape.find_by(name: 'Standard')) .first or raise StandardError, "No location #{location} on plate #{plate.inspect}" - FactoryBot.create(:tagged_well, map: map) + FactoryBot.create(:tagged_well, map:) end end end Given /^a transfer plate called "([^"]+)" exists as a child of "([^"]+)"$/ do |name, parent| parent_plate = Plate.find_by!(name: parent) - AssetLink.create!(ancestor: parent_plate, descendant: FactoryBot.create(:transfer_plate, name: name)) + AssetLink.create!(ancestor: parent_plate, descendant: FactoryBot.create(:transfer_plate, name:)) end Given(/^a transfer plate called "([^"]*)" exists as a child of plate (\d+)$/) do |name, parent_id| parent_plate = Plate.find(parent_id) - AssetLink.create!(ancestor: parent_plate, descendant: FactoryBot.create(:transfer_plate, name: name)) + AssetLink.create!(ancestor: parent_plate, descendant: FactoryBot.create(:transfer_plate, name:)) end # rubocop:todo Layout/LineLength @@ -83,7 +83,7 @@ def transfer_model(name) source = Plate.find_by(name: source_name) or raise StandardError, "Could not find source plate #{source_name.inspect}" destination = Plate.find_by(name: destination_name) or raise StandardError, "Could not find destination plate #{destination_plate.inspect}" - template.create!(source: source, destination: destination, user: FactoryBot.create(:user)) + template.create!(source:, destination:, user: FactoryBot.create(:user)) end def assert_request_state(state, targets, direction, request_class) @@ -99,7 +99,7 @@ def change_request_state(state, targets, direction, request_class) association = direction == 'to' ? :requests_as_target : :requests_as_source Request.where( id: Array(targets).map(&association).flatten.select { |r| r.is_a?(request_class) }.map(&:id) - ).update_all(state: state) + ).update_all(state:) end # rubocop:todo Layout/LineLength @@ -162,6 +162,6 @@ def change_request_state(state, targets, direction, request_class) plate.wells.includes(:aliquots).find_each { |w| w.aliquots.each { |a| assert_equal study.id, a.study_id } } end Given '{asset_name} is a {string}' do |plate, name| - plate_purpose = Purpose.find_by!(name: name) - plate.update!(plate_purpose: plate_purpose) + plate_purpose = Purpose.find_by!(name:) + plate.update!(plate_purpose:) end diff --git a/features/support/step_definitions/tube_steps.rb b/features/support/step_definitions/tube_steps.rb index 6ee3304a57..7ce48251df 100644 --- a/features/support/step_definitions/tube_steps.rb +++ b/features/support/step_definitions/tube_steps.rb @@ -2,5 +2,5 @@ Given /^a "([^"]*)" tube called "([^"]*)" exists$/ do |tube_purpose, tube_name| purpose = Tube::Purpose.find_by!(name: tube_purpose) - test = purpose.target_type.constantize.create!(name: tube_name, purpose: purpose) + test = purpose.target_type.constantize.create!(name: tube_name, purpose:) end diff --git a/features/support/step_definitions/user_steps.rb b/features/support/step_definitions/user_steps.rb index 108e3c275b..8b3f9dbf07 100644 --- a/features/support/step_definitions/user_steps.rb +++ b/features/support/step_definitions/user_steps.rb @@ -5,7 +5,7 @@ end Given /^a user with an api key of "([^"]*)" exists$/ do |api_key| - @current_user = FactoryBot.create :user, api_key: api_key + @current_user = FactoryBot.create :user, api_key: end Given /^I have an active project called "([^"]*)"$/ do |project_name| @@ -24,14 +24,14 @@ Given /^user "([^"]*)" exists with barcode "([^"]*)"$/ do |user_name, barcode| if User.find_by(login: user_name) - User.find_by(login: user_name).update!(barcode: barcode) + User.find_by(login: user_name).update!(barcode:) else - FactoryBot.create :user, barcode: barcode, login: user_name + FactoryBot.create :user, barcode:, login: user_name end end Given /^the user with login "([^"]+)" exists$/ do |login| - User.find_by(login: login) || FactoryBot.create(:user, login: login) + User.find_by(login:) || FactoryBot.create(:user, login:) end Then /^the user (\d+) should validate the swipecard code "([^"]+)"/ do |user_id, code| diff --git a/features/support/step_definitions/uuid_steps.rb b/features/support/step_definitions/uuid_steps.rb index 69d0136545..5aa850b2f7 100644 --- a/features/support/step_definitions/uuid_steps.rb +++ b/features/support/step_definitions/uuid_steps.rb @@ -57,7 +57,7 @@ def set_uuid_for(object, uuid_value) # rubocop:todo Layout/LineLength Given /^the UUID for the (#{SINGULAR_MODELS_BASED_ON_NAME_REGEXP}) "([^"]+)" is "([^"]+)"$/o do |model, name, uuid_value| # rubocop:enable Layout/LineLength - object = model.gsub(/\s+/, '_').classify.constantize.find_by(name: name) or + object = model.gsub(/\s+/, '_').classify.constantize.find_by(name:) or raise "Cannot find #{model} #{name.inspect}" set_uuid_for(object, uuid_value) end @@ -67,7 +67,7 @@ def set_uuid_for(object, uuid_value) # rubocop:todo Layout/LineLength Given /^the UUID for the receptacle in (#{SINGULAR_MODELS_BASED_ON_NAME_REGEXP}) "([^"]+)" is "([^"]+)"$/o do |model, name, uuid_value| # rubocop:enable Layout/LineLength - object = model.gsub(/\s+/, '_').classify.constantize.find_by(name: name) or + object = model.gsub(/\s+/, '_').classify.constantize.find_by(name:) or raise "Cannot find #{model} #{name.inspect}" set_uuid_for(object.receptacle, uuid_value) end @@ -75,15 +75,15 @@ def set_uuid_for(object, uuid_value) # rubocop:todo Layout/LineLength Given /^an? (#{SINGULAR_MODELS_BASED_ON_NAME_REGEXP}) called "([^"]+)" with UUID "([^"]+)"$/o do |model, name, uuid_value| # rubocop:enable Layout/LineLength - set_uuid_for(FactoryBot.create(model.gsub(/\s+/, '_').to_sym, name: name), uuid_value) + set_uuid_for(FactoryBot.create(model.gsub(/\s+/, '_').to_sym, name:), uuid_value) end Given /^a tube purpose called "([^"]+)" with UUID "([^"]+)"$/ do |name, uuid_value| - set_uuid_for(FactoryBot.create(:tube_purpose, name: name), uuid_value) + set_uuid_for(FactoryBot.create(:tube_purpose, name:), uuid_value) end Given /^an? (#{SINGULAR_MODELS_BASED_ON_NAME_REGEXP}) called "([^"]+)" with ID (\d+)$/o do |model, name, id| - FactoryBot.create(model.gsub(/\s+/, '_').to_sym, name: name, id: id) + FactoryBot.create(model.gsub(/\s+/, '_').to_sym, name:, id:) end # rubocop:todo Layout/LineLength @@ -225,7 +225,7 @@ def set_uuid_for(object, uuid_value) end Given /^the (#{SINGULAR_MODELS_BASED_ON_ID_REGEXP}) exists with ID (\d+)$/o do |model, id| - FactoryBot.create(model.gsub(/\s+/, '_').to_sym, id: id) + FactoryBot.create(model.gsub(/\s+/, '_').to_sym, id:) end # rubocop:todo Layout/LineLength diff --git a/features/support/step_definitions/various_object_construction_steps.rb b/features/support/step_definitions/various_object_construction_steps.rb index 47788fb49d..c926830224 100644 --- a/features/support/step_definitions/various_object_construction_steps.rb +++ b/features/support/step_definitions/various_object_construction_steps.rb @@ -3,9 +3,9 @@ # rubocop:todo Layout/LineLength Given /^(?:a|the) (project|study|sample|sample tube|library tube|plate|pulldown multiplexed library tube|multiplexed library tube|faculty sponsor) (?:named|called) "([^"]+)" exists$/ do |type, name| # rubocop:enable Layout/LineLength - FactoryBot.create(type.gsub(/[^a-z0-9]+/, '_').to_sym, name: name) + FactoryBot.create(type.gsub(/[^a-z0-9]+/, '_').to_sym, name:) end Given /^(?:a|the) lane (?:named|called) "([^"]+)" exists$/ do |name| - FactoryBot.create(:lane, name: name) + FactoryBot.create(:lane, name:) end diff --git a/features/support/step_definitions/web_steps.rb b/features/support/step_definitions/web_steps.rb index e71501cd4a..455722d372 100644 --- a/features/support/step_definitions/web_steps.rb +++ b/features/support/step_definitions/web_steps.rb @@ -75,7 +75,7 @@ def with_scope(locator) When /^(?:|I )check (the invisible )?"([^"]*)"(?: within "([^"]*)")?$/ do |invisible, field, selector| visible = invisible != 'the invisible ' - with_scope(selector) { check(field, visible: visible) } + with_scope(selector) { check(field, visible:) } end When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector| @@ -161,15 +161,15 @@ def with_scope(locator) stub_request(:get, "#{LabelPrinter::PmbClient.label_templates_filter_url}sqsc_96plate_label_template").with( headers: LabelPrinter::PmbClient.headers - ).to_return(status: 200, body: body) + ).to_return(status: 200, body:) stub_request(:get, "#{LabelPrinter::PmbClient.label_templates_filter_url}tube_label_template_1d").with( headers: LabelPrinter::PmbClient.headers - ).to_return(status: 200, body: body) + ).to_return(status: 200, body:) stub_request(:get, "#{LabelPrinter::PmbClient.label_templates_filter_url}sqsc_384plate_label_template").with( headers: LabelPrinter::PmbClient.headers - ).to_return(status: 200, body: body) + ).to_return(status: 200, body:) end Then /^Pmb is up and running$/ do @@ -180,5 +180,5 @@ def with_scope(locator) end When 'I click the header {string}' do |text| - find('th', text: text).click + find('th', text:).click end diff --git a/lib/ability_analysis.rb b/lib/ability_analysis.rb index fa80b1c729..8043e53c1d 100644 --- a/lib/ability_analysis.rb +++ b/lib/ability_analysis.rb @@ -73,7 +73,7 @@ def initialize(permissions: BASE_ABILITIES, roles: Role.keys, ability: Ability) end def generate_spec(output = $stdout) - AbilityAnalysis::SpecGenerator.new(self, output: output).generate + AbilityAnalysis::SpecGenerator.new(self, output:).generate end def abilities_for(user) diff --git a/lib/ability_analysis/spec_generator.rb b/lib/ability_analysis/spec_generator.rb index f1c189180d..4bd3400072 100644 --- a/lib/ability_analysis/spec_generator.rb +++ b/lib/ability_analysis/spec_generator.rb @@ -42,12 +42,12 @@ def generate # rubocop:todo Metrics/MethodLength private def generate_permissions_list(name, permissions_to_list, indent: 2) - output "let(:#{name}) do", indent: indent + output("let(:#{name}) do", indent:) output '{', indent: indent + 2 list = permissions_to_list.map { |klass, permissions| "#{klass} => %i[#{permissions.join(' ')}]" }.join(",\n") output list, indent: indent + 4 output '}', indent: indent + 2 - output 'end', indent: indent + output 'end', indent: end def generate_shared_example @@ -107,7 +107,7 @@ def generate_for(role) generate_authorized_models(role) output user = user_with_roles(role) - generate_tests(user, role: role) + generate_tests(user, role:) output 'end', indent: 2 end diff --git a/lib/accession/accession/contact.rb b/lib/accession/accession/contact.rb index 107bad8e2c..44109f1f23 100644 --- a/lib/accession/accession/contact.rb +++ b/lib/accession/accession/contact.rb @@ -19,7 +19,7 @@ def email end def to_h - { inform_on_error: email, inform_on_status: email, name: name } + { inform_on_error: email, inform_on_status: email, name: } end end end diff --git a/lib/acts_as_descriptable.rb b/lib/acts_as_descriptable.rb index 2725d22901..644b006e1a 100644 --- a/lib/acts_as_descriptable.rb +++ b/lib/acts_as_descriptable.rb @@ -34,7 +34,7 @@ def self.included(base) end def descriptors - descriptor_hash.map { |field, value| Descriptor.new(name: field, value: value) } + descriptor_hash.map { |field, value| Descriptor.new(name: field, value:) } end def descriptor_value(key) diff --git a/lib/event_factory.rb b/lib/event_factory.rb index 4c443eccfe..aacb070694 100644 --- a/lib/event_factory.rb +++ b/lib/event_factory.rb @@ -16,7 +16,7 @@ def self.new_project(project, user) eventful_type: 'Project', message: 'Project registered', created_by: user.login, - content: content, + content:, of_interest_to: 'administrators' ) event.save @@ -33,7 +33,7 @@ def self.project_approved(project, user) eventful_type: 'Project', message: 'Project approved', created_by: user.login, - content: content, + content:, of_interest_to: 'administrators' ) event.save @@ -48,7 +48,7 @@ def self.project_refund_request(project, user, reference) eventful_type: 'Project', message: "Refund #{reference}", created_by: user.login, - content: content, + content:, of_interest_to: 'administrators' ) event.save @@ -73,7 +73,7 @@ def self.request_update_note_to_manager(request, user, message) # rubocop:todo M eventful_type: 'Request', message: 'Request update(s) failed', created_by: user.login, - content: content, + content:, of_interest_to: 'manager' ) diff --git a/lib/insdc/import_countries.rb b/lib/insdc/import_countries.rb index db86dc4efe..e218162f7d 100644 --- a/lib/insdc/import_countries.rb +++ b/lib/insdc/import_countries.rb @@ -35,7 +35,7 @@ def import private def generate_countries(pending_countries) - Insdc::Country.import(pending_countries.map { |name| { name: name, sort_priority: priority_for(name) } }) + Insdc::Country.import(pending_countries.map { |name| { name:, sort_priority: priority_for(name) } }) end def priority_for(name) diff --git a/lib/lab_where_client.rb b/lib/lab_where_client.rb index d34683d23b..774d3278f2 100644 --- a/lib/lab_where_client.rb +++ b/lib/lab_where_client.rb @@ -113,7 +113,7 @@ class LabwareSearch < Endpoint def self.find_locations_by_barcodes(barcodes) return nil if barcodes.blank? - payload = { barcodes: barcodes } + payload = { barcodes: } attrs = LabWhere.new.post(self, '', payload) new(attrs) unless attrs.nil? diff --git a/lib/label_printer/label_printer/label/base_plate.rb b/lib/label_printer/label_printer/label/base_plate.rb index bc19fef959..d97af71f3f 100644 --- a/lib/label_printer/label_printer/label/base_plate.rb +++ b/lib/label_printer/label_printer/label/base_plate.rb @@ -6,7 +6,7 @@ class BasePlate def build_label(plate) { - top_left: top_left, + top_left:, bottom_left: bottom_left(plate), top_right: top_right(plate), bottom_right: bottom_right(plate), diff --git a/lib/label_printer/label_printer/pmb_client.rb b/lib/label_printer/label_printer/pmb_client.rb index 6f0032d0a3..80f0a3215d 100644 --- a/lib/label_printer/label_printer/pmb_client.rb +++ b/lib/label_printer/label_printer/pmb_client.rb @@ -92,7 +92,7 @@ def self.prettify_new_errors(errors) [].tap do |error_list| errors.each do |error| attribute = error['source']['pointer'].split('/').last.humanize - error_list << ('%{attribute} %{message}' % { attribute: attribute, message: error['detail'] }) + error_list << ('%{attribute} %{message}' % { attribute:, message: error['detail'] }) end end .join('; ') diff --git a/lib/label_printer/label_printer/print_job.rb b/lib/label_printer/label_printer/print_job.rb index 1f55858bd9..6e6d873306 100644 --- a/lib/label_printer/label_printer/print_job.rb +++ b/lib/label_printer/label_printer/print_job.rb @@ -32,8 +32,8 @@ def execute # rubocop:todo Metrics/MethodLength def build_attributes @build_attributes ||= { - printer_name: printer_name, - label_template_name: label_template_name, + printer_name:, + label_template_name:, labels: labels_attribute } end diff --git a/lib/limber/helper.rb b/lib/limber/helper.rb index f8fd60aa9a..51b8a20135 100644 --- a/lib/limber/helper.rb +++ b/lib/limber/helper.rb @@ -39,7 +39,7 @@ class TemplateConstructor # # @return [Array] An array of all matching submission templates. def self.find_for(name, sequencing = nil) - tc = TemplateConstructor.new(name: name, sequencing: sequencing) + tc = TemplateConstructor.new(name:, sequencing:) [true, false].map do |cherrypick| tc.sequencing.map do |sequencing_request_type| SubmissionTemplate.find_by!(name: tc.name_for(cherrypick, sequencing_request_type)) @@ -187,7 +187,7 @@ def each_submission_template def submission_parameters(cherrypick, sequencing) { request_type_ids_list: request_type_ids(cherrypick, sequencing), - order_role_id: OrderRole.find_or_create_by(role: role).id + order_role_id: OrderRole.find_or_create_by(role:).id } end end @@ -237,10 +237,10 @@ def request_type_ids(cherrypick, _sequencing) def self.find_project(name) if Rails.env.production? - Project.find_by!(name: name) + Project.find_by!(name:) else # In development mode or UAT we don't care so much - Project.find_by(name: name) || UatActions::StaticRecords.project + Project.find_by(name:) || UatActions::StaticRecords.project end end end diff --git a/lib/mbrave_tags_creator.rb b/lib/mbrave_tags_creator.rb index 09d9328cd8..a1c3cda285 100644 --- a/lib/mbrave_tags_creator.rb +++ b/lib/mbrave_tags_creator.rb @@ -129,7 +129,7 @@ def _validate_reverse_row(row) def _create_tag_group(tag_group_name, tags) raise "TagGroup #{tag_group_name} already exists" if TagGroup.find_by(name: tag_group_name) - TagGroup.create(name: tag_group_name, tags: tags) + TagGroup.create(name: tag_group_name, tags:) end def _add_to_yaml(_yaml_filename, tag_group_name, mbrave_tags, version, num_plate) @@ -157,13 +157,13 @@ def create_tag_plates(tag_layout_templates, user) # rubocop:todo Metrics/MethodL lot_type.lots.create!( lot_number: "PSD_#{Time.current.to_f}", template: tag_layout_template, - user: user, + user:, received_at: Time.current ) text_code = text_code_for_tag_layout(tag_layout_template) plate_barcode = PlateBarcode.create_barcode_with_text(text_code) # barcode object - qcc = QcableCreator.create!(lot: lot, user: user, supplied_barcode: plate_barcode) + qcc = QcableCreator.create!(lot:, user:, supplied_barcode: plate_barcode) qcc.qcables.each_with_index do |qcable, _index| qcable.update!(state: 'available') log_line { "#{tag_layout_template.name}:" } @@ -176,7 +176,7 @@ def create_tag_plates(tag_layout_templates, user) # rubocop:todo Metrics/MethodL # rubocop:enable Metrics/AbcSize def process_create_tag_plates(login, version) - user = User.find_by!(login: login) + user = User.find_by!(login:) tag_layout_templates = TagLayoutTemplate.select do |template| @@ -190,10 +190,10 @@ def process_create_tag_groups(forward_filename, reverse_filename, version) ActiveRecord::Base.transaction do mbrave_tags_creator = MbraveTagsCreator.new( - forward_filename: forward_filename, - reverse_filename: reverse_filename, + forward_filename:, + reverse_filename:, tag_identifier: MbraveTagsCreator::TAG_IDENTIFIER, - version: version, + version:, yaml_filename: MbraveTagsCreator::YAML_FILENAME ) diff --git a/lib/object_space_profile.rb b/lib/object_space_profile.rb index 85ed2f7377..ded7b8bda0 100644 --- a/lib/object_space_profile.rb +++ b/lib/object_space_profile.rb @@ -41,7 +41,7 @@ def measure(garbage_collect = true) # Export the collected information to the csv file named filename # @param [String] filename The csv file to generate (In the application base directory) def report(filename) - CSV.open(filename, 'wb', headers: headers, write_headers: true) do |csv| + CSV.open(filename, 'wb', headers:, write_headers: true) do |csv| @data.each_with_index { |data, index| csv << data.merge({ 'Iteration' => index }) } end end diff --git a/lib/product_helpers.rb b/lib/product_helpers.rb index 5c6be42db6..35188bc096 100644 --- a/lib/product_helpers.rb +++ b/lib/product_helpers.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true module ProductHelpers def self.single_template(name) - { name: name, selection_behaviour: 'SingleProduct', products: { nil => name } } + { name:, selection_behaviour: 'SingleProduct', products: { nil => name } } end end diff --git a/lib/record_loader/asset_shape_loader.rb b/lib/record_loader/asset_shape_loader.rb index e1fe8a8449..ccb582da5b 100644 --- a/lib/record_loader/asset_shape_loader.rb +++ b/lib/record_loader/asset_shape_loader.rb @@ -20,7 +20,7 @@ class AssetShapeLoader < ApplicationRecordLoader # @option options [String] :description_strategy The strategy for describing the plate # @option options [Array] :sizes The sizes of the plates to generate Maps for def create_or_update!(name, options) - config = { name: name }.merge(options.symbolize_keys) + config = { name: }.merge(options.symbolize_keys) # PlateMapGeneration expects a non-namespaced constant for # description_strategy. It adds "Map::" prefix to refer to a nested diff --git a/lib/record_loader/barcode_printer_type_loader.rb b/lib/record_loader/barcode_printer_type_loader.rb index 9f8e876b1b..2a2b8d50ba 100644 --- a/lib/record_loader/barcode_printer_type_loader.rb +++ b/lib/record_loader/barcode_printer_type_loader.rb @@ -11,7 +11,7 @@ class BarcodePrinterTypeLoader < ApplicationRecordLoader config_folder 'barcode_printer_types' def create_or_update!(name, options) - BarcodePrinterType.create_with(options).find_or_create_by!(name: name) + BarcodePrinterType.create_with(options).find_or_create_by!(name:) end end end diff --git a/lib/record_loader/flowcell_type_loader.rb b/lib/record_loader/flowcell_type_loader.rb index fe6143beca..598d026830 100644 --- a/lib/record_loader/flowcell_type_loader.rb +++ b/lib/record_loader/flowcell_type_loader.rb @@ -10,7 +10,7 @@ class FlowcellTypeLoader < ApplicationRecordLoader config_folder 'flowcell_types' def create_or_update!(name, options) - FlowcellType.create_with(options).find_or_create_by!(name: name) + FlowcellType.create_with(options).find_or_create_by!(name:) end end end diff --git a/lib/record_loader/library_type_loader.rb b/lib/record_loader/library_type_loader.rb index 4818743062..def91ef0c2 100644 --- a/lib/record_loader/library_type_loader.rb +++ b/lib/record_loader/library_type_loader.rb @@ -10,7 +10,7 @@ class LibraryTypeLoader < ApplicationRecordLoader config_folder 'library_types' def create_or_update!(name, options) - LibraryType.create_with(options).find_or_create_by!(name: name) + LibraryType.create_with(options).find_or_create_by!(name:) end def names diff --git a/lib/record_loader/pipeline_loader.rb b/lib/record_loader/pipeline_loader.rb index e74f78f56b..a04859260e 100644 --- a/lib/record_loader/pipeline_loader.rb +++ b/lib/record_loader/pipeline_loader.rb @@ -20,13 +20,13 @@ def add_spiked_in_control_event(workflow) name: 'Add Spiked in control', sorted: 0, lab_activity: true, - workflow: workflow + workflow: ).find_or_create_by!(pipeline_workflow_id: workflow.pipeline_id) end def add_loading_event(workflow) SetDescriptorsTask - .create_with(name: 'Loading', sorted: 1, lab_activity: true, workflow: workflow) + .create_with(name: 'Loading', sorted: 1, lab_activity: true, workflow:) .find_or_create_by!(pipeline_workflow_id: workflow.pipeline_id) do |task| task.descriptors.build( [ @@ -49,7 +49,7 @@ def create_or_update!(name, options) request_type_keys = obj.delete('request_type_keys') raise 'Request type keys not found' if request_type_keys.blank? request_types = RequestType.where(key: request_type_keys) - Pipeline.create_with(obj.merge(workflow: wf, request_types: request_types)).find_or_create_by!(name: name) + Pipeline.create_with(obj.merge(workflow: wf, request_types:)).find_or_create_by!(name:) return unless name == 'NovaSeqX PE' diff --git a/lib/record_loader/pipeline_request_information_type_loader.rb b/lib/record_loader/pipeline_request_information_type_loader.rb index 99b4837037..c5dee02e29 100644 --- a/lib/record_loader/pipeline_request_information_type_loader.rb +++ b/lib/record_loader/pipeline_request_information_type_loader.rb @@ -14,9 +14,9 @@ def create_or_update!(_name, options) pipeline = Pipeline.find_by!(name: options['pipeline_name']) req_inf_type = RequestInformationType.find_by!(key: options['request_information_type_key']) PipelineRequestInformationType.create_with( - pipeline: pipeline, + pipeline:, request_information_type: req_inf_type - ).find_or_create_by!(pipeline: pipeline, request_information_type: req_inf_type) + ).find_or_create_by!(pipeline:, request_information_type: req_inf_type) end end end diff --git a/lib/record_loader/plate_type_loader.rb b/lib/record_loader/plate_type_loader.rb index 94142d9c9a..00b347d829 100644 --- a/lib/record_loader/plate_type_loader.rb +++ b/lib/record_loader/plate_type_loader.rb @@ -11,7 +11,7 @@ class PlateTypeLoader < ApplicationRecordLoader config_folder 'plate_types' def create_or_update!(name, options) - PlateType.create_with(options).find_or_create_by!(name: name) + PlateType.create_with(options).find_or_create_by!(name:) end end end diff --git a/lib/record_loader/primer_panel_loader.rb b/lib/record_loader/primer_panel_loader.rb index 646ccdb4b2..e16a340bc6 100644 --- a/lib/record_loader/primer_panel_loader.rb +++ b/lib/record_loader/primer_panel_loader.rb @@ -11,7 +11,7 @@ class PrimerPanelLoader < ApplicationRecordLoader config_folder 'primer_panels' def create_or_update!(name, options) - PrimerPanel.create_with(options).find_or_create_by!(name: name) + PrimerPanel.create_with(options).find_or_create_by!(name:) end end end diff --git a/lib/record_loader/product_catalogue_loader.rb b/lib/record_loader/product_catalogue_loader.rb index 087a8c7993..a403bad828 100644 --- a/lib/record_loader/product_catalogue_loader.rb +++ b/lib/record_loader/product_catalogue_loader.rb @@ -10,7 +10,7 @@ class ProductCatalogueLoader < ApplicationRecordLoader config_folder 'product_catalogues' def create_or_update!(name, options) - ProductCatalogue.create_with(options).find_or_create_by!(name: name) + ProductCatalogue.create_with(options).find_or_create_by!(name:) end end end diff --git a/lib/record_loader/request_information_type_loader.rb b/lib/record_loader/request_information_type_loader.rb index ab7a314090..dbe80126a8 100644 --- a/lib/record_loader/request_information_type_loader.rb +++ b/lib/record_loader/request_information_type_loader.rb @@ -10,7 +10,7 @@ class RequestInformationTypeLoader < ApplicationRecordLoader config_folder 'request_information_types' def create_or_update!(key, options) - RequestInformationType.create_with(options).find_or_create_by!(key: key) + RequestInformationType.create_with(options).find_or_create_by!(key:) end end end diff --git a/lib/record_loader/request_type_loader.rb b/lib/record_loader/request_type_loader.rb index 07417756cc..637b690bf0 100644 --- a/lib/record_loader/request_type_loader.rb +++ b/lib/record_loader/request_type_loader.rb @@ -12,7 +12,7 @@ class RequestTypeLoader < ApplicationRecordLoader def create_or_update!(key, options) RequestType .create_with(filter_options(options)) - .find_or_create_by!(key: key) + .find_or_create_by!(key:) .tap do |request_type| add_library_types(request_type, options.fetch('library_types', [])) add_acceptable_purposes(request_type, options.fetch('acceptable_purposes', [])) @@ -26,7 +26,7 @@ def create_or_update!(key, options) def add_library_types(request_type, library_types) rt_lts = request_type.library_types.pluck(:name) library_types.each do |name| - request_type.library_types << LibraryType.find_or_create_by!(name: name) unless rt_lts.include?(name) + request_type.library_types << LibraryType.find_or_create_by!(name:) unless rt_lts.include?(name) end return if library_types.empty? || request_type.request_type_validators.exists?(request_option: 'library_type') @@ -39,13 +39,13 @@ def add_acceptable_purposes(request_type, purposes) purposes.each do |name| next if acceptable_purposes.include?(name) - request_type.acceptable_purposes << Purpose.find_by!(name: name) + request_type.acceptable_purposes << Purpose.find_by!(name:) end end def add_library_type_validator(request_type) RequestType::Validator.create!( - request_type: request_type, + request_type:, request_option: 'library_type', valid_options: RequestType::Validator::LibraryTypeValidator.new(request_type.id) ) diff --git a/lib/record_loader/request_type_validators_loader.rb b/lib/record_loader/request_type_validators_loader.rb index b23a6386a7..5ea0f2410e 100644 --- a/lib/record_loader/request_type_validators_loader.rb +++ b/lib/record_loader/request_type_validators_loader.rb @@ -12,7 +12,7 @@ class RequestTypeValidatorsLoader < ApplicationRecordLoader def create_or_update!(key, options) request_type_key = options.delete('request_type_key') rt = RequestType.find_by(key: request_type_key) - RequestType::Validator.create_with(options.merge(request_type_id: rt.id)).find_or_create_by!(key: key) + RequestType::Validator.create_with(options.merge(request_type_id: rt.id)).find_or_create_by!(key:) end end end diff --git a/lib/record_loader/robot_loader.rb b/lib/record_loader/robot_loader.rb index c2ea96d09b..97edb797e1 100644 --- a/lib/record_loader/robot_loader.rb +++ b/lib/record_loader/robot_loader.rb @@ -9,7 +9,7 @@ class RobotLoader < ApplicationRecordLoader config_folder 'robots' def create_or_update!(name, options) - Robot.create_with(options).find_or_create_by!(name: name) + Robot.create_with(options).find_or_create_by!(name:) end end end diff --git a/lib/record_loader/robot_property_loader.rb b/lib/record_loader/robot_property_loader.rb index db7890d68e..ac88c8fd25 100644 --- a/lib/record_loader/robot_property_loader.rb +++ b/lib/record_loader/robot_property_loader.rb @@ -10,7 +10,7 @@ class RobotPropertyLoader < ApplicationRecordLoader def create_or_update!(name, options) # find the robot by name - r = Robot.find_by(name: name) + r = Robot.find_by(name:) return if r.blank? # find or create each property diff --git a/lib/record_loader/submission_template_loader.rb b/lib/record_loader/submission_template_loader.rb index 340f840352..6fcf21241f 100644 --- a/lib/record_loader/submission_template_loader.rb +++ b/lib/record_loader/submission_template_loader.rb @@ -13,7 +13,7 @@ def create_or_update!(name, options) derived_options = generate_derived_options(options['related_records']) final_options = options.except('related_records').merge(derived_options) - SubmissionTemplate.create_with(final_options).find_or_create_by!(name: name) + SubmissionTemplate.create_with(final_options).find_or_create_by!(name:) end def generate_derived_options(related_records) @@ -43,19 +43,19 @@ def sort_request_type_ids(request_type_keys) def find_project(name) if Rails.env.production? - Project.find_by!(name: name) + Project.find_by!(name:) else # In development mode or UAT we don't care so much - Project.find_by(name: name) || UatActions::StaticRecords.project + Project.find_by(name:) || UatActions::StaticRecords.project end end def find_study(name) if Rails.env.production? - Study.find_by!(name: name) + Study.find_by!(name:) else # In development mode or UAT we don't care so much - Study.find_by(name: name) || UatActions::StaticRecords.study + Study.find_by(name:) || UatActions::StaticRecords.study end end end diff --git a/lib/record_loader/tag_group_adapter_type_loader.rb b/lib/record_loader/tag_group_adapter_type_loader.rb index 14799d0aef..f513c3256b 100644 --- a/lib/record_loader/tag_group_adapter_type_loader.rb +++ b/lib/record_loader/tag_group_adapter_type_loader.rb @@ -11,7 +11,7 @@ class TagGroupAdapterTypeLoader < ApplicationRecordLoader config_folder 'tag_group_adapter_types' def create_or_update!(name, _options) - TagGroup::AdapterType.find_or_create_by!(name: name) + TagGroup::AdapterType.find_or_create_by!(name:) end end end diff --git a/lib/record_loader/tag_group_loader.rb b/lib/record_loader/tag_group_loader.rb index 736ab36df6..72cca14402 100644 --- a/lib/record_loader/tag_group_loader.rb +++ b/lib/record_loader/tag_group_loader.rb @@ -15,9 +15,9 @@ def create_or_update!(name, options) TagGroup .create_with(options) - .find_or_create_by!(name: name) + .find_or_create_by!(name:) .tap do |tag_group| - tag_attributes = tags.map { |map_id, oligo| { map_id: map_id, oligo: oligo } } + tag_attributes = tags.map { |map_id, oligo| { map_id:, oligo: } } tag_group.tags.import(tag_attributes) if tag_group.tags.empty? end end diff --git a/lib/record_loader/tag_layout_templates_loader.rb b/lib/record_loader/tag_layout_templates_loader.rb index eab58d488d..9aa7248c82 100644 --- a/lib/record_loader/tag_layout_templates_loader.rb +++ b/lib/record_loader/tag_layout_templates_loader.rb @@ -11,7 +11,7 @@ class TagLayoutTemplatesLoader < ApplicationRecordLoader config_folder 'tag_layout_templates' def create_or_update!(name, options) - TagLayoutTemplate.create_with(options).find_or_create_by!(name: name) + TagLayoutTemplate.create_with(options).find_or_create_by!(name:) end end end diff --git a/lib/record_loader/tag_set_loader.rb b/lib/record_loader/tag_set_loader.rb index 010c8bf68f..29f0aeb04a 100644 --- a/lib/record_loader/tag_set_loader.rb +++ b/lib/record_loader/tag_set_loader.rb @@ -11,7 +11,7 @@ class TagSetLoader < ApplicationRecordLoader config_folder 'tag_sets' def create_or_update!(name, options) - TagSet.create_with(options).find_or_create_by!(name: name) + TagSet.create_with(options).find_or_create_by!(name:) end end end diff --git a/lib/record_loader/transfer_template_loader.rb b/lib/record_loader/transfer_template_loader.rb index e8935e9de0..5638eea8cb 100644 --- a/lib/record_loader/transfer_template_loader.rb +++ b/lib/record_loader/transfer_template_loader.rb @@ -13,7 +13,7 @@ def create_or_update!(name, options) # TransferTemplate.create_with(options).find_or_create_by!(name: name) # We use the following because it creates a new record or updates existing. - transfer_template = TransferTemplate.find_or_initialize_by(name: name) + transfer_template = TransferTemplate.find_or_initialize_by(name:) transfer_template.update!(options) # assign_attributes and save! end end diff --git a/lib/record_loader/tube_purpose_loader.rb b/lib/record_loader/tube_purpose_loader.rb index dc4ab8dbab..927b2f6a1f 100644 --- a/lib/record_loader/tube_purpose_loader.rb +++ b/lib/record_loader/tube_purpose_loader.rb @@ -11,7 +11,7 @@ class TubePurposeLoader < ApplicationRecordLoader config_folder 'tube_purposes' def create_or_update!(name, options) - Tube::Purpose.create_with(options).find_or_create_by!(name: name) + Tube::Purpose.create_with(options).find_or_create_by!(name:) end end end diff --git a/lib/record_loader/tube_rack_purpose_loader.rb b/lib/record_loader/tube_rack_purpose_loader.rb index 642d156e4f..e1c2e2e13d 100644 --- a/lib/record_loader/tube_rack_purpose_loader.rb +++ b/lib/record_loader/tube_rack_purpose_loader.rb @@ -15,7 +15,7 @@ class TubeRackPurposeLoader < ApplicationRecordLoader def create_or_update!(name, options) options['target_type'] = DEFAULT_TARGET_TYPE options['barcode_printer_type'] = barcode_printer_type(options['barcode_printer_type']) - TubeRack::Purpose.create_with(options).find_or_create_by!(name: name) + TubeRack::Purpose.create_with(options).find_or_create_by!(name:) end def barcode_printer_type(name) diff --git a/lib/record_loader/workflow_loader.rb b/lib/record_loader/workflow_loader.rb index e5a26dffca..6872b5fc38 100644 --- a/lib/record_loader/workflow_loader.rb +++ b/lib/record_loader/workflow_loader.rb @@ -10,7 +10,7 @@ class WorkflowLoader < ApplicationRecordLoader config_folder 'workflows' def create_or_update!(name, options) - Workflow.create_with(options).find_or_create_by!(name: name) + Workflow.create_with(options).find_or_create_by!(name:) end end end diff --git a/lib/request_class_deprecator.rb b/lib/request_class_deprecator.rb index 1c87ff82cf..ac5547fa7d 100644 --- a/lib/request_class_deprecator.rb +++ b/lib/request_class_deprecator.rb @@ -26,7 +26,7 @@ def deprecate_class(request_class_name, options = {}) # rubocop:todo Metrics/Abc ActiveRecord::Base.transaction do RequestType - .where(request_class_name: request_class_name) + .where(request_class_name:) .find_each do |rt| say "Deprecating: #{rt.name}" rt.update!(deprecated: true) diff --git a/lib/tasks/add_heron_product.rake b/lib/tasks/add_heron_product.rake index ab939c2620..fa3e49a7e8 100644 --- a/lib/tasks/add_heron_product.rake +++ b/lib/tasks/add_heron_product.rake @@ -22,7 +22,7 @@ namespace :product_heron do product = Product.create!(name: 'Heron') - ProductCriteria.create!(product: product, stage: 'stock', configuration: ADDITIONAL_CRITERIA) + ProductCriteria.create!(product:, stage: 'stock', configuration: ADDITIONAL_CRITERIA) end end diff --git a/lib/tasks/add_missing_asset_audit_records.rake b/lib/tasks/add_missing_asset_audit_records.rake index eef55f14c4..62393c99ed 100644 --- a/lib/tasks/add_missing_asset_audit_records.rake +++ b/lib/tasks/add_missing_asset_audit_records.rake @@ -58,7 +58,7 @@ namespace :asset_audit do created_by: row['created_by'], created_at: row['created_at'], message: "Process '#{row['message']}' performed on instrument Destroying instrument", - key: key + key: } asset_audit_data << data end diff --git a/lib/tasks/add_traction_records.rake b/lib/tasks/add_traction_records.rake index 9f4f31ab89..ee7c0754fd 100644 --- a/lib/tasks/add_traction_records.rake +++ b/lib/tasks/add_traction_records.rake @@ -70,7 +70,7 @@ namespace :traction do ActiveRecord::Base.transaction do (barcode_printer_type = BarcodePrinterType.find_by(name: '1D Tube')) || raise('Cannot find 1D printer') { 'saphyr' => %w[Tube::Purpose SampleTube] }.each do |name, (type, asset_type)| - type.constantize.create!(name: name, barcode_printer_type: barcode_printer_type, target_type: asset_type) + type.constantize.create!(name:, barcode_printer_type:, target_type: asset_type) end end end diff --git a/lib/tasks/benchmark_plate_transfer.rake b/lib/tasks/benchmark_plate_transfer.rake index 99225c1865..e5217c6cdb 100644 --- a/lib/tasks/benchmark_plate_transfer.rake +++ b/lib/tasks/benchmark_plate_transfer.rake @@ -5,7 +5,7 @@ namespace :benchmark do stock = Purpose.find_by(name: 'Shear').create! sample = Sample.find_or_create_by(name: 'test_sample') stock.wells.each do |w| - w.aliquots.create!(sample: sample, study_id: Study.find_or_create_by(name: 'test_study').id) + w.aliquots.create!(sample:, study_id: Study.find_or_create_by(name: 'test_study').id) end user = User.find_or_create_by(login: 'test_user') targets = [] @@ -20,7 +20,7 @@ namespace :benchmark do $stdout.puts 'Warming up...' 15.times do - Transfer::BetweenPlates.create!(source: stock, destination: targets.pop, transfers: all_wells.clone, user: user) + Transfer::BetweenPlates.create!(source: stock, destination: targets.pop, transfers: all_wells.clone, user:) print '.' end puts '' @@ -28,7 +28,7 @@ namespace :benchmark do start = Time.zone.now $stdout.puts "Starting #{start}" 15.times do - Transfer::BetweenPlates.create!(source: stock, destination: targets.pop, transfers: all_wells.clone, user: user) + Transfer::BetweenPlates.create!(source: stock, destination: targets.pop, transfers: all_wells.clone, user:) $stdout.print '.' end $stdout.puts diff --git a/lib/tasks/devour.rake b/lib/tasks/devour.rake index 56594d66b2..6b7ea430a0 100644 --- a/lib/tasks/devour.rake +++ b/lib/tasks/devour.rake @@ -24,7 +24,7 @@ namespace :devour do attributes[attr] = { jsonApi: relation } attributes[attr][:type] = details.resource_klass._type.to_s.singularize unless details.polymorphic? end - { resource: resource._type.to_s.singularize, attributes: attributes, options: {} } + { resource: resource._type.to_s.singularize, attributes:, options: {} } end serialized_config = JSON.generate(config, json_formatting) diff --git a/lib/tasks/hic_library_types.rake b/lib/tasks/hic_library_types.rake index d8d45350e9..a413712d59 100644 --- a/lib/tasks/hic_library_types.rake +++ b/lib/tasks/hic_library_types.rake @@ -8,9 +8,9 @@ namespace :hic_library_types do request_types = hic_library_type.request_types ['Hi-C - Arima v2', 'Hi-C – Qiagen', 'Hi-C – OmniC', 'Hi-C – Arima v1', 'Hi-C – Dovetail'].each do |name| - next if LibraryType.find_by(name: name) + next if LibraryType.find_by(name:) - LibraryType.create!(name: name, request_types: request_types) + LibraryType.create!(name:, request_types:) puts "Library type created for #{name}" end end diff --git a/lib/tasks/limber.rake b/lib/tasks/limber.rake index adfff1264c..a4b4ebf96c 100644 --- a/lib/tasks/limber.rake +++ b/lib/tasks/limber.rake @@ -142,13 +142,13 @@ namespace :limber do catalogue = ProductCatalogue.create_with(selection_behaviour: 'SingleProduct').find_or_create_by!(name: catalogue_name) Limber::Helper::TemplateConstructor.new( - prefix: prefix, - catalogue: catalogue, + prefix:, + catalogue:, sequencing_keys: params[:sequencing_list] ).build! unless params[:omit_library_templates] - Limber::Helper::LibraryOnlyTemplateConstructor.new(prefix: prefix, catalogue: catalogue).build! - Limber::Helper::LibraryAndMultiplexingTemplateConstructor.new(prefix: prefix, catalogue: catalogue).build! + Limber::Helper::LibraryOnlyTemplateConstructor.new(prefix:, catalogue:).build! + Limber::Helper::LibraryAndMultiplexingTemplateConstructor.new(prefix:, catalogue:).build! end end @@ -239,7 +239,7 @@ namespace :limber do catalogue = ProductCatalogue.create_with(selection_behaviour: 'SingleProduct').find_or_create_by!(name: 'Generic') Limber::Helper::TemplateConstructor.new( prefix: 'Multiplexing', - catalogue: catalogue, + catalogue:, sequencing_keys: base_list ).build! diff --git a/lib/tasks/limber_dev.rake b/lib/tasks/limber_dev.rake index 6baec2ae3b..fc1571c0a6 100644 --- a/lib/tasks/limber_dev.rake +++ b/lib/tasks/limber_dev.rake @@ -90,7 +90,7 @@ namespace :limber do OligoEnumerator .new(384, index * 384) .each_with_index - .map { |oligo, map_id| { oligo: oligo, map_id: map_id + 1 } } + .map { |oligo, map_id| { oligo:, map_id: map_id + 1 } } ) end TagLayoutTemplate.create!( @@ -110,7 +110,7 @@ namespace :limber do tg = TagGroup.create!(name: 'IDT for Illumina v1 - MOCK') do |group| group.tags.build( - OligoEnumerator.new(384).each_with_index.map { |oligo, map_id| { oligo: oligo, map_id: map_id + 1 } } + OligoEnumerator.new(384).each_with_index.map { |oligo, map_id| { oligo:, map_id: map_id + 1 } } ) end TagLayoutTemplate.create!( @@ -140,7 +140,7 @@ namespace :limber do OligoEnumerator .new(384, index * 384) .each_with_index - .map { |oligo, map_id| { oligo: oligo, map_id: map_id + 1 } } + .map { |oligo, map_id| { oligo:, map_id: map_id + 1 } } ) end TagLayoutTemplate.create!( diff --git a/lib/tasks/register_auto_imported_samples_as_stock.rake b/lib/tasks/register_auto_imported_samples_as_stock.rake index a61c168dc2..d4889f019d 100644 --- a/lib/tasks/register_auto_imported_samples_as_stock.rake +++ b/lib/tasks/register_auto_imported_samples_as_stock.rake @@ -37,7 +37,7 @@ namespace :auto_imported_samples do puts "labware count: #{labware.count}" receptacles = - Receptacle.where(labware: labware).joins(:aliquots).where("aliquots.study_id IN (#{relevant_study_ids})") + Receptacle.where(labware:).joins(:aliquots).where("aliquots.study_id IN (#{relevant_study_ids})") # 78,507 in training 2020-07-08 (85,440 before join with aliquots) puts "receptacles count: #{receptacles.count}" diff --git a/lib/tasks/retention_instructions.rake b/lib/tasks/retention_instructions.rake index dcf0ef5acc..d4fb68c821 100644 --- a/lib/tasks/retention_instructions.rake +++ b/lib/tasks/retention_instructions.rake @@ -24,7 +24,7 @@ namespace :retention_instructions do } ) labwares = labwares.limit(limit) unless limit.nil? - labwares.find_each(batch_size: batch_size) do |labware| + labwares.find_each(batch_size:) do |labware| puts "Processing labware #{labware.id}: #{labware.name}..." saved_count = process_labware(labware, saved_count) end diff --git a/lib/views_schema.rb b/lib/views_schema.rb index aeca2a23f4..f8b0d87ff1 100644 --- a/lib/views_schema.rb +++ b/lib/views_schema.rb @@ -72,7 +72,7 @@ def self.all_views # rubocop:todo Metrics/MethodLength # # @return [Void] def self.create_view(name, statement, algorithm: ALGORITHMS.first, security: SECURITIES.first) - execute(action: 'CREATE', name: name, statement: statement, algorithm: algorithm, security: security) + execute(action: 'CREATE', name:, statement:, algorithm:, security:) end # @@ -84,7 +84,7 @@ def self.create_view(name, statement, algorithm: ALGORITHMS.first, security: SEC # # @return [Void] def self.update_view(name, statement, algorithm: ALGORITHMS.first, security: SECURITIES.first) - execute(action: 'CREATE OR REPLACE', name: name, statement: statement, algorithm: algorithm, security: security) + execute(action: 'CREATE OR REPLACE', name:, statement:, algorithm:, security:) end # diff --git a/lib/working_setup/standard_seeder.rb b/lib/working_setup/standard_seeder.rb index f69fc2f2e3..d5bac2a34d 100644 --- a/lib/working_setup/standard_seeder.rb +++ b/lib/working_setup/standard_seeder.rb @@ -46,7 +46,7 @@ def seed end def plates_of_purpose(name, number) # rubocop:todo Metrics/AbcSize - purpose = Purpose.find_by!(name: name) + purpose = Purpose.find_by!(name:) number.times do purpose.create!.tap do |plate| plate.wells.each do |w| @@ -74,10 +74,10 @@ def tag_plates( # rubocop:todo Metrics/MethodLength .create!( lot_number: Time.current.to_i.to_s, template: TagLayoutTemplate.find_by!(name: template), - user: user, + user:, received_at: Time.current ) - qcc = QcableCreator.create!(lot: lot, user: user, count: size) + qcc = QcableCreator.create!(lot:, user:, count: size) qcc.qcables.each do |qcable| qcable.update!(state: 'available') puts "Tag Plate: #{qcable.asset.ean13_barcode}" @@ -110,11 +110,11 @@ def faculty_sponsor end def create_project(name) - existing = Project.find_by(name: name) + existing = Project.find_by(name:) return existing if existing Project.create!( - name: name, + name:, enforce_quotas: false, approved: true, project_metadata_attributes: { @@ -126,15 +126,15 @@ def create_project(name) end def create_study(name) - existing = Study.find_by(name: name) + existing = Study.find_by(name:) return existing if existing Study.create!( - name: name, + name:, study_metadata_attributes: { data_access_group: 'dag', study_type: StudyType.first, - faculty_sponsor: faculty_sponsor, + faculty_sponsor:, data_release_study_type: DataReleaseStudyType.first, study_description: 'A seeded test study', contaminated_human_dna: 'No', diff --git a/spec/api/dilution_plate_purpose_spec.rb b/spec/api/dilution_plate_purpose_spec.rb index 31222da6ad..5957019da7 100644 --- a/spec/api/dilution_plate_purpose_spec.rb +++ b/spec/api/dilution_plate_purpose_spec.rb @@ -7,7 +7,7 @@ let(:authorised_app) { create :api_application } let(:uuid) { '00000000-1111-2222-3333-444444444444' } - before { create :dilution_plate_purpose, :uuidable, uuid: uuid, name: 'Example purpose' } + before { create :dilution_plate_purpose, :uuidable, uuid:, name: 'Example purpose' } describe '#get' do subject(:url) { '/api/1/' + uuid } diff --git a/spec/api/extraction_attributes_spec.rb b/spec/api/extraction_attributes_spec.rb index f2465b5f14..64cac47b4f 100644 --- a/spec/api/extraction_attributes_spec.rb +++ b/spec/api/extraction_attributes_spec.rb @@ -358,6 +358,6 @@ def authorized_api_request(action, path, body) headers['CONTENT_TYPE'] = 'application/json' unless body.nil? headers['HTTP_X_SEQUENCESCAPE_CLIENT_ID'] = authorised_app.key yield(headers) if block_given? - send(action.downcase, path, params: body, headers: headers) + send(action.downcase, path, params: body, headers:) end end diff --git a/spec/api/multiplexed_library_tube_spec.rb b/spec/api/multiplexed_library_tube_spec.rb index 6c643ff792..993b003276 100644 --- a/spec/api/multiplexed_library_tube_spec.rb +++ b/spec/api/multiplexed_library_tube_spec.rb @@ -10,7 +10,7 @@ let(:purpose_uuid) { '00000000-1111-2222-3333-666666666666' } let(:purpose) { create :tube_purpose, :uuidable, uuid: purpose_uuid, name: 'Example purpose' } - let(:tube) { create :multiplexed_library_tube, purpose: purpose, volume: 8.76000000 } + let(:tube) { create :multiplexed_library_tube, purpose:, volume: 8.76000000 } let(:collection) { create(:custom_metadatum_collection, asset: tube) } before do diff --git a/spec/api/plate_purpose_spec.rb b/spec/api/plate_purpose_spec.rb index 9bf731c17c..e4ccaba86b 100644 --- a/spec/api/plate_purpose_spec.rb +++ b/spec/api/plate_purpose_spec.rb @@ -49,7 +49,7 @@ let(:authorised_app) { create :api_application } let(:uuid) { '00000000-1111-2222-3333-444444444444' } - before { create :plate_purpose, :uuidable, uuid: uuid, name: 'Example purpose' } + before { create :plate_purpose, :uuidable, uuid:, name: 'Example purpose' } describe '#get' do subject { '/api/1/' + uuid } diff --git a/spec/api/request_types_spec.rb b/spec/api/request_types_spec.rb index 3c3a4fa54b..89a99a75b3 100644 --- a/spec/api/request_types_spec.rb +++ b/spec/api/request_types_spec.rb @@ -7,7 +7,7 @@ let(:authorised_app) { create :api_application } let(:uuid) { '00000000-1111-2222-3333-444444444444' } - before { create :request_type, :uuidable, uuid: uuid, name: 'Sequencing by colour' } + before { create :request_type, :uuidable, uuid:, name: 'Sequencing by colour' } describe '#get' do subject(:url) { '/api/1/' + uuid } diff --git a/spec/api/specific_tube_creation_spec.rb b/spec/api/specific_tube_creation_spec.rb index d941f8296d..d24608dcf2 100644 --- a/spec/api/specific_tube_creation_spec.rb +++ b/spec/api/specific_tube_creation_spec.rb @@ -11,7 +11,7 @@ let(:parent_plate) { create :plate, well_count: 5 } let!(:stock_plate) { create :full_stock_plate, well_count: parent_plate.wells.count } - let!(:submission) { Submission.create!(user: user) } + let!(:submission) { Submission.create!(user:) } let(:child_purpose) { create :tube_purpose } @@ -24,8 +24,8 @@ .readonly(false) .each_with_index do |well, i| stock_well = stock_plate.wells[i] - create(:library_creation_request, asset: stock_well, target_asset: well, submission: submission) - create(:transfer_request, asset: stock_well, target_asset: well, submission: submission) + create(:library_creation_request, asset: stock_well, target_asset: well, submission:) + create(:transfer_request, asset: stock_well, target_asset: well, submission:) well.stock_wells.attach!([stock_well]) end end @@ -82,7 +82,7 @@ def construct_expected_response_body(parent_plate, new_tube_creation) describe 'Retrieving a Tube Creation' do let!(:tube_creation) do - SpecificTubeCreation.create!(user: user, parent: parent_plate, child_purposes: [child_purpose]) + SpecificTubeCreation.create!(user:, parent: parent_plate, child_purposes: [child_purpose]) end let(:response_code) { 200 } diff --git a/spec/api/state_change_spec.rb b/spec/api/state_change_spec.rb index 2e21b88ebe..ebfcd7cad7 100644 --- a/spec/api/state_change_spec.rb +++ b/spec/api/state_change_spec.rb @@ -20,10 +20,10 @@ state_change: { user: user.uuid, target: target_plate.uuid, - target_state: target_state, - contents: contents, - customer_accepts_responsibility: customer_accepts_responsibility, - reason: reason + target_state:, + contents:, + customer_accepts_responsibility:, + reason: } }.to_json end @@ -39,10 +39,10 @@ read: "http://www.example.com/api/1/#{target_plate.uuid}" } }, - target_state: target_state, - previous_state: previous_state, - contents: contents, - reason: reason + target_state:, + previous_state:, + contents:, + reason: } }.to_json end @@ -73,8 +73,8 @@ state_change: { user: user.uuid, target: target_plate.uuid, - target_state: target_state, - reason: reason + target_state:, + reason: } }.to_json end diff --git a/spec/api/submission_pool_spec.rb b/spec/api/submission_pool_spec.rb index 9f1c3d7093..9f4f5b25bd 100644 --- a/spec/api/submission_pool_spec.rb +++ b/spec/api/submission_pool_spec.rb @@ -41,9 +41,9 @@ before do plate.wells.each do |well| - create :library_creation_request, asset: well, submission: submission, request_type: request_type + create :library_creation_request, asset: well, submission:, request_type: end - create :tag2_layout_template_submission, submission: submission, tag2_layout_template: tag2_layout_template + create :tag2_layout_template_submission, submission:, tag2_layout_template: end let(:response_body) do @@ -74,8 +74,8 @@ plate.wells.each do |well| create :library_creation_request, asset: well, - submission: submission, - request_type: request_type, + submission:, + request_type:, state: 'cancelled' end end @@ -104,9 +104,9 @@ before do plate.wells.each do |well| - create :library_creation_request, asset: well, submission: submission, request_type: request_type + create :library_creation_request, asset: well, submission:, request_type: end - create :tag_layout_template_submission, submission: submission, tag_layout_template: tag_layout_template + create :tag_layout_template_submission, submission:, tag_layout_template: end let(:response_body) do @@ -136,10 +136,10 @@ before do plate.wells.each do |well| - create :library_creation_request, asset: well, submission: submission, request_type: request_type + create :library_creation_request, asset: well, submission:, request_type: end plate_b.wells.each do |well| - create :library_creation_request, asset: well, submission: submission, request_type: request_type + create :library_creation_request, asset: well, submission:, request_type: end end @@ -166,15 +166,15 @@ let(:plate_b) do plate = create :input_plate, well_count: 2 plate.wells.each do |well| - create :library_creation_request, asset: well, submission: submission, request_type: request_type + create :library_creation_request, asset: well, submission:, request_type: end plate end - let(:plate) { create :target_plate, well_count: 2, parent: plate_b, submission: submission } + let(:plate) { create :target_plate, well_count: 2, parent: plate_b, submission: } before do - create :tag2_layout_template_submission, submission: submission, tag2_layout_template: tag2_layout_template + create :tag2_layout_template_submission, submission:, tag2_layout_template: end let(:response_body) do diff --git a/spec/api/tube_creation_spec.rb b/spec/api/tube_creation_spec.rb index fd39e68661..b7f3f9b9fc 100644 --- a/spec/api/tube_creation_spec.rb +++ b/spec/api/tube_creation_spec.rb @@ -11,7 +11,7 @@ let(:parent_plate) { create :plate, well_count: 5 } let!(:stock_plate) { create :full_stock_plate, well_count: parent_plate.wells.count } - let!(:submission) { Submission.create!(user: user) } + let!(:submission) { Submission.create!(user:) } let(:child_purpose) { create :tube_purpose } @@ -24,8 +24,8 @@ .readonly(false) .each_with_index do |well, i| stock_well = stock_plate.wells[i] - create(:library_creation_request, asset: stock_well, target_asset: well, submission: submission) - create(:transfer_request, asset: stock_well, target_asset: well, submission: submission) + create(:library_creation_request, asset: stock_well, target_asset: well, submission:) + create(:transfer_request, asset: stock_well, target_asset: well, submission:) well.stock_wells.attach!([stock_well]) end end @@ -79,7 +79,7 @@ def construct_expected_response_body(parent_plate, child_purpose, new_tube_creat end describe 'Retrieving a Tube Creation' do - let!(:tube_creation) { TubeCreation.create!(user: user, parent: parent_plate, child_purpose: child_purpose) } + let!(:tube_creation) { TubeCreation.create!(user:, parent: parent_plate, child_purpose:) } let(:response_code) { 200 } diff --git a/spec/bulk_submission_excel/data_worksheet_spec.rb b/spec/bulk_submission_excel/data_worksheet_spec.rb index b5b03206e4..dfda70aaca 100644 --- a/spec/bulk_submission_excel/data_worksheet_spec.rb +++ b/spec/bulk_submission_excel/data_worksheet_spec.rb @@ -27,13 +27,13 @@ context 'data worksheet' do let!(:worksheet) do described_class.new( - workbook: workbook, + workbook:, columns: configuration.columns.all.dup, - assets: assets, + assets:, ranges: configuration.ranges.dup, defaults: { - user_login: user_login, - template_name: template_name + user_login:, + template_name: } ) end diff --git a/spec/bulk_submission_excel/download_spec.rb b/spec/bulk_submission_excel/download_spec.rb index 52375e7a63..148d19b0f0 100644 --- a/spec/bulk_submission_excel/download_spec.rb +++ b/spec/bulk_submission_excel/download_spec.rb @@ -16,7 +16,7 @@ let(:download) do described_class.new( - assets: assets, + assets:, column_list: columns, range_list: ranges, defaults: { diff --git a/spec/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller_spec.rb b/spec/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller_spec.rb index 2afd17af33..47799f5963 100644 --- a/spec/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller_spec.rb +++ b/spec/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller_spec.rb @@ -23,7 +23,7 @@ before do create :transfer_request, state: tube_state, target_asset: tube.receptacle - post api_v2_bioscan_export_pool_xp_to_traction_index_path, params: params + post api_v2_bioscan_export_pool_xp_to_traction_index_path, params: end context 'when the tube exists with the correct properties' do diff --git a/spec/controllers/api/v2/heron/plates_controller_spec.rb b/spec/controllers/api/v2/heron/plates_controller_spec.rb index 2298b4f593..ed9c91dbe7 100644 --- a/spec/controllers/api/v2/heron/plates_controller_spec.rb +++ b/spec/controllers/api/v2/heron/plates_controller_spec.rb @@ -20,7 +20,7 @@ data: { type: 'plates', attributes: { - barcode: barcode, + barcode:, wells: { A01: { content: { @@ -33,15 +33,15 @@ } } }, - purpose_uuid: purpose_uuid, - study_uuid: study_uuid + purpose_uuid:, + study_uuid: } } }.to_h.with_indifferent_access end let!(:before_plate_count) { Plate.count } - before { post api_v2_heron_plates_path, params: params } + before { post api_v2_heron_plates_path, params: } it 'creates a new plate successfully' do expect(response).to have_http_status(:created) @@ -56,7 +56,7 @@ end it 'fails if barcode is not unique with the barcode information' do - post api_v2_heron_plates_path, params: params + post(api_v2_heron_plates_path, params:) expect(response).to have_http_status(:unprocessable_entity) json = ActiveSupport::JSON.decode(response.body) expect(json['errors']).to eq(["The barcode '#{barcode}' is already in use."]) diff --git a/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb b/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb index 94e8df454b..d9b3cbc7c1 100644 --- a/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb +++ b/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb @@ -35,7 +35,7 @@ } }, purpose_uuid: purpose_96_uuid, - study_uuid: study_uuid + study_uuid: } } }.to_h.with_indifferent_access @@ -43,7 +43,7 @@ let!(:before_tube_rack_count) { TubeRack.count } let!(:before_tube_count) { Tube.count } - before { post api_v2_heron_tube_racks_path, params: params } + before { post api_v2_heron_tube_racks_path, params: } it 'creates a new tube rack successfully' do expect(response).to have_http_status(:created) diff --git a/spec/controllers/driver_files_controller_spec.rb b/spec/controllers/driver_files_controller_spec.rb index 5af26d8562..46846d4f17 100644 --- a/spec/controllers/driver_files_controller_spec.rb +++ b/spec/controllers/driver_files_controller_spec.rb @@ -24,7 +24,7 @@ state: 'passed' end - let(:batch) { create :batch, requests: requests, pipeline: pipeline, user: current_user } + let(:batch) { create :batch, requests:, pipeline:, user: current_user } before do get :show, params: { batch_id: batch.id, robot_id: robot.id, pick_number: 1 }, session: { user: current_user.id } diff --git a/spec/controllers/labwhere_receptions_controller_spec.rb b/spec/controllers/labwhere_receptions_controller_spec.rb index bde5bc9cb0..7c0954029c 100644 --- a/spec/controllers/labwhere_receptions_controller_spec.rb +++ b/spec/controllers/labwhere_receptions_controller_spec.rb @@ -12,7 +12,7 @@ shared_examples 'a reception' do before do expect(LabWhereClient::Scan).to receive(:create).with( - location_barcode: location_barcode, + location_barcode:, user_code: SBCF::SangerBarcode.from_human(user.barcode).machine_barcode.to_s, labware_barcodes: [plate.human_barcode, plate_2.machine_barcode, sample_tube.human_barcode] ).and_return(instance_double(LabWhereClient::Scan, valid?: true, errors: [])) @@ -22,7 +22,7 @@ labwhere_reception: { barcodes: [plate.human_barcode, plate_2.machine_barcode, sample_tube.human_barcode], user_code: SBCF::SangerBarcode.from_human(user.barcode).machine_barcode, - location_barcode: location_barcode + location_barcode: } } end diff --git a/spec/controllers/npg_actions/assets_controller_spec.rb b/spec/controllers/npg_actions/assets_controller_spec.rb index 4ab7067013..16cdc0db8e 100644 --- a/spec/controllers/npg_actions/assets_controller_spec.rb +++ b/spec/controllers/npg_actions/assets_controller_spec.rb @@ -11,25 +11,25 @@ let(:batch) { create :sequencing_batch, state: 'started', qc_state: 'qc_manual' } let(:valid_seq_request) do create :sequencing_request_with_assets, - batch: batch, + batch:, request_type: batch.pipeline.request_types.first, - study: study, + study:, target_asset: lane, state: 'passed' end let(:cancelled_seq_request) do create :sequencing_request_with_assets, - batch: batch, + batch:, request_type: batch.pipeline.request_types.first, - study: study, + study:, target_asset: lane, state: 'cancelled' end let(:failed_seq_request) do create :sequencing_request_with_assets, - batch: batch, + batch:, request_type: batch.pipeline.request_types.first, - study: study, + study:, target_asset: lane, state: 'failed' end diff --git a/spec/controllers/receptacles_controller_spec.rb b/spec/controllers/receptacles_controller_spec.rb index e48053fb78..9b8710e970 100644 --- a/spec/controllers/receptacles_controller_spec.rb +++ b/spec/controllers/receptacles_controller_spec.rb @@ -7,13 +7,13 @@ let!(:tube) { create(:sample_tube).receptacle } let!(:lane) { create :lane } - let!(:well) { create :untagged_well, study: study } + let!(:well) { create :untagged_well, study: } let(:study) { create :study } it_behaves_like 'it requires login' describe '#index' do - before { get :index, params: params, session: { user: current_user.id } } + before { get :index, params:, session: { user: current_user.id } } context 'when no parameters are specified' do let(:params) { {} } diff --git a/spec/controllers/report_fails_controller_spec.rb b/spec/controllers/report_fails_controller_spec.rb index 76d77a6909..adf1d1a89b 100644 --- a/spec/controllers/report_fails_controller_spec.rb +++ b/spec/controllers/report_fails_controller_spec.rb @@ -16,7 +16,7 @@ report_fail: { barcodes: [plate.human_barcode, plate_2.machine_barcode, sample_tube.human_barcode], user_code: SBCF::SangerBarcode.from_human(user.barcode).machine_barcode, - failure_id: failure_id + failure_id: } } end @@ -39,7 +39,7 @@ report_fail: { barcodes: [plate.human_barcode, plate_2.machine_barcode, sample_tube.human_barcode], user_code: SBCF::SangerBarcode.from_human(user.barcode).machine_barcode, - failure_id: failure_id + failure_id: } } end diff --git a/spec/controllers/robot_verifications_controller_spec.rb b/spec/controllers/robot_verifications_controller_spec.rb index 846451c7af..1008231ff9 100644 --- a/spec/controllers/robot_verifications_controller_spec.rb +++ b/spec/controllers/robot_verifications_controller_spec.rb @@ -53,22 +53,22 @@ user_id: user.id, batch_id: batch.id, robot_id: robot.id, - plate_types: plate_types, - barcodes: barcodes, - bed_barcodes: bed_barcodes, - plate_barcodes: plate_barcodes, - destination_bed_barcodes: destination_bed_barcodes, - destination_plate_barcodes: destination_plate_barcodes, + plate_types:, + barcodes:, + bed_barcodes:, + plate_barcodes:, + destination_bed_barcodes:, + destination_plate_barcodes:, pick_number: 1 } end before do expected_layout[1].each_with_index do |(barcode, _sort_number), index| - source_plate = create :plate, barcode: barcode + source_plate = create(:plate, barcode:) position = Map.for_position_on_plate(index + 1, 96, source_plate.asset_shape).first well = create :well, map: position, plate: source_plate - target_well = create :well, map: position, plate: plate + target_well = create(:well, map: position, plate:) well_request = create :request, state: 'passed', asset: well, target_asset: target_well batch.requests << well_request end @@ -239,7 +239,7 @@ end describe '#submission' do - let(:well) { create :well, plate: plate } + let(:well) { create :well, plate: } let(:well_request) { create :request, state: 'passed' } let(:source_plate) { create :plate, barcode: 'SQPD-1234' } let(:target_well) { create :well, plate: source_plate } diff --git a/spec/controllers/searches_controller_spec.rb b/spec/controllers/searches_controller_spec.rb index f4ccaacca0..a1461b292b 100644 --- a/spec/controllers/searches_controller_spec.rb +++ b/spec/controllers/searches_controller_spec.rb @@ -13,7 +13,7 @@ let!(:sample) { create :sample, name: 'FindMeSample' } let!(:asset) { create(:sample_tube, name: 'FindMeAsset') } let!(:other_asset) { create(:sample_tube) } - let!(:asset_group_to_find) { create :asset_group, name: 'FindMeAssetGroup', study: study } + let!(:asset_group_to_find) { create :asset_group, name: 'FindMeAssetGroup', study: } let!(:asset_group_to_not_find) { create :asset_group, name: 'IgnoreAssetGroup' } let!(:submission) { create :submission, name: 'FindMe' } diff --git a/spec/controllers/studies/information_controller_spec.rb b/spec/controllers/studies/information_controller_spec.rb index a6a14d14af..b6466ef5b0 100644 --- a/spec/controllers/studies/information_controller_spec.rb +++ b/spec/controllers/studies/information_controller_spec.rb @@ -23,7 +23,7 @@ let(:request_type1) { create :request_type } let(:request_type2) { create :request_type } let(:request_type3) { create :request_type } - let(:well) { create :untagged_well, study: study } + let(:well) { create :untagged_well, study: } before do request_type3 diff --git a/spec/controllers/studies_controller_spec.rb b/spec/controllers/studies_controller_spec.rb index ed391348d8..49f16a1d1b 100644 --- a/spec/controllers/studies_controller_spec.rb +++ b/spec/controllers/studies_controller_spec.rb @@ -45,7 +45,7 @@ describe '#create' do before do @study_count = Study.count - post :create, params: params + post :create, params: end context 'with valid options' do @@ -110,7 +110,7 @@ let!(:study) do # Create a study without poly_metadata options. - post :create, params: params + post(:create, params:) Study.last end diff --git a/spec/factories/accession/tags.rb b/spec/factories/accession/tags.rb index a2b291417c..c8d4de25c2 100644 --- a/spec/factories/accession/tags.rb +++ b/spec/factories/accession/tags.rb @@ -7,7 +7,7 @@ services { %i[SERVICE_1 SERVICE_2] } ebi_name { :ebi_tag_1 } - initialize_with { new(name: name, groups: groups, services: services, ebi_name: ebi_name) } + initialize_with { new(name:, groups:, services:, ebi_name:) } skip_create factory :sample_taxon_id_accession_tag do diff --git a/spec/factories/barcode_factories.rb b/spec/factories/barcode_factories.rb index f06347eef7..099cdce5cf 100644 --- a/spec/factories/barcode_factories.rb +++ b/spec/factories/barcode_factories.rb @@ -14,7 +14,7 @@ barcode_number end format { 'sanger_ean13' } - barcode { SBCF::SangerBarcode.new(prefix: prefix, number: barcode_number).human_barcode } + barcode { SBCF::SangerBarcode.new(prefix:, number: barcode_number).human_barcode } factory :sanger_ean13_tube do transient { prefix { 'NT' } } @@ -27,7 +27,7 @@ barcode_number end format { 'sanger_code39' } - barcode { SBCF::SangerBarcode.new(prefix: prefix, number: barcode_number).human_barcode } + barcode { SBCF::SangerBarcode.new(prefix:, number: barcode_number).human_barcode } factory :sanger_code39_tube do transient { prefix { 'NT' } } diff --git a/spec/factories/batch_factories.rb b/spec/factories/batch_factories.rb index b4077ba19f..bf831f4cd5 100644 --- a/spec/factories/batch_factories.rb +++ b/spec/factories/batch_factories.rb @@ -23,7 +23,7 @@ if evaluator.request_attributes.present? batch.requests = evaluator.request_attributes.map do |request_attribute| - build(evaluator.request_factory, request_attribute.reverse_merge(request_type: request_type)) + build(evaluator.request_factory, request_attribute.reverse_merge(request_type:)) end end end @@ -58,10 +58,10 @@ after(:build) do |batch, evaluator| evaluator.assets.each_with_index.each do |asset, index| create :pac_bio_sequencing_request, - asset: asset, + asset:, target_asset: evaluator.target_plate.wells[index], request_type: batch.pipeline.request_types.first, - batch: batch + batch: end end end diff --git a/spec/factories/custom_metadatum_collection_factories.rb b/spec/factories/custom_metadatum_collection_factories.rb index ea75323023..69a67db414 100644 --- a/spec/factories/custom_metadatum_collection_factories.rb +++ b/spec/factories/custom_metadatum_collection_factories.rb @@ -12,7 +12,7 @@ create_list( :custom_metadatum, evaluator.metadatum_count, - custom_metadatum_collection: custom_metadatum_collection + custom_metadatum_collection: ) end end diff --git a/spec/factories/lib_pcr_xp_factories.rb b/spec/factories/lib_pcr_xp_factories.rb index 7258eb7307..1b43825d01 100644 --- a/spec/factories/lib_pcr_xp_factories.rb +++ b/spec/factories/lib_pcr_xp_factories.rb @@ -9,7 +9,7 @@ .where_description(%w[A1 B2 E6]) .where_plate_size(plate.size) .where_plate_shape(AssetShape.default) - .map { |map| build(:tagged_well, map: map, requests: [create(:lib_pcr_xp_request)]) } + .map { |map| build(:tagged_well, map:, requests: [create(:lib_pcr_xp_request)]) } plate.wells.each do |well| well.well_attribute.current_volume = 160 well.save @@ -30,7 +30,7 @@ .map do |map| tube = create(:lib_pool_tube) plate.children << tube - build(:tagged_well, map: map).tap { |well| create(:lib_pcr_xp_request, asset: well, target_asset: tube) } + build(:tagged_well, map:).tap { |well| create(:lib_pcr_xp_request, asset: well, target_asset: tube) } end end end diff --git a/spec/factories/pipelines_factories.rb b/spec/factories/pipelines_factories.rb index 546a33f259..d70c8e14d9 100644 --- a/spec/factories/pipelines_factories.rb +++ b/spec/factories/pipelines_factories.rb @@ -64,7 +64,7 @@ name: pipeline.name, item_limit: evaluator.item_limit, locale: evaluator.locale, - pipeline: pipeline + pipeline: ) end end @@ -124,14 +124,14 @@ create( :set_descriptors_task, name: 'Specify Dilution Volume', - workflow: workflow, + workflow:, per_item: true, descriptor_attributes: [{ kind: 'Text', sorter: 0, name: 'Concentration' }] ) - create(:add_spiked_in_control_task, workflow: workflow) + create(:add_spiked_in_control_task, workflow:) create( :set_descriptors_task, - workflow: workflow, + workflow:, descriptor_attributes: [ { kind: 'Selection', @@ -204,14 +204,14 @@ item_limit { 2 } locale { 'Internal' } - after(:build) { |workflow| workflow.pipeline = build(:pipeline, workflow: workflow) unless workflow.pipeline } + after(:build) { |workflow| workflow.pipeline = build(:pipeline, workflow:) unless workflow.pipeline } end factory :fluidigm_pipeline_workflow, class: 'Workflow' do name { generate :lab_workflow_name } after(:build) do |workflow| - workflow.pipeline = build(:fluidigm_pipeline, workflow: workflow) unless workflow.pipeline + workflow.pipeline = build(:fluidigm_pipeline, workflow:) unless workflow.pipeline end tasks { [build(:fluidigm_template_task, workflow: nil), build(:cherrypick_task, workflow: nil)] } @@ -221,7 +221,7 @@ name { generate :lab_workflow_name } after(:build) do |workflow| - workflow.pipeline = build(:cherrypick_pipeline, workflow: workflow) unless workflow.pipeline + workflow.pipeline = build(:cherrypick_pipeline, workflow:) unless workflow.pipeline end tasks { [build(:plate_template_task, workflow: nil), build(:cherrypick_task, workflow: nil)] } diff --git a/spec/factories/plate_factories.rb b/spec/factories/plate_factories.rb index 5a59054e1c..b31939cc97 100644 --- a/spec/factories/plate_factories.rb +++ b/spec/factories/plate_factories.rb @@ -32,7 +32,7 @@ evaluator.well_locations.map do |map| build( evaluator.well_factory, - map: map, + map:, study: evaluator.studies_cycle.next, project: evaluator.projects_cycle.next ) @@ -61,7 +61,7 @@ transient { barcode { nil } } # May be a nicer way of doing this? - sanger_barcode { barcode.nil? ? build(:plate_barcode) : build(:plate_barcode, barcode: barcode) } + sanger_barcode { barcode.nil? ? build(:plate_barcode) : build(:plate_barcode, barcode:) } end factory :plate, traits: %i[plate_barcode with_wells] do @@ -95,7 +95,7 @@ create :transfer_request, asset: well_hash[well.map_description], target_asset: well, - outer_request: outer_request + outer_request: end end end @@ -159,7 +159,7 @@ after(:create) do |plate, evaluator| plate.wells = evaluator.occupied_map_locations.map.with_index do |map, i| - create(:well_for_location_report, map: map, study: evaluator.studies[i], project: nil) + create(:well_for_location_report, map:, study: evaluator.studies[i], project: nil) end end end @@ -284,6 +284,6 @@ name { 'Strip_tube' } size { 8 } plate_purpose { create :strip_tube_purpose } - after(:create) { |st| st.wells = st.maps.map { |map| create(:well, map: map) } } + after(:create) { |st| st.wells = st.maps.map { |map| create(:well, map:) } } end end diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 80588e8298..6f2361702c 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -9,7 +9,7 @@ project_metadata factory :project_with_order do - after(:build) { |project| project.orders ||= [create(:order, project: project)] } + after(:build) { |project| project.orders ||= [create(:order, project:)] } end end diff --git a/spec/factories/pulldown_factories.rb b/spec/factories/pulldown_factories.rb index 9bd4bf6a39..72b70f6c74 100644 --- a/spec/factories/pulldown_factories.rb +++ b/spec/factories/pulldown_factories.rb @@ -25,7 +25,7 @@ transient { tag_sequences { %w[ACGT TGCA] } } - tags { tag_sequences.each_with_index.map { |oligo, index| build(:tag, map_id: index + 1, oligo: oligo) } } + tags { tag_sequences.each_with_index.map { |oligo, index| build(:tag, map_id: index + 1, oligo:) } } end # Tag layouts and their templates @@ -92,11 +92,11 @@ .each_with_index do |pool, i| submission = create :submission pool.each do |well| - create :transfer_request, asset: stock_wells[i], target_asset: well, submission: submission + create(:transfer_request, asset: stock_wells[i], target_asset: well, submission:) mock_request_type.create!( asset: stock_wells[i], target_asset: well, - submission: submission, + submission:, request_metadata_attributes: create(:request_metadata_for_library_creation).attributes ) create :stock_well_link, target_well: well, source_well: stock_wells[i] @@ -130,7 +130,7 @@ { fragment_size_required_from: 100, fragment_size_required_to: 400, - bait_library: bait_library, + bait_library:, library_type: 'Agilent Pulldown' } end diff --git a/spec/factories/request_factories.rb b/spec/factories/request_factories.rb index 28bef29184..37bc174df9 100644 --- a/spec/factories/request_factories.rb +++ b/spec/factories/request_factories.rb @@ -131,7 +131,7 @@ target_asset factory: %i[well] request_type factory: %i[cherrypick_request_type] request_purpose { :standard } - request_metadata_attributes { { target_purpose: target_purpose } } + request_metadata_attributes { { target_purpose: } } factory :final_cherrypick_for_fluidigm_request do request_type factory: %i[request_type], key: 'pick_to_fluidigm' diff --git a/spec/factories/request_type_factories.rb b/spec/factories/request_type_factories.rb index 97a40577f9..ea378584ae 100644 --- a/spec/factories/request_type_factories.rb +++ b/spec/factories/request_type_factories.rb @@ -3,8 +3,8 @@ FactoryBot.define do trait :library_request_validators do after(:build) do |request_type| - request_type.library_types_request_types << create(:library_types_request_type, request_type: request_type) - request_type.request_type_validators << create(:library_request_type_validator, request_type: request_type) + request_type.library_types_request_types << create(:library_types_request_type, request_type:) + request_type.request_type_validators << create(:library_request_type_validator, request_type:) end end @@ -15,9 +15,9 @@ request_type.library_types_request_types << create( :library_types_request_type, library_type: evaluator.library_type, - request_type: request_type + request_type: ) - request_type.request_type_validators << create(:library_request_type_validator, request_type: request_type) + request_type.request_type_validators << create(:library_request_type_validator, request_type:) end end @@ -86,13 +86,13 @@ request_type.request_type_validators = [ build( :request_type_validator, - request_type: request_type, + request_type:, request_option: 'insert_size', options: [500, 1000, 2000, 5000, 10_000, 20_000] ), build( :request_type_validator, - request_type: request_type, + request_type:, request_option: 'sequencing_type', options: ['Standard', 'MagBead', 'MagBead OneCellPerWell v1'] ) @@ -117,7 +117,7 @@ srv = create( :sequencing_request_type_validator, - request_type: request_type, + request_type:, options: ev.read_lengths, default: ev.default ) @@ -130,7 +130,7 @@ asset_type { 'LibraryTube' } after(:build) do |request_type| - srv = create(:sequencing_request_type_validator, request_type: request_type, options: [54, 150, 250]) + srv = create(:sequencing_request_type_validator, request_type:, options: [54, 150, 250]) request_type.request_type_validators << srv end end @@ -141,8 +141,8 @@ for_multiplexing { true } after(:build) do |request_type| - request_type.library_types_request_types << create(:library_types_request_type, request_type: request_type) - request_type.request_type_validators << create(:library_request_type_validator, request_type: request_type) + request_type.library_types_request_types << create(:library_types_request_type, request_type:) + request_type.request_type_validators << create(:library_request_type_validator, request_type:) end end @@ -152,8 +152,8 @@ for_multiplexing { true } after(:build) do |request_type| - request_type.library_types_request_types << create(:library_types_request_type, request_type: request_type) - request_type.request_type_validators << create(:library_request_type_validator, request_type: request_type) + request_type.library_types_request_types << create(:library_types_request_type, request_type:) + request_type.request_type_validators << create(:library_request_type_validator, request_type:) end end diff --git a/spec/factories/sample_manifest_excel/columns.rb b/spec/factories/sample_manifest_excel/columns.rb index 18f47bea9e..6668de34e5 100644 --- a/spec/factories/sample_manifest_excel/columns.rb +++ b/spec/factories/sample_manifest_excel/columns.rb @@ -7,7 +7,7 @@ heading { "Column #{number}" } value { "Value #{number}" } - initialize_with { new(name: name, heading: heading, number: number, value: value) } + initialize_with { new(name:, heading:, number:, value:) } factory :sanger_sample_id_column do name { :sanger_sample_id } diff --git a/spec/factories/sample_manifest_excel/conditional_formattings.rb b/spec/factories/sample_manifest_excel/conditional_formattings.rb index 9d5664472f..363fe0a48e 100644 --- a/spec/factories/sample_manifest_excel/conditional_formattings.rb +++ b/spec/factories/sample_manifest_excel/conditional_formattings.rb @@ -5,11 +5,11 @@ options { { 'option1' => 'value1', 'option2' => 'value2', 'formula' => 'some_formula' } } style { { bg_color: '82CAFA', type: :dxf } } - initialize_with { new(options: options, style: style) } + initialize_with { new(options:, style:) } factory :conditional_formatting_with_formula, class: 'SequencescapeExcel::ConditionalFormatting' do formula { { type: :len, operator: '>', operand: 10 } } - initialize_with { new(options: options, style: style, formula: formula) } + initialize_with { new(options:, style:, formula:) } end skip_create diff --git a/spec/factories/sample_manifest_excel/ranges.rb b/spec/factories/sample_manifest_excel/ranges.rb index 64c3575c58..c4405f2a21 100644 --- a/spec/factories/sample_manifest_excel/ranges.rb +++ b/spec/factories/sample_manifest_excel/ranges.rb @@ -6,7 +6,7 @@ first_row { 1 } worksheet_name { 'Sheet1' } - initialize_with { new(options: options, first_row: first_row, worksheet_name: worksheet_name) } + initialize_with { new(options:, first_row:, worksheet_name:) } skip_create end diff --git a/spec/factories/sample_manifest_excel/test_download_plates.rb b/spec/factories/sample_manifest_excel/test_download_plates.rb index 83bb6ed682..a5395e1de1 100644 --- a/spec/factories/sample_manifest_excel/test_download_plates.rb +++ b/spec/factories/sample_manifest_excel/test_download_plates.rb @@ -34,18 +34,18 @@ initialize_with do new( - data: data, - columns: columns, - validation_errors: validation_errors, - partial: partial, - cgap: cgap, - study: study, - supplier: supplier, - num_plates: num_plates, - num_filled_wells_per_plate: num_filled_wells_per_plate, - num_rows_per_well: num_rows_per_well, - type: type, - manifest_type: manifest_type + data:, + columns:, + validation_errors:, + partial:, + cgap:, + study:, + supplier:, + num_plates:, + num_filled_wells_per_plate:, + num_rows_per_well:, + type:, + manifest_type: ) end diff --git a/spec/factories/sample_manifest_excel/test_download_tubes.rb b/spec/factories/sample_manifest_excel/test_download_tubes.rb index 42f872bdb0..3241bd7f3b 100644 --- a/spec/factories/sample_manifest_excel/test_download_tubes.rb +++ b/spec/factories/sample_manifest_excel/test_download_tubes.rb @@ -37,17 +37,17 @@ initialize_with do new( - data: data, - columns: columns, - validation_errors: validation_errors, - no_of_rows: no_of_rows, - partial: partial, - cgap: cgap, - study: study, - supplier: supplier, - count: count, - type: type, - manifest_type: manifest_type + data:, + columns:, + validation_errors:, + no_of_rows:, + partial:, + cgap:, + study:, + supplier:, + count:, + type:, + manifest_type: ) end diff --git a/spec/factories/sample_manifest_excel/test_download_tubes_in_rack.rb b/spec/factories/sample_manifest_excel/test_download_tubes_in_rack.rb index e4205730a6..a58c2c7411 100644 --- a/spec/factories/sample_manifest_excel/test_download_tubes_in_rack.rb +++ b/spec/factories/sample_manifest_excel/test_download_tubes_in_rack.rb @@ -37,17 +37,17 @@ initialize_with do new( - data: data, - columns: columns, - validation_errors: validation_errors, - no_of_rows: no_of_rows, - partial: partial, - cgap: cgap, - study: study, - supplier: supplier, - count: count, - type: type, - manifest_type: manifest_type + data:, + columns:, + validation_errors:, + no_of_rows:, + partial:, + cgap:, + study:, + supplier:, + count:, + type:, + manifest_type: ) end diff --git a/spec/factories/sample_manifest_excel/validations.rb b/spec/factories/sample_manifest_excel/validations.rb index 05d5d4a144..897433395f 100644 --- a/spec/factories/sample_manifest_excel/validations.rb +++ b/spec/factories/sample_manifest_excel/validations.rb @@ -5,7 +5,7 @@ options { { option1: 'value1', option2: 'value2', type: :none, formula1: 'smth' } } range_name { :some_range } - initialize_with { new(options: options) } + initialize_with { new(options:) } skip_create end diff --git a/spec/factories/sample_manifest_factories.rb b/spec/factories/sample_manifest_factories.rb index 21b2e041f7..a2fb97ef8f 100644 --- a/spec/factories/sample_manifest_factories.rb +++ b/spec/factories/sample_manifest_factories.rb @@ -32,7 +32,7 @@ :sample_manifest_asset, sanger_sample_id: generate(:sanger_sample_id), asset: well, - sample_manifest: sample_manifest + sample_manifest: ) end end @@ -57,7 +57,7 @@ :sample_manifest_asset, sanger_sample_id: generate(:sanger_sample_id), asset: tube.receptacle, - sample_manifest: sample_manifest + sample_manifest: ) end sample_manifest.barcodes = sample_manifest.labware.map(&:human_barcode) @@ -92,7 +92,7 @@ .flat_map(&:wells) .each do |well| evaluator.num_rows_per_well.times do - create(:sample_manifest_asset, asset: well, sample_manifest: sample_manifest) + create(:sample_manifest_asset, asset: well, sample_manifest:) end end end diff --git a/spec/factories/samples.rb b/spec/factories/samples.rb index 128023bbab..e868aae2d3 100644 --- a/spec/factories/samples.rb +++ b/spec/factories/samples.rb @@ -7,7 +7,7 @@ factory :sample_with_well do sequence(:sanger_sample_id, &:to_s) - after(:build) { |sample, _evaluator| sample.wells = create_list(:well_with_sample_and_plate, 1, sample: sample) } + after(:build) { |sample, _evaluator| sample.wells = create_list(:well_with_sample_and_plate, 1, sample:) } end factory :sample_with_gender do diff --git a/spec/factories/shared_traits.rb b/spec/factories/shared_traits.rb index 7ef04b736b..0b1705b761 100644 --- a/spec/factories/shared_traits.rb +++ b/spec/factories/shared_traits.rb @@ -27,7 +27,7 @@ # Using an after build as I need access to both the transient and the resource. after(:build) do |resource, context| - resource.uuid_object = build :uuid, external_id: context.uuid, resource: resource + resource.uuid_object = build(:uuid, external_id: context.uuid, resource:) end after(:create) { |resource, _context| resource.uuid_object.save! } diff --git a/spec/factories/submission_factories.rb b/spec/factories/submission_factories.rb index 12ae5caa42..6ea3dcd98d 100644 --- a/spec/factories/submission_factories.rb +++ b/spec/factories/submission_factories.rb @@ -18,7 +18,7 @@ submission_class_name { LinearSubmission.name } sequence(:name) { |i| "Template #{i}" } - submission_parameters { { request_type_ids_list: request_type_ids_list } } + submission_parameters { { request_type_ids_list: } } product_catalogue { |pc| pc.association(:single_product_catalogue) } factory :cherrypick_submission_template do diff --git a/spec/factories/tag2_layout_factories.rb b/spec/factories/tag2_layout_factories.rb index 4a11d2a6fd..da6f3ae88c 100644 --- a/spec/factories/tag2_layout_factories.rb +++ b/spec/factories/tag2_layout_factories.rb @@ -10,7 +10,7 @@ factory :tag2_layout_template do |_itlt| transient { oligo { generate :oligo } } sequence(:name) { |n| "Tag 2 layout template #{n}" } - tag { |tag| tag.association :tag, oligo: oligo } + tag { |tag| tag.association :tag, oligo: } end factory :tag2_layout_template_submission, class: 'Tag2Layout::TemplateSubmission' do diff --git a/spec/factories/tag_group_factories.rb b/spec/factories/tag_group_factories.rb index 11b023465c..d5a3ebae9c 100644 --- a/spec/factories/tag_group_factories.rb +++ b/spec/factories/tag_group_factories.rb @@ -24,7 +24,7 @@ adapter_type { build(:adapter_type, name: adapter_type_name) if adapter_type_name } after(:build) do |tag_group, evaluator| - evaluator.tag_count.times { |i| tag_group.tags << create(:tag, map_id: i + 1, tag_group: tag_group) } + evaluator.tag_count.times { |i| tag_group.tags << create(:tag, map_id: i + 1, tag_group:) } end factory :tag_group_with_tags do diff --git a/spec/factories/tube_factories.rb b/spec/factories/tube_factories.rb index 1fdc515d9c..b20fbe6b08 100644 --- a/spec/factories/tube_factories.rb +++ b/spec/factories/tube_factories.rb @@ -13,7 +13,7 @@ barcode { generate :barcode_number } prefix { 'NT' } end - sanger_barcode { { prefix: prefix, number: barcode_number } } + sanger_barcode { { prefix:, number: barcode_number } } end trait :in_a_rack do @@ -22,7 +22,7 @@ coordinate { nil } end after(:create) do |tube, evaluator| - create(:racked_tube, tube: tube, tube_rack: evaluator.tube_rack, coordinate: evaluator.coordinate) + create(:racked_tube, tube:, tube_rack: evaluator.tube_rack, coordinate: evaluator.coordinate) end end @@ -166,7 +166,7 @@ smrt_cells_available { 1 } end pac_bio_library_tube_metadata_attributes do - { prep_kit_barcode: prep_kit_barcode, smrt_cells_available: smrt_cells_available } + { prep_kit_barcode:, smrt_cells_available: } end after(:build) { |t, evaluator| t.receptacle.aliquots << evaluator.aliquot } end @@ -184,7 +184,7 @@ factory :spiked_buffer do transient do tag_option { 'Single' } # The PhiX Tag option to use, eg. Single/Dual - aliquot_attributes { { tag_option: tag_option } } + aliquot_attributes { { tag_option: } } end name { generate :asset_name } diff --git a/spec/factories/well_factories.rb b/spec/factories/well_factories.rb index 3f6f400556..739ddfe662 100644 --- a/spec/factories/well_factories.rb +++ b/spec/factories/well_factories.rb @@ -6,7 +6,7 @@ study { build :study } project { build :project } sample { build :sample } - aliquot_options { |_e, well| { study: study, project: project, receptacle: well, sample: sample } } + aliquot_options { |_e, well| { study:, project:, receptacle: well, sample: } } end association(:well_attribute, strategy: :build) @@ -37,7 +37,7 @@ factory :passed_well do transient do aliquot_options do |_e, well| - { study: study, project: project, receptacle: well, sample: sample, request: requests_as_target.first } + { study:, project:, receptacle: well, sample:, request: requests_as_target.first } end end stock_wells { [association(:well)] } @@ -74,7 +74,7 @@ end factory :well_for_qc_report, parent: :well do - samples { [create(:study_sample, study: study).sample] } + samples { [create(:study_sample, study:).sample] } plate { create(:plate) } map { create(:map) } diff --git a/spec/features/assets/asset_submission_spec.rb b/spec/features/assets/asset_submission_spec.rb index e7bdfa5247..da96644282 100644 --- a/spec/features/assets/asset_submission_spec.rb +++ b/spec/features/assets/asset_submission_spec.rb @@ -12,7 +12,7 @@ let(:selected_request_type) { original_request_type } let(:selected_read_length) { '76' } let!(:original_request) do - create(request_factory, study: study, project: project, asset: asset, request_type: original_request_type) + create(request_factory, study:, project:, asset:, request_type: original_request_type) end shared_examples 'it allows additional sequencing' do @@ -130,7 +130,7 @@ let(:study) { asset.aliquots.first.study } let(:project) { asset.aliquots.first.project } let!(:original_request) do - create(request_factory, study: nil, project: nil, asset: asset, request_type: original_request_type) + create(request_factory, study: nil, project: nil, asset:, request_type: original_request_type) end let(:selected_read_length) { '108' } diff --git a/spec/features/batches/failing_requests_spec.rb b/spec/features/batches/failing_requests_spec.rb index 135d1cabdf..685aefb232 100644 --- a/spec/features/batches/failing_requests_spec.rb +++ b/spec/features/batches/failing_requests_spec.rb @@ -7,7 +7,7 @@ let(:request_count) { 3 } let(:batch) do create :cherrypick_batch, - request_count: request_count, + request_count:, state: 'released', request_factory: :passed_cherrypick_request end diff --git a/spec/features/batches/sort_requests_spec.rb b/spec/features/batches/sort_requests_spec.rb index 94fd73b0b2..96e52dcafb 100644 --- a/spec/features/batches/sort_requests_spec.rb +++ b/spec/features/batches/sort_requests_spec.rb @@ -5,7 +5,7 @@ describe 'Batches controller', :js, :warren do let(:request_count) { 3 } - let(:batch) { create :sequencing_batch, request_count: request_count, created_at: 1.day.ago, updated_at: 1.day.ago } + let(:batch) { create :sequencing_batch, request_count:, created_at: 1.day.ago, updated_at: 1.day.ago } let(:user) { create :admin } let!(:flowcell_message) { create :flowcell_messenger, target: batch } diff --git a/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb b/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb index 05b417e33e..c17967c896 100644 --- a/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb +++ b/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb @@ -34,7 +34,7 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # :cherrypick_request, asset: plate.wells.located_at(source).first, target_asset: destination, - submission_id: submission_id + submission_id: ) end end diff --git a/spec/features/patient_consent_withdrawl_spec.rb b/spec/features/patient_consent_withdrawl_spec.rb index ce32397559..3296007190 100644 --- a/spec/features/patient_consent_withdrawl_spec.rb +++ b/spec/features/patient_consent_withdrawl_spec.rb @@ -10,7 +10,7 @@ # - If a patient withdraws consent we need to make sure everyone downstream knows # - We need to stop new orders being made. let(:user) { create :user, email: 'login@example.com' } - let(:sample) { create :sample_with_gender, consent_withdrawn: consent_withdrawn } + let(:sample) { create :sample_with_gender, consent_withdrawn: } let(:study) { create :study } before { study.samples << sample } @@ -56,16 +56,16 @@ # Lifted straight from the feature test with minimal rspecification # and optimization let(:submission_template) { create :submission_template, request_type_ids_list: [[create(:request_type).id]] } - let(:sample_tube) { create :sample_tube, sample: sample } + let(:sample_tube) { create :sample_tube, sample: } let(:asset_group) { create :asset_group, assets: [sample_tube.receptacle] } context 'defined by asset group' do let(:order) do submission_template.new_order( project: create(:project), - study: study, - asset_group: asset_group, - user: user, + study:, + asset_group:, + user:, request_options: { 'fragment_size_required_from' => 300, 'fragment_size_required_to' => 400, @@ -81,9 +81,9 @@ let(:order) do submission_template.new_order( project: create(:project), - study: study, + study:, assets: [sample_tube], - user: user, + user:, request_options: { 'fragment_size_required_from' => 300, 'fragment_size_required_to' => 400, diff --git a/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb b/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb index 2251c0a7a3..33a6b79929 100644 --- a/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb +++ b/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb @@ -27,12 +27,12 @@ end assets.each do |asset| create :cherrypick_for_fluidigm_request, - asset: asset, + asset:, request_type: pipeline.request_types.first, - submission: submission, - study: study, - project: project, - target_purpose: target_purpose + submission:, + study:, + project:, + target_purpose: end allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode, barcode: 'SQPD-2')) diff --git a/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb b/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb index 84f3d6521a..dbf46240f2 100644 --- a/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb +++ b/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb @@ -7,7 +7,7 @@ include BarcodeHelper let(:swipecard_code) { '123456' } - let(:user) { create :admin, swipecard_code: swipecard_code } + let(:user) { create :admin, swipecard_code: } let(:project) { create :project } let(:study) { create :study } let(:pipeline) { create :cherrypick_pipeline } @@ -45,12 +45,12 @@ def initialize_plates(plates) plates.each do |plate| plate.wells.each_with_index do |well, index| # create the requests for cherrypicking - create :cherrypick_request, + create(:cherrypick_request, asset: well, request_type: pipeline.request_types.first, - submission: submission, - study: study, - project: project + submission:, + study:, + project:) # create a concentration value on the wells if required next unless concentrations_required diff --git a/spec/features/pipelines/creating_an_empty_batch_spec.rb b/spec/features/pipelines/creating_an_empty_batch_spec.rb index d240403589..a92065f252 100644 --- a/spec/features/pipelines/creating_an_empty_batch_spec.rb +++ b/spec/features/pipelines/creating_an_empty_batch_spec.rb @@ -14,7 +14,7 @@ plates.each do |plate| plate.wells.each do |well| # create the requests for cherrypicking - create :cherrypick_request, asset: well, request_type: request_type, submission: submission + create :cherrypick_request, asset: well, request_type:, submission: end end end diff --git a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb index 26383ba494..8319ef15a1 100644 --- a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb +++ b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb @@ -13,7 +13,7 @@ create_list :sequencing_request_with_assets, 2, request_type: pipeline.request_types.first, - asset: asset, + asset:, target_asset: nil, submission: create(:submission) end @@ -114,7 +114,7 @@ context 'when a batch has been created' do let(:batch) do - create :batch, pipeline: pipeline, requests: pipeline.requests, state: 'released', updated_at: 1.day.ago + create :batch, pipeline:, requests: pipeline.requests, state: 'released', updated_at: 1.day.ago end let!(:flowcell_message) { Messenger.create!(target: batch, template: 'FlowcellIO', root: 'flowcell') } @@ -123,16 +123,16 @@ batch.requests.each_with_index do |request, i| create :lab_event, eventful: request, - batch: batch, - user: user, + batch:, + user:, description: 'Specify Dilution Volume', descriptors: { 'Concentration' => (1.2 + i).to_s } create :lab_event, eventful: request, - batch: batch, - user: user, + batch:, + user:, description: 'Set descriptors', descriptors: { 'Workflow (Standard or Xp)' => 'XP', diff --git a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb index 3a6facd24b..8b141cdd83 100644 --- a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb +++ b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb @@ -40,7 +40,7 @@ create_list :sequencing_request_with_assets, 2, request_type: pipeline.request_types.first, - asset: asset, + asset:, target_asset: nil, submission: create(:submission) end diff --git a/spec/features/pipelines/viewing_request_comments_spec.rb b/spec/features/pipelines/viewing_request_comments_spec.rb index 5f6dc0fe6e..8915bda6dc 100644 --- a/spec/features/pipelines/viewing_request_comments_spec.rb +++ b/spec/features/pipelines/viewing_request_comments_spec.rb @@ -9,7 +9,7 @@ let(:submission) { create :submission } let(:tube) { create :multiplexed_library_tube } let(:request) do - create :sequencing_request, asset: tube, request_type: pipeline.request_types.first, submission: submission + create :sequencing_request, asset: tube, request_type: pipeline.request_types.first, submission: end before do diff --git a/spec/features/sample_manifests/track_sample_manifest_updates_spec.rb b/spec/features/sample_manifests/track_sample_manifest_updates_spec.rb index cdd5fd21ce..e02458c018 100644 --- a/spec/features/sample_manifests/track_sample_manifest_updates_spec.rb +++ b/spec/features/sample_manifests/track_sample_manifest_updates_spec.rb @@ -33,7 +33,7 @@ def load_manifest_spec expect(page).to have_content('Create manifest for plates') expect(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode, barcode: 'SQPD-1234567')) - sample_manifest = create :sample_manifest, study: study, supplier: supplier, user: user + sample_manifest = create(:sample_manifest, study:, supplier:, user:) sample_manifest.generate expect(BroadcastEvent.count).to eq broadcast_events_count + 1 diff --git a/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb b/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb index 9e21150201..4e4772c341 100644 --- a/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb +++ b/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb @@ -30,7 +30,7 @@ context 'valid' do context 'standard' do - let(:download) { build(:test_download_tubes, columns: columns) } + let(:download) { build(:test_download_tubes, columns:) } it 'upload' do login_user(user) @@ -78,7 +78,7 @@ end context 'cgap foreign barcodes' do - let(:download) { build(:test_download_tubes_cgap, columns: columns) } + let(:download) { build(:test_download_tubes_cgap, columns:) } it 'upload' do login_user(user) @@ -92,7 +92,7 @@ context 'invalid' do context 'upload' do - let(:download) { build(:test_download_tubes, columns: columns, validation_errors: [:library_type]) } + let(:download) { build(:test_download_tubes, columns:, validation_errors: [:library_type]) } it 'validation errors' do login_user(user) @@ -111,7 +111,7 @@ end context 'cgap foreign barcodes' do - let(:download) { build(:test_download_tubes_cgap, columns: columns, validation_errors: [:library_type]) } + let(:download) { build(:test_download_tubes_cgap, columns:, validation_errors: [:library_type]) } it 'validation errors' do login_user(user) @@ -124,7 +124,7 @@ context 'duplicate cgap foreign barcodes' do let(:download) do - build(:test_download_tubes_cgap, columns: columns, validation_errors: [:sample_tube_id_duplicates]) + build(:test_download_tubes_cgap, columns:, validation_errors: [:sample_tube_id_duplicates]) end it 'validation errors' do @@ -151,7 +151,7 @@ context 'valid' do context 'upload and reupload' do let(:download) do - build(:test_download_tubes, columns: columns, manifest_type: 'tube_multiplexed_library_with_tag_sequences') + build(:test_download_tubes, columns:, manifest_type: 'tube_multiplexed_library_with_tag_sequences') end it 'with override' do @@ -196,7 +196,7 @@ let(:download) do build( :test_download_tubes_cgap, - columns: columns, + columns:, manifest_type: 'tube_multiplexed_library_with_tag_sequences' ) end @@ -216,7 +216,7 @@ let(:download) do build( :test_download_tubes, - columns: columns, + columns:, manifest_type: 'tube_multiplexed_library_with_tag_sequences', validation_errors: %i[library_type tags] ) @@ -243,7 +243,7 @@ let(:download) do build( :test_download_tubes_cgap, - columns: columns, + columns:, manifest_type: 'tube_multiplexed_library_with_tag_sequences', validation_errors: [:sanger_sample_id_invalid] ) @@ -262,7 +262,7 @@ let(:download) do build( :test_download_tubes_cgap, - columns: columns, + columns:, manifest_type: 'tube_multiplexed_library_with_tag_sequences', validation_errors: [:sample_tube_id_duplicates] ) @@ -291,7 +291,7 @@ context 'valid' do context 'upload and reupload' do - let(:download) { build(:test_download_tubes, columns: columns, manifest_type: 'tube_multiplexed_library') } + let(:download) { build(:test_download_tubes, columns:, manifest_type: 'tube_multiplexed_library') } it 'with override' do # upload @@ -332,7 +332,7 @@ end context 'cgap foreign barcodes' do - let(:download) { build(:test_download_tubes_cgap, columns: columns, manifest_type: 'tube_multiplexed_library') } + let(:download) { build(:test_download_tubes_cgap, columns:, manifest_type: 'tube_multiplexed_library') } it 'upload' do login_user(user) @@ -349,7 +349,7 @@ let(:download) do build( :test_download_tubes, - columns: columns, + columns:, manifest_type: 'tube_multiplexed_library', validation_errors: %i[tags] ) @@ -376,7 +376,7 @@ let(:download) do build( :test_download_tubes_cgap, - columns: columns, + columns:, manifest_type: 'tube_multiplexed_library', validation_errors: [:sanger_sample_id_invalid] ) @@ -395,7 +395,7 @@ let(:download) do build( :test_download_tubes_cgap, - columns: columns, + columns:, manifest_type: 'tube_multiplexed_library', validation_errors: [:sample_tube_id_duplicates] ) @@ -424,7 +424,7 @@ context 'valid' do context 'standard' do - let(:download) { build(:test_download_plates, columns: columns) } + let(:download) { build(:test_download_plates, columns:) } it 'upload' do login_user(user) @@ -436,7 +436,7 @@ end context 'partial' do - let(:download) { build(:test_download_plates_partial, columns: columns) } + let(:download) { build(:test_download_plates_partial, columns:) } it 'upload' do login_user(user) @@ -448,7 +448,7 @@ end context 'cgap foreign barcodes' do - let(:download) { build(:test_download_plates_cgap, columns: columns) } + let(:download) { build(:test_download_plates_cgap, columns:) } it 'upload' do login_user(user) @@ -460,7 +460,7 @@ end context 'cgap foreign barcodes partial' do - let(:download) { build(:test_download_plates_partial_cgap, columns: columns) } + let(:download) { build(:test_download_plates_partial_cgap, columns:) } it 'upload' do login_user(user) @@ -474,7 +474,7 @@ context 'invalid' do context 'no file' do - let(:download) { build(:test_download_plates, columns: columns) } + let(:download) { build(:test_download_plates, columns:) } it 'no file' do login_user(user) @@ -488,7 +488,7 @@ let(:download) do build( :test_download_plates_cgap, - columns: columns, + columns:, validation_errors: [:sample_plate_id_unrecognised_foreign] ) end @@ -504,7 +504,7 @@ context 'duplicate cgap foreign barcodes' do let(:download) do - build(:test_download_plates_cgap, columns: columns, validation_errors: [:sample_plate_id_duplicates]) + build(:test_download_plates_cgap, columns:, validation_errors: [:sample_plate_id_duplicates]) end it 'validation errors' do diff --git a/spec/features/starting_transfers_on_repools_starts_repools_spec.rb b/spec/features/starting_transfers_on_repools_starts_repools_spec.rb index 332f671dea..5a2b8108a4 100644 --- a/spec/features/starting_transfers_on_repools_starts_repools_spec.rb +++ b/spec/features/starting_transfers_on_repools_starts_repools_spec.rb @@ -20,13 +20,13 @@ describe 'Starting transfers on repools starts repools' do let(:original_input_plate) { create :input_plate_for_pooling } let(:secondary_input_plate) do - plate = PlateCreation.create!(user: user, parent: original_input_plate, child_purpose: create(:plate_purpose)).child + plate = PlateCreation.create!(user:, parent: original_input_plate, child_purpose: create(:plate_purpose)).child create :transfer_between_plates, source: original_input_plate, destination: plate plate end let(:target_plate) do - PlateCreation.create!(user: user, parent: original_input_plate, child_purpose: create(:plate_purpose)).child + PlateCreation.create!(user:, parent: original_input_plate, child_purpose: create(:plate_purpose)).child end let(:user) { create :user } @@ -42,7 +42,7 @@ before do allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode), build(:plate_barcode)) TransferRequestCollection.create!( - user: user, + user:, transfer_requests_attributes: [ { asset: source_a1, target_asset: target_a1, submission: library_creation_request_a1.submission }, { asset: source_b1, target_asset: target_b1, submission: library_creation_request_b1.submission } @@ -51,7 +51,7 @@ end it 'The target plate is started' do - StateChange.create(user: user, target: target_plate, target_state: 'started') + StateChange.create(user:, target: target_plate, target_state: 'started') expect(library_creation_request_a1.reload).to be_started expect(library_creation_request_b1.reload).to be_started end diff --git a/spec/features/studies/qc_reports_spec.rb b/spec/features/studies/qc_reports_spec.rb index b132ba7cf2..0933c957fa 100644 --- a/spec/features/studies/qc_reports_spec.rb +++ b/spec/features/studies/qc_reports_spec.rb @@ -11,9 +11,9 @@ before do create(:plate_purpose) - create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[0])) - create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[1])) - create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[2])) + create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[0])) + create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[1])) + create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[2])) end it 'create a new report' do diff --git a/spec/features/studies/view_study_properties_spec.rb b/spec/features/studies/view_study_properties_spec.rb index ddcb944ef6..238c966389 100644 --- a/spec/features/studies/view_study_properties_spec.rb +++ b/spec/features/studies/view_study_properties_spec.rb @@ -5,7 +5,7 @@ describe 'View study properties' do let(:user) { create :admin } let(:prelim_id) { 'A1234' } - let(:study) { create(:study, study_metadata: create(:study_metadata, prelim_id: prelim_id)) } + let(:study) { create(:study, study_metadata: create(:study_metadata, prelim_id:)) } it 'view open study properties', :js do login_user(user) diff --git a/spec/features/studies/view_study_request_links_spec.rb b/spec/features/studies/view_study_request_links_spec.rb index 764090be4e..bcfe5f0851 100644 --- a/spec/features/studies/view_study_request_links_spec.rb +++ b/spec/features/studies/view_study_request_links_spec.rb @@ -16,8 +16,8 @@ initial_study: study ) end - let(:library_tube) { create(:library_tube, samples: [sample], study: study) } - let(:sample_tube) { create(:sample_tube, sample: sample, study: study) } + let(:library_tube) { create(:library_tube, samples: [sample], study:) } + let(:sample_tube) { create(:sample_tube, sample:, study:) } before do user diff --git a/spec/features/submissions/bulk_submissions_spec.rb b/spec/features/submissions/bulk_submissions_spec.rb index 7b90879579..bec0978fe8 100644 --- a/spec/features/submissions/bulk_submissions_spec.rb +++ b/spec/features/submissions/bulk_submissions_spec.rb @@ -15,7 +15,7 @@ def process_submission(filename, encoding = nil) before do login_user user create :project, name: 'Test project' - create :asset_group, name: 'assetgroup123', study: study, asset_count: 2 + create :asset_group, name: 'assetgroup123', study:, asset_count: 2 visit bulk_submissions_path expect(page).to have_content('Bulk Submission New') create :library_type, name: 'Standard' diff --git a/spec/features/tag_set_spec.rb b/spec/features/tag_set_spec.rb index c210cf54de..aeb7d903db 100644 --- a/spec/features/tag_set_spec.rb +++ b/spec/features/tag_set_spec.rb @@ -5,8 +5,8 @@ describe 'Create a new tag set' do let(:user) { create :admin } let(:adapter_type) { create :adapter_type } - let(:tag_group) { create :tag_group, name: 'test-group-1', adapter_type: adapter_type } - let(:tag2_group) { create :tag_group, name: 'test-group-2', adapter_type: adapter_type } + let(:tag_group) { create :tag_group, name: 'test-group-1', adapter_type: } + let(:tag2_group) { create :tag_group, name: 'test-group-2', adapter_type: } before do tag_group diff --git a/spec/helpers/batches_helper_spec.rb b/spec/helpers/batches_helper_spec.rb index 78e7963e1d..83d3fa9772 100644 --- a/spec/helpers/batches_helper_spec.rb +++ b/spec/helpers/batches_helper_spec.rb @@ -34,10 +34,10 @@ context 'with potential tasks' do def stage_link(id) - { action: :stage, batch_id: nil, controller: :workflows, id: id, workflow_id: pipeline.workflow.id } + { action: :stage, batch_id: nil, controller: :workflows, id:, workflow_id: pipeline.workflow.id } end let(:pipeline) { create(:sequencing_pipeline, :with_workflow) } - let(:batch) { build :batch, state: 'pending', pipeline: pipeline } + let(:batch) { build :batch, state: 'pending', pipeline: } let(:task1) { ['Specify Dilution Volume', stage_link(0), true, nil] } let(:task2) { ['Add Spiked in control', stage_link(1), true, nil] } diff --git a/spec/helpers/compound_sample_helper_spec.rb b/spec/helpers/compound_sample_helper_spec.rb index 19c073132b..6881e0b2ef 100644 --- a/spec/helpers/compound_sample_helper_spec.rb +++ b/spec/helpers/compound_sample_helper_spec.rb @@ -22,7 +22,7 @@ end context 'when a compound sample already exists' do - let!(:compound_sample) { create(:sample, component_samples: component_samples) } + let!(:compound_sample) { create(:sample, component_samples:) } it 'does not create a new compound sample' do expect { helper.find_or_create_compound_sample(study, component_samples) }.not_to change(Sample, :count) diff --git a/spec/heron/factories/concerns/contents_spec.rb b/spec/heron/factories/concerns/contents_spec.rb index 2542cf9330..463ad16883 100644 --- a/spec/heron/factories/concerns/contents_spec.rb +++ b/spec/heron/factories/concerns/contents_spec.rb @@ -233,12 +233,12 @@ def recipients_key context 'with a tube rack' do let(:purpose) { create(:plate_purpose, target_type: 'Plate', name: 'Stock Plate', size: '96') } - let(:tube_rack) { TubeRack.create!(size: '96', purpose: purpose) } + let(:tube_rack) { TubeRack.create!(size: '96', purpose:) } let(:plate) { tube_rack } let(:tubes) do %w[A1 B1 C1].map do |coordinate| tube = create(:tube) - create(:racked_tube, tube: tube, coordinate: coordinate, tube_rack: tube_rack) + create(:racked_tube, tube:, coordinate:, tube_rack:) tube end end diff --git a/spec/heron/factories/concerns/eventful_spec.rb b/spec/heron/factories/concerns/eventful_spec.rb index 06b54f777f..2321d53f9b 100644 --- a/spec/heron/factories/concerns/eventful_spec.rb +++ b/spec/heron/factories/concerns/eventful_spec.rb @@ -25,7 +25,7 @@ def initialize(params) ] end let(:event_type) { BroadcastEvent::PlateCherrypicked::EVENT_TYPE } - let(:event) { { event: { event_type: event_type, subjects: subjects } } } + let(:event) { { event: { event_type:, subjects: } } } describe '#build_events' do it 'returns a list of events' do diff --git a/spec/heron/factories/event_spec.rb b/spec/heron/factories/event_spec.rb index a2c7bd759e..bae7e00a75 100644 --- a/spec/heron/factories/event_spec.rb +++ b/spec/heron/factories/event_spec.rb @@ -16,7 +16,7 @@ ] end let(:event_type) { BroadcastEvent::PlateCherrypicked::EVENT_TYPE } - let(:params) { { event: { event_type: event_type, subjects: subjects } } } + let(:params) { { event: { event_type:, subjects: } } } it 'is valid with all relevant attributes' do event = described_class.new(params, plate) diff --git a/spec/heron/factories/plate_spec.rb b/spec/heron/factories/plate_spec.rb index eb660d6396..005e7fcd75 100644 --- a/spec/heron/factories/plate_spec.rb +++ b/spec/heron/factories/plate_spec.rb @@ -6,7 +6,7 @@ let(:purpose) { create(:plate_purpose, target_type: 'Plate', name: 'Stock Plate', size: '96') } let(:study) { create(:study) } let(:barcode) { '0000000001' } - let(:params) { { purpose_uuid: purpose.uuid, barcode: barcode } } + let(:params) { { purpose_uuid: purpose.uuid, barcode: } } include BarcodeHelper @@ -41,14 +41,14 @@ end context 'without a plate purpose uuid' do - let(:params) { { barcode: barcode } } + let(:params) { { barcode: } } let(:error_messages) { ['Plate purpose uuid not defined'] } it_behaves_like 'an invalid parameter' end context 'with a plate purpose uuid set to nil' do - let(:params) { { purpose_uuid: nil, barcode: barcode } } + let(:params) { { purpose_uuid: nil, barcode: } } let(:error_messages) { ['Plate purpose for uuid () do not exist'] } it_behaves_like 'an invalid parameter' @@ -56,7 +56,7 @@ context 'with a plate purpose uuid that do not exist' do let(:uuid) { SecureRandom.uuid } - let(:params) { { purpose_uuid: uuid, barcode: barcode } } + let(:params) { { purpose_uuid: uuid, barcode: } } let(:error_messages) { ["Plate purpose for uuid (#{uuid}) do not exist"] } it_behaves_like 'an invalid parameter' @@ -107,7 +107,7 @@ } } end - let(:params) { { barcode: barcode, purpose_uuid: purpose.uuid, wells: wells } } + let(:params) { { barcode:, purpose_uuid: purpose.uuid, wells: } } it 'persists the plate' do expect { plate_factory.save }.to change(Plate, :count).by(1) @@ -157,7 +157,7 @@ end context 'when declaring events' do - let(:params) { { barcode: barcode, purpose_uuid: purpose.uuid, events: [event] } } + let(:params) { { barcode:, purpose_uuid: purpose.uuid, events: [event] } } let(:subjects) do [ build( @@ -170,7 +170,7 @@ ] end let(:event_type) { BroadcastEvent::PlateCherrypicked::EVENT_TYPE } - let(:event) { { event: { event_type: event_type, subjects: subjects } } } + let(:event) { { event: { event_type:, subjects: } } } it 'can persist the events' do expect { plate_factory.save }.to change(BroadcastEvent, :count).by(1) diff --git a/spec/heron/factories/sample_spec.rb b/spec/heron/factories/sample_spec.rb index f52fe446d9..58f8852afd 100644 --- a/spec/heron/factories/sample_spec.rb +++ b/spec/heron/factories/sample_spec.rb @@ -7,7 +7,7 @@ describe '#valid?' do context 'when receiving a study instance' do - let(:params) { { study: study } } + let(:params) { { study: } } it 'is valid' do factory = described_class.new(params) @@ -16,7 +16,7 @@ end context 'when receiving a column that does not exist in sample or sample metadata' do - let(:params) { { study: study, asdf: 'wrong' } } + let(:params) { { study:, asdf: 'wrong' } } it 'is not valid' do factory = described_class.new(params) @@ -32,7 +32,7 @@ context 'when receiving other fields and sample_uuid' do let(:sample) { create(:sample) } - let(:params) { { study: study, phenotype: 'A phenotype', sample_uuid: sample.uuid } } + let(:params) { { study:, phenotype: 'A phenotype', sample_uuid: sample.uuid } } it 'is not valid' do factory = described_class.new(params) @@ -82,7 +82,7 @@ context 'when the factory is valid' do let(:well) { create :well } let(:tag_id) { 1 } - let(:factory) { described_class.new(study: study, aliquot: { tag_id: tag_id }) } + let(:factory) { described_class.new(study:, aliquot: { tag_id: }) } it 'can create an aliquot of the sample in the well' do expect { factory.create_aliquot_at(well) }.to change(Aliquot, :count).by(1).and(change(Sample, :count).by(1)) @@ -113,24 +113,24 @@ context 'when the factory is valid' do it 'returns a sample instance' do - factory = described_class.new(study: study) + factory = described_class.new(study:) expect(factory.create.class).to eq(Sample) end it 'returns the same sample instance in any subsequent call' do - factory = described_class.new(study: study) + factory = described_class.new(study:) sample = factory.create sample2 = factory.create expect(sample).to eq(sample2) end it 'creates one sample' do - factory = described_class.new(study: study) + factory = described_class.new(study:) expect { factory.create }.to change(Sample, :count).by(1) end it 'creates one uuid for the sample' do - factory = described_class.new(study: study) + factory = described_class.new(study:) sample = factory.create expect(Uuid.where(resource: sample).count).to eq(1) end @@ -139,29 +139,29 @@ let(:sample) { create(:sample) } it 'wont create a new sample' do - factory = described_class.new(study: study, sample_uuid: sample.uuid) + factory = described_class.new(study:, sample_uuid: sample.uuid) expect { factory.create }.not_to change(Sample, :count) end it 'will return the sample with uuid specified' do - factory = described_class.new(study: study, sample_uuid: sample.uuid) + factory = described_class.new(study:, sample_uuid: sample.uuid) expect(factory.create).to eq(sample) end it 'will be invalid if providing any other extra attributes' do - factory = described_class.new(study: study, sample_uuid: sample.uuid, sample_id: '1234') + factory = described_class.new(study:, sample_uuid: sample.uuid, sample_id: '1234') expect(factory).not_to be_valid end it 'will be valid if providing any other attributes not sample related' do - factory = described_class.new(study: study, sample_uuid: sample.uuid, aliquot: { tag_id: 1 }) + factory = described_class.new(study:, sample_uuid: sample.uuid, aliquot: { tag_id: 1 }) expect(factory).to be_valid end end context 'when providing a sanger_sample_id' do let(:sample_id) { 'test' } - let(:factory) { described_class.new(study: study, sanger_sample_id: sample_id) } + let(:factory) { described_class.new(study:, sanger_sample_id: sample_id) } it 'sets the id provided as sanger_sample_id' do expect(factory.create.sanger_sample_id).to eq(sample_id) @@ -170,7 +170,7 @@ context 'when providing a name' do let(:sample_id) { 'test' } - let(:factory) { described_class.new(study: study, name: sample_id) } + let(:factory) { described_class.new(study:, name: sample_id) } it 'sets the id provided as name' do expect(factory.create.name).to eq(sample_id) @@ -180,7 +180,7 @@ context 'when providing both sanger_sample_id and name' do let(:sample_id) { 'test' } let(:name) { 'testingname' } - let(:factory) { described_class.new(study: study, name: name, sanger_sample_id: sample_id) } + let(:factory) { described_class.new(study:, name:, sanger_sample_id: sample_id) } it 'sets the id provided as sanger_sample_id' do expect(factory.create.sanger_sample_id).to eq(sample_id) @@ -196,7 +196,7 @@ end context 'when not providing a sanger_sample_id' do - let(:factory) { described_class.new(study: study) } + let(:factory) { described_class.new(study:) } it 'generates a new sanger_sample_id' do sample = nil @@ -215,13 +215,13 @@ context 'when the uuid does not exist already' do it 'creates a new sample using that uuid' do - factory = described_class.new(study: study, uuid: replaced_uuid) + factory = described_class.new(study:, uuid: replaced_uuid) sample = factory.create expect(sample.uuid).to eq(replaced_uuid) end it 'only creates one uuid' do - factory = described_class.new(study: study, uuid: replaced_uuid) + factory = described_class.new(study:, uuid: replaced_uuid) sample = factory.create expect(Uuid.where(resource: sample).count).to eq(1) end @@ -231,7 +231,7 @@ let(:sample) { create :sample } it 'will be invalid if providing any other extra attributes' do - factory = described_class.new(study: study, uuid: sample.uuid) + factory = described_class.new(study:, uuid: sample.uuid) expect { factory.create }.to raise_error(StandardError) end end @@ -239,13 +239,13 @@ context 'when providing other arguments' do it 'updates other sample attributes' do - factory = described_class.new(study: study, control: true) + factory = described_class.new(study:, control: true) sample = factory.create expect(sample.control).to be(true) end it 'updates other sample_metadata attributes' do - factory = described_class.new(study: study, phenotype: 'A phenotype') + factory = described_class.new(study:, phenotype: 'A phenotype') sample = factory.create expect(sample.sample_metadata.phenotype).to eq('A phenotype') end diff --git a/spec/heron/factories/tube_spec.rb b/spec/heron/factories/tube_spec.rb index b8f55f84d5..f645af5795 100644 --- a/spec/heron/factories/tube_spec.rb +++ b/spec/heron/factories/tube_spec.rb @@ -17,7 +17,7 @@ it 'is not valid unless the barcode is unique in database for that format' do barcode = 'FD00000001' - create(:barcode, barcode: barcode, asset: create(:sample_tube), format: Barcode.matching_barcode_format(barcode)) + create(:barcode, barcode:, asset: create(:sample_tube), format: Barcode.matching_barcode_format(barcode)) tube = described_class.new(params) expect(tube).not_to be_valid end diff --git a/spec/insdc/import_countries_spec.rb b/spec/insdc/import_countries_spec.rb index b61a65ebf9..35fc5207f7 100644 --- a/spec/insdc/import_countries_spec.rb +++ b/spec/insdc/import_countries_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Insdc::ImportCountries do subject(:importer) do - described_class.new(ena_root: ena_root, sample_checklist: sample_checklist, priorities: priorities) + described_class.new(ena_root:, sample_checklist:, priorities:) end before do diff --git a/spec/lib/ability_analysis_spec.rb b/spec/lib/ability_analysis_spec.rb index ffa11f9c73..fbf0cfb649 100644 --- a/spec/lib/ability_analysis_spec.rb +++ b/spec/lib/ability_analysis_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe AbilityAnalysis do - subject(:ability_analysis) { described_class.new(roles: roles, ability: ability, permissions: permissions) } + subject(:ability_analysis) { described_class.new(roles:, ability:, permissions:) } let(:roles) { %w[role_a role_b] } let(:permissions) { { 'Study' => %i[edit read], 'Project' => %i[edit read] } } diff --git a/spec/lib/label_printer/batch_plate_spec.rb b/spec/lib/label_printer/batch_plate_spec.rb index 80808c8a14..c6229d2d83 100644 --- a/spec/lib/label_printer/batch_plate_spec.rb +++ b/spec/lib/label_printer/batch_plate_spec.rb @@ -66,28 +66,28 @@ let(:study) { create :study } let(:request1) do order = - create(:order, order_role: OrderRole.new(role: 'test_role'), study: study, assets: [create(:empty_sample_tube)]) + create(:order, order_role: OrderRole.new(role: 'test_role'), study:, assets: [create(:empty_sample_tube)]) create( :well_request, asset: create(:well_with_sample_and_plate), target_asset: create(:well_with_sample_and_plate), - order: order + order: ) end let(:request2) do order = - create(:order, order_role: OrderRole.new(role: 'test_role'), study: study, assets: [create(:empty_sample_tube)]) + create(:order, order_role: OrderRole.new(role: 'test_role'), study:, assets: [create(:empty_sample_tube)]) create( :well_request, asset: create(:well_with_sample_and_plate), target_asset: create(:well_with_sample_and_plate), - order: order + order: ) end let(:plate1) { request1.target_asset.plate } let(:plate2) { request2.target_asset.plate } let(:printables) { { plate1.human_barcode => 'on' } } - let(:options) { { count: count, printable: printables, batch: batch } } + let(:options) { { count:, printable: printables, batch: } } before do batch.requests << request1 @@ -96,7 +96,7 @@ describe LabelPrinter::Label::BatchPlateDouble do context 'printing double labels' do - let(:label_options) { { count: count, printable: printables, batch: batch } } + let(:label_options) { { count:, printable: printables, batch: } } let(:expected_count) { count.to_i * 2 } it_behaves_like 'a correct double label printer' diff --git a/spec/lib/label_printer/sample_manifest_plate_double_spec.rb b/spec/lib/label_printer/sample_manifest_plate_double_spec.rb index d322b601c3..7f7f81f5d3 100644 --- a/spec/lib/label_printer/sample_manifest_plate_double_spec.rb +++ b/spec/lib/label_printer/sample_manifest_plate_double_spec.rb @@ -6,7 +6,7 @@ subject { described_class.new(label_options) } let(:sample_manifest) { create :pending_plate_sample_manifest } - let(:label_options) { { sample_manifest: sample_manifest, only_first_label: only_first_label } } + let(:label_options) { { sample_manifest:, only_first_label: } } let(:sample_manifest_plates) { sample_manifest.printables } context 'printing only the first label' do diff --git a/spec/lib/label_printer/swipecard_spec.rb b/spec/lib/label_printer/swipecard_spec.rb index dcc8c16c09..13f9cecbd2 100644 --- a/spec/lib/label_printer/swipecard_spec.rb +++ b/spec/lib/label_printer/swipecard_spec.rb @@ -2,7 +2,7 @@ context 'when printing swipecard' do let(:barcode_printer_type) { create(:plate_barcode_printer_type) } - let(:barcode_printer) { create(:barcode_printer, barcode_printer_type: barcode_printer_type) } + let(:barcode_printer) { create(:barcode_printer, barcode_printer_type:) } let(:user) { create(:user) } let(:label_class) { LabelPrinter::Label::Swipecard } let(:label_template_name) { configatron.swipecard_pmb_template } @@ -12,13 +12,13 @@ barcode_printer.name, label_class, user_login: user.login, - swipecard: swipecard, - label_template_name: label_template_name + swipecard:, + label_template_name: ) end let(:labels_attribute) { [{ left_text: user.login, barcode: swipecard, label_name: 'main' }] } let(:build_attributes) do - { printer_name: barcode_printer.name, label_template_name: label_template_name, labels: labels_attribute } + { printer_name: barcode_printer.name, label_template_name:, labels: labels_attribute } end it 'builds correct attributes' do diff --git a/spec/lib/limber/helper_spec.rb b/spec/lib/limber/helper_spec.rb index 24f9988e34..2ad625178c 100644 --- a/spec/lib/limber/helper_spec.rb +++ b/spec/lib/limber/helper_spec.rb @@ -5,7 +5,7 @@ subject(:template_constructor) do described_class::TemplateConstructor.new( prefix: 'WGS', - catalogue: catalogue, + catalogue:, sequencing_keys: [request_type.key], type: request_type.key ) @@ -53,7 +53,7 @@ hiseq_template_constructor = described_class::TemplateConstructor.new( prefix: 'WGS', - catalogue: catalogue, + catalogue:, sequencing_keys: [hiseq_request_type.key], type: request_type.key ) diff --git a/spec/lib/mbrave_tags_creator_spec.rb b/spec/lib/mbrave_tags_creator_spec.rb index 2b438dae0e..8227af8382 100644 --- a/spec/lib/mbrave_tags_creator_spec.rb +++ b/spec/lib/mbrave_tags_creator_spec.rb @@ -95,7 +95,7 @@ it 'creates the tag group with the right indexing' do run_task %w[Bioscan_reverse_4_1_v1 Bioscan_reverse_4_2_v1].each do |name| - indexes = TagGroup.find_by(name: name).tags.map(&:map_id) + indexes = TagGroup.find_by(name:).tags.map(&:map_id) expect(indexes).to eq([1, 2, 3, 4]) end diff --git a/spec/lib/record_loader/request_type_loader_spec.rb b/spec/lib/record_loader/request_type_loader_spec.rb index b059bc6d32..9b543e84df 100644 --- a/spec/lib/record_loader/request_type_loader_spec.rb +++ b/spec/lib/record_loader/request_type_loader_spec.rb @@ -6,7 +6,7 @@ # This file was initially generated via `rails g record_loader` RSpec.describe RecordLoader::RequestTypeLoader, :loader, type: :model do def a_new_record_loader(files = selected_files) - described_class.new(directory: test_directory, files: files) + described_class.new(directory: test_directory, files:) end subject(:record_loader) { a_new_record_loader } diff --git a/spec/lib/record_loader/tag_layout_templates_loader_spec.rb b/spec/lib/record_loader/tag_layout_templates_loader_spec.rb index d8a1e153bb..13de085ca1 100644 --- a/spec/lib/record_loader/tag_layout_templates_loader_spec.rb +++ b/spec/lib/record_loader/tag_layout_templates_loader_spec.rb @@ -19,8 +19,8 @@ def a_new_record_loader let(:expected_attributes) do { name: 'Tag Layout 1', - tag_group: tag_group, - tag2_group: tag2_group, + tag_group:, + tag2_group:, direction: 'column', walking_by: 'wells of plate' } diff --git a/spec/models/aliquot_spec.rb b/spec/models/aliquot_spec.rb index a1499fdf2d..ce932aea10 100644 --- a/spec/models/aliquot_spec.rb +++ b/spec/models/aliquot_spec.rb @@ -25,7 +25,7 @@ context 'with different tag 2' do let(:aliquot1) { build :aliquot, tag: tag1, tag2: tag1, sample: sample1 } - let(:aliquot2) { build :aliquot, tag: tag1, tag2: tag2, sample: sample1 } + let(:aliquot2) { build :aliquot, tag: tag1, tag2:, sample: sample1 } it { is_expected.to be false } end @@ -89,17 +89,17 @@ it 'allows mixing same tags with a different tag 2' do asset.aliquots << build(:aliquot, tag: tag1, tag2: tag1, sample: sample1) << - build(:aliquot, tag: tag1, tag2: tag2, sample: sample2) + build(:aliquot, tag: tag1, tag2:, sample: sample2) expect(asset.save).to be true end end describe '#set_library' do - subject { build :aliquot, receptacle: receptacle, library_id: initial_library_id } + subject { build :aliquot, receptacle:, library_id: initial_library_id } let(:receptacle) { create :empty_well } - before { subject.set_library(force: force) } + before { subject.set_library(force:) } context 'when not set' do let(:force) { false } diff --git a/spec/models/api/aliquot_io_spec.rb b/spec/models/api/aliquot_io_spec.rb index 722ac20093..e66d35aee0 100644 --- a/spec/models/api/aliquot_io_spec.rb +++ b/spec/models/api/aliquot_io_spec.rb @@ -6,14 +6,14 @@ subject do create :aliquot, receptacle: well, - sample: sample, - study: study, - project: project, + sample:, + study:, + project:, library: well, - tag: tag, + tag:, insert_size_from: 100, insert_size_to: 200, - bait_library: bait_library + bait_library: end let(:well) { create :empty_well } diff --git a/spec/models/api/asset_link_io_spec.rb b/spec/models/api/asset_link_io_spec.rb index 536ecde75a..cf051928ed 100644 --- a/spec/models/api/asset_link_io_spec.rb +++ b/spec/models/api/asset_link_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::AssetLinkIO do - subject { create :asset_link, ancestor: ancestor, descendant: descendant } + subject { create :asset_link, ancestor:, descendant: } let(:ancestor) { create :sample_tube } let(:descendant) { create :multiplexed_library_tube } diff --git a/spec/models/api/batch_io_spec.rb b/spec/models/api/batch_io_spec.rb index 80dd898569..9ea6ce01dd 100644 --- a/spec/models/api/batch_io_spec.rb +++ b/spec/models/api/batch_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::BatchIO do - subject { create :batch, user: user, assignee: user2, pipeline: pipeline } + subject { create :batch, user:, assignee: user2, pipeline: } let(:user) { create :user } let(:user2) { create :user } diff --git a/spec/models/api/batch_request_io_spec.rb b/spec/models/api/batch_request_io_spec.rb index 3cd2feb99c..45e960d7f3 100644 --- a/spec/models/api/batch_request_io_spec.rb +++ b/spec/models/api/batch_request_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::BatchRequestIO do - subject { create :batch_request, request: request } + subject { create :batch_request, request: } let(:request) { create :request } diff --git a/spec/models/api/library_tube_io_spec.rb b/spec/models/api/library_tube_io_spec.rb index 03470953e1..3efa4bd318 100644 --- a/spec/models/api/library_tube_io_spec.rb +++ b/spec/models/api/library_tube_io_spec.rb @@ -4,12 +4,12 @@ RSpec.describe Api::LibraryTubeIO do subject do - create :empty_library_tube, public_name: 'ABC', closed: false, aliquots: aliquots, volume: 12.0, concentration: 8.0 + create :empty_library_tube, public_name: 'ABC', closed: false, aliquots:, volume: 12.0, concentration: 8.0 end let(:sample) { create :sample } let(:tag) { create :tag } - let(:aliquots) { [create(:aliquot, sample: sample, tag: tag, library_type: 'Standard')] } + let(:aliquots) { [create(:aliquot, sample:, tag:, library_type: 'Standard')] } let!(:library_request) { create :library_creation_request, target_asset: subject } diff --git a/spec/models/api/messages/flowcell_io_spec.rb b/spec/models/api/messages/flowcell_io_spec.rb index 993b851be2..3932022cdd 100644 --- a/spec/models/api/messages/flowcell_io_spec.rb +++ b/spec/models/api/messages/flowcell_io_spec.rb @@ -15,7 +15,7 @@ asset: mx_tube1, batch: sequencing_batch, target_asset: lane1, - request_type: request_type, + request_type:, event_descriptors: request_data end diff --git a/spec/models/api/messages/qc_result_io_spec.rb b/spec/models/api/messages/qc_result_io_spec.rb index d527a0af7d..939dec267d 100644 --- a/spec/models/api/messages/qc_result_io_spec.rb +++ b/spec/models/api/messages/qc_result_io_spec.rb @@ -22,7 +22,7 @@ context 'the qc_result asset is a well' do let(:aliquots) { create_list(:aliquot, 1, library: sample_tube) } - let(:well) { create :well_with_sample_and_plate, aliquots: aliquots } + let(:well) { create :well_with_sample_and_plate, aliquots: } let(:qc_result) { create :qc_result, asset: well } it 'generates a valid json' do diff --git a/spec/models/api/messages/well_stock_resource_io_spec.rb b/spec/models/api/messages/well_stock_resource_io_spec.rb index 575171a93c..b46c752705 100644 --- a/spec/models/api/messages/well_stock_resource_io_spec.rb +++ b/spec/models/api/messages/well_stock_resource_io_spec.rb @@ -19,7 +19,7 @@ well_attribute: create(:complete_well_attribute) end let(:study) { create :study } - let(:aliquot) { create :aliquot, study: study, sample: sample, receptacle: well } + let(:aliquot) { create :aliquot, study:, sample:, receptacle: well } before { aliquot } # rubocop:todo RSpec/ScatteredSetup diff --git a/spec/models/api/order_io_spec.rb b/spec/models/api/order_io_spec.rb index 9510c30222..ad19dd1b45 100644 --- a/spec/models/api/order_io_spec.rb +++ b/spec/models/api/order_io_spec.rb @@ -5,10 +5,10 @@ RSpec.describe Api::OrderIO do subject do create :order, - user: user, + user:, template_name: 'Cool template', - study: study, - project: project, + study:, + project:, comments: 'Good', request_options: { read_length: '200', diff --git a/spec/models/api/project_io_spec.rb b/spec/models/api/project_io_spec.rb index 2d40938ddc..9e38878cd5 100644 --- a/spec/models/api/project_io_spec.rb +++ b/spec/models/api/project_io_spec.rb @@ -38,7 +38,7 @@ external_funding_source: 'Tooth fairy', sequencing_budget_cost_centre: '123', funding_comments: 'It is funded', - project_manager: project_manager + project_manager: } end diff --git a/spec/models/api/request_io_spec.rb b/spec/models/api/request_io_spec.rb index aa6e79d52b..ef58dc2d4e 100644 --- a/spec/models/api/request_io_spec.rb +++ b/spec/models/api/request_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::RequestIO do - subject { create :request, asset: source_asset, target_asset: target_asset } + subject { create :request, asset: source_asset, target_asset: } context 'between tubes' do let(:source_asset) { create :sample_tube } diff --git a/spec/models/api/sample_tube_io_spec.rb b/spec/models/api/sample_tube_io_spec.rb index b1f1210586..de0d443032 100644 --- a/spec/models/api/sample_tube_io_spec.rb +++ b/spec/models/api/sample_tube_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::SampleTubeIO do - subject { create :sample_tube, volume: 12.0, concentration: 8.0, sample: sample } + subject { create :sample_tube, volume: 12.0, concentration: 8.0, sample: } let(:sample) { create :sample } diff --git a/spec/models/api/study_io_spec.rb b/spec/models/api/study_io_spec.rb index db1188fd17..be797b58dc 100644 --- a/spec/models/api/study_io_spec.rb +++ b/spec/models/api/study_io_spec.rb @@ -10,7 +10,7 @@ faculty_sponsor: create(:faculty_sponsor, name: 'John Smith'), data_release_strategy: 'open', data_release_timing: 'standard', - reference_genome: reference_genome, + reference_genome:, array_express_accession_number: 'AE111', ega_policy_accession_number: 'EGA222', ega_dac_accession_number: 'DAC333', diff --git a/spec/models/api/study_sample_io_spec.rb b/spec/models/api/study_sample_io_spec.rb index 0ed500c2ba..f509289e65 100644 --- a/spec/models/api/study_sample_io_spec.rb +++ b/spec/models/api/study_sample_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::StudySampleIO do - subject { create :study_sample, study: study, sample: sample } + subject { create :study_sample, study:, sample: } let(:study) { create :study } let(:sample) { create :sample } diff --git a/spec/models/api/submission_io_spec.rb b/spec/models/api/submission_io_spec.rb index 35577d4565..13fefbebb3 100644 --- a/spec/models/api/submission_io_spec.rb +++ b/spec/models/api/submission_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::SubmissionIO do - subject { create :submission, user: user } + subject { create :submission, user: } let(:user) { create :user } diff --git a/spec/models/api/well_io_spec.rb b/spec/models/api/well_io_spec.rb index f581e945cb..bbe46cbaad 100644 --- a/spec/models/api/well_io_spec.rb +++ b/spec/models/api/well_io_spec.rb @@ -8,7 +8,7 @@ subject do create :well_with_sample_and_without_plate, map: Map.find_by(description: 'A1', asset_size: plate.size), - plate: plate + plate: end let(:plate) { create :plate, barcode: 'SQPD-1' } @@ -45,7 +45,7 @@ # As of the current records, the 'description' and 'asset_size' attributes can uniquely identify a map. create :well_with_sample_and_without_plate, map: Map.find_by(description: 'A1', asset_size: plate.size), - plate: plate, + plate:, aliquot_count: 2 end diff --git a/spec/models/barcode/format_handlers_spec.rb b/spec/models/barcode/format_handlers_spec.rb index b363388fe1..20a9408560 100644 --- a/spec/models/barcode/format_handlers_spec.rb +++ b/spec/models/barcode/format_handlers_spec.rb @@ -12,7 +12,7 @@ def self.it_has_a_valid_barcode(barcode, number: nil, prefix: nil, suffix: nil, it 'parses the barcode correctly', :aggregate_failures do expect(format_handler).to be_valid - expect(format_handler).to have_attributes(number: number, barcode_prefix: prefix, suffix: suffix, child: child) + expect(format_handler).to have_attributes(number:, barcode_prefix: prefix, suffix:, child:) end end end diff --git a/spec/models/batch_spec.rb b/spec/models/batch_spec.rb index 6ac7c0c5ba..7fb8fc0872 100644 --- a/spec/models/batch_spec.rb +++ b/spec/models/batch_spec.rb @@ -52,7 +52,7 @@ subject(:batch_for_user) { described_class.for_user(query) } let(:user) { create :user } - let!(:owned_batch) { create :batch, user: user } + let!(:owned_batch) { create :batch, user: } let!(:assigned_batch) { create :batch, assignee: user } let!(:other_batch) { create :batch } @@ -80,7 +80,7 @@ describe '::add_dynamic_validations' do # Specific validator tests can be found in spec/validators let(:pipeline) { create :pipeline, validator_class_name: 'TestPipelineValidator' } - let(:batch) { described_class.new pipeline: pipeline } + let(:batch) { described_class.new pipeline: } it 'fails validation when dynamic validations fail' do stub_const( diff --git a/spec/models/broadcast_event/broadcast_event_spec.rb b/spec/models/broadcast_event/broadcast_event_spec.rb index e98ea36287..7b8a26dd87 100644 --- a/spec/models/broadcast_event/broadcast_event_spec.rb +++ b/spec/models/broadcast_event/broadcast_event_spec.rb @@ -134,7 +134,7 @@ def accessible data_method_a: value_a ) end - let(:event) { ExampleEvent.new(seed: seed, user: user, created_at: time) } + let(:event) { ExampleEvent.new(seed:, user:, created_at: time) } it 'finds subjects with a 1 to 1 relationship' do expect(event.subjects).to be_present diff --git a/spec/models/broadcast_event/lab_event_spec.rb b/spec/models/broadcast_event/lab_event_spec.rb index 572d91c3bd..7e15c6f725 100644 --- a/spec/models/broadcast_event/lab_event_spec.rb +++ b/spec/models/broadcast_event/lab_event_spec.rb @@ -6,7 +6,7 @@ RSpec.describe BroadcastEvent::LabEvent, :broadcast_event do subject do - described_class.create!(seed: lab_event, user: user, created_at: Time.zone.parse('2018-01-12T13:37:03+00:00')) + described_class.create!(seed: lab_event, user:, created_at: Time.zone.parse('2018-01-12T13:37:03+00:00')) end let(:json) { JSON.parse(subject.to_json) } @@ -14,7 +14,7 @@ let(:batch) { create :sequencing_batch } let(:study) { create :study } let!(:request) do - create :sequencing_request_with_assets, batch: batch, request_type: batch.pipeline.request_types.first, study: study + create :sequencing_request_with_assets, batch:, request_type: batch.pipeline.request_types.first, study: end let(:sample) { request.asset.samples.first } let(:stock_asset) { request.asset.labware } @@ -26,7 +26,7 @@ 'key_a' => 'value a', 'key_b' => 'value b' }, - eventful: eventful + eventful: end let(:user) { create :user } diff --git a/spec/models/broadcast_event/library_complete_spec.rb b/spec/models/broadcast_event/library_complete_spec.rb index a0233be7fe..5ff5af70f8 100644 --- a/spec/models/broadcast_event/library_complete_spec.rb +++ b/spec/models/broadcast_event/library_complete_spec.rb @@ -7,8 +7,8 @@ include_context 'a limber target plate with submissions' let(:user) { create(:user) } - let(:work_completion) { WorkCompletion.create!(user: user, target: target_plate, submissions: [target_submission]) } - let(:event) { described_class.create!(seed: work_completion, user: user, properties: { order_id: order.id }) } + let(:work_completion) { WorkCompletion.create!(user:, target: target_plate, submissions: [target_submission]) } + let(:event) { described_class.create!(seed: work_completion, user:, properties: { order_id: order.id }) } let(:subject_hash) { event.as_json['event'][:subjects].group_by(&:role_type) } let(:metadata) { event.as_json['event'][:metadata] } diff --git a/spec/models/broadcast_event/plate_cherrypicked_spec.rb b/spec/models/broadcast_event/plate_cherrypicked_spec.rb index b28c9f4031..a63290b638 100644 --- a/spec/models/broadcast_event/plate_cherrypicked_spec.rb +++ b/spec/models/broadcast_event/plate_cherrypicked_spec.rb @@ -4,7 +4,7 @@ RSpec.describe BroadcastEvent::PlateCherrypicked, :broadcast_event, :heron_events do def subject_record(subject_type, role_type, friendly_name, uuid) - { role_type: role_type, subject_type: subject_type, friendly_name: friendly_name, uuid: uuid } + { role_type:, subject_type:, friendly_name:, uuid: } end let(:uuids) { Array.new(6) { SecureRandom.uuid } } diff --git a/spec/models/broadcast_event/pool_released_spec.rb b/spec/models/broadcast_event/pool_released_spec.rb index 8d2cf90a48..173fb84ef2 100644 --- a/spec/models/broadcast_event/pool_released_spec.rb +++ b/spec/models/broadcast_event/pool_released_spec.rb @@ -19,14 +19,14 @@ asset: source_plate.wells.first, target_asset: tube.receptacle, state: 'passed', - order: order + order: end let(:request2) do create :multiplex_request, asset: source_plate.wells.last, target_asset: tube.receptacle, state: 'passed', - order: order + order: end let(:library_request) { create :library_request, target_asset: source_plate.wells.first } diff --git a/spec/models/broadcast_event/qc_assay_spec.rb b/spec/models/broadcast_event/qc_assay_spec.rb index a611892d5c..f7263eb61f 100644 --- a/spec/models/broadcast_event/qc_assay_spec.rb +++ b/spec/models/broadcast_event/qc_assay_spec.rb @@ -28,7 +28,7 @@ context 'A single assay qc_assay' do let(:qc_assay) do create :qc_assay, - lot_number: lot_number, + lot_number:, qc_results: [ build(:qc_result_concentration, asset: well1, assay_type: 'Example Assay', assay_version: 'v0.0'), build(:qc_result_concentration, asset: well2, assay_type: 'Example Assay', assay_version: 'v0.0') @@ -101,7 +101,7 @@ # but event wise these should be distinguishable. let(:qc_assay) do create :qc_assay, - lot_number: lot_number, + lot_number:, qc_results: [ build(:qc_result_concentration, asset: well1, assay_type: 'Example Assay', assay_version: 'v0.0'), build(:qc_result_concentration, asset: well2, assay_type: 'Other Assay', assay_version: 'v0.0') diff --git a/spec/models/broadcast_event/sequencing_complete_spec.rb b/spec/models/broadcast_event/sequencing_complete_spec.rb index b7e7690b1a..d09ff2e859 100644 --- a/spec/models/broadcast_event/sequencing_complete_spec.rb +++ b/spec/models/broadcast_event/sequencing_complete_spec.rb @@ -7,7 +7,7 @@ let(:study) { create(:study) } let(:project) { create(:project) } let(:sample) { create(:sample) } - let(:aliquot) { create(:aliquot, study: study, project: project, sample: sample) } + let(:aliquot) { create(:aliquot, study:, project:, sample:) } let(:pipeline) { create(:pipeline) } let(:submission) { create(:submission_without_order, priority: 3) } let(:request_type) { create(:sequencing_request_type, product_line: create(:product_line)) } @@ -17,9 +17,9 @@ :sequencing_request_with_assets, project: nil, study: nil, - batch: create(:batch, pipeline: pipeline), - request_type: request_type, - submission: submission, + batch: create(:batch, pipeline:), + request_type:, + submission:, target_asset: lane, request_metadata_attributes: { fragment_size_required_from: 100, @@ -31,7 +31,7 @@ let(:event) do described_class.create!( seed: lane, - user: user, + user:, properties: { result: :passed }, diff --git a/spec/models/bulk_submission_spec.rb b/spec/models/bulk_submission_spec.rb index 6871bd386c..80a63badfa 100644 --- a/spec/models/bulk_submission_spec.rb +++ b/spec/models/bulk_submission_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe BulkSubmission, with: :uploader do - subject { described_class.new(spreadsheet: submission_file, encoding: encoding) } + subject { described_class.new(spreadsheet: submission_file, encoding:) } let(:encoding) { 'Windows-1252' } let(:spreadsheet_path) { Rails.root.join('features', 'submission', 'csv', spreadsheet_filename) } @@ -19,7 +19,7 @@ after { submission_file.close } let!(:study) { create :study, name: 'abc123_study' } - let!(:asset_group) { create :asset_group, name: 'assetgroup123', study: study, asset_count: 2 } + let!(:asset_group) { create :asset_group, name: 'assetgroup123', study:, asset_count: 2 } let!(:library_type) { create :library_type, name: 'Standard' } before do diff --git a/spec/models/cherrypick_request_spec.rb b/spec/models/cherrypick_request_spec.rb index 15d36961e2..e255ed7430 100644 --- a/spec/models/cherrypick_request_spec.rb +++ b/spec/models/cherrypick_request_spec.rb @@ -7,7 +7,7 @@ let(:source_asset) { create :tagged_well } let(:target_asset) { create :empty_well } - before { create :cherrypick_request, asset: source_asset, target_asset: target_asset } + before { create :cherrypick_request, asset: source_asset, target_asset: } it 'transfers the contents of the source asset to the target asset' do expect(target_asset.aliquots.length).to eq(source_asset.aliquots.length) diff --git a/spec/models/cherrypick_task/control_locator_spec.rb b/spec/models/cherrypick_task/control_locator_spec.rb index d69cfe7dc5..7680ad9249 100644 --- a/spec/models/cherrypick_task/control_locator_spec.rb +++ b/spec/models/cherrypick_task/control_locator_spec.rb @@ -5,10 +5,10 @@ RSpec.describe CherrypickTask::ControlLocator do let(:instance) do described_class.new( - batch_id: batch_id, - total_wells: total_wells, - num_control_wells: num_control_wells, - wells_to_leave_free: wells_to_leave_free + batch_id:, + total_wells:, + num_control_wells:, + wells_to_leave_free: ) end @@ -133,7 +133,7 @@ let(:range) { (1...1000) } let(:control_positions) do range.map do |batch_id| - described_class.new(batch_id: batch_id, total_wells: 96, num_control_wells: 1).control_positions(0).first + described_class.new(batch_id:, total_wells: 96, num_control_wells: 1).control_positions(0).first end end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index e0e14f2c2d..4c6c8fefb7 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -53,17 +53,17 @@ let(:asset2) { create :empty_sample_tube } - let(:order1) { create :order_with_submission, study: study, assets: [asset], project: project } - let(:order2) { create :order, study: study, assets: [asset], project: project } - let(:order3) { create :order, study: study, assets: [asset2], project: project } - let(:order4) { create :order_with_submission, study: study, assets: [asset2], project: project } + let(:order1) { create :order_with_submission, study:, assets: [asset], project: } + let(:order2) { create :order, study:, assets: [asset], project: } + let(:order3) { create :order, study:, assets: [asset2], project: } + let(:order4) { create :order_with_submission, study:, assets: [asset2], project: } let(:submission) { order1.submission } let(:submission2) { order4.submission } - let!(:sequencing_request) { create :request_with_sequencing_request_type, submission: submission } - let!(:request) { create :request, order: order1, asset: asset, submission: submission } - let!(:request2) { create :request, order: order2, submission: submission } + let!(:sequencing_request) { create :request_with_sequencing_request_type, submission: } + let!(:request) { create :request, order: order1, asset:, submission: } + let!(:request2) { create :request, order: order2, submission: } let!(:request3) { create :request, order: order4, submission: order4.submission } let!(:sequencing_request2) { create :request_with_sequencing_request_type, submission: order4.submission } @@ -127,7 +127,7 @@ context 'adding to a plate' do let(:plate) { create :plate, well_count: 1 } let(:submission) { create :submission } - let!(:request) { create :request, asset: plate.wells.first, submission: submission } + let!(:request) { create :request, asset: plate.wells.first, submission: } it 'also adds to the request' do create :comment, commentable: plate, description: 'Hello' diff --git a/spec/models/external_release_event_spec.rb b/spec/models/external_release_event_spec.rb index df5c5645c6..27d3306b23 100644 --- a/spec/models/external_release_event_spec.rb +++ b/spec/models/external_release_event_spec.rb @@ -6,7 +6,7 @@ describe '::create_for_asset!' do subject { described_class.create_for_asset!(asset, sendmail) } - let(:asset) { build :lane, aliquots: aliquots, external_release: true } + let(:asset) { build :lane, aliquots:, external_release: true } let(:aliquots) { [study_a, study_a, study_b].map { |s| build :aliquot, study: s } } let(:expected_recipients) { [user_on_multiple_studies.email, user_on_single_study.email] } let(:expected_message) { 'Data to be released externally set true' } diff --git a/spec/models/flowcell_type_spec.rb b/spec/models/flowcell_type_spec.rb index d9baeb9090..1e8ae8f625 100644 --- a/spec/models/flowcell_type_spec.rb +++ b/spec/models/flowcell_type_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe FlowcellType do - subject { described_class.new(name: name) } + subject { described_class.new(name:) } context 'without a name' do let(:name) { '' } diff --git a/spec/models/library_type_spec.rb b/spec/models/library_type_spec.rb index b9fa5787e2..40e85afa8b 100644 --- a/spec/models/library_type_spec.rb +++ b/spec/models/library_type_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe LibraryType do - subject { described_class.new(name: name) } + subject { described_class.new(name:) } context 'without a name' do let(:name) { '' } diff --git a/spec/models/linear_submission_spec.rb b/spec/models/linear_submission_spec.rb index 2a601dadf9..18b12d266b 100644 --- a/spec/models/linear_submission_spec.rb +++ b/spec/models/linear_submission_spec.rb @@ -23,7 +23,7 @@ create :well_request_type, :with_library_types, target_purpose: purpose, for_multiplexing: true end let(:product_criteria) { create :product_criteria } - let(:current_report) { create :qc_report, product_criteria: product_criteria } + let(:current_report) { create :qc_report, product_criteria: } let(:stock_well) { create :well } let(:request_well) do well = create :well @@ -37,11 +37,11 @@ let(:mpx_submission) do create( :linear_submission, - study: study, - project: project, - user: user, + study:, + project:, + user:, request_types: [library_creation_request_type.id, sequencing_request_type.id], - request_options: request_options, + request_options:, product: product_criteria.product, assets: [request_well] ).submission @@ -73,12 +73,12 @@ let(:mpx_submission) do create( :linear_submission, - study: study, - project: project, - user: user, + study:, + project:, + user:, assets: mpx_assets, request_types: request_type_option, - request_options: request_options + request_options: ).submission end @@ -135,12 +135,12 @@ let(:assets) { create_list(:untagged_well, 2) } let(:basic_options) do { - study: study, - project: project, - user: user, + study:, + project:, + user:, request_types: request_type_option, - request_options: request_options, - assets: assets + request_options:, + assets: } end let(:submission) { create(:linear_submission, basic_options).submission.tap(&:built!) } @@ -160,12 +160,12 @@ let(:submission) do create( :linear_submission, - study: study, - project: project, - user: user, - assets: assets, + study:, + project:, + user:, + assets:, request_types: request_type_option, - request_options: request_options, + request_options:, comments: 'This is a comment' ).submission end @@ -259,10 +259,10 @@ let(:submission) do create( :linear_submission, - study: study, - project: project, - user: user, - assets: assets, + study:, + project:, + user:, + assets:, request_types: [lib_request_type.id, sequencing_request_type.id], request_options: { :multiplier => { @@ -289,10 +289,10 @@ let(:submission) do create( :linear_submission, - study: study, - project: project, - user: user, - assets: assets, + study:, + project:, + user:, + assets:, request_types: [mx_request_type.id, sequencing_request_type.id], request_options: { :multiplier => { diff --git a/spec/models/location_report_form_spec.rb b/spec/models/location_report_form_spec.rb index 830e90742a..191dc3955f 100644 --- a/spec/models/location_report_form_spec.rb +++ b/spec/models/location_report_form_spec.rb @@ -44,15 +44,15 @@ let(:location_report_form) do build( :location_report_form, - report_type: report_type, - name: name, - location_barcode: location_barcode, - faculty_sponsor_ids: faculty_sponsor_ids, - study_id: study_id, - start_date: start_date, - end_date: end_date, - plate_purpose_ids: plate_purpose_ids, - barcodes_text: barcodes_text + report_type:, + name:, + location_barcode:, + faculty_sponsor_ids:, + study_id:, + start_date:, + end_date:, + plate_purpose_ids:, + barcodes_text: ) end let(:report_type) { nil } diff --git a/spec/models/location_report_spec.rb b/spec/models/location_report_spec.rb index e1911820a7..f449acebb2 100644 --- a/spec/models/location_report_spec.rb +++ b/spec/models/location_report_spec.rb @@ -44,7 +44,7 @@ # add retention instruction metadata to plate 1 custom metadatum collection let(:retention_key) { 'retention_instruction' } let(:retention_value) { 'Long term storage' } - let(:plate_1_custom_metadatum_collection) { create :custom_metadatum_collection, asset: plate_1, user: user } + let(:plate_1_custom_metadatum_collection) { create :custom_metadatum_collection, asset: plate_1, user: } let(:plate_1_custom_metadatum) do create :custom_metadatum, custom_metadatum_collection: plate_1_custom_metadatum_collection, @@ -78,7 +78,7 @@ let(:plt_3_received_date) { 'Unknown' } # add retention instruction metadata to plate 3 custom metadatum collection - let(:plate_3_custom_metadatum_collection) { create :custom_metadatum_collection, asset: plate_3, user: user } + let(:plate_3_custom_metadatum_collection) { create :custom_metadatum_collection, asset: plate_3, user: } let(:plate_3_custom_metadatum) do create :custom_metadatum, custom_metadatum_collection: plate_3_custom_metadatum_collection, @@ -107,15 +107,15 @@ let(:location_report) do build( :location_report, - report_type: report_type, - name: name, - location_barcode: location_barcode, - faculty_sponsor_ids: faculty_sponsor_ids, - study_id: study_id, - start_date: start_date, - end_date: end_date, - plate_purpose_ids: plate_purpose_ids, - barcodes: barcodes + report_type:, + name:, + location_barcode:, + faculty_sponsor_ids:, + study_id:, + start_date:, + end_date:, + plate_purpose_ids:, + barcodes: ) end let(:report_type) { nil } @@ -240,9 +240,9 @@ [plate_3.machine_barcode.to_s, 'Shelf 3', locn_prefix] ].each do |lw_barcode, lw_locn_name, lw_locn_parentage| stub_lwclient_labware_find_by_bc( - lw_barcode: lw_barcode, - lw_locn_name: lw_locn_name, - lw_locn_parentage: lw_locn_parentage + lw_barcode:, + lw_locn_name:, + lw_locn_parentage: ) end diff --git a/spec/models/lot_type_spec.rb b/spec/models/lot_type_spec.rb index d2a76a4121..205c63e4bd 100644 --- a/spec/models/lot_type_spec.rb +++ b/spec/models/lot_type_spec.rb @@ -21,7 +21,7 @@ let(:lot_type) { create :lot_type } let(:user) { create :user } let(:template) { PlateTemplate.new } - let(:lot) { lot_type.create!(template: template, user: user, lot_number: '123456789', received_at: '2014-02-01') } + let(:lot) { lot_type.create!(template:, user:, lot_number: '123456789', received_at: '2014-02-01') } context 'create' do it 'change Lot.count by 1' do diff --git a/spec/models/orders/automated_order_spec.rb b/spec/models/orders/automated_order_spec.rb index 667fd020a2..fa5d1c01f6 100644 --- a/spec/models/orders/automated_order_spec.rb +++ b/spec/models/orders/automated_order_spec.rb @@ -4,10 +4,10 @@ require_relative 'shared_order_specs' RSpec.describe AutomatedOrder do - subject { build :automated_order, assets: assets } + subject { build :automated_order, assets: } let(:assets) { [tube] } - let(:tube) { create :multiplexed_library_tube, aliquots: aliquots } + let(:tube) { create :multiplexed_library_tube, aliquots: } let(:study) { create :study } let(:project) { create :project } diff --git a/spec/models/orders/order_spec.rb b/spec/models/orders/order_spec.rb index f9962ff643..8993c0be82 100644 --- a/spec/models/orders/order_spec.rb +++ b/spec/models/orders/order_spec.rb @@ -17,15 +17,15 @@ subject(:order) do build :order, - assets: assets, - autodetect_studies: autodetect_studies, - autodetect_projects: autodetect_projects, + assets:, + autodetect_studies:, + autodetect_projects:, study: nil, project: nil end let(:assets) { [tube] } - let(:tube) { create :sample_tube, aliquots: aliquots } + let(:tube) { create :sample_tube, aliquots: } let(:study_state) { 'active' } context 'with autodetection turned on' do @@ -48,7 +48,7 @@ context 'with autodetection turned off' do let(:autodetect_studies) { false } let(:autodetect_projects) { false } - let(:aliquots) { create_list :tagged_aliquot, 2, study: study, project: project } + let(:aliquots) { create_list :tagged_aliquot, 2, study:, project: } it { is_expected.not_to be_valid } end @@ -116,13 +116,13 @@ end it 'order should not be valid if study is not active' do - order = build :order, study: study, assets: [asset.receptacle], project: project + order = build(:order, study:, assets: [asset.receptacle], project:) expect(order).not_to be_valid end it 'order should be valid if study is active on create' do study.activate! - order = create :order, study: study, assets: [asset.receptacle], project: project + order = create(:order, study:, assets: [asset.receptacle], project:) assert order.valid? study.deactivate! new_asset = create :empty_sample_tube diff --git a/spec/models/orders/shared_order_specs.rb b/spec/models/orders/shared_order_specs.rb index 3abe93fbe6..a83dbba565 100644 --- a/spec/models/orders/shared_order_specs.rb +++ b/spec/models/orders/shared_order_specs.rb @@ -16,7 +16,7 @@ end context 'with a single study/project tube' do - let(:aliquots) { create_list :tagged_aliquot, 2, study: study, project: project } + let(:aliquots) { create_list :tagged_aliquot, 2, study:, project: } it { is_expected.to be_valid } diff --git a/spec/models/phi_x/spiked_buffer_spec.rb b/spec/models/phi_x/spiked_buffer_spec.rb index 260178d970..71181f96aa 100644 --- a/spec/models/phi_x/spiked_buffer_spec.rb +++ b/spec/models/phi_x/spiked_buffer_spec.rb @@ -69,7 +69,7 @@ concentration: '0.8', volume: '10', number: 2, - study_id: study_id + study_id: end before { save } @@ -128,7 +128,7 @@ it 'sets study on the new aliquots' do phi_x_spiked_buffer.created_spiked_buffers.each do |tube| - expect(tube.aliquots).to all have_attributes(study_id: study_id) + expect(tube.aliquots).to all have_attributes(study_id:) end end end diff --git a/spec/models/phi_x/stock_spec.rb b/spec/models/phi_x/stock_spec.rb index 51a0a54097..e0f515cdca 100644 --- a/spec/models/phi_x/stock_spec.rb +++ b/spec/models/phi_x/stock_spec.rb @@ -50,7 +50,7 @@ subject(:save) { phi_x_stock.save } let(:phi_x_stock) do - build :phi_x_stock, number: 2, name: 'Example', concentration: '0.8', tags: tags, study_id: study_id + build :phi_x_stock, number: 2, name: 'Example', concentration: '0.8', tags:, study_id: end let(:tags) { 'Single' } @@ -82,7 +82,7 @@ end it 'sets study id the aliquot in each tube' do - phi_x_stock.created_stocks.each { |tube| expect(tube.aliquots).to all have_attributes(study_id: study_id) } + phi_x_stock.created_stocks.each { |tube| expect(tube.aliquots).to all have_attributes(study_id:) } end it 'generates an aliquot with PhiX sample' do diff --git a/spec/models/pick_list_spec.rb b/spec/models/pick_list_spec.rb index b2c6524d37..64e228e430 100644 --- a/spec/models/pick_list_spec.rb +++ b/spec/models/pick_list_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' RSpec.describe PickList, :pick_list do - subject(:pick_list) { described_class.new(pick_attributes: picks, asynchronous: asynchronous) } + subject(:pick_list) { described_class.new(pick_attributes: picks, asynchronous:) } let(:wells) { create_list :untagged_well, 2 } let(:asynchronous) { false } @@ -29,7 +29,7 @@ context 'when wells lack project information but the pick provides it' do let(:wells) { create_list :untagged_well, 2, project: nil } - let(:picks) { wells.map { |well| { source_receptacle: well, project: project } } } + let(:picks) { wells.map { |well| { source_receptacle: well, project: } } } it { is_expected.to be_valid } end diff --git a/spec/models/plate/quad_creator_spec.rb b/spec/models/plate/quad_creator_spec.rb index aae8a50e50..b8bf4bd7cd 100644 --- a/spec/models/plate/quad_creator_spec.rb +++ b/spec/models/plate/quad_creator_spec.rb @@ -9,7 +9,7 @@ let(:target_purpose) { create :plate_purpose, size: 384 } let(:user) { create :user } - let(:creation_options) { { parent_barcodes: parent_barcodes_hash, target_purpose: target_purpose, user: user } } + let(:creation_options) { { parent_barcodes: parent_barcodes_hash, target_purpose:, user: } } before { allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode)) } @@ -31,7 +31,7 @@ end context 'when loading from barcodes' do - let(:creation_options) { { parent_barcodes: parent_barcodes_hash, target_purpose: target_purpose, user: user } } + let(:creation_options) { { parent_barcodes: parent_barcodes_hash, target_purpose:, user: } } context 'when a barcode is invalid' do let(:parent_barcodes_hash) { { 'quad_1' => 'INVALID' } } diff --git a/spec/models/plate_purpose_spec.rb b/spec/models/plate_purpose_spec.rb index f2a7fabf6e..f9a8aa24aa 100644 --- a/spec/models/plate_purpose_spec.rb +++ b/spec/models/plate_purpose_spec.rb @@ -4,7 +4,7 @@ require 'shared_contexts/limber_shared_context' describe PlatePurpose do - let(:plate_purpose) { create :plate_purpose, target_type: target_type, size: size } + let(:plate_purpose) { create :plate_purpose, target_type:, size: } shared_examples 'a plate factory' do before { expect(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode)) } diff --git a/spec/models/plate_spec.rb b/spec/models/plate_spec.rb index 47db2477ac..133f3a302b 100644 --- a/spec/models/plate_spec.rb +++ b/spec/models/plate_spec.rb @@ -25,7 +25,7 @@ context 'with requests out of the wells' do before do submission = create :submission - request = create :well_request, asset: plate.wells.first, submission: submission + request = create(:well_request, asset: plate.wells.first, submission:) create :comment, commentable: request, description: 'Comment on request' plate.reload end @@ -46,9 +46,9 @@ context 'with requests in progress the wells' do before do submission = create :submission - request = create :well_request, submission: submission - plate.wells.first.aliquots << create(:aliquot, request: request) - create :transfer_request, target_asset: plate.wells.first, submission: submission + request = create(:well_request, submission:) + plate.wells.first.aliquots << create(:aliquot, request:) + create(:transfer_request, target_asset: plate.wells.first, submission:) create :comment, commentable: request, description: 'Comment on request' plate.reload end @@ -63,8 +63,8 @@ context 'with multiple identical comments' do before do submission = create :submission - request = create :well_request, asset: plate.wells.first, submission: submission - request2 = create :well_request, asset: plate.wells.last, submission: submission + request = create(:well_request, asset: plate.wells.first, submission:) + request2 = create(:well_request, asset: plate.wells.last, submission:) create :comment, commentable: request, description: 'Duplicate comment' create :comment, commentable: request2, description: 'Duplicate comment' create :comment, commentable: plate, description: 'Duplicate comment' diff --git a/spec/models/pooling_spec.rb b/spec/models/pooling_spec.rb index 955bd4eb46..5e1ab770ec 100644 --- a/spec/models/pooling_spec.rb +++ b/spec/models/pooling_spec.rb @@ -13,8 +13,8 @@ let(:barcode_printer_option) { nil } let(:pooling) do described_class.new( - barcodes: barcodes, - stock_mx_tube_required: stock_mx_tube_required, + barcodes:, + stock_mx_tube_required:, barcode_printer: barcode_printer_option, count: 1 ) @@ -154,7 +154,7 @@ # set the tags in the second tube to be the same as the first, to create a tag clash tag1 = tagged_lb_tube1.aliquots.first.tag tag2 = tagged_lb_tube1.aliquots.first.tag2 - tagged_lb_tube2.aliquots.first.update!(tag: tag1, tag2: tag2) + tagged_lb_tube2.aliquots.first.update!(tag: tag1, tag2:) end it 'is not valid due to the tag clash' do diff --git a/spec/models/pulldown/requests/isc_library_request_spec.rb b/spec/models/pulldown/requests/isc_library_request_spec.rb index 01f701da30..55287ce817 100644 --- a/spec/models/pulldown/requests/isc_library_request_spec.rb +++ b/spec/models/pulldown/requests/isc_library_request_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Pulldown::Requests::IscLibraryRequest do - subject { build :isc_request, bait_library: bait_library } + subject { build :isc_request, bait_library: } context 'with a active bait library' do let(:bait_library) { create(:bait_library) } diff --git a/spec/models/qc_report_spec.rb b/spec/models/qc_report_spec.rb index 8536b45de6..a6e17582c7 100644 --- a/spec/models/qc_report_spec.rb +++ b/spec/models/qc_report_spec.rb @@ -22,7 +22,7 @@ [@study, @other_study].each do |study| 2.times do |i| attribute = create :well_attribute, current_volume: 500, concentration: 200 - sample = create(:study_sample, study: study).sample + sample = create(:study_sample, study:).sample sample.update!(sanger_sample_id: 'TEST1') well = create :well, @@ -30,7 +30,7 @@ plate: stock_plate, map: create(:map, location_id: i), well_attribute: attribute - well.aliquots.each { |a| a.update!(study: study) } + well.aliquots.each { |a| a.update!(study:) } end end @@ -81,15 +81,15 @@ @matching_report = create :qc_report, - study: study, + study:, exclude_existing: true, product_criteria: current_criteria, report_identifier: 'Override' - @other_report = create :qc_report, study: study, exclude_existing: true, product_criteria: other_criteria + @other_report = create :qc_report, study:, exclude_existing: true, product_criteria: other_criteria @attribute = create :well_attribute, current_volume: 500, concentration: 200 - sample = create(:study_sample, study: study).sample + sample = create(:study_sample, study:).sample @unreported_sample = well = create :well, @@ -97,19 +97,19 @@ plate: stock_plate, map: create(:map, location_id: 1), well_attribute: attribute - well.aliquots.each { |a| a.update!(study: study) } + well.aliquots.each { |a| a.update!(study:) } - sample = create(:study_sample, study: study).sample + sample = create(:study_sample, study:).sample well = create :well, samples: [sample], plate: stock_plate, map: create(:map, location_id: 2), well_attribute: attribute - well.aliquots.each { |a| a.update!(study: study) } + well.aliquots.each { |a| a.update!(study:) } create :qc_metric, asset: well, qc_report: matching_report - sample = create(:study_sample, study: study).sample + sample = create(:study_sample, study:).sample @other_reported_sample = well = create :well, @@ -117,21 +117,21 @@ plate: stock_plate, map: create(:map, location_id: 3), well_attribute: attribute - well.aliquots.each { |a| a.update!(study: study) } + well.aliquots.each { |a| a.update!(study:) } create :qc_metric, asset: well, qc_report: other_report - sample = create(:study_sample, study: study).sample + sample = create(:study_sample, study:).sample well = create :well, samples: [sample], plate: stock_plate, map: create(:map, location_id: 4), well_attribute: attribute - well.aliquots.each { |a| a.update!(study: study) } + well.aliquots.each { |a| a.update!(study:) } create :qc_metric, asset: well, qc_report: matching_report create :qc_metric, asset: well, qc_report: other_report - @qc_report = create :qc_report, study: study, exclude_existing: true, product_criteria: current_criteria + @qc_report = create :qc_report, study:, exclude_existing: true, product_criteria: current_criteria @qc_metric_count = QcMetric.count qc_report.generate! end @@ -168,13 +168,13 @@ let(:plate_purpose_names) { plate_purposes.map(&:name) } before do - create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[0])) - create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[1])) - create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[2])) + create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[0])) + create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[1])) + create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[2])) @qc_report = create :qc_report, - study: study, + study:, exclude_existing: false, product_criteria: create(:product_criteria), plate_purposes: plate_purpose_names diff --git a/spec/models/qc_result/qc_result_spec.rb b/spec/models/qc_result/qc_result_spec.rb index 68143b16cd..2724eaacff 100644 --- a/spec/models/qc_result/qc_result_spec.rb +++ b/spec/models/qc_result/qc_result_spec.rb @@ -55,7 +55,7 @@ it 'can update its asset' do expect(asset).to receive(:update_from_qc).with(an_instance_of(described_class)) - create :qc_result, asset: asset + create :qc_result, asset: end end end diff --git a/spec/models/qcable_creator_spec.rb b/spec/models/qcable_creator_spec.rb index 6d0fd85479..2babb48899 100644 --- a/spec/models/qcable_creator_spec.rb +++ b/spec/models/qcable_creator_spec.rb @@ -7,13 +7,13 @@ let(:lot) { create(:tag2_lot) } it 'will create some qcables with a count' do - qcable_creator = described_class.create(count: 10, user: user, lot: lot) + qcable_creator = described_class.create(count: 10, user:, lot:) expect(qcable_creator.qcables.count).to eq(10) end it 'will create some qcables with a list of barcodes' do barcodes = 'CGAP-1,CGAP-2,CGAP-3,CGAP-4,CGAP-5' - qcable_creator = described_class.create(barcodes: barcodes, user: user, lot: lot) + qcable_creator = described_class.create(barcodes:, user:, lot:) expect(qcable_creator.qcables.count).to eq(5) expect(qcable_creator.qcables.first.barcodes.first.barcode).to eq('CGAP-1') expect(qcable_creator.qcables.last.barcodes.first.barcode).to eq('CGAP-5') @@ -24,7 +24,7 @@ let(:lot) { create(:tag_layout_lot) } it 'will create qcables with single barcode' do - qcable_creator = described_class.create(user: user, lot: lot, supplied_barcode: plate_barcode) + qcable_creator = described_class.create(user:, lot:, supplied_barcode: plate_barcode) expect(qcable_creator.qcables.count).to eq(1) expect(qcable_creator.qcables.first.barcodes.count).to eq(1) expect(qcable_creator.qcables.first.barcodes.first).to eq(plate_barcode) diff --git a/spec/models/qcable_spec.rb b/spec/models/qcable_spec.rb index 8057a1906f..b8ee3536b0 100644 --- a/spec/models/qcable_spec.rb +++ b/spec/models/qcable_spec.rb @@ -7,7 +7,7 @@ let(:qcable_creator) { create(:qcable_creator) } it 'can create an asset with a barcode' do - qcable = described_class.create(qcable_creator: qcable_creator, lot: lot, barcode: 'CGAP-123456') + qcable = described_class.create(qcable_creator:, lot:, barcode: 'CGAP-123456') expect(qcable.asset.barcodes.first.barcode).to eq('CGAP-123456') end end diff --git a/spec/models/racked_tube_spec.rb b/spec/models/racked_tube_spec.rb index d6f583309a..64c26ff7ed 100644 --- a/spec/models/racked_tube_spec.rb +++ b/spec/models/racked_tube_spec.rb @@ -56,7 +56,7 @@ before do Array.new(num_tubes) do |i| - create(:sample_tube, :in_a_rack, tube_rack: tube_rack, coordinate: locations[i], barcodes: [barcodes[i]]) + create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) end end diff --git a/spec/models/receptacle/downstream_aliquots_removal_spec.rb b/spec/models/receptacle/downstream_aliquots_removal_spec.rb index e660c6f25c..e140839344 100644 --- a/spec/models/receptacle/downstream_aliquots_removal_spec.rb +++ b/spec/models/receptacle/downstream_aliquots_removal_spec.rb @@ -32,7 +32,7 @@ context 'when any of the downstream assets have a batch' do let(:batch) { create(:sequencing_batch, request_count: 1) } - before { outer_requests_graph[2].update(batch: batch) } + before { outer_requests_graph[2].update(batch:) } it 'returns false' do expect(original_well).not_to be_allow_to_remove_downstream_aliquots diff --git a/spec/models/receptacle_spec.rb b/spec/models/receptacle_spec.rb index 31688d40d7..51a566f407 100644 --- a/spec/models/receptacle_spec.rb +++ b/spec/models/receptacle_spec.rb @@ -27,7 +27,7 @@ end describe '#update_from_qc' do - let(:qc_result) { build :qc_result, key: key, value: value, units: units, assay_type: 'assay', assay_version: 1 } + let(:qc_result) { build :qc_result, key:, value:, units:, assay_type: 'assay', assay_version: 1 } before { receptacle.update_from_qc(qc_result) } @@ -96,7 +96,7 @@ let(:tag2) { create :tag } let(:receptacle) { create :receptacle } - before { receptacle.update(aliquots: aliquots) } + before { receptacle.update(aliquots:) } context 'when the receptacle has no aliquots' do let(:aliquots) { [] } diff --git a/spec/models/request/traction/grid_ion_spec.rb b/spec/models/request/traction/grid_ion_spec.rb index ec57155c50..fd40ea4615 100644 --- a/spec/models/request/traction/grid_ion_spec.rb +++ b/spec/models/request/traction/grid_ion_spec.rb @@ -8,13 +8,13 @@ build :request_traction_grid_ion, asset: well, request_metadata_attributes: metadata, - order: order, - submission: submission, - request_type: request_type, - state: state + order:, + submission:, + request_type:, + state: end - let(:order) { build(:order, submission: submission, assets: [well], request_types: [request_type.id]) } + let(:order) { build(:order, submission:, assets: [well], request_types: [request_type.id]) } let(:request_type) { create :well_request_type } let(:submission) { build(:submission) } let(:well) { create :well } diff --git a/spec/models/request_information_type_spec.rb b/spec/models/request_information_type_spec.rb index b219efb829..119006403b 100644 --- a/spec/models/request_information_type_spec.rb +++ b/spec/models/request_information_type_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe RequestInformationType do - subject(:request_information_type) { described_class.new(name: name, key: key, label: label, data_type: data_type) } + subject(:request_information_type) { described_class.new(name:, key:, label:, data_type:) } let(:label) { 'example' } @@ -15,7 +15,7 @@ read_length: 76, created_at: Date.parse('2021-03-01') }, - batch: batch + batch: end context 'when key is a request metadata' do @@ -36,8 +36,8 @@ context 'when key is an event' do before do - create :lab_event, descriptors: { 'My event' => 'old value' }, eventful: request, batch: batch - create :lab_event, descriptors: { 'My event' => 'new value' }, eventful: request, batch: batch + create(:lab_event, descriptors: { 'My event' => 'old value' }, eventful: request, batch:) + create :lab_event, descriptors: { 'My event' => 'new value' }, eventful: request, batch: end let(:name) { 'My event' } diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 81886ed366..9edef5b542 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -6,16 +6,16 @@ let(:study) { create :study } let(:project) { create :project } let(:submission) { create :submission } - let(:order1) { create :order, study: study, project: project, submission: submission } - let(:order2) { create :order, study: study, project: project, submission: submission } - let(:order3) { create :order, study: study, project: project, submission: submission } - let(:order4) { create :order_with_submission, study: study, project: project } + let(:order1) { create :order, study:, project:, submission: } + let(:order2) { create :order, study:, project:, submission: } + let(:order3) { create :order, study:, project:, submission: } + let(:order4) { create :order_with_submission, study:, project: } describe '#for_order_including_submission_based_requests' do before do - @sequencing_request = create :request_with_sequencing_request_type, submission: submission - @request = create :request, order: order1, submission: submission, asset: @asset - @request2 = create :request, order: order2, submission: submission + @sequencing_request = create(:request_with_sequencing_request_type, submission:) + @request = create :request, order: order1, submission:, asset: @asset + @request2 = create(:request, order: order2, submission:) @request3 = create :request, order: order4, submission: order4.submission @sequencing_request2 = create :request_with_sequencing_request_type, submission: order4.submission @@ -107,8 +107,8 @@ # themselves via FactoryBot until the two behaviours are uncoupled describe '#next_requests' do let(:submission) { create :submission, orders: [order1, order2], state: 'pending' } - let(:order1) { create(:linear_submission, request_types: order1_request_types, request_options: request_options) } - let(:order2) { create(:linear_submission, request_types: order2_request_types, request_options: request_options) } + let(:order1) { create(:linear_submission, request_types: order1_request_types, request_options:) } + let(:order2) { create(:linear_submission, request_types: order2_request_types, request_options:) } let(:order1_request1) do submission.requests.detect { |r| r.order == order1 && r.request_type_id == order1_request_types.first } end @@ -233,7 +233,7 @@ describe '#copy' do before do @request_type = create :request_type - @request = create :request, request_type: @request_type, study: study, state: 'failed' + @request = create :request, request_type: @request_type, study:, state: 'failed' @new_request = @request.copy end @@ -259,7 +259,7 @@ describe '#after_create' do context 'successful' do let(:study) { create :study } - let(:request) { create :request, study: study } + let(:request) { create :request, study: } it 'not have ActiveRecord errors' do expect(request.errors).to be_empty @@ -273,7 +273,7 @@ describe '#state' do before do - @request = create :request_suitable_for_starting, study: study + @request = create(:request_suitable_for_starting, study:) @user = create :admin @user.grant_owner study end @@ -389,7 +389,7 @@ describe '#eventful_studies' do let(:asset) { create :untagged_well } - let(:request) { create :request, asset: asset, initial_study: study } + let(:request) { create :request, asset:, initial_study: study } context 'with no study itself' do let(:study) { nil } @@ -411,7 +411,7 @@ @all_states = @open_states + @closed_states - @all_states.each { |state| create :request, state: state } + @all_states.each { |state| create :request, state: } expect(described_class.count).to eq(@all_states.size) end @@ -497,7 +497,7 @@ describe '.get_all_comments' do let(:labware) { create :labware } - let(:receptacle) { create :receptacle, labware: labware } + let(:receptacle) { create :receptacle, labware: } let(:request) { create :request, asset: receptacle } before do diff --git a/spec/models/request_type/validator/library_type_validator_spec.rb b/spec/models/request_type/validator/library_type_validator_spec.rb index 767ccd0b46..8e3c8e791a 100644 --- a/spec/models/request_type/validator/library_type_validator_spec.rb +++ b/spec/models/request_type/validator/library_type_validator_spec.rb @@ -4,7 +4,7 @@ describe RequestType::Validator::LibraryTypeValidator do let(:library_type) { create :library_type, name: 'MyLibraryType' } - let(:request_type) { create :library_creation_request_type, :with_library_types, library_type: library_type } + let(:request_type) { create :library_creation_request_type, :with_library_types, library_type: } let(:validator) { described_class.new(request_type.id) } context 'when initialising' do @@ -41,14 +41,14 @@ before do request_type.library_types_request_types << create( :library_types_request_type, - library_type: library_type, - request_type: request_type, + library_type:, + request_type:, is_default: false ) request_type.library_types_request_types << create( :library_types_request_type, library_type: library_type2, - request_type: request_type, + request_type:, is_default: true ) end @@ -62,14 +62,14 @@ before do request_type.library_types_request_types << create( :library_types_request_type, - library_type: library_type, - request_type: request_type, + library_type:, + request_type:, is_default: false ) request_type.library_types_request_types << create( :library_types_request_type, library_type: library_type2, - request_type: request_type, + request_type:, is_default: false ) end diff --git a/spec/models/robot/generator/tecan_spec.rb b/spec/models/robot/generator/tecan_spec.rb index 3fae3deba7..c07789b3b8 100644 --- a/spec/models/robot/generator/tecan_spec.rb +++ b/spec/models/robot/generator/tecan_spec.rb @@ -7,7 +7,7 @@ describe '.as_text' do let(:batch) { instance_double(Batch, total_volume_to_cherrypick: 13) } let(:layout) { Robot::Verification::SourceDestBeds.new.layout_data_object(data_object) } - let(:generator) { described_class.new(picking_data: data_object, batch: batch, layout: layout) } + let(:generator) { described_class.new(picking_data: data_object, batch:, layout:) } context 'when mapping wells from 1 96 well source plate to 1 96 well destination plate' do it 'returns a String object' do diff --git a/spec/models/robot/pick_data_spec.rb b/spec/models/robot/pick_data_spec.rb index b5518b3c2d..c84c586c54 100644 --- a/spec/models/robot/pick_data_spec.rb +++ b/spec/models/robot/pick_data_spec.rb @@ -54,7 +54,7 @@ let(:user) { create :user } - let(:batch) { create :batch, requests: requests, pipeline: pipeline, user: user } + let(:batch) { create :batch, requests:, pipeline:, user: } shared_examples_for 'a picking process' do # This is how the output of the process should be displayed: diff --git a/spec/models/robot/verification/source_dest_beds_spec.rb b/spec/models/robot/verification/source_dest_beds_spec.rb index 03b030c91b..d8eaa11c01 100644 --- a/spec/models/robot/verification/source_dest_beds_spec.rb +++ b/spec/models/robot/verification/source_dest_beds_spec.rb @@ -70,7 +70,7 @@ end end - let(:batch) { create :batch, requests: requests, pipeline: pipeline } + let(:batch) { create :batch, requests:, pipeline: } context 'without control plates' do let(:source_plate_2) { create :plate, well_count: 2 } diff --git a/spec/models/robot/verification/source_dest_control_beds_spec.rb b/spec/models/robot/verification/source_dest_control_beds_spec.rb index 8785f6f502..0846766b6a 100644 --- a/spec/models/robot/verification/source_dest_control_beds_spec.rb +++ b/spec/models/robot/verification/source_dest_control_beds_spec.rb @@ -65,7 +65,7 @@ end end - let(:batch) { create :batch, requests: requests, pipeline: pipeline } + let(:batch) { create :batch, requests:, pipeline: } let(:user) { create :user } let(:robot) { create :hamilton, barcode: '444' } diff --git a/spec/models/sample/metadata_spec.rb b/spec/models/sample/metadata_spec.rb index 8fcc27164b..dfe4f78e43 100644 --- a/spec/models/sample/metadata_spec.rb +++ b/spec/models/sample/metadata_spec.rb @@ -7,7 +7,7 @@ let(:user) { create :user } let(:sample) { create :sample } let(:sample_metadata) { create :sample_metadata_for_api } - let(:sample_with_metadata) { create :sample, sample_metadata: sample_metadata } + let(:sample_with_metadata) { create :sample, sample_metadata: } before { sample.sample_metadata.update(user_id_of_consent_withdrawn: user.id) } diff --git a/spec/models/sample_manifest/generator_spec.rb b/spec/models/sample_manifest/generator_spec.rb index 32d6a976f0..5159ad37eb 100644 --- a/spec/models/sample_manifest/generator_spec.rb +++ b/spec/models/sample_manifest/generator_spec.rb @@ -27,7 +27,7 @@ let(:template) { 'plate_full' } let(:attributes) do - { template: template, study_id: study.id, supplier_id: supplier.id, count: '4' }.with_indifferent_access + { template:, study_id: study.id, supplier_id: supplier.id, count: '4' }.with_indifferent_access end after(:all) { SampleManifestExcel.reset! } diff --git a/spec/models/sample_manifest_spec.rb b/spec/models/sample_manifest_spec.rb index 9b5b09e9db..656db31715 100644 --- a/spec/models/sample_manifest_spec.rb +++ b/spec/models/sample_manifest_spec.rb @@ -11,7 +11,7 @@ describe '#default_filename' do let(:date) { Date.parse('25/10/2018') } - let(:manifest) { create :sample_manifest, study: study, created_at: date } + let(:manifest) { create :sample_manifest, study:, created_at: date } it 'includes the information requested' do expect(manifest.default_filename).to eq("#{study.id}stdy_manifest_#{manifest.id}_251018") @@ -19,7 +19,7 @@ end describe '#generate' do - let(:manifest) { create :sample_manifest, study: study, count: count, asset_type: asset_type, purpose: purpose } + let(:manifest) { create :sample_manifest, study:, count:, asset_type:, purpose: } let(:purpose) { nil } let(:first_plate_barcode) { build(:plate_barcode) } let(:second_plate_barcode) { build(:plate_barcode) } @@ -152,7 +152,7 @@ end context 'with no rapid generation' do - let(:manifest) { create :sample_manifest, study: study } + let(:manifest) { create :sample_manifest, study: } it 'adds created broadcast event when sample manifest is created' do expect { manifest.generate }.to change(BroadcastEvent::SampleManifestCreated, :count).by(1) @@ -359,9 +359,9 @@ describe '#pools' do let(:manifest) do create :plate_sample_manifest_with_manifest_assets, - study: study, + study:, asset_type: 'plate', - num_samples_per_well: num_samples_per_well + num_samples_per_well: end context 'when there is only one sample per well' do diff --git a/spec/models/sample_spec.rb b/spec/models/sample_spec.rb index 08042600fa..eccaf012e9 100644 --- a/spec/models/sample_spec.rb +++ b/spec/models/sample_spec.rb @@ -137,7 +137,7 @@ it 'can have a priority' do %w[backlog surveillance priority].each do |priority| - expect(build(:sample, priority: priority).priority).to eq(priority) + expect(build(:sample, priority:).priority).to eq(priority) end end end diff --git a/spec/models/sequencing_request_spec.rb b/spec/models/sequencing_request_spec.rb index 846df5c234..6ec0f0b195 100644 --- a/spec/models/sequencing_request_spec.rb +++ b/spec/models/sequencing_request_spec.rb @@ -137,11 +137,11 @@ context 'on start' do let(:samples) { create_list :sample, 2 } - let(:study) { create :study, samples: samples } + let(:study) { create :study, samples: } let(:project) { create :project } let(:destination) { create :receptacle } let(:aliquots) { [aliquot1, aliquot2] } - let(:source) { create :receptacle, aliquots: aliquots } + let(:source) { create :receptacle, aliquots: } let(:library_tube) { create :library_tube, receptacles: [source] } let(:sequencing_request) do create( @@ -155,8 +155,8 @@ let(:tags) { create_list :tag, 4 } context 'when compound samples are not necessary because each aliquot has a unique tag combination' do - let(:aliquot1) { create :aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, study: study } - let(:aliquot2) { create :aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[2].id, study: study } + let(:aliquot1) { create :aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, study: } + let(:aliquot2) { create :aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[2].id, study: } it 'performs a normal transfer of aliquots' do expect(sequencing_request.target_asset.aliquots.count).to eq(0) @@ -174,8 +174,8 @@ tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, - study: study, - project: project + study:, + project: end let(:aliquot2) do create :aliquot, @@ -183,8 +183,8 @@ tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, - study: study, - project: project + study:, + project: end it 'creates a compound sample and transfers an aliquot of it' do @@ -198,16 +198,16 @@ context 'when there are two tag combinations' do let(:samples) { create_list :sample, 4 } let(:aliquot1) do - create :aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, study: study + create :aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, study: end let(:aliquot2) do - create :aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, study: study + create :aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, study: end let(:aliquot3) do - create :aliquot, sample: samples[2], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 1, study: study + create :aliquot, sample: samples[2], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 1, study: end let(:aliquot4) do - create :aliquot, sample: samples[3], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 2, study: study + create :aliquot, sample: samples[3], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 2, study: end let(:aliquots) { [aliquot1, aliquot2, aliquot3, aliquot4] } diff --git a/spec/models/specific_tube_creations_spec.rb b/spec/models/specific_tube_creations_spec.rb index ec731b1235..d60e45b793 100644 --- a/spec/models/specific_tube_creations_spec.rb +++ b/spec/models/specific_tube_creations_spec.rb @@ -53,7 +53,7 @@ context 'with no custom names' do let(:names) { [nil] * purpose_count } - let(:creation_parameters) { { user: user, child_purposes: [child_purpose] * purpose_count, parent: parent } } + let(:creation_parameters) { { user:, child_purposes: [child_purpose] * purpose_count, parent: } } context 'with one child purpose' do let(:purpose_count) { 1 } @@ -71,9 +71,9 @@ context 'with custom names' do let(:names) { %w[example_1 example_2] } let(:purpose_count) { 2 } - let(:tube_attributes) { names.map { |name| { name: name } } } + let(:tube_attributes) { names.map { |name| { name: } } } let(:creation_parameters) do - { user: user, child_purposes: [child_purpose] * purpose_count, parent: parent, tube_attributes: tube_attributes } + { user:, child_purposes: [child_purpose] * purpose_count, parent:, tube_attributes: } end it_behaves_like 'a specific tube creator' @@ -85,9 +85,9 @@ let(:names) { ['example_1'] } let(:purpose_count) { 1 } let(:foreign_barcode) { 'FD00000001' } - let(:tube_attributes) { [{ name: names[0], foreign_barcode: foreign_barcode }] } + let(:tube_attributes) { [{ name: names[0], foreign_barcode: }] } let(:creation_parameters) do - { user: user, child_purposes: [child_purpose], parent: parent, tube_attributes: tube_attributes } + { user:, child_purposes: [child_purpose], parent:, tube_attributes: } end describe '#save' do diff --git a/spec/models/state_changer/initial_stock_tube_spec.rb b/spec/models/state_changer/initial_stock_tube_spec.rb index 4fb18fc1fc..a855e0188a 100644 --- a/spec/models/state_changer/initial_stock_tube_spec.rb +++ b/spec/models/state_changer/initial_stock_tube_spec.rb @@ -6,10 +6,10 @@ RSpec.describe StateChanger::InitialStockTube do let(:state_changer) do described_class.new( - labware: labware, - target_state: target_state, - user: user, - customer_accepts_responsibility: customer_accepts_responsibility + labware:, + target_state:, + user:, + customer_accepts_responsibility: ) end @@ -25,7 +25,7 @@ state: transfer_request_state, outer_request: request end - let!(:request) { create :customer_request, asset: well, state: request_state, submission: submission } + let!(:request) { create :customer_request, asset: well, state: request_state, submission: } before do well.stock_wells << well diff --git a/spec/models/state_changer/input_plate_spec.rb b/spec/models/state_changer/input_plate_spec.rb index 4ef4d3361a..23f28eaf92 100644 --- a/spec/models/state_changer/input_plate_spec.rb +++ b/spec/models/state_changer/input_plate_spec.rb @@ -8,10 +8,10 @@ let(:state_changer) do described_class.new( labware: input_plate, - target_state: target_state, - user: user, - contents: contents, - customer_accepts_responsibility: customer_accepts_responsibility + target_state:, + user:, + contents:, + customer_accepts_responsibility: ) end let(:user) { build_stubbed :user } diff --git a/spec/models/state_changer/mx_tube_spec.rb b/spec/models/state_changer/mx_tube_spec.rb index 791f1945de..81ad9b4710 100644 --- a/spec/models/state_changer/mx_tube_spec.rb +++ b/spec/models/state_changer/mx_tube_spec.rb @@ -6,10 +6,10 @@ RSpec.describe StateChanger::MxTube do let(:state_changer) do described_class.new( - labware: labware, - target_state: target_state, - user: user, - customer_accepts_responsibility: customer_accepts_responsibility + labware:, + target_state:, + user:, + customer_accepts_responsibility: ) end @@ -17,7 +17,7 @@ let(:customer_accepts_responsibility) { false } let(:labware) { create :multiplexed_library_tube } let(:transfer_request) { create :transfer_request, target_asset: labware.receptacle, state: transfer_request_state } - let(:request) { create :request, target_asset: labware.receptacle, state: request_state, order: order } + let(:request) { create :request, target_asset: labware.receptacle, state: request_state, order: } let(:requests) { [request] } let(:order) { create :order } diff --git a/spec/models/state_changer/qcable_labware_spec.rb b/spec/models/state_changer/qcable_labware_spec.rb index b8a57f5fa7..10a19408b2 100644 --- a/spec/models/state_changer/qcable_labware_spec.rb +++ b/spec/models/state_changer/qcable_labware_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe StateChanger::QcableLabware do - let(:state_changer) { described_class.new(labware: labware, target_state: 'exhausted', user: user) } + let(:state_changer) { described_class.new(labware:, target_state: 'exhausted', user:) } let!(:qcable) { create :qcable, asset: labware, state: 'available' } let(:labware) { create :plate } let(:user) { build_stubbed :user } diff --git a/spec/models/state_changer/qcable_library_plate_spec.rb b/spec/models/state_changer/qcable_library_plate_spec.rb index 1fd755cd82..2ec8e3327e 100644 --- a/spec/models/state_changer/qcable_library_plate_spec.rb +++ b/spec/models/state_changer/qcable_library_plate_spec.rb @@ -6,11 +6,11 @@ RSpec.describe StateChanger::QcableLibraryPlate do let(:state_changer) do described_class.new( - labware: labware, + labware:, target_state: 'passed', - user: user, - contents: contents, - customer_accepts_responsibility: customer_accepts_responsibility + user:, + contents:, + customer_accepts_responsibility: ) end let(:labware) { instance_double('Plate', wells: [well]) } # rubocop:todo RSpec/VerifiedDoubleReference diff --git a/spec/models/state_changer/standard_plate_spec.rb b/spec/models/state_changer/standard_plate_spec.rb index b12f2b10ca..6a3421bfdf 100644 --- a/spec/models/state_changer/standard_plate_spec.rb +++ b/spec/models/state_changer/standard_plate_spec.rb @@ -7,10 +7,10 @@ let(:state_changer) do described_class.new( labware: target_plate, - target_state: target_state, - user: user, - contents: contents, - customer_accepts_responsibility: customer_accepts_responsibility + target_state:, + user:, + contents:, + customer_accepts_responsibility: ) end let(:user) { build_stubbed :user } diff --git a/spec/models/state_changer/stock_tube_spec.rb b/spec/models/state_changer/stock_tube_spec.rb index 30708aecb7..4c5680edca 100644 --- a/spec/models/state_changer/stock_tube_spec.rb +++ b/spec/models/state_changer/stock_tube_spec.rb @@ -6,10 +6,10 @@ RSpec.describe StateChanger::StockTube do let(:state_changer) do described_class.new( - labware: labware, - target_state: target_state, - user: user, - customer_accepts_responsibility: customer_accepts_responsibility + labware:, + target_state:, + user:, + customer_accepts_responsibility: ) end @@ -20,7 +20,7 @@ let!(:request) { create :request, target_asset: labware.receptacle, state: request_state } before do - labware.receptacle.aliquots << build(:aliquot, request: request) + labware.receptacle.aliquots << build(:aliquot, request:) state_changer.update_labware_state end diff --git a/spec/models/std_library_request_spec.rb b/spec/models/std_library_request_spec.rb index 67f94842ad..46694a31a1 100644 --- a/spec/models/std_library_request_spec.rb +++ b/spec/models/std_library_request_spec.rb @@ -6,7 +6,7 @@ let(:tagged_well) { create :tagged_well } describe '#pass' do - subject { create :library_request, target_asset: tagged_well, state: state } + subject { create :library_request, target_asset: tagged_well, state: } let(:state) { 'started' } @@ -18,7 +18,7 @@ describe '#request_metadata' do subject do - build :library_request, request_metadata_attributes: request_metadata_attributes, request_type: request_type + build :library_request, request_metadata_attributes:, request_type: end let(:fragment_size_required_from) { 1 } @@ -28,10 +28,10 @@ let(:request_metadata_attributes) do { - fragment_size_required_from: fragment_size_required_from, - fragment_size_required_to: fragment_size_required_to, - library_type: library_type, - pcr_cycles: pcr_cycles + fragment_size_required_from:, + fragment_size_required_to:, + library_type:, + pcr_cycles: } end @@ -47,7 +47,7 @@ name: library_type }, request_type: subject.request_type.key, - pcr_cycles: pcr_cycles, + pcr_cycles:, for_multiplexing: false } end diff --git a/spec/models/study_spec.rb b/spec/models/study_spec.rb index 410a566681..a20c613e6c 100644 --- a/spec/models/study_spec.rb +++ b/spec/models/study_spec.rb @@ -12,25 +12,25 @@ requests = [].tap do |r| # Cancelled - 3.times { r << (create :cancelled_request, study: study, request_type: request_type) } + 3.times { r << (create :cancelled_request, study:, request_type:) } # Failed - r << (create :failed_request, study: study, request_type: request_type) + r << (create :failed_request, study:, request_type:) # Passed - 3.times { r << (create :passed_request, study: study, request_type: request_type) } + 3.times { r << (create :passed_request, study:, request_type:) } - r << (create :passed_request, study: study, request_type: request_type_2) - r << (create :passed_request, study: study, request_type: request_type_3) - r << (create :passed_request, study: study, request_type: request_type_3) + r << (create :passed_request, study:, request_type: request_type_2) + r << (create :passed_request, study:, request_type: request_type_3) + r << (create :passed_request, study:, request_type: request_type_3) # Pending - r << (create :pending_request, study: study, request_type: request_type) - r << (create :pending_request, study: study, request_type: request_type_3) + r << (create :pending_request, study:, request_type:) + r << (create :pending_request, study:, request_type: request_type_3) end # we have to hack t - requests.each { |request| request.asset.aliquots.each { |a| a.update(study: study) } } + requests.each { |request| request.asset.aliquots.each { |a| a.update(study:) } } study.save! expect(study).to be_valid @@ -208,9 +208,9 @@ context 'with submissions still unprocessed' do before do - FactoryHelp.submission study: study, state: 'building', assets: [asset] - FactoryHelp.submission study: study, state: 'pending', assets: [asset] - FactoryHelp.submission study: study, state: 'processing', assets: [asset] + FactoryHelp.submission study:, state: 'building', assets: [asset] + FactoryHelp.submission study:, state: 'pending', assets: [asset] + FactoryHelp.submission study:, state: 'processing', assets: [asset] end it 'returns true' do @@ -220,8 +220,8 @@ context 'with no submissions unprocessed' do before do - FactoryHelp.submission study: study, state: 'ready', assets: [asset] - FactoryHelp.submission study: study, state: 'failed', assets: [asset] + FactoryHelp.submission study:, state: 'ready', assets: [asset] + FactoryHelp.submission study:, state: 'failed', assets: [asset] end it 'returns false' do @@ -242,14 +242,14 @@ before do 2.times do - r = create(:passed_request, request_type: request_type, initial_study_id: study.id) + r = create(:passed_request, request_type:, initial_study_id: study.id) r.asset.aliquots.each do |al| al.study = study al.save! end end - create_list(:order, 2, study: study) + create_list(:order, 2, study:) study.projects.each { |project| project.enforce_quotas = true } study.save! @@ -380,10 +380,10 @@ let(:purpose_2) { create :plate_purpose } let(:purpose_3) { create :plate_purpose } let(:purpose_4) { create :plate_purpose } - let!(:well_1) { create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: purpose_1)) } - let!(:well_2) { create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: purpose_2)) } - let!(:well_3) { create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: purpose_3)) } - let!(:well_4) { create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: purpose_4)) } + let!(:well_1) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_1)) } + let!(:well_2) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_2)) } + let!(:well_3) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_3)) } + let!(:well_4) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_4)) } it 'will limit by stock plate purposes if there are no plate purposes' do wells_count = 0 diff --git a/spec/models/submission/submission_creator_spec.rb b/spec/models/submission/submission_creator_spec.rb index 52145bbcda..d2aff207d2 100644 --- a/spec/models/submission/submission_creator_spec.rb +++ b/spec/models/submission/submission_creator_spec.rb @@ -10,7 +10,7 @@ context 'a full template' do let(:library_type) { create :library_type } let(:library_creation_request_type) do - create(:library_request_type, :with_library_types, library_type: library_type) + create(:library_request_type, :with_library_types, library_type:) end let(:template) do create :submission_template, request_types: [library_creation_request_type, create(:sequencing_request_type)] diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index f06ab635cd..9342628fb6 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -39,9 +39,9 @@ request_type_3.id, request_type_4.id ] - order1 = create(:order, request_types: request_types, request_options: { read_length: 100 }) - order2 = create(:order, request_types: request_types, request_options: { read_length: 100 }) - order3 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order1 = create(:order, request_types:, request_options: { read_length: 100 }) + order2 = create(:order, request_types:, request_options: { read_length: 100 }) + order3 = create(:order, request_types:, request_options: { read_length: 100 }) order4 = create(:order, request_types: [request_type_1.id] + request_types, request_options: { read_length: 100 }) expect(build(:submission, orders: [order1, order2, order3, order4])).to be_valid end @@ -65,30 +65,30 @@ it 'are not compatible with different request types after a multiplexed request types' do request_types = [request_type_1.id, request_type_2.id, request_type_for_multiplexing.id, request_type_3.id] - order1 = create(:order, request_types: request_types, request_options: { read_length: 100 }) - order2 = create(:order, request_types: request_types, request_options: { read_length: 100 }) - order3 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order1 = create(:order, request_types:, request_options: { read_length: 100 }) + order2 = create(:order, request_types:, request_options: { read_length: 100 }) + order3 = create(:order, request_types:, request_options: { read_length: 100 }) request_types[3] = request_type_4.id - order4 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order4 = create(:order, request_types:, request_options: { read_length: 100 }) expect(build(:submission, orders: [order1, order2, order3, order4])).not_to be_valid end it 'are not compatible if any of the read lengths are different' do request_types = [request_type_1.id, request_type_2.id, request_type_for_multiplexing.id, request_type_3.id] - order1 = create(:order, request_types: request_types, request_options: { read_length: 100 }) - order2 = create(:order, request_types: request_types, request_options: { read_length: 100 }) - order3 = create(:order, request_types: request_types, request_options: { read_length: 200 }) - order4 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order1 = create(:order, request_types:, request_options: { read_length: 100 }) + order2 = create(:order, request_types:, request_options: { read_length: 100 }) + order3 = create(:order, request_types:, request_options: { read_length: 200 }) + order4 = create(:order, request_types:, request_options: { read_length: 100 }) expect(build(:submission, orders: [order1, order2, order3, order4])).not_to be_valid end it 'are not compatible if at least one of the request types are not for multiplexing' do request_types = [request_type_1.id, request_type_2.id, request_type_for_multiplexing.id, request_type_3.id] - order1 = create(:order, request_types: request_types, request_options: { read_length: 100 }) - order2 = create(:order, request_types: request_types, request_options: { read_length: 100 }) - order3 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order1 = create(:order, request_types:, request_options: { read_length: 100 }) + order2 = create(:order, request_types:, request_options: { read_length: 100 }) + order3 = create(:order, request_types:, request_options: { read_length: 100 }) request_types = [request_type_1.id, request_type_2.id, request_type_3.id, request_type_4.id] - order4 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order4 = create(:order, request_types:, request_options: { read_length: 100 }) expect(build(:submission, orders: [order1, order2, order3, order4])).not_to be_valid end end @@ -109,8 +109,8 @@ describe '#used_tags' do let(:submission) { create :submission } - let(:request_1) { create :request, submission: submission } - let(:request_2) { create :request, submission: submission } + let(:request_1) { create :request, submission: } + let(:request_2) { create :request, submission: } let(:tag_a) { create :tag } let(:tag2_a) { create :tag } let(:tag_b) { create :tag } diff --git a/spec/models/tag2_layout_spec.rb b/spec/models/tag2_layout_spec.rb index d51b417d47..52eb27d9fd 100644 --- a/spec/models/tag2_layout_spec.rb +++ b/spec/models/tag2_layout_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' RSpec.describe Tag2Layout do - subject { create :tag2_layout, plate: plate, tag: tag } + subject { create :tag2_layout, plate:, tag: } let(:plate) { create :plate_with_untagged_wells, :with_submissions, sample_count: 2 } let(:tag) { create :tag } - let!(:tag2_layout_template) { create :tag2_layout_template, tag: tag } + let!(:tag2_layout_template) { create :tag2_layout_template, tag: } it 'applies its tag to every well of the plate' do expect(subject.plate.wells).to be_present diff --git a/spec/models/tag2_layout_template_spec.rb b/spec/models/tag2_layout_template_spec.rb index 618d69597a..e6e7335e65 100644 --- a/spec/models/tag2_layout_template_spec.rb +++ b/spec/models/tag2_layout_template_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' RSpec.describe Tag2LayoutTemplate do - subject { tag2_layout_template.create! plate: plate, tag: tag, user: user } + subject { tag2_layout_template.create! plate:, tag:, user: } let(:plate) { create :plate_with_untagged_wells, :with_submissions, sample_count: 2 } let(:tag) { create :tag } let(:user) { create :user } - let(:tag2_layout_template) { create :tag2_layout_template, tag: tag } + let(:tag2_layout_template) { create :tag2_layout_template, tag: } it 'applies its tag to every well of the plate' do expect(subject.plate.wells).to be_present diff --git a/spec/models/tag_group/adapter_type_spec.rb b/spec/models/tag_group/adapter_type_spec.rb index 762f371bb8..5c83667610 100644 --- a/spec/models/tag_group/adapter_type_spec.rb +++ b/spec/models/tag_group/adapter_type_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe TagGroup::AdapterType do - subject(:adapter_type) { build :adapter_type, name: name } + subject(:adapter_type) { build :adapter_type, name: } context 'when it has a unique name' do let(:name) { 'name' } @@ -18,7 +18,7 @@ end context 'when it is in use' do - before { create :tag_group, adapter_type: adapter_type } + before { create :tag_group, adapter_type: } it { is_expected.to be false } end diff --git a/spec/models/tag_group_spec.rb b/spec/models/tag_group_spec.rb index 3d32ddc190..eb8279a17d 100644 --- a/spec/models/tag_group_spec.rb +++ b/spec/models/tag_group_spec.rb @@ -52,7 +52,7 @@ describe '#adapter_type_name' do subject { tag_group.adapter_type_name } - let(:tag_group) { build_stubbed :tag_group, adapter_type: adapter_type } + let(:tag_group) { build_stubbed :tag_group, adapter_type: } context 'when an adapter type is specified' do let(:adapter_type) { build_stubbed :adapter_type, name: 'name' } @@ -69,7 +69,7 @@ describe '#by_adaptor_type' do let!(:adapter_type) { create(:adapter_type, name: 'test_adapter') } - let!(:tag_group) { create(:tag_group, adapter_type: adapter_type) } + let!(:tag_group) { create(:tag_group, adapter_type:) } context 'a tag group' do it 'is selected when the scope adapter name matches' do diff --git a/spec/models/tag_layout_spec.rb b/spec/models/tag_layout_spec.rb index cb1f537a81..0476597a57 100644 --- a/spec/models/tag_layout_spec.rb +++ b/spec/models/tag_layout_spec.rb @@ -11,7 +11,7 @@ def generate_tag_layout(plate, tag_type = :tag) end let(:plate) { create :plate_with_untagged_wells, well_count: 8 } - let(:tag_group) { create :tag_group, tag_count: tag_count } + let(:tag_group) { create :tag_group, tag_count: } let(:tag2_group) { nil } let(:tag_count) { 16 } let(:user) { create :user } @@ -44,13 +44,13 @@ def generate_tag_layout(plate, tag_type = :tag) before do create( :tag_layout, - plate: plate, - user: user, - tag_group: tag_group, - tag2_group: tag2_group, - walking_by: walking_by, - direction: direction, - initial_tag: initial_tag + plate:, + user:, + tag_group:, + tag2_group:, + walking_by:, + direction:, + initial_tag: ) end @@ -110,7 +110,7 @@ def generate_tag_layout(plate, tag_type = :tag) context 'with a 384 well plate' do let(:plate) { create :plate_with_untagged_wells, sample_count: 4 * 16, size: 384 } let(:tag_count) { 384 } - let(:tag2_group) { create :tag_group, tag_count: tag_count } + let(:tag2_group) { create :tag_group, tag_count: } let(:expected_tag_layout) do { 'A1' => [1], @@ -271,7 +271,7 @@ def generate_tag_layout(plate, tag_type = :tag) context 'with a 384 well plate' do let(:plate) { create :plate_with_untagged_wells, sample_count: 4 * 16, size: 384 } let(:tag_count) { 384 } - let(:tag2_group) { create :tag_group, tag_count: tag_count } + let(:tag2_group) { create :tag_group, tag_count: } let(:expected_tag_layout) do { 'A1' => [1], @@ -428,7 +428,7 @@ def generate_tag_layout(plate, tag_type = :tag) context 'with a 384 well plate' do let(:plate) { create :plate_with_untagged_wells, sample_count: 4 * 16, size: 384 } let(:tag_count) { 384 } - let(:tag2_group) { create :tag_group, tag_count: tag_count } + let(:tag2_group) { create :tag_group, tag_count: } let(:expected_tag_layout) do { 'A1' => [1], @@ -585,7 +585,7 @@ def generate_tag_layout(plate, tag_type = :tag) context 'with a 384 well plate' do let(:plate) { create :plate_with_untagged_wells, sample_count: 4 * 16, size: 384 } let(:tag_count) { 384 } - let(:tag2_group) { create :tag_group, tag_count: tag_count } + let(:tag2_group) { create :tag_group, tag_count: } let(:expected_tag_layout) do { 'A1' => [96], @@ -742,7 +742,7 @@ def generate_tag_layout(plate, tag_type = :tag) context 'with a 384 well plate' do let(:plate) { create :plate_with_untagged_wells, sample_count: 4 * 16, size: 384 } let(:tag_count) { 384 } - let(:tag2_group) { create :tag_group, tag_count: tag_count } + let(:tag2_group) { create :tag_group, tag_count: } let(:expected_tag_layout) do { 'A1' => [1], @@ -1025,7 +1025,7 @@ def generate_tag_layout(plate, tag_type = :tag) end context 'with a tag2 group' do - let(:tag2_group) { create :tag_group, tag_count: tag_count } + let(:tag2_group) { create :tag_group, tag_count: } let(:walking_by) { 'wells of plate' } let(:direction) { 'column' } let(:expected_tag_layout) do diff --git a/spec/models/tag_layout_template_spec.rb b/spec/models/tag_layout_template_spec.rb index 65473dc58c..297b06eed6 100644 --- a/spec/models/tag_layout_template_spec.rb +++ b/spec/models/tag_layout_template_spec.rb @@ -9,14 +9,14 @@ describe TagLayoutTemplate do let(:template) do build :tag_layout_template, - direction_algorithm: direction_algorithm, - walking_algorithm: walking_algorithm, - tag2_group: tag2_group, + direction_algorithm:, + walking_algorithm:, + tag2_group:, tags: ['AAA'] end describe '#create!' do - subject { template.create!(plate: plate, user: user) } + subject { template.create!(plate:, user:) } let(:user) { build :user } @@ -79,7 +79,7 @@ end context 'with a tag2 group with uniqueness unenforced' do - subject { template.create!(plate: plate, user: user, enforce_uniqueness: enforce_uniqueness) } + subject { template.create!(plate:, user:, enforce_uniqueness:) } let(:enforce_uniqueness) { nil } let(:tag2_group) { create :tag_group_with_tags } diff --git a/spec/models/tag_set_spec.rb b/spec/models/tag_set_spec.rb index 243f9917a7..6e0b60d4ad 100644 --- a/spec/models/tag_set_spec.rb +++ b/spec/models/tag_set_spec.rb @@ -16,9 +16,9 @@ it 'is valid when the tag groups have the same adapter type' do adapter_type = build(:adapter_type) - tag_group = create(:tag_group, adapter_type: adapter_type) - tag_group2 = create(:tag_group, adapter_type: adapter_type) - tag_set = build(:tag_set, tag_group: tag_group, tag2_group: tag_group2) + tag_group = create(:tag_group, adapter_type:) + tag_group2 = create(:tag_group, adapter_type:) + tag_set = build(:tag_set, tag_group:, tag2_group: tag_group2) expect(tag_set).to be_valid end @@ -93,13 +93,13 @@ describe '#visible' do it 'returns true if it only has one tag_group and it is set to visible' do tag_group = create(:tag_group, visible: true) - tag_set = create(:tag_set, tag_group: tag_group, tag2_group: nil) + tag_set = create(:tag_set, tag_group:, tag2_group: nil) expect(tag_set.visible).to be(true) end it 'returns false if it only has one tag_group and it is not set to visible' do tag_group = create(:tag_group, visible: false) - tag_set = create(:tag_set, tag_group: tag_group, tag2_group: nil) + tag_set = create(:tag_set, tag_group:, tag2_group: nil) expect(tag_set.visible).to be(false) end @@ -112,7 +112,7 @@ it 'returns false if one of the tag_groups is not set to visible' do tag_group = create(:tag_group, visible: true) tag_group2 = create(:tag_group, visible: false) - tag_set = create(:tag_set, tag_group: tag_group, tag2_group: tag_group2) + tag_set = create(:tag_set, tag_group:, tag2_group: tag_group2) expect(tag_set.visible).to be(false) end end @@ -120,7 +120,7 @@ describe '#adapter_type' do it 'delegates to tag_group' do tag_group = create(:tag_group) - tag_set = create(:tag_set, tag_group: tag_group, tag2_group: nil) + tag_set = create(:tag_set, tag_group:, tag2_group: nil) expect(tag_set.adapter_type).to eq(tag_group.adapter_type) end end diff --git a/spec/models/tasks/cherrypick_task_spec.rb b/spec/models/tasks/cherrypick_task_spec.rb index e27499943b..2d38d77456 100644 --- a/spec/models/tasks/cherrypick_task_spec.rb +++ b/spec/models/tasks/cherrypick_task_spec.rb @@ -8,12 +8,12 @@ let!(:plate) { create :plate_with_untagged_wells, sample_count: 4 } let(:control_plate) { create :control_plate, sample_count: 2 } let(:requests) do - plate.wells.in_column_major_order.map { |w| create(:cherrypick_request, asset: w, submission: submission) } + plate.wells.in_column_major_order.map { |w| create(:cherrypick_request, asset: w, submission:) } end let(:template) { create(:plate_template, size: 6) } let(:robot) { instance_double('Robot', max_beds: 2) } # rubocop:todo RSpec/VerifiedDoubleReference let(:purpose) { create :purpose } - let(:batch) { instance_double('Batch', id: 1235, requests: requests) } # rubocop:todo RSpec/VerifiedDoubleReference + let(:batch) { instance_double('Batch', id: 1235, requests:) } # rubocop:todo RSpec/VerifiedDoubleReference let(:submission) { create :submission } let(:wells_to_leave_free) { Rails.application.config.plate_default_control_wells_to_leave_free } @@ -36,7 +36,7 @@ def requests_for_plate(plate) batch_id: 1235, total_wells: 6, num_control_wells: 2, - wells_to_leave_free: wells_to_leave_free + wells_to_leave_free: ).and_return(locator) end @@ -63,7 +63,7 @@ def requests_for_plate(plate) context 'when control positions clashes with templates' do let(:instance) { described_class.new } let(:wells) { build_stubbed_list(:well, 1, map_id: 6) } - let(:template) { build_stubbed(:plate_template, size: 6, wells: wells) } + let(:template) { build_stubbed(:plate_template, size: 6, wells:) } let(:destinations) do [ [ @@ -109,7 +109,7 @@ def requests_for_plate(plate) context 'with controls' do before do - requests.first.update(submission: submission) + requests.first.update(submission:) allow(requests.first).to receive(:batch).and_return(batch) end diff --git a/spec/models/tasks/plate_template_task_spec.rb b/spec/models/tasks/plate_template_task_spec.rb index ca528ec5dd..bc33eaf0e4 100644 --- a/spec/models/tasks/plate_template_task_spec.rb +++ b/spec/models/tasks/plate_template_task_spec.rb @@ -27,7 +27,7 @@ create :plate, barcode: "SQPD-#{plate_b_barcode_number}", well_count: 4, well_factory: :untagged_well end - let(:batch) { create :batch, requests: requests, pipeline: pipeline } + let(:batch) { create :batch, requests:, pipeline: } let(:request) { instance_double(ActionDispatch::Request, parameters: params) } let(:workflow) { pipeline.workflow } @@ -57,7 +57,7 @@ let(:file) { instance_double(ActionDispatch::Http::UploadedFile, 'blank?' => false, :read => payload) } - let(:workflow_controller) { instance_double(WorkflowsController, batch: batch) } + let(:workflow_controller) { instance_double(WorkflowsController, batch:) } let(:user) { build :user } describe '#render_task' do @@ -79,7 +79,7 @@ let(:params) do ActionController::Parameters.new( workflow_id: workflow.id, - file: file, + file:, plate_purpose_id: create(:plate_purpose).id ) end diff --git a/spec/models/tasks/set_descriptors_handler/handler_spec.rb b/spec/models/tasks/set_descriptors_handler/handler_spec.rb index c8ebc7c2a9..edd1567dde 100644 --- a/spec/models/tasks/set_descriptors_handler/handler_spec.rb +++ b/spec/models/tasks/set_descriptors_handler/handler_spec.rb @@ -5,7 +5,7 @@ # This is a very tangled test, as I'm hoping to unhook the current dependencies # so need to wrap it at its current level of messiness RSpec.describe Tasks::SetDescriptorsHandler::Handler do - subject(:handler) { described_class.new(controller: controller, params: params, task: task, user: user) } + subject(:handler) { described_class.new(controller:, params:, task:, user:) } let(:batch) { create :batch, request_count: 1 } let(:request) { batch.requests.first } @@ -30,7 +30,7 @@ it 'sets attributes on the lab event' do handler.perform event = request.reload.lab_events.first - expect(event).to have_attributes(description: 'Step 1', descriptor_hash: { 'key' => 'value ' }, user: user) + expect(event).to have_attributes(description: 'Step 1', descriptor_hash: { 'key' => 'value ' }, user:) end it 'sets attributes on the batch event' do @@ -42,7 +42,7 @@ 'task' => 'Step 1', 'task_id' => '1' }, - user: user + user: ) end end diff --git a/spec/models/transfer/between_plates_spec.rb b/spec/models/transfer/between_plates_spec.rb index 2520c6607e..b3583e96da 100644 --- a/spec/models/transfer/between_plates_spec.rb +++ b/spec/models/transfer/between_plates_spec.rb @@ -9,9 +9,9 @@ before do described_class.create!( - source: source, - destination: destination, - user: user, + source:, + destination:, + user:, transfers: { 'A1' => 'A1', 'B1' => 'B1', diff --git a/spec/models/transfer_request_collection_spec.rb b/spec/models/transfer_request_collection_spec.rb index e357ec1de5..fb287f045e 100644 --- a/spec/models/transfer_request_collection_spec.rb +++ b/spec/models/transfer_request_collection_spec.rb @@ -11,7 +11,7 @@ context 'with a single transfer' do let(:creation_attributes) do - { user: user, transfer_requests_attributes: [{ asset: asset, target_asset: target_asset }] } + { user:, transfer_requests_attributes: [{ asset:, target_asset: }] } end context 'and no outer requests' do @@ -36,7 +36,7 @@ context 'and one outer request' do let(:submission) { create :submission } - let!(:outer_request) { create :request, asset: asset, submission: submission } + let!(:outer_request) { create :request, asset:, submission: } describe '#save' do let(:transfer_request) { subject.transfer_requests.first } @@ -60,8 +60,8 @@ context 'and two outer requests' do let(:submission_a) { create :submission } let(:submission_b) { create :submission } - let!(:outer_request) { create :request, asset: asset, submission: submission_a } - let!(:other_outer_request) { create :request, asset: asset, submission: submission_b } + let!(:outer_request) { create :request, asset:, submission: submission_a } + let!(:other_outer_request) { create :request, asset:, submission: submission_b } describe '#save' do let(:transfer_request) { subject.transfer_requests.first } @@ -69,9 +69,9 @@ context 'specifying submission' do let(:creation_attributes) do { - user: user, + user:, transfer_requests_attributes: [ - { asset: asset, target_asset: target_asset, submission: outer_request.submission } + { asset:, target_asset:, submission: outer_request.submission } ] } end @@ -103,8 +103,8 @@ context 'and two outer requests in the same submission' do let(:submission) { create :submission } - let!(:outer_request) { create :request, asset: asset, submission: submission } - let!(:other_outer_request) { create :request, asset: asset, submission: submission } + let!(:outer_request) { create :request, asset:, submission: } + let!(:other_outer_request) { create :request, asset:, submission: } describe '#save' do let(:transfer_request) { subject.transfer_requests.first } @@ -112,9 +112,9 @@ context 'specifying submission' do let(:creation_attributes) do { - user: user, + user:, transfer_requests_attributes: [ - { asset: asset, target_asset: target_asset, submission: outer_request.submission } + { asset:, target_asset:, submission: outer_request.submission } ] } end @@ -127,8 +127,8 @@ context 'specifying outer_request' do let(:creation_attributes) do { - user: user, - transfer_requests_attributes: [{ asset: asset, target_asset: target_asset, outer_request: outer_request }] + user:, + transfer_requests_attributes: [{ asset:, target_asset:, outer_request: }] } end diff --git a/spec/models/transfer_request_spec.rb b/spec/models/transfer_request_spec.rb index 662d6d9d02..7b72c4a7fc 100644 --- a/spec/models/transfer_request_spec.rb +++ b/spec/models/transfer_request_spec.rb @@ -241,19 +241,19 @@ it 'does not permit transfers to the same asset' do asset = create(:sample_tube) - expect { described_class.create!(asset: asset, target_asset: asset) }.to raise_error(ActiveRecord::RecordInvalid) + expect { described_class.create!(asset:, target_asset: asset) }.to raise_error(ActiveRecord::RecordInvalid) end context 'with a tag clash' do let!(:tag) { create :tag } let!(:tag2) { create :tag } - let!(:aliquot_1) { create :aliquot, tag: tag, tag2: tag2 } - let!(:aliquot_2) { create :aliquot, tag: tag, tag2: tag2, receptacle: create(:well) } + let!(:aliquot_1) { create :aliquot, tag:, tag2: } + let!(:aliquot_2) { create :aliquot, tag:, tag2:, receptacle: create(:well) } let!(:target_asset) { create :well, aliquots: [aliquot_1] } it 'raises an exception' do expect do - described_class.create!(asset: aliquot_2.receptacle.reload, target_asset: target_asset) + described_class.create!(asset: aliquot_2.receptacle.reload, target_asset:) end.to raise_error(Aliquot::TagClash) end end @@ -316,7 +316,7 @@ end (%i[pending started passed failed qc_complete cancelled] - transitions.keys).each do |state| it "does not allow #{state} requests to #{event}" do - tf = build :transfer_request, state: state + tf = build(:transfer_request, state:) expect(tf).not_to allow_event(event) end end @@ -409,7 +409,7 @@ context 'when any of the downstream assets have a batch' do let(:batch) { create(:sequencing_batch, request_count: 1) } - before { outer_requests_graph[2].update(batch: batch) } + before { outer_requests_graph[2].update(batch:) } it 'does not remove the downstream aliquots' do expect { transfer_requests.first.fail! }.not_to change { @@ -443,7 +443,7 @@ let(:submission) { create :submission } let(:order) do create :library_order, - submission: submission, + submission:, request_types: [library_request_type.id, multiplex_request_type.id], assets: [source_well_a, source_well_b] end @@ -452,8 +452,8 @@ create :library_request, asset: source_well_a, target_asset: target_well, - submission: submission, - order: order, + submission:, + order:, state: 'passed', request_type: library_request_type end @@ -461,8 +461,8 @@ create :library_request, asset: source_well_b, target_asset: target_well, - submission: submission, - order: order, + submission:, + order:, state: 'passed', request_type: library_request_type end @@ -472,16 +472,16 @@ create :multiplex_request, asset: target_well, target_asset: multiplexed_library_tube, - submission: submission, - order: order, + submission:, + order:, request_type: multiplex_request_type end let(:multiplex_request_b) do create :multiplex_request, asset: target_well, target_asset: multiplexed_library_tube, - submission: submission, - order: order, + submission:, + order:, request_type: multiplex_request_type end @@ -492,12 +492,12 @@ library_request_b multiplex_request_a multiplex_request_b - create :transfer_request, asset: source_well_a, target_asset: target_well, submission: submission - create :transfer_request, asset: source_well_b, target_asset: target_well, submission: submission + create(:transfer_request, asset: source_well_a, target_asset: target_well, submission:) + create :transfer_request, asset: source_well_b, target_asset: target_well, submission: end it 'associated each aliquot with a different library request' do - create :transfer_request, asset: target_well, target_asset: multiplexed_library_tube, submission: submission + create(:transfer_request, asset: target_well, target_asset: multiplexed_library_tube, submission:) expect(multiplexed_library_tube.reload.aliquots.map(&:request_id)).to eq( [multiplex_request_a.id, multiplex_request_a.id, multiplex_request_b.id] ) diff --git a/spec/models/tube_purpose_spec.rb b/spec/models/tube_purpose_spec.rb index 4284e66a31..8581ce7a97 100644 --- a/spec/models/tube_purpose_spec.rb +++ b/spec/models/tube_purpose_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Tube::Purpose do - let(:tube_purpose) { create :tube_purpose, prefix: barcode_prefix, target_type: target_type } + let(:tube_purpose) { create :tube_purpose, prefix: barcode_prefix, target_type: } shared_examples 'a tube factory' do describe '#create!' do diff --git a/spec/models/tube_rack_spec.rb b/spec/models/tube_rack_spec.rb index 2e10216e4b..8a3678bb99 100644 --- a/spec/models/tube_rack_spec.rb +++ b/spec/models/tube_rack_spec.rb @@ -62,7 +62,7 @@ let(:barcodes) { Array.new(num_tubes) { create :fluidx } } let!(:tubes) do Array.new(num_tubes) do |i| - create(:sample_tube, :in_a_rack, tube_rack: tube_rack, coordinate: locations[i], barcodes: [barcodes[i]]) + create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) end end @@ -73,10 +73,10 @@ context 'with a rack with tubes and requests' do let(:tube_rack) { create :tube_rack } - let(:tube_a) { create :tube, :in_a_rack, tube_rack: tube_rack, coordinate: 'A1' } - let(:tube_b) { create :tube, :in_a_rack, tube_rack: tube_rack, coordinate: 'H12' } - let(:aliquot) { create :aliquot, receptacle: tube_a.receptacle, request: create(:request, submission: submission) } - let(:outer_request) { create :request, asset: tube_b.receptacle, submission: submission } + let(:tube_a) { create :tube, :in_a_rack, tube_rack:, coordinate: 'A1' } + let(:tube_b) { create :tube, :in_a_rack, tube_rack:, coordinate: 'H12' } + let(:aliquot) { create :aliquot, receptacle: tube_a.receptacle, request: create(:request, submission:) } + let(:outer_request) { create :request, asset: tube_b.receptacle, submission: } let(:submission) { create :submission } # The comments scope should also retrieve comments associated with tubes, and diff --git a/spec/models/tube_spec.rb b/spec/models/tube_spec.rb index 7e3643c426..71f53282c3 100644 --- a/spec/models/tube_spec.rb +++ b/spec/models/tube_spec.rb @@ -12,7 +12,7 @@ before do Array.new(num_tubes) do |i| - create(:sample_tube, :in_a_rack, tube_rack: tube_rack, coordinate: locations[i], barcodes: [barcodes[i]]) + create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) end end @@ -87,7 +87,7 @@ context 'with requests' do let(:submission) { create :submission } - let!(:request) { create :well_request, asset: tube, submission: submission } + let!(:request) { create :well_request, asset: tube, submission: } before do create :comment, commentable: request, description: 'Comment on request' @@ -111,9 +111,9 @@ context 'with requests in progress the wells' do before do submission = create :submission - request = create :well_request, submission: submission - tube.receptacle.aliquots << create(:aliquot, request: request) - create :transfer_request, target_asset: tube, submission: submission + request = create(:well_request, submission:) + tube.receptacle.aliquots << create(:aliquot, request:) + create(:transfer_request, target_asset: tube, submission:) create :comment, commentable: request, description: 'Comment on request' tube.reload end @@ -128,8 +128,8 @@ context 'with multiple identical comments' do before do submission = create :submission - request = create :well_request, asset: tube, submission: submission - request2 = create :well_request, asset: tube, submission: submission + request = create(:well_request, asset: tube, submission:) + request2 = create(:well_request, asset: tube, submission:) create :comment, commentable: request, description: 'Duplicate comment' create :comment, commentable: request2, description: 'Duplicate comment' create :comment, commentable: tube, description: 'Duplicate comment' diff --git a/spec/models/user_query_spec.rb b/spec/models/user_query_spec.rb index 95b9aa19a7..a987f9e09b 100644 --- a/spec/models/user_query_spec.rb +++ b/spec/models/user_query_spec.rb @@ -8,7 +8,7 @@ let!(:user_query_attributes) do { user_email: 'another_email@example.com', - user: user, + user:, url: 'url', what_was_trying_to_do: 'create', what_happened: 'it did not work', diff --git a/spec/models/well_attribute_spec.rb b/spec/models/well_attribute_spec.rb index d09f8755e9..3c58df2683 100644 --- a/spec/models/well_attribute_spec.rb +++ b/spec/models/well_attribute_spec.rb @@ -4,7 +4,7 @@ describe WellAttribute do let(:well_attribute) { create :well_attribute } - let(:well) { create :well, well_attribute: well_attribute } + let(:well) { create :well, well_attribute: } let!(:warehouse_message) { Messenger.create!(target: well, template: 'WellStockResourceIO', root: 'stock_resource') } it 'does not let current_volume to get negative' do diff --git a/spec/models/well_spec.rb b/spec/models/well_spec.rb index 2cd6989c94..ef5b10e02c 100644 --- a/spec/models/well_spec.rb +++ b/spec/models/well_spec.rb @@ -73,7 +73,7 @@ describe '#update_from_qc' do let(:well_attributes) { { concentration: nil } } - let(:qc_result) { build :qc_result, key: key, value: value, units: units, assay_type: 'assay', assay_version: 1 } + let(:qc_result) { build :qc_result, key:, value:, units:, assay_type: 'assay', assay_version: 1 } before { well.update_from_qc(qc_result) } @@ -162,7 +162,7 @@ purposes = create_list :plate_purpose, 4 stock_plate = create :plate_with_untagged_wells, sample_count: 3 - norm_plates = purposes.map { |purpose| create :plate_with_untagged_wells, purpose: purpose, sample_count: 3 } + norm_plates = purposes.map { |purpose| create :plate_with_untagged_wells, purpose:, sample_count: 3 } well_plate_concentrations = [ # Plate 1, Plate 2, Plate 3 @@ -284,8 +284,8 @@ robot_minimum_picking_volume = 1.0 @source_well.well_attribute.update!( concentration: measured_concentration, - measured_volume: measured_volume, - current_volume: current_volume + measured_volume:, + current_volume: ) @target_well.volume_to_cherrypick_by_nano_grams( minimum_volume, @@ -524,7 +524,7 @@ build(:qc_result_molarity), build(:qc_result_rin) ] - well = create(:well, qc_results: qc_results) + well = create(:well, qc_results:) expect(well.qc_results_by_key.size).to eq(4) expect(well.qc_results_by_key['concentration'].length).to eq(1) end diff --git a/spec/models/work_order_spec.rb b/spec/models/work_order_spec.rb index 8f813399cc..903537e2b5 100644 --- a/spec/models/work_order_spec.rb +++ b/spec/models/work_order_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe WorkOrder do - subject { build :work_order, work_order_type: work_order_type } + subject { build :work_order, work_order_type: } context 'with a work_order_type' do let(:work_order_type) { create :work_order_type } @@ -19,7 +19,7 @@ context 'with requests' do let(:requests) { build_list(:request, 2) } - let(:work_order) { build :work_order, requests: requests } + let(:work_order) { build :work_order, requests: } describe '#state=' do before { work_order.state = 'passed' } @@ -33,14 +33,14 @@ describe WorkOrder::Factory do subject(:factory) { described_class.new(submission) } - let(:submission) { create :submission, requests: requests } + let(:submission) { create :submission, requests: } let(:request_type) { create :request_type } - let(:requests_set_a) { create_list(:request, 3, asset: create(:well), request_type: request_type) } + let(:requests_set_a) { create_list(:request, 3, asset: create(:well), request_type:) } let(:requests) { requests_set_a + requests_set_b } context 'where request types match' do - let(:requests_set_b) { create_list(:request, 3, asset: create(:well), request_type: request_type) } + let(:requests_set_b) { create_list(:request, 3, asset: create(:well), request_type:) } it { is_expected.to be_valid } diff --git a/spec/models/work_order_type_spec.rb b/spec/models/work_order_type_spec.rb index 2e6bd39805..17b6bd85a7 100644 --- a/spec/models/work_order_type_spec.rb +++ b/spec/models/work_order_type_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe WorkOrderType do - subject { build :work_order_type, name: name } + subject { build :work_order_type, name: } context 'with a name' do let(:name) { 'test_order' } @@ -13,7 +13,7 @@ end context 'which already exists' do - before { create :work_order_type, name: name } + before { create :work_order_type, name: } it { is_expected.not_to be_valid } end diff --git a/spec/requests/api/v2/heron/plates_spec.rb b/spec/requests/api/v2/heron/plates_spec.rb index d10ce771c4..9e41c5d208 100644 --- a/spec/requests/api/v2/heron/plates_spec.rb +++ b/spec/requests/api/v2/heron/plates_spec.rb @@ -231,7 +231,7 @@ build(:event_subject, role_type: BroadcastEvent::PlateCherrypicked::ROBOT_ROLE_TYPE, subject_type: 'robot') ] end - let(:events) { [{ event: { event_type: BroadcastEvent::PlateCherrypicked::EVENT_TYPE, subjects: subjects } }] } + let(:events) { [{ event: { event_type: BroadcastEvent::PlateCherrypicked::EVENT_TYPE, subjects: } }] } it_behaves_like 'a successful plate creation' diff --git a/spec/requests/api/v2/heron/tube_racks_spec.rb b/spec/requests/api/v2/heron/tube_racks_spec.rb index 4df9dd827d..bb75f6eae5 100644 --- a/spec/requests/api/v2/heron/tube_racks_spec.rb +++ b/spec/requests/api/v2/heron/tube_racks_spec.rb @@ -43,10 +43,10 @@ data: { 'type' => 'tube_rack', :attributes => { - purpose_uuid: purpose_uuid, + purpose_uuid:, study_uuid: study.uuid, barcode: tube_rack_barcode, - tubes: tubes + tubes: } } } diff --git a/spec/requests/api/v2/receptacles_spec.rb b/spec/requests/api/v2/receptacles_spec.rb index e333bb0ea7..5f46f3f5be 100644 --- a/spec/requests/api/v2/receptacles_spec.rb +++ b/spec/requests/api/v2/receptacles_spec.rb @@ -42,11 +42,11 @@ let(:receptacle) do create :receptacle, - pcr_cycles: pcr_cycles, - submit_for_sequencing: submit_for_sequencing, - sub_pool: sub_pool, - coverage: coverage, - diluent_volume: diluent_volume + pcr_cycles:, + submit_for_sequencing:, + sub_pool:, + coverage:, + diluent_volume: end before { api_get "#{base_endpoint}/#{receptacle.id}" } diff --git a/spec/requests/api/v2/shared_examples/api_key_authenticatable.rb b/spec/requests/api/v2/shared_examples/api_key_authenticatable.rb index 0fae5d16b8..5b93545c22 100644 --- a/spec/requests/api/v2/shared_examples/api_key_authenticatable.rb +++ b/spec/requests/api/v2/shared_examples/api_key_authenticatable.rb @@ -30,7 +30,7 @@ let(:headers) { client_headers.merge!({ 'X-Sequencescape-Client-Id': 'invalid-key' }) } it 'gets an unauthorized response' do - api_get base_endpoint, headers: headers + api_get(base_endpoint, headers:) expect(response).to have_http_status(:unauthorized) end @@ -38,7 +38,7 @@ it 'logs the request with client details' do allow(Rails.logger).to receive(:info) - api_get base_endpoint, headers: headers + api_get(base_endpoint, headers:) expect(Rails.logger).to have_received(:info).with(/Request made with invalid API key/) expect(Rails.logger).to have_received(:info).with(/:remote_ip=>"127.0.0.1"/) @@ -55,7 +55,7 @@ let(:headers) { client_headers.merge!({ 'X-Sequencescape-Client-Id': api_application.key }) } it 'gets a success response' do - api_get base_endpoint, headers: headers + api_get(base_endpoint, headers:) expect(response).to have_http_status(:success) end diff --git a/spec/requests/api/v2/users_spec.rb b/spec/requests/api/v2/users_spec.rb index e87f01c2c5..fe56865dbe 100644 --- a/spec/requests/api/v2/users_spec.rb +++ b/spec/requests/api/v2/users_spec.rb @@ -28,7 +28,7 @@ let(:swipecard_code) { '1234567' } before do - user.update(swipecard_code: swipecard_code) + user.update(swipecard_code:) api_get "#{base_endpoint}?filter[user_code]=#{swipecard_code}" end diff --git a/spec/requests/api/v2/wells_spec.rb b/spec/requests/api/v2/wells_spec.rb index 912695e16d..a2342943e5 100644 --- a/spec/requests/api/v2/wells_spec.rb +++ b/spec/requests/api/v2/wells_spec.rb @@ -33,11 +33,11 @@ let(:well) do create :well, - pcr_cycles: pcr_cycles, - submit_for_sequencing: submit_for_sequencing, - sub_pool: sub_pool, - coverage: coverage, - diluent_volume: diluent_volume + pcr_cycles:, + submit_for_sequencing:, + sub_pool:, + coverage:, + diluent_volume: end describe '#get' do diff --git a/spec/requests/api/v2/work_orders_spec.rb b/spec/requests/api/v2/work_orders_spec.rb index 48d3dfb01b..2ed8fc439e 100644 --- a/spec/requests/api/v2/work_orders_spec.rb +++ b/spec/requests/api/v2/work_orders_spec.rb @@ -100,7 +100,7 @@ context 'with a request' do let(:requests) { create_list :library_request, 2 } - let(:work_order) { create :work_order, requests: requests } + let(:work_order) { create :work_order, requests: } let(:payload) do { diff --git a/spec/requests/plate_picks_request_spec.rb b/spec/requests/plate_picks_request_spec.rb index ebaa591159..1c34437436 100644 --- a/spec/requests/plate_picks_request_spec.rb +++ b/spec/requests/plate_picks_request_spec.rb @@ -55,14 +55,14 @@ end it 'returns the plate', :aggregate_failures do - get "/plate_picks/plates/#{plate.machine_barcode}", headers: headers + get("/plate_picks/plates/#{plate.machine_barcode}", headers:) expect(response.media_type).to eq('application/json') expect(response).to have_http_status(:success) expect(response.parsed_body).to eq(found_plate) end it 'returns 404 if the plate is missing', :aggregate_failures do - get '/plate_picks/plates/not_a_barcode', headers: headers + get('/plate_picks/plates/not_a_barcode', headers:) expect(response.media_type).to eq('application/json') expect(response).to have_http_status(:not_found) expect(response.body).to eq(missing_plate) @@ -78,21 +78,21 @@ end it 'returns the batch', :aggregate_failures do - get "/plate_picks/batches/#{released_cherrypick_batch.id}", headers: headers + get("/plate_picks/batches/#{released_cherrypick_batch.id}", headers:) expect(response.media_type).to eq('application/json') expect(response).to have_http_status(:success) expect(response.parsed_body).to eq(found_batch) end it 'returns an error if the batch has no pick info', :aggregate_failures do - get "/plate_picks/batches/#{pending_cherrypick_batch.id}", headers: headers + get("/plate_picks/batches/#{pending_cherrypick_batch.id}", headers:) expect(response.media_type).to eq('application/json') expect(response).to have_http_status(:conflict) expect(response.body).to eq(not_suitable) end it 'returns 404 if the batch is missing', :aggregate_failures do - get '/plate_picks/batches/not_a_barcode', headers: headers + get('/plate_picks/batches/not_a_barcode', headers:) expect(response.media_type).to eq('application/json') expect(response).to have_http_status(:not_found) expect(response.body).to eq(missing_batch) diff --git a/spec/requests/qc_files_spec.rb b/spec/requests/qc_files_spec.rb index 83d3f5714e..0a67e06808 100644 --- a/spec/requests/qc_files_spec.rb +++ b/spec/requests/qc_files_spec.rb @@ -18,7 +18,7 @@ 'HTTP_COOKIE' => '' } - post "/api/1/#{plate.uuid}/qc_files", params: file.read, headers: headers + post("/api/1/#{plate.uuid}/qc_files", params: file.read, headers:) expect(response).to have_http_status(:success) diff --git a/spec/resources/api/v2/lot_type_resource_spec.rb b/spec/resources/api/v2/lot_type_resource_spec.rb index d32ae1fee1..d120176c53 100644 --- a/spec/resources/api/v2/lot_type_resource_spec.rb +++ b/spec/resources/api/v2/lot_type_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::LotTypeResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :lot_type, template_class: template_class } + let(:resource_model) { build_stubbed :lot_type, template_class: } let(:template_class) { 'TagLayoutTemplate' } # Test attributes diff --git a/spec/resources/api/v2/plate_purpose_resource_spec.rb b/spec/resources/api/v2/plate_purpose_resource_spec.rb index 5bec47000d..0cd64b879b 100644 --- a/spec/resources/api/v2/plate_purpose_resource_spec.rb +++ b/spec/resources/api/v2/plate_purpose_resource_spec.rb @@ -10,7 +10,7 @@ let(:purpose) { PlatePurpose.new } # New instance of PlatePurpose model let(:resource) { described_class.new(purpose, {}) } # Resource wrapping the instance let(:receive) { resource.replace_fields(payload[:data]) } # Simulate receiving payload - let(:payload) { { data: { type: 'plate_purposes', attributes: attributes } } } # Payload to be received + let(:payload) { { data: { type: 'plate_purposes', attributes: } } } # Payload to be received let(:purpose_name) { 'Example Purpose' } let(:plate_size) { 16 } let(:asset_shape_name) { 'Shape4x1' } diff --git a/spec/resources/api/v2/request_resource_spec.rb b/spec/resources/api/v2/request_resource_spec.rb index 23782cc69a..7cb7a0ff1e 100644 --- a/spec/resources/api/v2/request_resource_spec.rb +++ b/spec/resources/api/v2/request_resource_spec.rb @@ -34,7 +34,7 @@ end context 'isc request' do - let(:resource_model) { build_stubbed :isc_request, bait_library: bait_library } + let(:resource_model) { build_stubbed :isc_request, bait_library: } let(:bait_library) { create :bait_library } let(:expected_metadata) do { diff --git a/spec/resources/api/v2/submission_resource_spec.rb b/spec/resources/api/v2/submission_resource_spec.rb index e8e0bc20e3..c94a48d613 100644 --- a/spec/resources/api/v2/submission_resource_spec.rb +++ b/spec/resources/api/v2/submission_resource_spec.rb @@ -7,7 +7,7 @@ subject(:resource) { described_class.new(resource_model, {}) } let(:sequencing_requests) { build_stubbed_list(:sequencing_request, 3) } - let(:resource_model) { build_stubbed :submission, sequencing_requests: sequencing_requests } + let(:resource_model) { build_stubbed :submission, sequencing_requests: } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/tag_group_resource_spec.rb b/spec/resources/api/v2/tag_group_resource_spec.rb index 6c61f3bfd5..54fb257d58 100644 --- a/spec/resources/api/v2/tag_group_resource_spec.rb +++ b/spec/resources/api/v2/tag_group_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::TagGroupResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :tag_group, tags: tags } + let(:resource_model) { build_stubbed :tag_group, tags: } let(:tags) do [ build(:tag, oligo: 'AAA', map_id: 1), diff --git a/spec/resources/api/v2/well_resource_spec.rb b/spec/resources/api/v2/well_resource_spec.rb index 83147eaeb9..a6e88e7731 100644 --- a/spec/resources/api/v2/well_resource_spec.rb +++ b/spec/resources/api/v2/well_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::WellResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :well, plate: plate, map: position } + let(:resource_model) { build_stubbed :well, plate:, map: position } shared_examples 'a well resource' do # Test attributes diff --git a/spec/resources/api/v2/work_order_resource_spec.rb b/spec/resources/api/v2/work_order_resource_spec.rb index bcf6afa6f2..245f994660 100644 --- a/spec/resources/api/v2/work_order_resource_spec.rb +++ b/spec/resources/api/v2/work_order_resource_spec.rb @@ -7,7 +7,7 @@ shared_examples_for 'a work order resource' do subject { described_class.new(work_order, {}) } - let(:work_order) { create(:work_order, requests: requests).reload } + let(:work_order) { create(:work_order, requests:).reload } it { is_expected.to have_attribute :order_type } it { is_expected.to have_attribute :state } diff --git a/spec/sample_manifest_excel/upload/data_spec.rb b/spec/sample_manifest_excel/upload/data_spec.rb index 46e911bdc7..b1bbeb7c2d 100644 --- a/spec/sample_manifest_excel/upload/data_spec.rb +++ b/spec/sample_manifest_excel/upload/data_spec.rb @@ -13,7 +13,7 @@ let(:test_file_name) { 'test_file.xlsx' } let(:test_file) { Rack::Test::UploadedFile.new(Rails.root.join(test_file_name), '') } let(:columns) { SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup } - let!(:download) { build(:test_download_tubes, columns: columns) } + let!(:download) { build(:test_download_tubes, columns:) } before { download.save(test_file_name) } diff --git a/spec/sample_manifest_excel/upload/processor_spec.rb b/spec/sample_manifest_excel/upload/processor_spec.rb index 1faa5aea8d..71fadee0a7 100644 --- a/spec/sample_manifest_excel/upload/processor_spec.rb +++ b/spec/sample_manifest_excel/upload/processor_spec.rb @@ -28,7 +28,7 @@ def cell(row, column) end let(:column_list) { configuration.columns.send(manifest_type) } - let(:upload) { SampleManifestExcel::Upload::Base.new(file: test_file, column_list: column_list, start_row: 9) } + let(:upload) { SampleManifestExcel::Upload::Base.new(file: test_file, column_list:, start_row: 9) } let(:processor) { described_class.new(upload) } let(:test_file_name) { 'test_file.xlsx' } let(:new_test_file_name) { 'new_test_file.xlsx' } @@ -50,7 +50,7 @@ def cell(row, column) reupload2 = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -70,7 +70,7 @@ def cell(row, column) reupload2 = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -89,7 +89,7 @@ def cell(row, column) reupload2 = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -104,7 +104,7 @@ def cell(row, column) reupload2 = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -123,7 +123,7 @@ def cell(row, column) reupload2 = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -144,7 +144,7 @@ def cell(row, column) reupload2 = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -167,7 +167,7 @@ def cell(row, column) reupload2 = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -185,7 +185,7 @@ def cell(row, column) describe SampleManifestExcel::Upload::Processor::OneDTube do let(:manifest_type) { 'tube_library_with_tag_sequences' } - let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } + let(:download) { build(:test_download_tubes, columns: column_list, manifest_type:) } context 'when valid' do it 'will not generate samples on initialisation' do @@ -232,9 +232,9 @@ def cell(row, column) let(:reupload) do SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, - override: override + override: ) end let(:processor) { described_class.new(reupload) } @@ -261,9 +261,9 @@ def cell(row, column) let(:reupload) do SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, - override: override + override: ) end let(:processor) { described_class.new(reupload) } @@ -288,7 +288,7 @@ def cell(row, column) context 'with mandatory fields' do let(:column_list) { configuration.columns.tube_extraction.dup } let(:manifest_type) { 'tube_extraction' } - let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } + let(:download) { build(:test_download_tubes, columns: column_list, manifest_type:) } let(:new_test_file) { Rack::Test::UploadedFile.new(Rails.root.join(new_test_file_name), '') } after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } @@ -300,7 +300,7 @@ def cell(row, column) column_no = column.number cell(row_no - 1, column_no - 1).value = nil # zero-based index download.save(new_test_file_name) - upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list) + upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:) processor = described_class.new(upload) processor.run(nil) expect(processor.errors.full_messages).to include(expected_message) @@ -325,7 +325,7 @@ def cell(row, column) context 'when using extraction tube' do let(:column_list) { configuration.columns.tube_extraction.dup } let(:manifest_type) { 'tube_extraction' } - let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } + let(:download) { build(:test_download_tubes, columns: column_list, manifest_type:) } let(:new_test_file) { Rack::Test::UploadedFile.new(Rails.root.join(new_test_file_name), '') } after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } @@ -336,7 +336,7 @@ def cell(row, column) column_no = column.number cell(row_no - 1, column_no - 1).value = nil # zero-based index download.save(new_test_file_name) - upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list) + upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:) processor = described_class.new(upload) processor.run(nil) expected = "Retention instruction checks failed at row: #{row_no}. Value cannot be blank." @@ -350,7 +350,7 @@ def cell(row, column) (row1..rown).each { |x| cell(x, col1).value = 'Destroy after 2 years' } # Set all the same cell(rown, col1).value = 'Long term storage' # Set one of them different download.save(new_test_file_name) - upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list) + upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:) processor = described_class.new(upload) processor.run(nil) col1 = download.worksheet.columns.find_by(:name, :sanger_tube_id).number - 1 @@ -365,7 +365,7 @@ def cell(row, column) end describe SampleManifestExcel::Upload::Processor::LibraryTube do - let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } + let(:download) { build(:test_download_tubes, columns: column_list, manifest_type:) } context 'with chromium tag-columns' do let(:manifest_type) { 'tube_chromium_library' } @@ -391,7 +391,7 @@ def cell(row, column) describe SampleManifestExcel::Upload::Processor::MultiplexedLibraryTube do let(:manifest_type) { 'tube_multiplexed_library_with_tag_sequences' } - let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } + let(:download) { build(:test_download_tubes, columns: column_list, manifest_type:) } context 'when using tag sequences' do context 'when valid' do @@ -427,7 +427,7 @@ def cell(row, column) end context 'with a partial manifest' do - let(:download) { build(:test_download_tubes_partial, manifest_type: manifest_type, columns: column_list) } + let(:download) { build(:test_download_tubes_partial, manifest_type:, columns: column_list) } it 'will process partial upload and cancel unprocessed requests' do expect(upload.sample_manifest.pending_external_library_creation_requests.count).to eq 6 @@ -455,7 +455,7 @@ def cell(row, column) context 'with mismatched tags' do let(:download) do - build(:test_download_tubes, manifest_type: manifest_type, columns: column_list, validation_errors: [:tags]) + build(:test_download_tubes, manifest_type:, columns: column_list, validation_errors: [:tags]) end it 'will not be valid' do @@ -470,7 +470,7 @@ def cell(row, column) let(:manifest_type) { 'tube_multiplexed_library' } context 'when valid' do - let(:download) { build(:test_download_tubes, manifest_type: manifest_type, columns: column_list) } + let(:download) { build(:test_download_tubes, manifest_type:, columns: column_list) } it 'will process', :aggregate_failures do processor.run(nil) @@ -496,7 +496,7 @@ def cell(row, column) end context 'when partially filled in' do - let(:download) { build(:test_download_tubes_partial, manifest_type: manifest_type, columns: column_list) } + let(:download) { build(:test_download_tubes_partial, manifest_type:, columns: column_list) } it 'will process partial upload and cancel unprocessed requests' do processor = described_class.new(upload) @@ -511,7 +511,7 @@ def cell(row, column) end context 'when manifest is reuploaded and overriden' do - let(:download) { build(:test_download_tubes, manifest_type: manifest_type, columns: column_list) } + let(:download) { build(:test_download_tubes, manifest_type:, columns: column_list) } let(:new_test_file) { Rack::Test::UploadedFile.new(Rails.root.join(new_test_file_name), '') } @@ -529,7 +529,7 @@ def cell(row, column) reupload = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -553,7 +553,7 @@ def cell(row, column) reupload = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -567,7 +567,7 @@ def cell(row, column) reupload = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -580,7 +580,7 @@ def cell(row, column) context 'when tags are mismatched' do let(:download) do - build(:test_download_tubes, manifest_type: manifest_type, columns: column_list, validation_errors: [:tags]) + build(:test_download_tubes, manifest_type:, columns: column_list, validation_errors: [:tags]) end it 'will not be valid' do @@ -702,7 +702,7 @@ def cell(row, column) reupload = SampleManifestExcel::Upload::Base.new( file: new_test_file, - column_list: column_list, + column_list:, start_row: 9, override: true ) @@ -718,7 +718,7 @@ def cell(row, column) it 'will not update the samples if samples data has changed and override is set false' do reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list, start_row: 9) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(reupload.rows).not_to be_all(&:sample_updated?) @@ -750,7 +750,7 @@ def cell(row, column) cell(11, 0).value = 'CGAP-00000' download.save(new_test_file_name) reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list, start_row: 9) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -761,7 +761,7 @@ def cell(row, column) cell(10, 0).value = 'CGAP-11111' download.save(new_test_file_name) reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list, start_row: 9) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -786,7 +786,7 @@ def cell(row, column) cell(row1, col1).value = nil download.save(new_test_file_name) reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list, start_row: 9) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -803,7 +803,7 @@ def cell(row, column) cell(row2, col1).value = 'Long term storage' download.save(new_test_file_name) reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list, start_row: 9) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -1005,8 +1005,8 @@ def cell(row, column) tube_barcode = mock_microservice_responses[tube_rack_barcode]['layout'].keys[counter] Barcode.create(asset: tube, barcode: tube_barcode, format: 'fluidx_barcode') RackedTube.create( - tube: tube, - tube_rack: tube_rack, + tube:, + tube_rack:, coordinate: mock_microservice_responses[tube_rack_barcode]['layout'].values[counter] ) counter += 1 diff --git a/spec/sample_manifest_excel/upload/row_spec.rb b/spec/sample_manifest_excel/upload/row_spec.rb index 9dcca8dfda..797fff391a 100644 --- a/spec/sample_manifest_excel/upload/row_spec.rb +++ b/spec/sample_manifest_excel/upload/row_spec.rb @@ -103,30 +103,30 @@ end it 'is not valid without row number' do - expect(described_class.new(number: 'one', data: data, columns: columns)).not_to be_valid - expect(described_class.new(data: data, columns: columns)).not_to be_valid + expect(described_class.new(number: 'one', data:, columns:)).not_to be_valid + expect(described_class.new(data:, columns:)).not_to be_valid end it 'is not valid without some data' do - expect(described_class.new(number: 1, columns: columns)).not_to be_valid + expect(described_class.new(number: 1, columns:)).not_to be_valid end it 'is not valid without some columns' do - expect(described_class.new(number: 1, data: data)).not_to be_valid + expect(described_class.new(number: 1, data:)).not_to be_valid end it '#value returns value for specified key' do - expect(described_class.new(number: 1, data: data, columns: columns).value(:sanger_sample_id)).to eq( + expect(described_class.new(number: 1, data:, columns:).value(:sanger_sample_id)).to eq( sample_manifest.labware.first.sample_manifest_assets.first.sanger_sample_id ) end it '#at returns value at specified index (offset by 1)' do - expect(described_class.new(number: 1, data: data, columns: columns).at(3)).to eq('AA') + expect(described_class.new(number: 1, data:, columns:).at(3)).to eq('AA') end it '#at strips down spaces including non-breaking ones (\u00A0)' do - row = described_class.new(number: 1, data: data_with_spaces, columns: columns) + row = described_class.new(number: 1, data: data_with_spaces, columns:) tag_cell_content = data_with_spaces[2] tag_cell_content_retrieved = row.at(3) expect(tag_cell_content.bytes[0]).to eq(32) @@ -135,7 +135,7 @@ end it '#at strips down spaces' do - row = described_class.new(number: 1, data: data_with_spaces, columns: columns) + row = described_class.new(number: 1, data: data_with_spaces, columns:) reference_genome_cell_content = data_with_spaces[4] reference_genome_cell_content_retrieved = row.at(5) volume_cell_content = data_with_spaces[6] @@ -148,37 +148,37 @@ end it '#first? is true if this is the first row' do - expect(described_class.new(number: 1, data: data, columns: columns)).to be_first + expect(described_class.new(number: 1, data:, columns:)).to be_first end it 'is not valid without a primary receptacle or sample' do data[1] = 2 - expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be false + expect(described_class.new(number: 1, data:, columns:).validate_sample).to be false data[1] = 999_999 - row = described_class.new(number: 1, data: data, columns: columns) + row = described_class.new(number: 1, data:, columns:) expect(row.validate_sample).to be false expect(row.errors.full_messages).to include('Row 1 - Sample can\'t be blank.') end it 'is not valid unless all specialised fields are valid' do - expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be true + expect(described_class.new(number: 1, data:, columns:).validate_sample).to be true data[5] = 'Dodgy library type' - expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be false + expect(described_class.new(number: 1, data:, columns:).validate_sample).to be false data[5] = 'My New Library Type' data[6] = 'one' - expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be false + expect(described_class.new(number: 1, data:, columns:).validate_sample).to be false end it 'is not valid unless metadata is valid' do - described_class.new(number: 1, data: data, columns: columns) - expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be true + described_class.new(number: 1, data:, columns:) + expect(described_class.new(number: 1, data:, columns:).validate_sample).to be true data[16] = 'Cell-line' - expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be false + expect(described_class.new(number: 1, data:, columns:).validate_sample).to be false end it 'updates the aliquot with the specialised fields' do sample_count = Sample.count - row = described_class.new(number: 1, data: data, columns: columns) + row = described_class.new(number: 1, data:, columns:) row.sample row.update_specialised_fields(tag_group) aliquot = row.aliquots.first @@ -190,7 +190,7 @@ end it 'updates the sample metadata' do - row = described_class.new(number: 1, data: data, columns: columns) + row = described_class.new(number: 1, data:, columns:) row.update_metadata_fields expect(row.metadata).to have_attributes( concentration: '1', @@ -209,7 +209,7 @@ end it 'updates the sample' do - row = described_class.new(number: 1, data: data, columns: columns) + row = described_class.new(number: 1, data:, columns:) row.update_sample(tag_group, false) row.metadata expect(row).to be_sample_updated @@ -257,8 +257,8 @@ sample_manifest.labware.first.sample_manifest_assets.first.sanger_sample_id, '' ] - row = described_class.new(number: 1, data: data, columns: columns) - empty_row = described_class.new(number: 1, data: empty_data, columns: columns) + row = described_class.new(number: 1, data:, columns:) + empty_row = described_class.new(number: 1, data: empty_data, columns:) expect(row.empty?).to be false expect(empty_row.empty?).to be true end @@ -267,7 +267,7 @@ let(:columns) { configuration.columns.tube_multiplexed_library.dup } it 'links up specialised fields' do - row = described_class.new(number: 1, data: data, columns: columns) + row = described_class.new(number: 1, data:, columns:) tag_index = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::TagIndex) } tag_group = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::TagGroup) } tag2_index = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::Tag2Index) } @@ -281,7 +281,7 @@ let(:columns) { configuration.columns.plate_chromium_library.dup } it 'links up specialised fields' do - row = described_class.new(number: 1, data: data, columns: columns) + row = described_class.new(number: 1, data:, columns:) tag_well = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::ChromiumTagWell) } tag_group = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::ChromiumTagGroup) } expect(tag_well.sf_tag_group).to eq tag_group @@ -294,7 +294,7 @@ it 'links up specialised fields' do data[4] = 'Tag Set 1' data[5] = 'B1' - row = described_class.new(number: 1, data: data, columns: columns) + row = described_class.new(number: 1, data:, columns:) dual_index_tag_set = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::DualIndexTagSet) } dual_index_tag_well = @@ -347,7 +347,7 @@ end it 'links up specialised fields' do - row = described_class.new(number: 1, data: data, columns: columns) + row = described_class.new(number: 1, data:, columns:) bs_well = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::Well) } bioscan_supplier_name = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::BioscanSupplierName) } @@ -380,7 +380,7 @@ row_data[1] = sma.sanger_sample_id row_data[2] = tags[i][:i7] row_data[3] = tags[i][:i5] - rows << described_class.new(number: i + 1, data: row_data, columns: columns) + rows << described_class.new(number: i + 1, data: row_data, columns:) end end @@ -424,7 +424,7 @@ row_data[1] = tube.samples.first.sanger_sample_id row_data[2] = tags[i][:i7] row_data[3] = tags[i][:i5] - rows << described_class.new(number: i + 1, data: row_data, columns: columns) + rows << described_class.new(number: i + 1, data: row_data, columns:) end end diff --git a/spec/sample_manifest_excel/upload/rows_spec.rb b/spec/sample_manifest_excel/upload/rows_spec.rb index 8d3ef7fa08..ddc2256a07 100644 --- a/spec/sample_manifest_excel/upload/rows_spec.rb +++ b/spec/sample_manifest_excel/upload/rows_spec.rb @@ -23,32 +23,32 @@ end it 'is not valid without some columns' do - download = build(:test_download_tubes, columns: columns) + download = build(:test_download_tubes, columns:) download.save(test_file_name) expect(described_class.new(SampleManifestExcel::Upload::Data.new(test_file), nil)).not_to be_valid end it 'is not valid unless all of the rows are valid' do - download = build(:test_download_tubes, columns: columns, validation_errors: [:sanger_sample_id_invalid]) + download = build(:test_download_tubes, columns:, validation_errors: [:sanger_sample_id_invalid]) download.save(test_file_name) expect(described_class.new(SampleManifestExcel::Upload::Data.new(test_file), columns)).not_to be_valid end it 'is valid if some rows are empty' do - download = build(:test_download_tubes_partial, columns: columns) + download = build(:test_download_tubes_partial, columns:) download.save(test_file_name) expect(described_class.new(SampleManifestExcel::Upload::Data.new(test_file), columns)).to be_valid end it 'creates the row number relative to the start row' do - download = build(:test_download_tubes, columns: columns, validation_errors: [:insert_size_from]) + download = build(:test_download_tubes, columns:, validation_errors: [:insert_size_from]) download.save(test_file_name) rows = described_class.new(SampleManifestExcel::Upload::Data.new(test_file), columns) expect(rows.first.number).to eq(10) end it 'knows values for all rows at particular column' do - download = build(:test_download_tubes, columns: columns, validation_errors: [:insert_size_from]) + download = build(:test_download_tubes, columns:, validation_errors: [:insert_size_from]) download.save(test_file_name) rows = described_class.new(SampleManifestExcel::Upload::Data.new(test_file), columns) diff --git a/spec/sample_manifest_excel/upload/upload_spec.rb b/spec/sample_manifest_excel/upload/upload_spec.rb index 4833e3b5d5..83a67fdc94 100644 --- a/spec/sample_manifest_excel/upload/upload_spec.rb +++ b/spec/sample_manifest_excel/upload/upload_spec.rb @@ -133,7 +133,7 @@ describe '#processor' do context '1dtube' do let!(:columns) { SampleManifestExcel.configuration.columns.tube_full.dup } - let!(:download) { build(:test_download_tubes, columns: columns) } + let!(:download) { build(:test_download_tubes, columns:) } let(:upload) { SampleManifestExcel::Upload::Base.new(file: test_file, column_list: columns, start_row: 9) } before { download.save(test_file_name) } @@ -151,7 +151,7 @@ context 'library tube with tag sequences' do let!(:columns) { SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup } let!(:download) do - build(:test_download_tubes, columns: columns, manifest_type: 'tube_library_with_tag_sequences') + build(:test_download_tubes, columns:, manifest_type: 'tube_library_with_tag_sequences') end before { download.save(test_file_name) } @@ -311,7 +311,7 @@ context 'plate' do let!(:plate_columns) { SampleManifestExcel.configuration.columns.plate_full.dup } - let(:download) { build(:test_download_plates, columns: plate_columns, study: study) } + let(:download) { build(:test_download_plates, columns: plate_columns, study:) } let(:study) { create(:open_study, accession_number: 'acc') } let(:upload) { SampleManifestExcel::Upload::Base.new(file: test_file, column_list: plate_columns, start_row: 9) } diff --git a/spec/sample_manifest_excel/worksheet_spec.rb b/spec/sample_manifest_excel/worksheet_spec.rb index 7910a82b6b..ba2aabec9e 100644 --- a/spec/sample_manifest_excel/worksheet_spec.rb +++ b/spec/sample_manifest_excel/worksheet_spec.rb @@ -33,13 +33,13 @@ def save_file after { File.delete(test_file) if File.exist?(test_file) } context 'type' do - let(:options) { { workbook: workbook, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' } } + let(:options) { { workbook:, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' } } it 'be Plates for any plate based manifest' do column_list = SampleManifestExcel.configuration.columns.plate_full.dup worksheet = SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest: sample_manifest) + options.merge(columns: column_list, sample_manifest:) ) expect(worksheet.type).to eq('Plates') end @@ -49,7 +49,7 @@ def save_file column_list = SampleManifestExcel.configuration.columns.tube_full.dup worksheet = SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest: sample_manifest) + options.merge(columns: column_list, sample_manifest:) ) expect(worksheet.type).to eq('Tubes') end @@ -59,7 +59,7 @@ def save_file column_list = SampleManifestExcel.configuration.columns.tube_extraction.dup worksheet = SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest: sample_manifest) + options.merge(columns: column_list, sample_manifest:) ) expect(worksheet.type).to eq('Tubes') end @@ -69,7 +69,7 @@ def save_file column_list = SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup worksheet = SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest: sample_manifest) + options.merge(columns: column_list, sample_manifest:) ) expect(worksheet.type).to eq('Tubes') end @@ -79,7 +79,7 @@ def save_file column_list = SampleManifestExcel.configuration.columns.tube_multiplexed_library_with_tag_sequences.dup worksheet = SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest: sample_manifest) + options.merge(columns: column_list, sample_manifest:) ) expect(worksheet.type).to eq('Tubes') end @@ -89,7 +89,7 @@ def save_file column_list = SampleManifestExcel.configuration.columns.tube_rack_default.dup worksheet = SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest: sample_manifest) + options.merge(columns: column_list, sample_manifest:) ) expect(worksheet.type).to eq('Tube Racks') end @@ -98,9 +98,9 @@ def save_file context 'data worksheet' do let!(:worksheet) do SampleManifestExcel::Worksheet::DataWorksheet.new( - workbook: workbook, + workbook:, columns: SampleManifestExcel.configuration.columns.plate_full.dup, - sample_manifest: sample_manifest, + sample_manifest:, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' ) @@ -185,9 +185,9 @@ def save_file context 'tube rack worksheet' do let!(:worksheet) do SampleManifestExcel::Worksheet::DataWorksheet.new( - workbook: workbook, + workbook:, columns: SampleManifestExcel.configuration.columns.tube_rack_default.dup, - sample_manifest: sample_manifest, + sample_manifest:, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' ) @@ -255,9 +255,9 @@ def save_file asset_type: 'multiplexed_library' ) SampleManifestExcel::Worksheet::DataWorksheet.new( - workbook: workbook, + workbook:, columns: SampleManifestExcel.configuration.columns.tube_multiplexed_library_with_tag_sequences.dup, - sample_manifest: sample_manifest, + sample_manifest:, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' ) @@ -292,9 +292,9 @@ def save_file let(:attributes) do { - workbook: workbook, + workbook:, columns: SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup, - data: data, + data:, no_of_rows: 5, study: 'WTCCC', supplier: 'Test supplier', @@ -541,9 +541,9 @@ def save_file end let(:attributes) do { - workbook: workbook, + workbook:, columns: SampleManifestExcel.configuration.columns.tube_extraction.dup, - data: data, + data:, no_of_rows: 5, study: 'WTCCC', supplier: 'Test supplier', @@ -589,9 +589,9 @@ def save_file let(:attributes) do { - workbook: workbook, + workbook:, columns: SampleManifestExcel.configuration.columns.plate_default.dup, - data: data, + data:, no_of_rows: 5, study: 'WTCCC', supplier: 'Test supplier', diff --git a/spec/sequencescape_excel/column_spec.rb b/spec/sequencescape_excel/column_spec.rb index 9453a9c737..769fafc734 100644 --- a/spec/sequencescape_excel/column_spec.rb +++ b/spec/sequencescape_excel/column_spec.rb @@ -199,7 +199,7 @@ end describe '#style' do - subject { described_class.new({ **options, unlocked: unlocked }).style } + subject { described_class.new({ **options, unlocked: }).style } context 'when locked' do let(:unlocked) { false } diff --git a/spec/sequencescape_excel/conditional_formatting_list_spec.rb b/spec/sequencescape_excel/conditional_formatting_list_spec.rb index f97f1ebbb9..586b74b661 100644 --- a/spec/sequencescape_excel/conditional_formatting_list_spec.rb +++ b/spec/sequencescape_excel/conditional_formatting_list_spec.rb @@ -9,7 +9,7 @@ let(:rules) { load_file(folder, 'conditional_formattings') } let(:conditional_formatting_list) { described_class.new(rules) } let(:worksheet) { Axlsx::Workbook.new.add_worksheet } - let(:options) { build(:range).references.merge(worksheet: worksheet) } + let(:options) { build(:range).references.merge(worksheet:) } it 'must have the correct number of options' do expect(conditional_formatting_list.count).to eq(rules.length) diff --git a/spec/sequencescape_excel/conditional_formatting_spec.rb b/spec/sequencescape_excel/conditional_formatting_spec.rb index bfa5c1920d..792dedb008 100644 --- a/spec/sequencescape_excel/conditional_formatting_spec.rb +++ b/spec/sequencescape_excel/conditional_formatting_spec.rb @@ -48,7 +48,7 @@ end it 'update the style from a workbook' do - expect(conditional_formatting.update(worksheet: worksheet)).to be_styled + expect(conditional_formatting.update(worksheet:)).to be_styled end it '#to_h produces a hash of options' do @@ -58,7 +58,7 @@ it 'duplicates correctly' do dup = conditional_formatting.dup expect(dup.formula).to be_nil - conditional_formatting.update(worksheet: worksheet) + conditional_formatting.update(worksheet:) expect(dup).not_to be_styled end end @@ -66,7 +66,7 @@ context 'with formula' do let(:references) { build(:range).references } let(:formula) { { type: :len, operator: '<', operand: 333 } } - let(:conditional_formatting) { described_class.new(rule.merge(formula: formula)) } + let(:conditional_formatting) { described_class.new(rule.merge(formula:)) } it 'has a formula' do expect(conditional_formatting.formula).to eq(SequencescapeExcel::Formula.new(formula)) @@ -83,12 +83,12 @@ end it 'update the style from a worksheet' do - expect(conditional_formatting.update(references.merge(worksheet: worksheet))).to be_styled + expect(conditional_formatting.update(references.merge(worksheet:))).to be_styled end it 'duplicate correctly' do dup = conditional_formatting.dup - conditional_formatting.update(references.merge(worksheet: worksheet)) + conditional_formatting.update(references.merge(worksheet:)) expect(dup.options).not_to eq(conditional_formatting.options) expect(dup.formula).not_to eq(conditional_formatting.formula) end diff --git a/spec/sequencescape_excel/range_spec.rb b/spec/sequencescape_excel/range_spec.rb index 49acf82e95..39a2aefad2 100644 --- a/spec/sequencescape_excel/range_spec.rb +++ b/spec/sequencescape_excel/range_spec.rb @@ -7,7 +7,7 @@ it 'is comparable' do attributes = { - options: options, + options:, first_column: 4, first_row: 5, last_column: 8, @@ -23,7 +23,7 @@ end context 'with static options' do - let(:range) { described_class.new(options: options, first_row: 4) } + let(:range) { described_class.new(options:, first_row: 4) } it 'has some options' do expect(range.options).to eq(options) @@ -39,7 +39,7 @@ it 'sets the last column' do expect(range.last_column).to eq(3) - expect(described_class.new(options: options, first_column: 4, first_row: 4).last_column).to eq(6) + expect(described_class.new(options:, first_column: 4, first_row: 4).last_column).to eq(6) end it 'has a first_cell' do @@ -161,7 +161,7 @@ end context 'without first row' do - let(:range) { described_class.new(options: options) } + let(:range) { described_class.new(options:) } it 'is be valid' do expect(range).not_to be_valid diff --git a/spec/sequencescape_excel/specialised_field_spec.rb b/spec/sequencescape_excel/specialised_field_spec.rb index 6079b25665..94c422295d 100644 --- a/spec/sequencescape_excel/specialised_field_spec.rb +++ b/spec/sequencescape_excel/specialised_field_spec.rb @@ -4,20 +4,20 @@ RSpec.describe SequencescapeExcel::SpecialisedField, :sample_manifest, :sample_manifest_excel, type: :model do let(:map) { create(:map) } - let(:asset) { create(:untagged_well, map: map) } - let(:asset2) { create(:untagged_well, map: map) } + let(:asset) { create(:untagged_well, map:) } + let(:asset2) { create(:untagged_well, map:) } let(:sample_manifest) { create :sample_manifest } let(:sample_manifest_asset) do create :sample_manifest_asset, - asset: asset, + asset:, sanger_sample_id: sample.sanger_sample_id, - sample_manifest: sample_manifest + sample_manifest: end let(:sample_manifest_asset2) do create :sample_manifest_asset, asset: asset2, sanger_sample_id: sample2.sanger_sample_id, - sample_manifest: sample_manifest + sample_manifest: end let!(:library_type) { create(:library_type) } let!(:reference_genome) { create(:reference_genome, name: 'new one') } @@ -31,13 +31,13 @@ let(:class_with_base) { Class.new { include SequencescapeExcel::SpecialisedField::Base } } it 'can be initialized with a value and a sample_manifest_asset' do - thing = class_with_base.new(value: 'value', sample_manifest_asset: sample_manifest_asset) + thing = class_with_base.new(value: 'value', sample_manifest_asset:) expect(thing.value).to eq 'value' expect(thing.sample).to eq sample end it 'knows if value is present' do - thing = class_with_base.new(sample_manifest_asset: sample_manifest_asset) + thing = class_with_base.new(sample_manifest_asset:) expect(thing).not_to be_value_present thing.value = 'value' expect(thing).to be_value_present @@ -67,24 +67,24 @@ def self.name describe SequencescapeExcel::SpecialisedField::LibraryType do it 'will not be valid without a persisted library type' do - expect(described_class.new(value: library_type.name, sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: library_type.name, sample_manifest_asset:)).to be_valid expect( - described_class.new(value: 'A new library type', sample_manifest_asset: sample_manifest_asset) + described_class.new(value: 'A new library type', sample_manifest_asset:) ).not_to be_valid end it 'will add the the value to the aliquot' do - specialised_field = described_class.new(value: library_type.name, sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) + specialised_field = described_class.new(value: library_type.name, sample_manifest_asset:) + specialised_field.update(aliquot:) expect(aliquot.library_type).to eq(library_type.name) end context 'with multiple aliquots' do - let(:asset) { create(:tagged_well, map: map, aliquot_count: 2) } + let(:asset) { create(:tagged_well, map:, aliquot_count: 2) } it 'will add the the value to all aliquots' do - specialised_field = described_class.new(value: library_type.name, sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) + specialised_field = described_class.new(value: library_type.name, sample_manifest_asset:) + specialised_field.update(aliquot:) expect(asset.aliquots).to all(have_attributes(library_type: library_type.name)) end end @@ -92,21 +92,21 @@ def self.name describe SequencescapeExcel::SpecialisedField::ReferenceGenome do it 'is valid, if a value was not provided' do - expect(described_class.new(sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(sample_manifest_asset:)).to be_valid end it 'will not be valid without a persisted reference genome if a value is provided' do expect( - described_class.new(value: reference_genome.name, sample_manifest_asset: sample_manifest_asset) + described_class.new(value: reference_genome.name, sample_manifest_asset:) ).to be_valid expect( - described_class.new(value: 'A new reference genome', sample_manifest_asset: sample_manifest_asset) + described_class.new(value: 'A new reference genome', sample_manifest_asset:) ).not_to be_valid end it 'will add reference genome to sample_metadata' do specialised_field = - described_class.new(value: reference_genome.name, sample_manifest_asset: sample_manifest_asset) + described_class.new(value: reference_genome.name, sample_manifest_asset:) specialised_field.update expect(sample_manifest_asset.sample.sample_metadata.reference_genome).to eq(reference_genome) end @@ -117,13 +117,13 @@ def self.name let(:value2) { '8' } it 'will update the volume in sample metadata' do - specialised_field = described_class.new(value: value, sample_manifest_asset: sample_manifest_asset) + specialised_field = described_class.new(value:, sample_manifest_asset:) specialised_field.update expect(sample_manifest_asset.sample.sample_metadata.volume).to eq(value) end it 'will create a QC result for the asset' do - specialised_field = described_class.new(value: value, sample_manifest_asset: sample_manifest_asset) + specialised_field = described_class.new(value:, sample_manifest_asset:) specialised_field.update qc_result = sample_manifest_asset.asset.qc_results.first expect(qc_result.value).to eq(value.to_f.to_s) @@ -133,7 +133,7 @@ def self.name end it 'will create a QC assay for each sample manifest' do - specialised_field1 = described_class.new(value: value, sample_manifest_asset: sample_manifest_asset) + specialised_field1 = described_class.new(value:, sample_manifest_asset:) specialised_field1.update specialised_field2 = described_class.new(value: value2, sample_manifest_asset: sample_manifest_asset2) specialised_field2.update @@ -145,14 +145,14 @@ def self.name end it 'will not create QC results for the asset if the value is blank' do - specialised_field = described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset) + specialised_field = described_class.new(value: nil, sample_manifest_asset:) specialised_field.update qc_result = sample_manifest_asset.asset.qc_results.first expect(qc_result).to be_nil end it 'will not create QC assays for the asset if the value is blank' do - specialised_field = described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset) + specialised_field = described_class.new(value: nil, sample_manifest_asset:) specialised_field.update qc_assay = QcAssay.find_by(lot_number: "sample_manifest_id:#{sample_manifest.id}") expect(qc_assay).to be_nil @@ -161,22 +161,22 @@ def self.name describe SequencescapeExcel::SpecialisedField::InsertSizeFrom do it 'value must be a valid number greater than 0' do - expect(described_class.new(value: 'zero', sample_manifest_asset: sample_manifest_asset)).not_to be_valid - expect(described_class.new(value: -1, sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: 'zero', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: -1, sample_manifest_asset:)).not_to be_valid end it 'will add the value to the aliquot' do - specialised_field = described_class.new(value: 100, sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) + specialised_field = described_class.new(value: 100, sample_manifest_asset:) + specialised_field.update(aliquot:) expect(aliquot.insert_size_from).to eq(100) end context 'with multiple aliquots' do - let(:asset) { create(:tagged_well, map: map, aliquot_count: 2) } + let(:asset) { create(:tagged_well, map:, aliquot_count: 2) } it 'will add the the value to all aliquots' do - specialised_field = described_class.new(value: 100, sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) + specialised_field = described_class.new(value: 100, sample_manifest_asset:) + specialised_field.update(aliquot:) expect(asset.aliquots).to all(have_attributes(insert_size_from: 100)) end end @@ -184,22 +184,22 @@ def self.name describe SequencescapeExcel::SpecialisedField::InsertSizeTo do it 'value must be a valid number greater than 0' do - expect(described_class.new(value: 'zero', sample_manifest_asset: sample_manifest_asset)).not_to be_valid - expect(described_class.new(value: -1, sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: 'zero', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: -1, sample_manifest_asset:)).not_to be_valid end it 'will add the value to the aliquot' do - specialised_field = described_class.new(value: 100, sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) + specialised_field = described_class.new(value: 100, sample_manifest_asset:) + specialised_field.update(aliquot:) expect(aliquot.insert_size_to).to eq(100) end context 'with multiple aliquots' do - let(:asset) { create(:tagged_well, map: map, aliquot_count: 2) } + let(:asset) { create(:tagged_well, map:, aliquot_count: 2) } it 'will add the the value to all aliquots' do - specialised_field = described_class.new(value: 100, sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) + specialised_field = described_class.new(value: 100, sample_manifest_asset:) + specialised_field.update(aliquot:) expect(asset.aliquots).to all(have_attributes(insert_size_to: 100)) end end @@ -246,7 +246,7 @@ def self.name describe SequencescapeExcel::SpecialisedField::SangerSampleId do it 'will set the sanger sample id from the sample' do - expect(described_class.new(value: '1234', sample_manifest_asset: sample_manifest_asset).value).to eq('1234') + expect(described_class.new(value: '1234', sample_manifest_asset:).value).to eq('1234') end end @@ -291,11 +291,11 @@ def self.name describe SequencescapeExcel::SpecialisedField::Well do it 'will not be valid unless the value matches the well description' do - expect(described_class.new(value: 'well', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: 'well', sample_manifest_asset:)).not_to be_valid expect( described_class.new( value: sample_manifest_asset.asset.map_description, - sample_manifest_asset: sample_manifest_asset + sample_manifest_asset: ) ).to be_valid end @@ -303,12 +303,12 @@ def self.name describe SequencescapeExcel::SpecialisedField::SampleEbiAccessionNumber do it 'will not be valid if the value is different to the sample accession number' do - expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: 'EB123', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: '', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: 'EB123', sample_manifest_asset:)).to be_valid sample_manifest_asset.sample.sample_metadata.sample_ebi_accession_number = 'EB123' - expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: 'EB1234', sample_manifest_asset: sample_manifest_asset)).not_to be_valid - expect(described_class.new(value: 'EB123', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: '', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: 'EB1234', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: 'EB123', sample_manifest_asset:)).to be_valid end end @@ -317,20 +317,20 @@ def self.name let(:oligo) { 'AA' } describe SequencescapeExcel::SpecialisedField::I7 do - let(:i7) { described_class.new(value: oligo, sample_manifest_asset: sample_manifest_asset) } + let(:i7) { described_class.new(value: oligo, sample_manifest_asset:) } it 'will be valid if the tag contains just A, C, G or T' do - expect(described_class.new(value: 'ACGT', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: 'acgt', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: 'acgt', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: 'aatc', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: 'ACGT', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: 'acgt', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: 'acgt', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: 'aatc', sample_manifest_asset:)).to be_valid end it 'will not be valid if the tag does not contain A, C, G or T' do - expect(described_class.new(value: 'ACGT ACGT', sample_manifest_asset: sample_manifest_asset)).not_to be_valid - expect(described_class.new(value: 'BCGT', sample_manifest_asset: sample_manifest_asset)).not_to be_valid - expect(described_class.new(value: '-CGT', sample_manifest_asset: sample_manifest_asset)).not_to be_valid - expect(described_class.new(value: 'xCGT', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: 'ACGT ACGT', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: 'BCGT', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: '-CGT', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: 'xCGT', sample_manifest_asset:)).not_to be_valid end it 'will add the value' do @@ -338,8 +338,8 @@ def self.name end it 'will update the aliquot and create the tag if oligo is present' do - i7.update(aliquot: aliquot, tag_group: tag_group) - tag = tag_group.tags.find_by(oligo: oligo) + i7.update(aliquot:, tag_group:) + tag = tag_group.tags.find_by(oligo:) expect(tag).to be_present expect(tag.oligo).to eq(oligo) expect(tag.map_id).to eq(1) @@ -347,25 +347,25 @@ def self.name end it 'if oligo is not present aliquot tag should be -1' do - i7 = described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset) - i7.update(aliquot: aliquot, tag_group: tag_group) + i7 = described_class.new(value: nil, sample_manifest_asset:) + i7.update(aliquot:, tag_group:) aliquot.save expect(aliquot.tag_id).to eq(-1) end it 'will find the tag if it already exists' do - tag = tag_group.tags.create(oligo: oligo, map_id: 10) - i7.update(aliquot: aliquot, tag_group: tag_group) + tag = tag_group.tags.create(oligo:, map_id: 10) + i7.update(aliquot:, tag_group:) expect(aliquot.tag).to eq(tag) end end describe SequencescapeExcel::SpecialisedField::I5 do - let(:i5) { described_class.new(value: oligo, sample_manifest_asset: sample_manifest_asset) } + let(:i5) { described_class.new(value: oligo, sample_manifest_asset:) } it 'will not be valid if the tag does not contain A, C, G or T' do - expect(described_class.new(value: 'ACGT', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: 'BCGT', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: 'ACGT', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: 'BCGT', sample_manifest_asset:)).not_to be_valid end it 'will add the value' do @@ -373,9 +373,9 @@ def self.name end it 'will update the aliquot' do - i5.update(aliquot: aliquot, tag_group: tag_group) + i5.update(aliquot:, tag_group:) aliquot.save - expect(aliquot.tag2).to eq(tag_group.tags.find_by(oligo: oligo)) + expect(aliquot.tag2).to eq(tag_group.tags.find_by(oligo:)) end end end @@ -390,21 +390,21 @@ def self.name describe 'tag group' do it 'will add the value' do - sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset) + sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset:) expect(sf_tag_group.value).to eq(tag_group_name) end it 'will be valid with an existing tag group name' do - expect(described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: tag_group_name, sample_manifest_asset:)).to be_valid end it 'will not be valid without an existing tag group name' do - expect(described_class.new(value: 'unknown', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: 'unknown', sample_manifest_asset:)).not_to be_valid end it 'responds to update method but does nothing to tag on aliquot' do - sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset) - expect(sf_tag_group.update(aliquot: aliquot, tag_group: nil)).to be_nil + sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset:) + expect(sf_tag_group.update(aliquot:, tag_group: nil)).to be_nil aliquot.save expect(aliquot.tag).to be_nil end @@ -412,22 +412,22 @@ def self.name describe SequencescapeExcel::SpecialisedField::TagIndex do it 'will add the value' do - sf_tag_index = described_class.new(value: tag_index, sample_manifest_asset: sample_manifest_asset) + sf_tag_index = described_class.new(value: tag_index, sample_manifest_asset:) expect(sf_tag_index.value).to eq(tag_index) end it 'will not have a valid tag index when unlinked from a tag group' do - expect(described_class.new(value: tag_index, sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: tag_index, sample_manifest_asset:)).not_to be_valid end describe 'linking' do let!(:sf_tag_group) do SequencescapeExcel::SpecialisedField::TagGroup.new( value: tag_group_name, - sample_manifest_asset: sample_manifest_asset + sample_manifest_asset: ) end - let!(:sf_tag_index) { described_class.new(value: tag_index, sample_manifest_asset: sample_manifest_asset) } + let!(:sf_tag_index) { described_class.new(value: tag_index, sample_manifest_asset:) } before { sf_tag_index.sf_tag_group = sf_tag_group } @@ -436,13 +436,13 @@ def self.name end it 'will not have a valid tag index when index does not match to a map_id in the tag group' do - sf_tag_index2 = described_class.new(value: 10, sample_manifest_asset: sample_manifest_asset) + sf_tag_index2 = described_class.new(value: 10, sample_manifest_asset:) sf_tag_index2.sf_tag_group = sf_tag_group expect(sf_tag_index2).not_to be_valid end it 'will update the aliquot with tag if its oligo is present' do - sf_tag_index.update(aliquot: aliquot, tag_group: nil) + sf_tag_index.update(aliquot:, tag_group: nil) tag = tag_group.tags.find_by(map_id: tag_index) expect(tag).to be_present expect(tag.oligo).to eq(tag_group.tags[0].oligo) @@ -457,7 +457,7 @@ def self.name tag.oligo = nil tag.save expect(tag.oligo).to be_nil - sf_tag_index.update(aliquot: aliquot, tag_group: nil) + sf_tag_index.update(aliquot:, tag_group: nil) aliquot.save expect(aliquot.tag_id).to eq(-1) end @@ -466,21 +466,21 @@ def self.name describe SequencescapeExcel::SpecialisedField::Tag2Group do it 'will add the value' do - sf_tag2_group = described_class.new(value: tag2_group_name, sample_manifest_asset: sample_manifest_asset) + sf_tag2_group = described_class.new(value: tag2_group_name, sample_manifest_asset:) expect(sf_tag2_group.value).to eq(tag2_group_name) end it 'will be valid with an existing tag2 group name' do - expect(described_class.new(value: tag2_group_name, sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: tag2_group_name, sample_manifest_asset:)).to be_valid end it 'will not be valid without an existing tag2 group name' do - expect(described_class.new(value: 'unknown', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: 'unknown', sample_manifest_asset:)).not_to be_valid end it 'responds to update method but does nothing to tag2 on aliquot' do - sf_tag2_group = described_class.new(value: tag2_group_name, sample_manifest_asset: sample_manifest_asset) - expect(sf_tag2_group.update(aliquot: aliquot, tag_group: nil)).to be_nil + sf_tag2_group = described_class.new(value: tag2_group_name, sample_manifest_asset:) + expect(sf_tag2_group.update(aliquot:, tag_group: nil)).to be_nil aliquot.save expect(aliquot.tag2).to be_nil end @@ -488,12 +488,12 @@ def self.name describe SequencescapeExcel::SpecialisedField::Tag2Index do it 'will add the value' do - sf_tag2_index = described_class.new(value: tag2_index, sample_manifest_asset: sample_manifest_asset) + sf_tag2_index = described_class.new(value: tag2_index, sample_manifest_asset:) expect(sf_tag2_index.value).to eq(tag2_index) end it 'will not have a valid tag index when unlinked from a tag group' do - expect(described_class.new(value: tag2_index, sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: tag2_index, sample_manifest_asset:)).not_to be_valid end context 'when value and index are nil and tag exists that matches based on nil values' do @@ -507,7 +507,7 @@ def self.name it 'does not retrieve nil tag' do expect(sf_tag2_index).to be_valid - sf_tag2_index.update(aliquot: aliquot) + sf_tag2_index.update(aliquot:) expect(aliquot.tag2_id).to eq(-1) end end @@ -516,10 +516,10 @@ def self.name let!(:sf_tag2_group) do SequencescapeExcel::SpecialisedField::Tag2Group.new( value: tag2_group_name, - sample_manifest_asset: sample_manifest_asset + sample_manifest_asset: ) end - let!(:sf_tag2_index) { described_class.new(value: tag2_index, sample_manifest_asset: sample_manifest_asset) } + let!(:sf_tag2_index) { described_class.new(value: tag2_index, sample_manifest_asset:) } before { sf_tag2_index.sf_tag2_group = sf_tag2_group } @@ -528,13 +528,13 @@ def self.name end it 'will not have a valid tag index when index does not match to a map_id in the tag group' do - sf_tag2_index2 = described_class.new(value: 10, sample_manifest_asset: sample_manifest_asset) + sf_tag2_index2 = described_class.new(value: 10, sample_manifest_asset:) sf_tag2_index2.sf_tag2_group = sf_tag2_group expect(sf_tag2_index2).not_to be_valid end it 'will update the aliquot with tag2 if its oligo is present' do - sf_tag2_index.update(aliquot: aliquot, tag_group: nil) + sf_tag2_index.update(aliquot:, tag_group: nil) tag2 = tag2_group.tags.find_by(map_id: tag2_index) expect(tag2).to be_present expect(tag2.oligo).to eq(tag2_group.tags[0].oligo) @@ -549,7 +549,7 @@ def self.name tag2.oligo = nil tag2.save expect(tag2.oligo).to be_nil - sf_tag2_index.update(aliquot: aliquot, tag_group: nil) + sf_tag2_index.update(aliquot:, tag_group: nil) aliquot.save expect(aliquot.tag2_id).to eq(-1) end @@ -559,18 +559,18 @@ def self.name describe SequencescapeExcel::SpecialisedField::ChromiumTagGroup do let(:adapter_type) { create :adapter_type, name: 'Chromium' } - let(:tag_group) { create(:tag_group_with_tags, adapter_type: adapter_type) } + let(:tag_group) { create(:tag_group_with_tags, adapter_type:) } let(:tag_group_name) { tag_group.name } let(:tag_well) { 'A1' } describe 'tag group' do it 'will add the value' do - sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset) + sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset:) expect(sf_tag_group.value).to eq(tag_group_name) end it 'will be valid with an existing tag group name' do - expect(described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: tag_group_name, sample_manifest_asset:)).to be_valid end context 'when the tag group is not Chromium' do @@ -578,14 +578,14 @@ def self.name it 'will not be valid' do expect( - described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset) + described_class.new(value: tag_group_name, sample_manifest_asset:) ).not_to be_valid end end it 'responds to update method but does nothing to tag on aliquot' do - sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset) - expect(sf_tag_group.update(aliquot: aliquot, tag_group: nil)).to be_nil + sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset:) + expect(sf_tag_group.update(aliquot:, tag_group: nil)).to be_nil aliquot.save expect(aliquot.tag).to be_nil end @@ -593,22 +593,22 @@ def self.name describe SequencescapeExcel::SpecialisedField::ChromiumTagWell do it 'will add the value' do - sf_tag_well = described_class.new(value: tag_well, sample_manifest_asset: sample_manifest_asset) + sf_tag_well = described_class.new(value: tag_well, sample_manifest_asset:) expect(sf_tag_well.value).to eq(tag_well) end it 'will not have a valid tag index when unlinked from a tag group' do - expect(described_class.new(value: tag_well, sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: tag_well, sample_manifest_asset:)).not_to be_valid end describe 'linking' do let(:sf_tag_group) do SequencescapeExcel::SpecialisedField::ChromiumTagGroup.new( value: tag_group_name, - sample_manifest_asset: sample_manifest_asset + sample_manifest_asset: ) end - let(:sf_tag_well) { described_class.new(value: tag_well, sample_manifest_asset: sample_manifest_asset) } + let(:sf_tag_well) { described_class.new(value: tag_well, sample_manifest_asset:) } before { sf_tag_well.sf_tag_group = sf_tag_group } @@ -625,15 +625,15 @@ def self.name end it 'will apply the four tags associated with the map_id' do - sf_tag_well.update(aliquot: aliquot, tag_group: nil) + sf_tag_well.update(aliquot:, tag_group: nil) expect(asset.reload.aliquots.map { |a| a.tag.map_id }).to contain_exactly(1, 2, 3, 4) end context 'when applied to a re-upload' do - let(:asset) { create(:tagged_well, map: map, aliquot_count: 4) } + let(:asset) { create(:tagged_well, map:, aliquot_count: 4) } it 'will apply the four tags associated with the map_id' do - sf_tag_well.update(aliquot: aliquot, tag_group: nil) + sf_tag_well.update(aliquot:, tag_group: nil) expect(asset.aliquots.map { |a| a.tag.map_id }).to contain_exactly(1, 2, 3, 4) end end @@ -649,7 +649,7 @@ def self.name describe 'dual index tag set' do let(:sf_dual_index_tag_set) do - described_class.new(value: dual_index_tag_set.name, sample_manifest_asset: sample_manifest_asset) + described_class.new(value: dual_index_tag_set.name, sample_manifest_asset:) end it 'will add the value' do @@ -661,7 +661,7 @@ def self.name end context 'when no tag set name is provided' do - let(:sf_dual_index_tag_set) { described_class.new(value: '', sample_manifest_asset: sample_manifest_asset) } + let(:sf_dual_index_tag_set) { described_class.new(value: '', sample_manifest_asset:) } it 'will be not be valid' do expect(sf_dual_index_tag_set).not_to be_valid @@ -671,7 +671,7 @@ def self.name context 'when the tag set name is unknown' do let(:sf_dual_index_tag_set) do - described_class.new(value: 'bananas', sample_manifest_asset: sample_manifest_asset) + described_class.new(value: 'bananas', sample_manifest_asset:) end it 'will be not be valid' do @@ -696,12 +696,12 @@ def self.name describe SequencescapeExcel::SpecialisedField::DualIndexTagWell do let(:sf_dual_index_tag_well) do - described_class.new(value: dual_index_tag_well, sample_manifest_asset: sample_manifest_asset) + described_class.new(value: dual_index_tag_well, sample_manifest_asset:) end let(:sf_dual_index_tag_set) do SequencescapeExcel::SpecialisedField::DualIndexTagSet.new( value: dual_index_tag_set.name, - sample_manifest_asset: sample_manifest_asset + sample_manifest_asset: ) end @@ -719,7 +719,7 @@ def self.name end it 'will apply the two tags associated with the map_id' do - sf_dual_index_tag_well.update(aliquot: aliquot, tag_group: nil) + sf_dual_index_tag_well.update(aliquot:, tag_group: nil) # well location 'A1' => map_id '1' expect(asset.aliquots.first.tag.map_id).to eq 1 expect(asset.aliquots.first.tag.tag_group).to eq tag_group1 @@ -736,11 +736,11 @@ def self.name end context 'when applied to a re-upload' do - let(:asset) { create(:tagged_well, map: map, aliquot_count: 1) } + let(:asset) { create(:tagged_well, map:, aliquot_count: 1) } let(:dual_index_tag_well) { 'd1' } it 'will apply the 2 tags associated with the updated map_id' do - sf_dual_index_tag_well.update(aliquot: aliquot, tag_group: nil) + sf_dual_index_tag_well.update(aliquot:, tag_group: nil) # well location 'D1' => map_id '4' expect(asset.reload.aliquots.first.tag.map_id).to eq 4 expect(asset.reload.aliquots.first.tag2.map_id).to eq 4 @@ -776,55 +776,55 @@ def self.name let(:primer_panel) { create :primer_panel } it 'will not be valid without a persisted primer panel' do - expect(described_class.new(value: primer_panel.name, sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: primer_panel.name, sample_manifest_asset:)).to be_valid expect( - described_class.new(value: 'A new primer panel', sample_manifest_asset: sample_manifest_asset) + described_class.new(value: 'A new primer panel', sample_manifest_asset:) ).not_to be_valid end it 'will be valid if blank' do - expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: '', sample_manifest_asset:)).to be_valid end it 'will add the the value to the aliquot' do - specialised_field = described_class.new(value: primer_panel.name, sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) + specialised_field = described_class.new(value: primer_panel.name, sample_manifest_asset:) + specialised_field.update(aliquot:) expect(aliquot.primer_panel).to eq(primer_panel) end context 'with multiple aliquots' do - let(:asset) { create(:tagged_well, map: map, aliquot_count: 2) } + let(:asset) { create(:tagged_well, map:, aliquot_count: 2) } it 'will add the the value to all aliquots' do - specialised_field = described_class.new(value: primer_panel.name, sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) - expect(asset.aliquots).to all(have_attributes(primer_panel: primer_panel)) + specialised_field = described_class.new(value: primer_panel.name, sample_manifest_asset:) + specialised_field.update(aliquot:) + expect(asset.aliquots).to all(have_attributes(primer_panel:)) end end end describe SequencescapeExcel::SpecialisedField::Priority do it 'will be valid if value blank string or nil' do - expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: '', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: nil, sample_manifest_asset:)).to be_valid end it 'will be valid if value matches enum' do - expect(described_class.new(value: '0', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: '1', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: '2', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: '3', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: '0', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: '1', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: '2', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: '3', sample_manifest_asset:)).to be_valid end it 'will not be valid if value does not match enum' do - sf = described_class.new(value: '5', sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: '5', sample_manifest_asset:) expect(sf).not_to be_valid expect(sf.errors.full_messages.join).to include('the priority 5 was not recognised.') end it 'will update the priority on the sample when present' do - specialised_field = described_class.new(value: '1', sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) + specialised_field = described_class.new(value: '1', sample_manifest_asset:) + specialised_field.update(aliquot:) aliquot.save expect(sample_manifest_asset.sample.priority).to eq('backlog') end @@ -832,24 +832,24 @@ def self.name describe SequencescapeExcel::SpecialisedField::ControlType do it 'will be valid if value blank string or nil' do - expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: '', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: nil, sample_manifest_asset:)).to be_valid end it 'will be valid if value matches enum' do - expect(described_class.new(value: 'positive', sample_manifest_asset: sample_manifest_asset)).to be_valid - expect(described_class.new(value: 'negative', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: 'positive', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: 'negative', sample_manifest_asset:)).to be_valid end it 'will not be valid if value does not match enum' do - sf = described_class.new(value: 'rubbish', sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: 'rubbish', sample_manifest_asset:) expect(sf).not_to be_valid expect(sf.errors.full_messages).to include('the control type rubbish was not recognised.') end it 'will update the control and control type on the sample when present' do - specialised_field = described_class.new(value: 'positive', sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) + specialised_field = described_class.new(value: 'positive', sample_manifest_asset:) + specialised_field.update(aliquot:) aliquot.save expect(sample_manifest_asset.sample.control).to be(true) expect(sample_manifest_asset.sample.control_type).to eq('positive') @@ -860,8 +860,8 @@ def self.name sample_manifest_asset.sample.control = true sample_manifest_asset.sample.control_type = 'positive' sample_manifest_asset.sample.save - specialised_field = described_class.new(value: '', sample_manifest_asset: sample_manifest_asset) - specialised_field.update(aliquot: aliquot) + specialised_field = described_class.new(value: '', sample_manifest_asset:) + specialised_field.update(aliquot:) aliquot.save expect(sample_manifest_asset.sample.control).to be(false) expect(sample_manifest_asset.sample.control_type).to be_nil @@ -874,25 +874,25 @@ def self.name let!(:bs_supplier_name) do SequencescapeExcel::SpecialisedField::BioscanSupplierName.new( value: sample_supplier_name, - sample_manifest_asset: sample_manifest_asset + sample_manifest_asset: ) end let!(:sf_well) do - SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset: sample_manifest_asset) + SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) end # test value matches to the enum in the sample model # for Bioscan we have three types of control it 'will be valid if value matches enum' do - sf_pcr_pos = described_class.new(value: 'pcr positive', sample_manifest_asset: sample_manifest_asset) + sf_pcr_pos = described_class.new(value: 'pcr positive', sample_manifest_asset:) sf_pcr_pos.supplier_name = bs_supplier_name expect(sf_pcr_pos).to be_valid - sf_pcr_neg = described_class.new(value: 'pcr negative', sample_manifest_asset: sample_manifest_asset) + sf_pcr_neg = described_class.new(value: 'pcr negative', sample_manifest_asset:) sf_pcr_neg.supplier_name = bs_supplier_name expect(sf_pcr_neg).to be_valid - sf_lysate_neg = described_class.new(value: 'lysate negative', sample_manifest_asset: sample_manifest_asset) + sf_lysate_neg = described_class.new(value: 'lysate negative', sample_manifest_asset:) sf_lysate_neg.supplier_name = bs_supplier_name sf_lysate_neg.well = sf_well expect(sf_lysate_neg).to be_valid @@ -900,7 +900,7 @@ def self.name # test field is not valid if value does not match to the enum in the sample model it 'will not be valid if value does not match enum' do - sf = described_class.new(value: 'rubbish', sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: 'rubbish', sample_manifest_asset:) sf.supplier_name = bs_supplier_name expect(sf).not_to be_valid @@ -909,9 +909,9 @@ def self.name # test control flag and type are set on sample it 'will update the control and control type on the sample when present' do - sf = described_class.new(value: 'pcr positive', sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: 'pcr positive', sample_manifest_asset:) sf.supplier_name = bs_supplier_name - sf.update(aliquot: aliquot) + sf.update(aliquot:) aliquot.save expect(sample_manifest_asset.sample.control).to be(true) expect(sample_manifest_asset.sample.control_type).to eq('pcr positive') @@ -922,9 +922,9 @@ def self.name sample_manifest_asset.sample.control = true sample_manifest_asset.sample.control_type = 'pcr positive' sample_manifest_asset.sample.save - sf = described_class.new(value: '', sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: '', sample_manifest_asset:) sf.supplier_name = bs_supplier_name - sf.update(aliquot: aliquot) + sf.update(aliquot:) aliquot.save expect(sample_manifest_asset.sample.control).to be(false) expect(sample_manifest_asset.sample.control_type).to be_nil @@ -932,11 +932,11 @@ def self.name context 'when pcr positive in H12' do let!(:bs_well) do - SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset: sample_manifest_asset) + SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) end it 'will be invalid' do - control_type_sf = described_class.new(value: 'pcr positive', sample_manifest_asset: sample_manifest_asset) + control_type_sf = described_class.new(value: 'pcr positive', sample_manifest_asset:) control_type_sf.supplier_name = bs_supplier_name control_type_sf.well = bs_well expect(control_type_sf).not_to be_valid @@ -945,11 +945,11 @@ def self.name context 'when pcr positive not in H12' do let!(:bs_well) do - SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset: sample_manifest_asset) + SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset:) end it 'will be valid' do - control_type_sf = described_class.new(value: 'pcr positive', sample_manifest_asset: sample_manifest_asset) + control_type_sf = described_class.new(value: 'pcr positive', sample_manifest_asset:) control_type_sf.supplier_name = bs_supplier_name control_type_sf.well = bs_well expect(control_type_sf).to be_valid @@ -958,11 +958,11 @@ def self.name context 'when lysate negative in H12' do let!(:bs_well) do - SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset: sample_manifest_asset) + SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) end it 'will be valid' do - control_type_sf = described_class.new(value: 'lysate negative', sample_manifest_asset: sample_manifest_asset) + control_type_sf = described_class.new(value: 'lysate negative', sample_manifest_asset:) control_type_sf.supplier_name = bs_supplier_name control_type_sf.well = bs_well expect(control_type_sf).to be_valid @@ -971,11 +971,11 @@ def self.name context 'when lysate negative not in H12' do let!(:bs_well) do - SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset: sample_manifest_asset) + SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset:) end it 'will be invalid' do - control_type_sf = described_class.new(value: 'lysate negative', sample_manifest_asset: sample_manifest_asset) + control_type_sf = described_class.new(value: 'lysate negative', sample_manifest_asset:) control_type_sf.supplier_name = bs_supplier_name control_type_sf.well = bs_well expect(control_type_sf).not_to be_valid @@ -992,12 +992,12 @@ def self.name # supplier name is a primary field and must be present in the manifest rows it 'will not be valid if blank' do - expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: '', sample_manifest_asset:)).not_to be_valid end # test supplier name is stored in the sample metadata on update it 'will add supplier name to sample_metadata' do - sf = described_class.new(value: sample_supplier_name, sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: sample_supplier_name, sample_manifest_asset:) sf.update expect(sample_manifest_asset.sample.sample_metadata.supplier_name).to eq(sample_supplier_name) end @@ -1009,7 +1009,7 @@ def self.name shared_examples 'a retention instruction labware' do it 'will be invalid if the value is not set' do - sf = described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: nil, sample_manifest_asset:) expect(sf).not_to be_valid expect(sf.errors.full_messages.join).to include('Retention instruction can\'t be blank') @@ -1017,12 +1017,12 @@ def self.name it 'will be valid if the value matches one of the expected values' do expect( - described_class.new(value: 'Long term storage', sample_manifest_asset: sample_manifest_asset) + described_class.new(value: 'Long term storage', sample_manifest_asset:) ).to be_valid end it 'will create labware custom metadata on the labware and set the retention instruction choice' do - sf = described_class.new(value: 'Long term storage', sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: 'Long term storage', sample_manifest_asset:) sf.update expect(sf.asset.labware.retention_instruction.to_sym).to eq(:long_term_storage) @@ -1034,7 +1034,7 @@ def self.name asset.labware.save # Update the retention instruction value - sf = described_class.new(value: 'Long term storage', sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: 'Long term storage', sample_manifest_asset:) sf.update expect(sf.asset.labware.retention_instruction.to_sym).to eq(:long_term_storage) @@ -1044,7 +1044,7 @@ def self.name # As long as the validation on the manifest re-upload passes (and for a plate that all wells for a labware # have the same retention instruction value, it is valid to update. it 'will be valid to update if the labware already contains a retention instruction metadata' do - sf = described_class.new(value: 'Destroy after 2 years', sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: 'Destroy after 2 years', sample_manifest_asset:) expect(sf).to be_valid sf.update @@ -1082,7 +1082,7 @@ def self.name custom_metadatum_collection.save! custom_metadatum.save! - sf = described_class.new(value: 'Long term storage', sample_manifest_asset: sample_manifest_asset) + sf = described_class.new(value: 'Long term storage', sample_manifest_asset:) sf.update end diff --git a/spec/sequencescape_excel/validation_spec.rb b/spec/sequencescape_excel/validation_spec.rb index 2aa5248d56..ee347c3798 100644 --- a/spec/sequencescape_excel/validation_spec.rb +++ b/spec/sequencescape_excel/validation_spec.rb @@ -14,15 +14,15 @@ it 'is comparable' do # We are explicitly checking that comparable non-identical object show equality # rubocop:disable RSpec/IdenticalEqualityAssertion - expect(described_class.new(options: options)).to eq(described_class.new(options: options)) + expect(described_class.new(options:)).to eq(described_class.new(options:)) # rubocop:enable RSpec/IdenticalEqualityAssertion - expect(described_class.new(options: options.except(:formula1))).not_to eq(described_class.new(options: options)) + expect(described_class.new(options: options.except(:formula1))).not_to eq(described_class.new(options:)) end context 'without range name' do - let(:validation) { described_class.new(options: options) } + let(:validation) { described_class.new(options:) } it 'will have some options' do expect(validation.options).to eq(options) @@ -34,12 +34,12 @@ it '#does not add a range' do expect(worksheet).to receive(:add_data_validation).with('N10:N30', **options) - validation.update(range: range, worksheet: worksheet, reference: 'N10:N30') + validation.update(range:, worksheet:, reference: 'N10:N30') end end context 'with range name' do - let(:validation) { described_class.new(options: options, range_name: :a_range) } + let(:validation) { described_class.new(options:, range_name: :a_range) } it 'will have a range name' do expect(validation.range_name).to eq(:a_range) @@ -47,13 +47,13 @@ it '#update will set formula1' do expect(worksheet).to receive(:add_data_validation).with('N10:N30', **options, formula1: range.absolute_reference) - validation.update(range: range, worksheet: worksheet, reference: 'N10:N30') + validation.update(range:, worksheet:, reference: 'N10:N30') end end context 'with a custom formula' do let(:options) { { type: :custom, formula1: 'AND(A1>5,A1<10)' } } - let(:validation) { described_class.new(options: options) } + let(:validation) { described_class.new(options:) } it 'sends and escaped formula to the worksheet' do expect(worksheet).to receive(:add_data_validation).with( @@ -61,21 +61,21 @@ type: :custom, formula1: 'AND(N10>5,N10<10)' ) - validation.update(reference: 'N10:N30', worksheet: worksheet) + validation.update(reference: 'N10:N30', worksheet:) end end context 'with worksheet' do let(:worksheet) { Axlsx::Package.new.workbook.add_worksheet } let(:range) { build(:range) } - let(:validation) { described_class.new(options: options) } + let(:validation) { described_class.new(options:) } it 'has some options' do expect(validation.options).to eq(options) end it 'adds validation to the worksheet' do - validation.update(reference: range.reference, worksheet: worksheet) + validation.update(reference: range.reference, worksheet:) validations = worksheet.data_validation_rules expect(validation).to be_saved expect(validations.count).to eq(1) @@ -83,13 +83,13 @@ end it 'is comparable' do - validation.update(reference: range.reference, worksheet: worksheet) - other_validation = described_class.new(options: options) - other_validation.update(reference: range.reference, worksheet: worksheet) + validation.update(reference: range.reference, worksheet:) + other_validation = described_class.new(options:) + other_validation.update(reference: range.reference, worksheet:) expect(other_validation).to eq(validation) other_validation = described_class.new(options: options.merge(option3: 'value3')) - other_validation.update(reference: range.reference, worksheet: worksheet) + other_validation.update(reference: range.reference, worksheet:) expect(other_validation).not_to eq(validation) end end diff --git a/spec/sequencescape_excel/worksheet_spec.rb b/spec/sequencescape_excel/worksheet_spec.rb index 16ba4e6cca..dd96272d45 100644 --- a/spec/sequencescape_excel/worksheet_spec.rb +++ b/spec/sequencescape_excel/worksheet_spec.rb @@ -38,7 +38,7 @@ def save_file describe 'validations ranges worksheet' do let!(:range_list) { SampleManifestExcel.configuration.ranges.dup } - let!(:worksheet) { SequencescapeExcel::Worksheet::RangesWorksheet.new(workbook: workbook, ranges: range_list) } + let!(:worksheet) { SequencescapeExcel::Worksheet::RangesWorksheet.new(workbook:, ranges: range_list) } before { save_file } diff --git a/spec/shared_contexts/it_requires_login.rb b/spec/shared_contexts/it_requires_login.rb index fc43ce6c09..1d5cd05827 100644 --- a/spec/shared_contexts/it_requires_login.rb +++ b/spec/shared_contexts/it_requires_login.rb @@ -18,7 +18,7 @@ params["#{parent_resource}_id"] = (create parent_resource).id end begin - get action, params: params + get(action, params:) rescue AbstractController::ActionNotFound flunk "Testing for an unknown action: #{action}" rescue ActiveRecord::RecordNotFound @@ -45,7 +45,7 @@ params["#{parent_resource}_id"] = (create parent_resource).id end begin - get action, params: params + get(action, params:) rescue AbstractController::ActionNotFound flunk "Testing for an unknown action: #{action}" end diff --git a/spec/shared_contexts/limber_shared_context.rb b/spec/shared_contexts/limber_shared_context.rb index 2d8e4905ee..080c96725c 100644 --- a/spec/shared_contexts/limber_shared_context.rb +++ b/spec/shared_contexts/limber_shared_context.rb @@ -38,13 +38,13 @@ let(:build_library_requests) do input_plate.wells.each do |well| - create_list :library_request, + create_list(:library_request, requests_per_well, request_type: library_request_type, asset: well, submission: target_submission, state: library_state, - order: order + order:) create :library_request, request_type: library_request_type, asset: well, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 813b1f0804..b99d202beb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -55,7 +55,7 @@ options.add_argument('--headless=old') options.add_argument('--disable-gpu') options.add_argument('--disable-search-engine-choice-screen') - Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) + Capybara::Selenium::Driver.new(app, browser: :chrome, options:) end Capybara.register_driver :selenium_chrome do |app| @@ -64,7 +64,7 @@ options.add_preference('download.default_directory', DownloadHelpers::PATH.to_s) options.add_argument('--disable-gpu') options.add_argument('--disable-search-engine-choice-screen') - Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) + Capybara::Selenium::Driver.new(app, browser: :chrome, options:) end Capybara.javascript_driver = ENV.fetch('JS_DRIVER', 'headless_chrome').to_sym diff --git a/spec/support/api_helper.rb b/spec/support/api_helper.rb index dc907ed53e..8ee320fc2c 100644 --- a/spec/support/api_helper.rb +++ b/spec/support/api_helper.rb @@ -6,14 +6,14 @@ def api_request(action, path, body = nil) headers['CONTENT_TYPE'] = 'application/json' unless body.nil? headers['HTTP_X_SEQUENCESCAPE_CLIENT_ID'] = authorised_app.key yield(headers) if block_given? - send(action.downcase, path, params: body, headers: headers) + send(action.downcase, path, params: body, headers:) end def unauthorized_api_request(action, path, body = nil) headers = { 'HTTP_ACCEPT' => 'application/json' } headers['CONTENT_TYPE'] = 'application/json' unless body.nil? yield(headers) if block_given? - send(action.downcase, path, params: body, headers: headers) + send(action.downcase, path, params: body, headers:) end def user_api_request(user, action, path, body = nil) @@ -21,6 +21,6 @@ def user_api_request(user, action, path, body = nil) cookies['api_key'] = user.api_key headers['CONTENT_TYPE'] = 'application/json' unless body.nil? yield(headers) if block_given? - send(action.downcase, path, params: body, headers: headers) + send(action.downcase, path, params: body, headers:) end end diff --git a/spec/support/api_v2_helper.rb b/spec/support/api_v2_helper.rb index e148ccd6e3..26e61c9ed4 100644 --- a/spec/support/api_v2_helper.rb +++ b/spec/support/api_v2_helper.rb @@ -5,17 +5,17 @@ module ApiV2Helper def api_get(path, headers: {}) headers.merge!(DEFAULT_HEADERS) - get(path, headers: headers) + get(path, headers:) end def api_patch(path, payload, headers: {}) headers.merge!(DEFAULT_HEADERS) - patch(path, params: payload.to_json, headers: headers) + patch(path, params: payload.to_json, headers:) end def api_post(path, payload, headers: {}) headers.merge!(DEFAULT_HEADERS) - post(path, params: payload.to_json, headers: headers) + post(path, params: payload.to_json, headers:) end def json diff --git a/spec/uat_actions/generate_project_spec.rb b/spec/uat_actions/generate_project_spec.rb index 8d99d25a59..ba7a889e4e 100644 --- a/spec/uat_actions/generate_project_spec.rb +++ b/spec/uat_actions/generate_project_spec.rb @@ -7,7 +7,7 @@ let(:uat_action) { described_class.new(parameters) } let(:project_name) { 'Test Project' } let(:project_cost_code) { '1234' } - let(:parameters) { { project_name: project_name, project_cost_code: project_cost_code } } + let(:parameters) { { project_name:, project_cost_code: } } describe '#perform' do context 'when generating a project' do diff --git a/spec/uat_actions/generate_sample_manifest_spec.rb b/spec/uat_actions/generate_sample_manifest_spec.rb index df8551c09d..d3fb5b3d45 100644 --- a/spec/uat_actions/generate_sample_manifest_spec.rb +++ b/spec/uat_actions/generate_sample_manifest_spec.rb @@ -15,10 +15,10 @@ { study_name: study.name, supplier_name: supplier.name, - asset_type: asset_type, - count: count, + asset_type:, + count:, tube_purpose_name: purpose.name, - with_samples: with_samples + with_samples: } end @@ -70,11 +70,11 @@ describe '#create_sample_manifest' do let(:manifest) do create :sample_manifest, - study: study, - supplier: supplier, - count: count, - asset_type: asset_type, - purpose: purpose + study:, + supplier:, + count:, + asset_type:, + purpose: end it 'sets the created sample manifest' do @@ -87,11 +87,11 @@ describe '#generate_manifest' do let(:manifest) do create :sample_manifest, - study: study, - supplier: supplier, - count: count, - asset_type: asset_type, - purpose: purpose + study:, + supplier:, + count:, + asset_type:, + purpose: end it 'create tubes(s)' do diff --git a/spec/uat_actions/generate_study_spec.rb b/spec/uat_actions/generate_study_spec.rb index 9f4e302fa9..2f287b1843 100644 --- a/spec/uat_actions/generate_study_spec.rb +++ b/spec/uat_actions/generate_study_spec.rb @@ -6,7 +6,7 @@ context 'with valid options' do let(:uat_action) { described_class.new(parameters) } let(:study_name) { 'Test Study' } - let(:parameters) { { study_name: study_name } } + let(:parameters) { { study_name: } } describe '#perform' do context 'when generating a study' do diff --git a/spec/uat_actions/generate_tag_layout_template_spec.rb b/spec/uat_actions/generate_tag_layout_template_spec.rb index 0fddbe859c..eb7637fbe3 100644 --- a/spec/uat_actions/generate_tag_layout_template_spec.rb +++ b/spec/uat_actions/generate_tag_layout_template_spec.rb @@ -5,8 +5,8 @@ describe UatActions::GenerateTagLayoutTemplate do context 'with valid options' do let(:tag_count) { 96 } - let(:tag_group) { create :tag_group, tag_count: tag_count } - let(:tag2_group) { create :tag_group, tag_count: tag_count } + let(:tag_group) { create :tag_group, tag_count: } + let(:tag2_group) { create :tag_group, tag_count: } let(:parameters) do { diff --git a/spec/uat_actions/plate_information_spec.rb b/spec/uat_actions/plate_information_spec.rb index df5e875e17..9151085b5a 100644 --- a/spec/uat_actions/plate_information_spec.rb +++ b/spec/uat_actions/plate_information_spec.rb @@ -5,12 +5,12 @@ describe UatActions::PlateInformation do context 'when the plate has aliquots' do let(:plate_barcode) { 'SQPD-1' } - let(:parameters) { { plate_barcode: plate_barcode } } + let(:parameters) { { plate_barcode: } } let(:uat_action) { described_class.new(parameters) } let(:report) do # A report is a hash of key value pairs which get returned to the user. # It should include information such as barcodes and identifiers - { plate_barcode: plate_barcode, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } + { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } end before { create :plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode } @@ -23,12 +23,12 @@ context 'when the plate is without aliquots' do let(:plate_barcode) { 'SQPD-2' } - let(:parameters) { { plate_barcode: plate_barcode } } + let(:parameters) { { plate_barcode: } } let(:uat_action) { described_class.new(parameters) } let(:report) do # A report is a hash of key value pairs which get returned to the user. # It should include information such as barcodes and identifiers - { plate_barcode: plate_barcode, wells_with_aliquots: '', wells_with_active_requests_as_source: '' } + { plate_barcode:, wells_with_aliquots: '', wells_with_active_requests_as_source: '' } end before { create :plate_with_empty_wells, well_count: 3, barcode: plate_barcode } @@ -58,13 +58,13 @@ # We expect to return the wells that have been submitted (have active requests as source) context 'when the plate has a partial submission' do let(:plate_barcode) { 'SQPD-3' } - let(:parameters) { { plate_barcode: plate_barcode } } + let(:parameters) { { plate_barcode: } } let(:uat_action) { described_class.new(parameters) } let(:submission) { create :submission } let(:request_type) { create :library_creation_request_type } let(:report) do { - plate_barcode: plate_barcode, + plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: 'A1, C1' } @@ -78,16 +78,16 @@ req1 = create :library_creation_request, asset: plate_wells.first, - submission: submission, - request_type: request_type, + submission:, + request_type:, state: 'started' plate_wells.first.requests_as_source << req1 req2 = create :library_creation_request, asset: plate_wells.last, - submission: submission, - request_type: request_type, + submission:, + request_type:, state: 'started' plate_wells.last.requests_as_source << req2 end @@ -102,12 +102,12 @@ # i.e. only want wells with ACTIVE requests as source so this should not return any wells context 'when the plate has a closed submission' do let(:plate_barcode) { 'SQPD-4' } - let(:parameters) { { plate_barcode: plate_barcode } } + let(:parameters) { { plate_barcode: } } let(:uat_action) { described_class.new(parameters) } let(:submission) { create :submission } let(:request_type) { create :library_creation_request_type } let(:report) do - { plate_barcode: plate_barcode, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } + { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } end before do @@ -118,16 +118,16 @@ req1 = create :library_creation_request, asset: plate_wells.first, - submission: submission, - request_type: request_type, + submission:, + request_type:, state: 'passed' plate_wells.first.requests_as_source << req1 req2 = create :library_creation_request, asset: plate_wells.last, - submission: submission, - request_type: request_type, + submission:, + request_type:, state: 'passed' plate_wells.last.requests_as_source << req2 end @@ -142,14 +142,14 @@ # subsets of wells) - we expect to only return the wells with the new (active) submission context 'when the plate has both active and closed submissions' do let(:plate_barcode) { 'SQPD-4' } - let(:parameters) { { plate_barcode: plate_barcode } } + let(:parameters) { { plate_barcode: } } let(:uat_action) { described_class.new(parameters) } let(:submission) { create :submission } let(:submission2) { create :submission } let(:request_type) { create :library_creation_request_type } let(:report) do { - plate_barcode: plate_barcode, + plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: 'A1, C1' } @@ -163,24 +163,24 @@ req1 = create :library_creation_request, asset: plate_wells.first, - submission: submission, - request_type: request_type, + submission:, + request_type:, state: 'passed' plate_wells.first.requests_as_source << req1 req2 = create :library_creation_request, asset: plate_wells.second, - submission: submission, - request_type: request_type, + submission:, + request_type:, state: 'passed' plate_wells.second.requests_as_source << req2 req3 = create :library_creation_request, asset: plate_wells.last, - submission: submission, - request_type: request_type, + submission:, + request_type:, state: 'passed' plate_wells.last.requests_as_source << req3 @@ -188,7 +188,7 @@ create :library_creation_request, asset: plate_wells.first, submission: submission2, - request_type: request_type, + request_type:, state: 'started' plate_wells.first.requests_as_source << req4 @@ -196,7 +196,7 @@ create :library_creation_request, asset: plate_wells.last, submission: submission2, - request_type: request_type, + request_type:, state: 'started' plate_wells.last.requests_as_source << req5 end diff --git a/spec/views/labware/show_chromium_chip_spec.rb b/spec/views/labware/show_chromium_chip_spec.rb index f9c7fe11e3..71acab24f5 100644 --- a/spec/views/labware/show_chromium_chip_spec.rb +++ b/spec/views/labware/show_chromium_chip_spec.rb @@ -14,7 +14,7 @@ let(:current_user) { user } let(:purpose_name) { 'chromium-chip-purpose' } let(:purpose) { create :shape4x1_purpose, name: purpose_name } # AssetShape Shape4x1, size 16 - let(:plate) { create :child_plate, well_factory: :passed_well, purpose: purpose, size: 16, sample_count: 16 } + let(:plate) { create :child_plate, well_factory: :passed_well, purpose:, size: 16, sample_count: 16 } let(:doc) { Nokogiri.HTML(rendered) } before do diff --git a/spec/views/labware/show_html_erb_spec.rb b/spec/views/labware/show_html_erb_spec.rb index 578e5e17e6..0b57c6da76 100644 --- a/spec/views/labware/show_html_erb_spec.rb +++ b/spec/views/labware/show_html_erb_spec.rb @@ -71,7 +71,7 @@ let(:barcodes) { Array.new(num_tubes) { create :fluidx } } let!(:tubes) do Array.new(num_tubes) do |i| - create(:sample_tube, :in_a_rack, tube_rack: tube_rack, coordinate: locations[i], barcodes: [barcodes[i]]) + create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) end end @@ -111,10 +111,10 @@ end context 'when the tube is inside a rack' do - before { tube.update(racked_tube: racked_tube) } + before { tube.update(racked_tube:) } let(:coordinate) { 'A1' } - let(:racked_tube) { build :racked_tube, tube_rack: tube_rack, coordinate: coordinate } + let(:racked_tube) { build :racked_tube, tube_rack:, coordinate: } let(:rack_barcode) { create :barcode } let(:tube_rack) { create :tube_rack, barcodes: [rack_barcode] } diff --git a/spec/views/tube_rack_summaries/show_html_erb_spec.rb b/spec/views/tube_rack_summaries/show_html_erb_spec.rb index d631bc8875..c9ed0a1279 100644 --- a/spec/views/tube_rack_summaries/show_html_erb_spec.rb +++ b/spec/views/tube_rack_summaries/show_html_erb_spec.rb @@ -16,7 +16,7 @@ before do Array.new(num_tubes) do |i| - create(:sample_tube, :in_a_rack, tube_rack: tube_rack, coordinate: locations[i], barcodes: [barcodes[i]]) + create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) end assign(:tube_rack, tube_rack) # sets @widget = Widget.new in the view template diff --git a/test/controllers/batches_controller_test.rb b/test/controllers/batches_controller_test.rb index 83f9220666..89d5590d41 100644 --- a/test/controllers/batches_controller_test.rb +++ b/test/controllers/batches_controller_test.rb @@ -53,7 +53,7 @@ class BatchesControllerTest < ActionController::TestCase } ) - @batch = create :batch, pipeline: pipeline + @batch = create(:batch, pipeline:) @batch.batch_requests.create!(request: @request_one, position: 1) @batch.reload @batch.start!(create(:user)) @@ -552,12 +552,12 @@ class BatchesControllerTest < ActionController::TestCase asset = create :empty_sample_tube order_role = OrderRole.new role: 'test' - order = create :order, order_role: order_role, study: study, assets: [asset], project: project + order = create(:order, order_role:, study:, assets: [asset], project:) request = - create :well_request, + create(:well_request, asset: (create :well_with_sample_and_plate), target_asset: (create :well_with_sample_and_plate), - order: order + order:) @batch = create :batch @batch.requests << request @@ -586,7 +586,7 @@ class BatchesControllerTest < ActionController::TestCase params: { printer: barcode_printer.name, count: '3', - printable: printable, + printable:, batch_id: @batch.id.to_s } end diff --git a/test/controllers/plate_summaries_controller_test.rb b/test/controllers/plate_summaries_controller_test.rb index 5d0ce8c28e..b7154d6487 100644 --- a/test/controllers/plate_summaries_controller_test.rb +++ b/test/controllers/plate_summaries_controller_test.rb @@ -15,8 +15,8 @@ class PlateSummariesControllerTest < ActionController::TestCase context 'with some plates' do setup do purpose = create :source_plate_purpose - @source_plate_a = create :source_plate, purpose: purpose - @source_plate_b = create :source_plate, purpose: purpose + @source_plate_a = create(:source_plate, purpose:) + @source_plate_b = create(:source_plate, purpose:) @child_plate_a = create :child_plate, parent: @source_plate_a @child_plate_b = create :child_plate, parent: @source_plate_b end diff --git a/test/controllers/plates_controller_test.rb b/test/controllers/plates_controller_test.rb index 5267c7c938..23008e4187 100644 --- a/test/controllers/plates_controller_test.rb +++ b/test/controllers/plates_controller_test.rb @@ -223,7 +223,7 @@ class PlatesControllerTest < ActionController::TestCase should 'keep the created labware persisted' do barcode = @tube_rack.children.first.barcodes.first.barcode - assert_equal(1, Plate.joins(:barcodes).where(barcodes: { barcode: barcode }).count) + assert_equal(1, Plate.joins(:barcodes).where(barcodes: { barcode: }).count) end should set_flash[:warning].to(/Barcode labels failed to print/) diff --git a/test/controllers/requests_comments_controller_test.rb b/test/controllers/requests_comments_controller_test.rb index 821795d068..40b0fed56d 100644 --- a/test/controllers/requests_comments_controller_test.rb +++ b/test/controllers/requests_comments_controller_test.rb @@ -26,7 +26,7 @@ class CommentsControllerTest < ActionController::TestCase setup do @rq = create :request - %w[this is a test].each { |description| create :comment, description: description, commentable: @rq } + %w[this is a test].each { |description| create :comment, description:, commentable: @rq } end should 'return a ul of comments' do diff --git a/test/functional/pre_cap_groups_test.rb b/test/functional/pre_cap_groups_test.rb index 60981ff284..47d2d90e7b 100644 --- a/test/functional/pre_cap_groups_test.rb +++ b/test/functional/pre_cap_groups_test.rb @@ -119,7 +119,7 @@ def with_pools(*pools) @pools = create_list :pre_capture_pool, 3 with_pools(%w[A1 B1 C1], %w[D1 E1 F1]) transfers = @test_plate.wells.each_with_object({}) { |w, hash| hash[w.map_description] = w.map_description } - create :transfer_between_plates, transfers: transfers, source: @plate, destination: @test_plate + create :transfer_between_plates, transfers:, source: @plate, destination: @test_plate end should 'report the pools from the stock plate' do diff --git a/test/lib/label_printer/batch_tube_test.rb b/test/lib/label_printer/batch_tube_test.rb index fdc7b42337..a3df154ff5 100644 --- a/test/lib/label_printer/batch_tube_test.rb +++ b/test/lib/label_printer/batch_tube_test.rb @@ -16,7 +16,7 @@ class BatchTubeTest < ActiveSupport::TestCase @batch.requests << request printable = { request.id => 'on' } - options = { count: '1', printable: printable, batch: batch, stock: true } + options = { count: '1', printable:, batch:, stock: true } @tube_label = LabelPrinter::Label::BatchTube.new(options) assert_equal 1, tube_label.tubes.count @@ -32,7 +32,7 @@ class BatchTubeTest < ActiveSupport::TestCase @batch.requests << request printable = { request.id => 'on' } - options = { count: '1', printable: printable, batch: batch, stock: false } + options = { count: '1', printable:, batch:, stock: false } @tube_label = LabelPrinter::Label::BatchTube.new(options) assert_equal 1, tube_label.tubes.count diff --git a/test/lib/label_printer/plate_creator_test.rb b/test/lib/label_printer/plate_creator_test.rb index ed3b3c5162..99d4e2592a 100644 --- a/test/lib/label_printer/plate_creator_test.rb +++ b/test/lib/label_printer/plate_creator_test.rb @@ -27,16 +27,16 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength plate_purpose = create :plate_purpose, name: purpose_name @plate1 = create :child_plate, - parent: parent, + parent:, barcode: barcode1, - plate_purpose: plate_purpose, + plate_purpose:, well_count: 1, well_factory: :untagged_well, studies: @studies @plates = [plate1] @user = 'user' @study_abbreviation = 'WTCCC' - options = { plate_purpose: plate_purpose, plates: plates, user_login: user } + options = { plate_purpose:, plates:, user_login: user } @plate_label = LabelPrinter::Label::PlateCreator.new(options) @label = { top_left: (Date.today.strftime('%e-%^b-%Y')).to_s, diff --git a/test/lib/label_printer/plate_to_tube_test.rb b/test/lib/label_printer/plate_to_tube_test.rb index 47ec23c504..d17311aeda 100644 --- a/test/lib/label_printer/plate_to_tube_test.rb +++ b/test/lib/label_printer/plate_to_tube_test.rb @@ -15,7 +15,7 @@ def setup # rubocop:todo Metrics/AbcSize @tube1 = create :sample_tube, barcode: barcode1, name: asset_name @sample_tubes = create_list :sample_tube, 4 sample_tubes.unshift(tube1) - options = { sample_tubes: sample_tubes } + options = { sample_tubes: } @tube_label = LabelPrinter::Label::PlateToTubes.new(options) @label = { first_line: (asset_name).to_s, diff --git a/test/lib/label_printer/print_job_test.rb b/test/lib/label_printer/print_job_test.rb index 5d8631a145..55255047bf 100644 --- a/test/lib/label_printer/print_job_test.rb +++ b/test/lib/label_printer/print_job_test.rb @@ -31,15 +31,15 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength ] @attributes = { printer_name: barcode_printer.name, - label_template_name: label_template_name, + label_template_name:, labels: labels_attributes } @print_job = LabelPrinter::PrintJob.new( barcode_printer.name, LabelPrinter::Label::PlateCreator, - plates: plates, - plate_purpose: plate_purpose, + plates:, + plate_purpose:, user_login: 'user' ) end diff --git a/test/performance/state_change_test.rb b/test/performance/state_change_test.rb index 79803f59fe..9f087ccb3b 100644 --- a/test/performance/state_change_test.rb +++ b/test/performance/state_change_test.rb @@ -13,7 +13,7 @@ def setup @source = create :transfer_plate, well_count: 96 @destination = create :plate, well_count: 96 transfers = @source.wells.each_with_object({}) { |w, h| h[w.map_description] = w.map_description } - @transfer = create :transfer_between_plates, source: @source, destination: @destination, transfers: transfers + @transfer = create(:transfer_between_plates, source: @source, destination: @destination, transfers:) @user = create :user end diff --git a/test/shoulda_macros/sanger_macros.rb b/test/shoulda_macros/sanger_macros.rb index 8bbca6d698..fbb5ba45e9 100644 --- a/test/shoulda_macros/sanger_macros.rb +++ b/test/shoulda_macros/sanger_macros.rb @@ -23,7 +23,7 @@ def should_require_login(*actions) # rubocop:todo Metrics/CyclomaticComplexity, setup do session[:user] = create(:user) begin - get action, params: params + get(action, params:) rescue AbstractController::ActionNotFound flunk "Testing for an unknown action: #{action}" rescue ActiveRecord::RecordNotFound @@ -53,7 +53,7 @@ def should_require_login(*actions) # rubocop:todo Metrics/CyclomaticComplexity, params["#{parent_resource}_id"] = (create parent_resource).id end begin - get action, params: params + get(action, params:) rescue AbstractController::ActionNotFound flunk "Testing for an unknown action: #{action}" end diff --git a/test/unit/accession_service_test.rb b/test/unit/accession_service_test.rb index d6139559fa..4219237cf7 100644 --- a/test/unit/accession_service_test.rb +++ b/test/unit/accession_service_test.rb @@ -8,7 +8,7 @@ def assert_tag(tag_label, value) tag = acc.tags.detect { |tag| tag.label == tag_label } assert tag, "Could not find #{tag} in #{acc.tags.map(&:label).join(',')}" subject_tag = { tag: tag.label, value: tag.value } - assert_equal({ tag: tag_label, value: value }, subject_tag) + assert_equal({ tag: tag_label, value: }, subject_tag) end # temporary test for hotfix diff --git a/test/unit/aliquot_indexer_test.rb b/test/unit/aliquot_indexer_test.rb index 72b412faa9..61f52ab7a0 100644 --- a/test/unit/aliquot_indexer_test.rb +++ b/test/unit/aliquot_indexer_test.rb @@ -8,8 +8,8 @@ class AliquotIndexerTest < ActiveSupport::TestCase setup do @pre_count = AliquotIndex.count @lane = create :lane - @tags = [1, 8, 2, 4].map { |map_id| create :tag, map_id: map_id } - @tag2s = [1, 2].map { |map_id| create :tag, map_id: map_id } * 2 + @tags = [1, 8, 2, 4].map { |map_id| create(:tag, map_id:) } + @tag2s = [1, 2].map { |map_id| create(:tag, map_id:) } * 2 @aliquots = Array.new(4) { |i| create :aliquot, receptacle: @lane, tag: @tags[i], tag2: @tag2s[i] } @aliquot_index = [1, 4, 2, 3] @@ -64,7 +64,7 @@ class AliquotIndexerTest < ActiveSupport::TestCase setup do @pre_count = AliquotIndex.count @lane = create :lane - @tags = [1, 8, 2, 4].map { |map_id| create :tag, map_id: map_id } + @tags = [1, 8, 2, 4].map { |map_id| create(:tag, map_id:) } @aliquots = Array.new(4) { |i| create :aliquot, receptacle: @lane, tag: @tags[i], tag2_id: -1 } @aliquot_index = [1, 4, 2, 3] @@ -119,7 +119,7 @@ class AliquotIndexerTest < ActiveSupport::TestCase setup do @pre_count = AliquotIndex.count @lane = create :lane - @tags = [1, 8, 2, 4].map { |map_id| create :tag, map_id: map_id } + @tags = [1, 8, 2, 4].map { |map_id| create(:tag, map_id:) } @aliquots = Array.new(4) { |i| create :aliquot, receptacle: @lane, tag_id: -1, tag2: @tags[i] } @aliquot_index = [1, 4, 2, 3] diff --git a/test/unit/fluidigm_plate_test.rb b/test/unit/fluidigm_plate_test.rb index a248ad5577..49be6195fa 100644 --- a/test/unit/fluidigm_plate_test.rb +++ b/test/unit/fluidigm_plate_test.rb @@ -7,7 +7,7 @@ class FluidigmPlateTest < ActiveSupport::TestCase setup do barcode = build(:plate_barcode) PlateBarcode.stubs(:create_barcode).returns(barcode) - @plate = create(:fluidigm_96_purpose).create!(barcode: barcode) + @plate = create(:fluidigm_96_purpose).create!(barcode:) end should 'have 96 wells' do @@ -28,7 +28,7 @@ class FluidigmPlateTest < ActiveSupport::TestCase setup do barcode = build(:plate_barcode) PlateBarcode.stubs(:create_barcode).returns(barcode) - @plate = create(:fluidigm_192_purpose).create!(barcode: barcode) + @plate = create(:fluidigm_192_purpose).create!(barcode:) end should 'have 192 wells' do diff --git a/test/unit/import_fluidigm_data_test.rb b/test/unit/import_fluidigm_data_test.rb index 52ba361280..c3bf1ce504 100644 --- a/test/unit/import_fluidigm_data_test.rb +++ b/test/unit/import_fluidigm_data_test.rb @@ -34,18 +34,18 @@ def create_stock_plate(barcode) well_count: 1, well_factory: :untagged_well, purpose: PlatePurpose.stock_plate_purpose, - barcode: barcode + barcode: end def create_plate_with_fluidigm(_barcode, fluidigm_barcode, stock_plate) fgp = create :fluidigm_96_purpose plate_target = - create :plate, + create(:plate, size: 96, purpose: fgp, well_count: 1, well_factory: :empty_well, - fluidigm_barcode: fluidigm_barcode + fluidigm_barcode:) well_target = plate_target.wells.first diff --git a/test/unit/lab_interface/workflow_test.rb b/test/unit/lab_interface/workflow_test.rb index 2a29552977..80594c137a 100644 --- a/test/unit/lab_interface/workflow_test.rb +++ b/test/unit/lab_interface/workflow_test.rb @@ -13,8 +13,8 @@ class WorkflowTest < ActiveSupport::TestCase @workflow.update!(name: 'Workflow for WorkflowTest') task = create :task, workflow: @workflow - create :descriptor, task: task, name: 'prop', value: 'something', key: 'something' - create :descriptor, task: task, name: 'prop_2', value: 'upstairs', key: 'upstairs' + create :descriptor, task:, name: 'prop', value: 'something', key: 'something' + create :descriptor, task:, name: 'prop_2', value: 'upstairs', key: 'upstairs' end subject { @workflow } diff --git a/test/unit/lib_pool_norm_tube_generator_test.rb b/test/unit/lib_pool_norm_tube_generator_test.rb index 51ed05c490..d66911e562 100644 --- a/test/unit/lib_pool_norm_tube_generator_test.rb +++ b/test/unit/lib_pool_norm_tube_generator_test.rb @@ -22,7 +22,7 @@ def mock_transfer(generator) generator.lib_pool_tubes.each do |source| transfer = mock('transfer') transfer.stubs(:destination).returns(create(:lib_pool_norm_tube, parent_tube: source)) - generator.transfer_template.stubs(:create!).with(user: @user, source: source).returns(transfer) + generator.transfer_template.stubs(:create!).with(user: @user, source:).returns(transfer) end end diff --git a/test/unit/plate_test.rb b/test/unit/plate_test.rb index 8e0124e709..860b709754 100644 --- a/test/unit/plate_test.rb +++ b/test/unit/plate_test.rb @@ -11,7 +11,7 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) name: "Cherrypicked #{plate_barcode}", size: 192, barcode: plate_barcode, - fluidigm_barcode: fluidigm_barcode + fluidigm_barcode: ) end @@ -116,7 +116,7 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) @plate = create :transfer_plate user = create(:user) @plate.wells.each_with_index do |well, index| - create :request, asset: well, submission: Submission.create!(priority: index + 1, user: user) + create :request, asset: well, submission: Submission.create!(priority: index + 1, user:) end end diff --git a/test/unit/product_catalogue/library_driven_test.rb b/test/unit/product_catalogue/library_driven_test.rb index 3e41985130..c055cb5fe2 100644 --- a/test/unit/product_catalogue/library_driven_test.rb +++ b/test/unit/product_catalogue/library_driven_test.rb @@ -7,8 +7,8 @@ class LibraryDrivenTest < ActiveSupport::TestCase setup do def link_product_with_pc(product, product_catalogue, library_type_name) FactoryBot.create :product_product_catalogue, - product: product, - product_catalogue: product_catalogue, + product:, + product_catalogue:, selection_criterion: library_type_name end diff --git a/test/unit/product_criteria_test.rb b/test/unit/product_criteria_test.rb index df89eac787..f1689e01fb 100644 --- a/test/unit/product_criteria_test.rb +++ b/test/unit/product_criteria_test.rb @@ -64,7 +64,7 @@ class ProductCriteriaTest < ActiveSupport::TestCase should 'validate wells with the provided criteria' do well_attribute = create :well_attribute, concentration: 800, current_volume: 100 - well = create :well, well_attribute: well_attribute + well = create(:well, well_attribute:) assesment = @criteria_a.assess(well) assert assesment.is_a?(ProductCriteria::Basic) assert assesment.passed? diff --git a/test/unit/qc_report_test.rb b/test/unit/qc_report_test.rb index 86d5b392b0..9413a7ff2a 100644 --- a/test/unit/qc_report_test.rb +++ b/test/unit/qc_report_test.rb @@ -22,7 +22,7 @@ class QcReportTest < ActiveSupport::TestCase [@study, @other_study].each do |study| 2.times do |i| attribute = create :well_attribute, current_volume: 500, concentration: 200 - sample = create(:study_sample, study: study).sample + sample = create(:study_sample, study:).sample sample.update!(sanger_sample_id: 'TEST1') well = create :well, @@ -30,7 +30,7 @@ class QcReportTest < ActiveSupport::TestCase plate: @stock_plate, map: create(:map, location_id: i), well_attribute: attribute - well.aliquots.each { |a| a.update!(study: study) } + well.aliquots.each { |a| a.update!(study:) } end end From a3ce9569530ae5a2e072a344548d92d6c6c722c4 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 23 Sep 2024 16:27:31 +0100 Subject: [PATCH 113/158] style: rubocop Naming/BlockForwarding bundle exec rubocop -a --- .rubocop_todo.yml | 57 ------------------- app/api/core/endpoint/base.rb | 8 +-- .../core/endpoint/basic_handler/actions.rb | 4 +- .../endpoint/basic_handler/actions/bound.rb | 4 +- .../basic_handler/actions/bound/handler.rb | 4 +- .../endpoint/basic_handler/actions/factory.rb | 8 +-- .../endpoint/basic_handler/actions/guards.rb | 4 +- .../basic_handler/actions/inner_action.rb | 4 +- .../basic_handler/associations/belongs_to.rb | 4 +- .../basic_handler/associations/has_many.rb | 4 +- .../associations/has_many/handler.rb | 4 +- app/api/core/io/json/grammar.rb | 4 +- app/api/core/service.rb | 20 +++---- app/helpers/application_helper.rb | 4 +- app/helpers/assets_helper.rb | 4 +- app/helpers/bootstrap_helper.rb | 28 ++++----- app/helpers/descriptor_javascript_helper.rb | 8 +-- app/models/aliquot/aliquotable.rb | 4 +- app/models/api/base.rb | 8 +-- app/models/metadata.rb | 12 ++-- app/models/metadata/builder_base.rb | 6 +- app/models/metadata/form_builder.rb | 6 +- app/models/metadata/view_builder.rb | 2 +- .../parsers/cardinal_pbmc_count_parser.rb | 4 +- app/models/plate.rb | 4 +- .../presenters/batch_submenu_presenter.rb | 4 +- app/models/request_type.rb | 18 +++--- app/models/sample_manifest/core_behaviour.rb | 4 +- app/models/strip_tube.rb | 4 +- app/models/study_report/study_details.rb | 10 ++-- app/models/submission/presenter_skeleton.rb | 6 +- app/models/tube.rb | 4 +- .../manifest_type_list.rb | 4 +- .../sample_manifest_excel/upload/data.rb | 4 +- .../sample_manifest_excel/upload/rows.rb | 4 +- .../sequencescape_excel/list.rb | 4 +- .../sequencescape_excel/range_list.rb | 4 +- app/uploaders/polymorphic_uploader.rb | 2 +- config/initializers/api_routing.rb | 4 +- .../support/step_definitions/api_steps.rb | 6 +- .../step_definitions/submission_steps.rb | 4 +- lib/accession/accession/submission.rb | 4 +- lib/accession/accession/tag_list.rb | 4 +- lib/authenticated_test_helper.rb | 4 +- lib/capybara_failure_logger.rb | 4 +- lib/eventful_record.rb | 8 +-- .../test/helpers/authentication_helper.rb | 4 +- lib/mbrave_tags_creator.rb | 4 +- spec/lib/mock_parser.rb | 4 +- .../unit/tag_qc/qcable_statemachine_checks.rb | 8 +-- test/unit/task_test_base.rb | 4 +- 51 files changed, 148 insertions(+), 205 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c3717c6db0..72df599763 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -368,63 +368,6 @@ Naming/AccessorMethodName: - 'lib/authenticated_system.rb' - 'lib/tasks/add_templates_and_printers_to_pmb.rake' -# Offense count: 148 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, BlockForwardingName. -# SupportedStyles: anonymous, explicit -Naming/BlockForwarding: - Exclude: - - 'app/api/core/endpoint/base.rb' - - 'app/api/core/endpoint/basic_handler/actions.rb' - - 'app/api/core/endpoint/basic_handler/actions/bound.rb' - - 'app/api/core/endpoint/basic_handler/actions/bound/handler.rb' - - 'app/api/core/endpoint/basic_handler/actions/factory.rb' - - 'app/api/core/endpoint/basic_handler/actions/guards.rb' - - 'app/api/core/endpoint/basic_handler/actions/inner_action.rb' - - 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb' - - 'app/api/core/endpoint/basic_handler/associations/has_many.rb' - - 'app/api/core/endpoint/basic_handler/associations/has_many/handler.rb' - - 'app/api/core/io/json/grammar.rb' - - 'app/api/core/service.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/assets_helper.rb' - - 'app/helpers/bootstrap_helper.rb' - - 'app/helpers/descriptor_javascript_helper.rb' - - 'app/models/aliquot/aliquotable.rb' - - 'app/models/api/base.rb' - - 'app/models/metadata.rb' - - 'app/models/metadata/builder_base.rb' - - 'app/models/metadata/form_builder.rb' - - 'app/models/metadata/view_builder.rb' - - 'app/models/parsers/cardinal_pbmc_count_parser.rb' - - 'app/models/plate.rb' - - 'app/models/presenters/batch_submenu_presenter.rb' - - 'app/models/request_type.rb' - - 'app/models/sample_manifest/core_behaviour.rb' - - 'app/models/strip_tube.rb' - - 'app/models/study_report/study_details.rb' - - 'app/models/submission/presenter_skeleton.rb' - - 'app/models/tube.rb' - - 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb' - - 'app/sample_manifest_excel/sample_manifest_excel/upload/data.rb' - - 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb' - - 'app/sequencescape_excel/sequencescape_excel/list.rb' - - 'app/sequencescape_excel/sequencescape_excel/range_list.rb' - - 'app/uploaders/polymorphic_uploader.rb' - - 'config/initializers/api_routing.rb' - - 'features/support/step_definitions/api_steps.rb' - - 'features/support/step_definitions/submission_steps.rb' - - 'lib/accession/accession/submission.rb' - - 'lib/accession/accession/tag_list.rb' - - 'lib/authenticated_test_helper.rb' - - 'lib/capybara_failure_logger.rb' - - 'lib/eventful_record.rb' - - 'lib/informatics/test/helpers/authentication_helper.rb' - - 'lib/mbrave_tags_creator.rb' - - 'spec/lib/mock_parser.rb' - - 'test/unit/tag_qc/qcable_statemachine_checks.rb' - - 'test/unit/task_test_base.rb' - # Offense count: 6 Naming/ConstantName: Exclude: diff --git a/app/api/core/endpoint/base.rb b/app/api/core/endpoint/base.rb index c11382b057..18ed6542ca 100644 --- a/app/api/core/endpoint/base.rb +++ b/app/api/core/endpoint/base.rb @@ -57,8 +57,8 @@ def self.extended(base) # This is where you define your actions. # # @return [Void] - def instance(&block) - handler = Class.new(Handler).tap { |handler_class| const_set(:Instance, handler_class) }.new(&block) + def instance(&) + handler = Class.new(Handler).tap { |handler_class| const_set(:Instance, handler_class) }.new(&) handler.instance_variable_set(:@name, name) self.instance_handler = handler end @@ -96,8 +96,8 @@ def self.extended(base) # This is where you define your actions. # # @return [Void] - def model(&block) - handler = Class.new(Handler).tap { |handler_class| const_set(:Model, handler_class) }.new(&block) + def model(&) + handler = Class.new(Handler).tap { |handler_class| const_set(:Model, handler_class) }.new(&) self.model_handler = handler end end diff --git a/app/api/core/endpoint/basic_handler/actions.rb b/app/api/core/endpoint/basic_handler/actions.rb index 4ea6b2e366..b53673131d 100644 --- a/app/api/core/endpoint/basic_handler/actions.rb +++ b/app/api/core/endpoint/basic_handler/actions.rb @@ -95,8 +95,8 @@ def _#{action}(request, response) end end - def action(name, options = {}, &block) - declare_action(name, options, &block) + def action(name, options = {}, &) + declare_action(name, options, &) attach_action(options[:as] || name, name) action_guard(name, options[:if]) if options.key?(:if) end diff --git a/app/api/core/endpoint/basic_handler/actions/bound.rb b/app/api/core/endpoint/basic_handler/actions/bound.rb index 7b244c6d38..9a7b8e7f82 100644 --- a/app/api/core/endpoint/basic_handler/actions/bound.rb +++ b/app/api/core/endpoint/basic_handler/actions/bound.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Core::Endpoint::BasicHandler::Actions::Bound - def bind_action(name, options, &block) + def bind_action(name, options, &) class_handler = Class.new(Handler).tap { |handler| self.class.const_set(options[:as].to_s.camelize, handler) } - register_handler(options[:to], class_handler.new(self, name, options, &block)) + register_handler(options[:to], class_handler.new(self, name, options, &)) end def self.delegate_to_bound_handler(name, target = name) diff --git a/app/api/core/endpoint/basic_handler/actions/bound/handler.rb b/app/api/core/endpoint/basic_handler/actions/bound/handler.rb index 0d894be764..66b504e449 100644 --- a/app/api/core/endpoint/basic_handler/actions/bound/handler.rb +++ b/app/api/core/endpoint/basic_handler/actions/bound/handler.rb @@ -6,8 +6,8 @@ class Core::Endpoint::BasicHandler::Actions::Bound::Handler < Core::Endpoint::Ba include Core::Endpoint::BasicHandler::Actions::InnerAction include Core::Endpoint::BasicHandler::Paged - def initialize(owner, name, options, &block) - super(name, options, &block) + def initialize(owner, name, options, &) + super(name, options, &) @owner = owner end diff --git a/app/api/core/endpoint/basic_handler/actions/factory.rb b/app/api/core/endpoint/basic_handler/actions/factory.rb index 9b1e8327e0..8f75e21849 100644 --- a/app/api/core/endpoint/basic_handler/actions/factory.rb +++ b/app/api/core/endpoint/basic_handler/actions/factory.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module Core::Endpoint::BasicHandler::Actions::Factory class Nested < Core::Endpoint::BasicHandler - def initialize(name, &block) - super(&block) + def initialize(name, &) + super(&) @name = name.to_s end @@ -21,8 +21,8 @@ def core_path(*args) end end - def nested(json, &block) + def nested(json, &) class_handler = Class.new(Nested).tap { |handler| self.class.const_set(json.to_s.camelize, handler) } - register_handler(json, class_handler.new(json, &block)) + register_handler(json, class_handler.new(json, &)) end end diff --git a/app/api/core/endpoint/basic_handler/actions/guards.rb b/app/api/core/endpoint/basic_handler/actions/guards.rb index fcf29c54ba..f3bd969630 100644 --- a/app/api/core/endpoint/basic_handler/actions/guards.rb +++ b/app/api/core/endpoint/basic_handler/actions/guards.rb @@ -61,8 +61,8 @@ def accessible_action?(_handler, action, request, object) end private :accessible_action? - def action_guard(name, method_name = nil, &block) - guard_for(name).push(Guard.new(method_name, &block)) + def action_guard(name, method_name = nil, &) + guard_for(name).push(Guard.new(method_name, &)) end def guard_for(name) diff --git a/app/api/core/endpoint/basic_handler/actions/inner_action.rb b/app/api/core/endpoint/basic_handler/actions/inner_action.rb index 8f998c73a4..676556581a 100644 --- a/app/api/core/endpoint/basic_handler/actions/inner_action.rb +++ b/app/api/core/endpoint/basic_handler/actions/inner_action.rb @@ -20,10 +20,10 @@ def for_json nil end - def rooted_json(options, &block) + def rooted_json(options, &) return yield(options[:stream]) if @options.key?(:json) - options[:stream].block(@options[:json].to_s, &block) + options[:stream].block(@options[:json].to_s, &) end private :rooted_json diff --git a/app/api/core/endpoint/basic_handler/associations/belongs_to.rb b/app/api/core/endpoint/basic_handler/associations/belongs_to.rb index 1e5403cd88..4ad0a73799 100644 --- a/app/api/core/endpoint/basic_handler/associations/belongs_to.rb +++ b/app/api/core/endpoint/basic_handler/associations/belongs_to.rb @@ -62,9 +62,9 @@ def initialize @endpoints = [] end - def belongs_to(name, options, &block) + def belongs_to(name, options, &) class_handler = Class.new(Handler).tap { |handler| self.class.const_set(name.to_s.camelize, handler) } - @endpoints.push(class_handler.new(name, options, &block)) + @endpoints.push(class_handler.new(name, options, &)) end def related diff --git a/app/api/core/endpoint/basic_handler/associations/has_many.rb b/app/api/core/endpoint/basic_handler/associations/has_many.rb index dfc9e968f0..c4110e31a9 100644 --- a/app/api/core/endpoint/basic_handler/associations/has_many.rb +++ b/app/api/core/endpoint/basic_handler/associations/has_many.rb @@ -12,8 +12,8 @@ module Core::Endpoint::BasicHandler::Associations::HasMany # @yield [] Use block to define additional actions on the association. # # @return [Void] - def has_many(name, options, &block) + def has_many(name, options, &) class_handler = Class.new(Handler).tap { |handler| self.class.const_set(name.to_s.camelize, handler) } - register_handler(options[:to], class_handler.new(name, options, &block)) + register_handler(options[:to], class_handler.new(name, options, &)) end end diff --git a/app/api/core/endpoint/basic_handler/associations/has_many/handler.rb b/app/api/core/endpoint/basic_handler/associations/has_many/handler.rb index faa6e56e2b..d6566fb9f1 100644 --- a/app/api/core/endpoint/basic_handler/associations/has_many/handler.rb +++ b/app/api/core/endpoint/basic_handler/associations/has_many/handler.rb @@ -2,8 +2,8 @@ class Core::Endpoint::BasicHandler::Associations::HasMany::Handler < Core::Endpoint::BasicHandler include Core::Endpoint::BasicHandler::Paged - def initialize(association, options, &block) - super(&block) + def initialize(association, options, &) + super(&) @association, @options = association, options end diff --git a/app/api/core/io/json/grammar.rb b/app/api/core/io/json/grammar.rb index 45411559e0..f6e2e2e47e 100644 --- a/app/api/core/io/json/grammar.rb +++ b/app/api/core/io/json/grammar.rb @@ -100,10 +100,10 @@ def call(object, options, stream) end end - def rooted_json(stream, nested, &block) + def rooted_json(stream, nested, &) return yield(stream) if nested - stream.block(json_root, &block) + stream.block(json_root, &) end private :rooted_json diff --git a/app/api/core/service.rb b/app/api/core/service.rb index 31692d790c..a0ab319f8f 100644 --- a/app/api/core/service.rb +++ b/app/api/core/service.rb @@ -99,12 +99,12 @@ def api_path(*sub_path) "#{request.scheme}://#{request.host_with_port}/#{self.class.api_version_path}/#{sub_path.compact.join('/')}" end - def self.before_all_actions(&block) - before('/*', &block) + def self.before_all_actions(&) + before('/*', &) end - def self.after_all_actions(&block) - after('/*', &block) + def self.after_all_actions(&) + after('/*', &) end attr_reader :command @@ -126,9 +126,9 @@ class Request delegate :user, to: :service - def initialize(identifier, *args, &block) + def initialize(identifier, *args, &) @identifier, @started_at = identifier, Time.zone.now - super(*args, &block) + super(*args, &) @ability = Core::Abilities.create(self) end @@ -143,8 +143,8 @@ def authentication_code @service.request.cookies['api_key'] || @service.request.cookies['WTSISignOn'] end - def response(&block) - ::Core::Service::Response.new(self, &block) + def response(&) + ::Core::Service::Response.new(self, &) end # Safe way to push a particular value on to the request target stack. Ensures that the @@ -216,10 +216,10 @@ def multiple_choices delegate :endpoint_for_object, to: 'request.service' private :endpoint_for_object - def initialize(request, &block) + def initialize(request, &) @request, @io, @include_actions = request, nil, true status(200) - super(&block) + super(&) end #-- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bcfde2c15a..abdbc4f2c3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -278,8 +278,8 @@ def hidden_label_tag_for_testing(name, text = nil, options = {}) label_tag(name, text, options.merge(style: 'display:none;')) end - def help_text(&block) - tag.small(class: 'form-text text-muted col', &block) + def help_text(&) + tag.small(class: 'form-text text-muted col', &) end def help_link(text, entry = '', options = {}) diff --git a/app/helpers/assets_helper.rb b/app/helpers/assets_helper.rb index 7acca83674..1773f4b2cd 100644 --- a/app/helpers/assets_helper.rb +++ b/app/helpers/assets_helper.rb @@ -41,10 +41,10 @@ def new_request_receptacle_path_in_context(asset) # parameter along with its current value, based either on the instance variable ID value or the # ID parameter. For instance, if the 'name' is 'foo' then either the '@foo.id' value will be yielded, # or the 'params[:foo_id]' value if @foo is nil. - def instance_variable_or_id_param(name, &block) + def instance_variable_or_id_param(name, &) field_name, value = :"#{name}_id", instance_variable_get(:"@#{name}") value_id = value.nil? ? params[field_name] : value.id - concat(capture(field_name, value_id, &block)) + concat(capture(field_name, value_id, &)) end # Returns a select tag that has it's options ordered by name (assumes present of sorted_by_name function) diff --git a/app/helpers/bootstrap_helper.rb b/app/helpers/bootstrap_helper.rb index 3893ddfdf2..d889e89e5f 100644 --- a/app/helpers/bootstrap_helper.rb +++ b/app/helpers/bootstrap_helper.rb @@ -3,20 +3,20 @@ # A collection of view helpers to assist with rendering bootstrap components module BootstrapHelper - def panel(type = :default, options = {}, &block) - bs_custom_panel(type, :div, { class: 'card-body' }, options, &block) + def panel(type = :default, options = {}, &) + bs_custom_panel(type, :div, { class: 'card-body' }, options, &) end - def list_panel(type = :default, options = {}, &block) - bs_custom_panel(type, :ul, { class: 'list-group list-group-flush' }, options, &block) + def list_panel(type = :default, options = {}, &) + bs_custom_panel(type, :ul, { class: 'list-group list-group-flush' }, options, &) end - def link_panel(type = :default, options = {}, &block) - bs_custom_panel(type, :div, { class: 'link-panel' }, options, &block) + def link_panel(type = :default, options = {}, &) + bs_custom_panel(type, :div, { class: 'link-panel' }, options, &) end - def panel_no_body(type = :default, options = {}, &block) - bs_custom_panel(type, :div, {}, options, &block) + def panel_no_body(type = :default, options = {}, &) + bs_custom_panel(type, :div, {}, options, &) end def bs_custom_panel(type, body_type, body_options, options, &block) @@ -31,10 +31,10 @@ def bs_custom_panel(type, body_type, body_options, options, &block) # - def alert(type = :default, options = {}, &block) + def alert(type = :default, options = {}, &) options[:role] ||= 'alert' append_class!(options, "alert alert-#{type}") - tag.div(**options, &block) + tag.div(**options, &) end # Summary composites a panel with a table to deliver @@ -92,12 +92,12 @@ def pagination(collection) end #
- def form_group(&block) - tag.div(class: 'form-group row sqs-form', &block) + def form_group(&) + tag.div(class: 'form-group row sqs-form', &) end - def bs_column(size = 6, screen = 'md', &block) - tag.div(class: "col-#{screen}-#{size}", &block) + def bs_column(size = 6, screen = 'md', &) + tag.div(class: "col-#{screen}-#{size}", &) end def progress_bar(count) # rubocop:todo Metrics/MethodLength diff --git a/app/helpers/descriptor_javascript_helper.rb b/app/helpers/descriptor_javascript_helper.rb index fa3e84cb23..b7cd7f987d 100644 --- a/app/helpers/descriptor_javascript_helper.rb +++ b/app/helpers/descriptor_javascript_helper.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true module DescriptorJavascriptHelper - def link_to_remove_asset(index, &block) - link_to_with_onclick_only("removeAsset(#{index});return false;", &block) + def link_to_remove_asset(index, &) + link_to_with_onclick_only("removeAsset(#{index});return false;", &) end private - def link_to_with_onclick_only(on_click_code, &block) - concat(tag.a(capture(&block), href: 'javascript:void();', onClick: on_click_code)) + def link_to_with_onclick_only(on_click_code, &) + concat(tag.a(capture(&), href: 'javascript:void();', onClick: on_click_code)) end end diff --git a/app/models/aliquot/aliquotable.rb b/app/models/aliquot/aliquotable.rb index a084537dac..ac5b7a1a31 100644 --- a/app/models/aliquot/aliquotable.rb +++ b/app/models/aliquot/aliquotable.rb @@ -22,8 +22,8 @@ def self.included(base) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength end module ClassMethods - def receptacle_alias(name, options = {}, &block) - has_many(name, -> { distinct }, options.merge(through: :aliquots, source: :receptacle), &block) + def receptacle_alias(name, options = {}, &) + has_many(name, -> { distinct }, options.merge(through: :aliquots, source: :receptacle), &) end end end diff --git a/app/models/api/base.rb b/app/models/api/base.rb index aed42ede31..a87d4d67cd 100644 --- a/app/models/api/base.rb +++ b/app/models/api/base.rb @@ -173,9 +173,9 @@ def self.default_object end # rubocop:todo Metrics/MethodLength - def self.with_association(association, options = {}, &block) # rubocop:todo Metrics/AbcSize + def self.with_association(association, options = {}, &) # rubocop:todo Metrics/AbcSize association_helper = Class.new(Api::Base) - association_helper.class_eval(&block) + association_helper.class_eval(&) association_helper.singleton_class.class_eval do alias_method(:default_object, options[:if_nil_use]) if options.key?(:if_nil_use) define_method(:lookup_by) { options[:lookup_by] } @@ -192,9 +192,9 @@ def self.with_association(association, options = {}, &block) # rubocop:todo Metr # rubocop:enable Metrics/MethodLength # rubocop:todo Metrics/MethodLength - def self.with_nested_has_many_association(association, options = {}, &block) # rubocop:todo Metrics/AbcSize + def self.with_nested_has_many_association(association, options = {}, &) # rubocop:todo Metrics/AbcSize association_helper = Class.new(Api::Base) - association_helper.class_eval(&block) + association_helper.class_eval(&) association_helper.singleton_class.class_eval do define_method(:association) { association } define_method(:alias) { options[:as] || association } diff --git a/app/models/metadata.rb b/app/models/metadata.rb index 07029b123a..6601fe536a 100644 --- a/app/models/metadata.rb +++ b/app/models/metadata.rb @@ -4,10 +4,10 @@ module Metadata # @!macro [attach] has_metadata # @!parse class Metadata < Metadata::Base; end - def has_metadata(options = {}, &block) + def has_metadata(options = {}, &) as_class = options.delete(:as) || self table_name = options.delete(:table_name) || "#{as_class.name.demodulize.underscore}_metadata" - construct_metadata_class(table_name, as_class, &block) + construct_metadata_class(table_name, as_class, &) build_association(as_class, options) end @@ -88,9 +88,9 @@ def for?(service) end end - def construct_metadata_class(table_name, as_class, &block) + def construct_metadata_class(table_name, as_class, &) parent_class = self == as_class ? Metadata::Base : as_class::Metadata - metadata = Class.new(parent_class, &block) + metadata = Class.new(parent_class, &) as_name = as_class.name.demodulize.underscore @@ -117,8 +117,8 @@ class Base < ApplicationRecord # This ensures that the default values are stored within the DB, meaning that this information will be # preserved for the future, unlike the original properties information which didn't store values when # nil which lead to us having to guess. - def initialize(attributes = {}, *args, &block) - super(self.class.defaults.merge(attributes.try(:symbolize_keys) || {}), *args, &block) + def initialize(attributes = {}, *args, &) + super(self.class.defaults.merge(attributes.try(:symbolize_keys) || {}), *args, &) end before_validation :merge_instance_defaults, on: :create diff --git a/app/models/metadata/builder_base.rb b/app/models/metadata/builder_base.rb index 0ec0867791..e9bd2618b0 100644 --- a/app/models/metadata/builder_base.rb +++ b/app/models/metadata/builder_base.rb @@ -2,13 +2,13 @@ class Metadata::BuilderBase < ActionView::Helpers::FormBuilder attr_writer :locals - def initialize(*args, &block) + def initialize(*args, &) super @views, @locals, @root = {}, {}, nil end - def view_for(type, partial_name = nil, &block) - @views[type.to_sym] = partial_name.nil? ? { inline: capture(&block) } : { partial: partial_name } + def view_for(type, partial_name = nil, &) + @views[type.to_sym] = partial_name.nil? ? { inline: capture(&) } : { partial: partial_name } end private diff --git a/app/models/metadata/form_builder.rb b/app/models/metadata/form_builder.rb index dee73ee0c0..08bec8a67e 100644 --- a/app/models/metadata/form_builder.rb +++ b/app/models/metadata/form_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true class Metadata::FormBuilder < Metadata::BuilderBase - def initialize(*args, &block) + def initialize(*args, &) super view_for(:field, 'shared/metadata/edit_field') view_for(:radio_field, 'shared/metadata/radio_field') @@ -104,14 +104,14 @@ def header(field, options = {}) # You can use `:to` to give the name of the field, `:when` for the single value when the fields should # be shown, and `:in` for a group of values. You *must* call finalize_related_fields at the end of # your view to get the appropriate behaviour - def related_fields(options, &block) # rubocop:todo Metrics/AbcSize + def related_fields(options, &) # rubocop:todo Metrics/AbcSize options.symbolize_keys! values = (options.fetch(:in, Array(options[:when])) - Array(options[:not])).map do |v| v.to_s.downcase.gsub(/[^a-z0-9]+/, '_') end - content = capture(&block) + content = capture(&) concat(tag.div(content, class: [:related_to, options[:to], values].flatten.join(' '))) @related_fields.push(options[:to]) diff --git a/app/models/metadata/view_builder.rb b/app/models/metadata/view_builder.rb index e9b5861ff8..e7de07ca1f 100644 --- a/app/models/metadata/view_builder.rb +++ b/app/models/metadata/view_builder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true class Metadata::ViewBuilder < Metadata::BuilderBase - def initialize(*args, &block) + def initialize(*args, &) super view_for(:plain_value, 'shared/metadata/plain_field') view_for(:file, 'shared/metadata/file') diff --git a/app/models/parsers/cardinal_pbmc_count_parser.rb b/app/models/parsers/cardinal_pbmc_count_parser.rb index c6489be771..560cdb3a67 100644 --- a/app/models/parsers/cardinal_pbmc_count_parser.rb +++ b/app/models/parsers/cardinal_pbmc_count_parser.rb @@ -60,8 +60,8 @@ def get_well_location(cell) cell.split(':')[1] end - def each_well_and_parameters(&block) - qc_data.each(&block) + def each_well_and_parameters(&) + qc_data.each(&) end def qc_metrics_hash(row) diff --git a/app/models/plate.rb b/app/models/plate.rb index b9a650ec2c..086fc5f859 100644 --- a/app/models/plate.rb +++ b/app/models/plate.rb @@ -336,10 +336,10 @@ def stock_plate end deprecate stock_plate: 'Stock plate is nebulous and can easily lead to unexpected behaviour' - def self.create_with_barcode!(*args, &block) + def self.create_with_barcode!(*args, &) attributes = args.extract_options! attributes[:sanger_barcode] ||= PlateBarcode.create_barcode - create!(attributes, &block) + create!(attributes, &) end def number_of_blank_samples diff --git a/app/models/presenters/batch_submenu_presenter.rb b/app/models/presenters/batch_submenu_presenter.rb index 7af5a00e98..f79b8dec89 100644 --- a/app/models/presenters/batch_submenu_presenter.rb +++ b/app/models/presenters/batch_submenu_presenter.rb @@ -40,9 +40,9 @@ def add_submenu_option(text, action_params) @options += [{ label: text, url: action_params }] end - def each_option(&block) + def each_option(&) build_submenu if @options.nil? - @options.each(&block) + @options.each(&) end private diff --git a/app/models/request_type.rb b/app/models/request_type.rb index e81108dfc7..659597d926 100644 --- a/app/models/request_type.rb +++ b/app/models/request_type.rb @@ -112,16 +112,16 @@ def construct_request(construct_method, attributes, klass = request_class) new_request end - def create!(attributes = {}, &block) - construct_request(:create!, attributes, &block) + def create!(attributes = {}, &) + construct_request(:create!, attributes, &) end - def new(attributes = {}, &block) - construct_request(:new, attributes, &block) + def new(attributes = {}, &) + construct_request(:new, attributes, &) end - def create_control!(attributes = {}, &block) - construct_request(:create!, attributes, ControlRequest, &block) + def create_control!(attributes = {}, &) + construct_request(:create!, attributes, ControlRequest, &) end def self.create_asset @@ -172,14 +172,14 @@ def extract_metadata_from_hash(request_options) attributes.delete_if { |k, _| common_attributes.exclude?(k) } end - def create_target_asset!(&block) + def create_target_asset!(&) case when target_purpose.present? - target_purpose.create!(&block).receptacle + target_purpose.create!(&).receptacle when target_asset_type.blank? nil else - target_asset_type.constantize.create!(&block) + target_asset_type.constantize.create!(&) end end diff --git a/app/models/sample_manifest/core_behaviour.rb b/app/models/sample_manifest/core_behaviour.rb index 9b62d7d30c..c5b743133b 100644 --- a/app/models/sample_manifest/core_behaviour.rb +++ b/app/models/sample_manifest/core_behaviour.rb @@ -27,8 +27,8 @@ def generate_sanger_ids(count = 1) Array.new(count) { SangerSampleId::Factory.instance.next! } end - def details(&block) - details_array.each(&block) + def details(&) + details_array.each(&) end end diff --git a/app/models/strip_tube.rb b/app/models/strip_tube.rb index ebb6aa6656..014e8ca5fd 100644 --- a/app/models/strip_tube.rb +++ b/app/models/strip_tube.rb @@ -19,10 +19,10 @@ def library_source_plates end # Until we know how barcodes are going to work, we'll just override this - def self.create_with_barcode!(*args, &block) + def self.create_with_barcode!(*args, &) attributes = args.extract_options! attributes.delete(:barcode) attributes.delete(:sanger_barcode) - create!(attributes, &block) + create!(attributes, &) end end diff --git a/app/models/study_report/study_details.rb b/app/models/study_report/study_details.rb index 8e26348d3d..bd801f715c 100644 --- a/app/models/study_report/study_details.rb +++ b/app/models/study_report/study_details.rb @@ -4,13 +4,13 @@ module StudyReport::StudyDetails BATCH_SIZE = 1000 # This will pull out all well ids from stock plates in the study - def each_stock_well_id_in_study_in_batches(&block) # rubocop:todo Metrics/MethodLength + def each_stock_well_id_in_study_in_batches(&) # rubocop:todo Metrics/MethodLength # Stock wells are determined by the requests leading from the stock plate handle_wells( :requests, { requests: { initial_study_id: id } }, PlatePurpose.where(name: Study::STOCK_PLATE_PURPOSES).pluck(:id), - &block + & ) # Aliquot 1,2,3,4 & 5 plates are determined by the aliquots in their wells @@ -20,15 +20,15 @@ def each_stock_well_id_in_study_in_batches(&block) # rubocop:todo Metrics/Method PlatePurpose.where( name: ['Aliquot 1', 'Aliquot 2', 'Aliquot 3', 'Aliquot 4', 'Aliquot 1', 'Pre-Extracted Plate'] ).pluck(:id), - &block + & ) end # Similar to find in batches, we pluck out the relevant asset ids, then slice them into batches of the # batch size. This allows us to perform one query to grab all our ids. - def handle_wells(join, study_condition, plate_purpose_id, &block) + def handle_wells(join, study_condition, plate_purpose_id, &) asset_ids = well_report_ids(join, study_condition, plate_purpose_id) - asset_ids.each_slice(BATCH_SIZE, &block) + asset_ids.each_slice(BATCH_SIZE, &) end private :handle_wells diff --git a/app/models/submission/presenter_skeleton.rb b/app/models/submission/presenter_skeleton.rb index 2d7f176593..1931b8a3a4 100644 --- a/app/models/submission/presenter_skeleton.rb +++ b/app/models/submission/presenter_skeleton.rb @@ -25,13 +25,13 @@ def lanes_of_sequencing def cross_compatible? end - def each_submission_warning(&block) - submission.each_submission_warning(&block) + def each_submission_warning(&) + submission.each_submission_warning(&) end protected - def method_missing(name, *args, &block) + def method_missing(name, *args, &) name_without_assignment = name.to_s.sub(/=$/, '').to_sym return super unless attributes.include?(name_without_assignment) diff --git a/app/models/tube.rb b/app/models/tube.rb index 3bb36fbe62..134c8c755a 100644 --- a/app/models/tube.rb +++ b/app/models/tube.rb @@ -83,7 +83,7 @@ def after_comment_addition(comment) comments.add_comment_to_submissions(comment) end - def self.create_with_barcode!(*args, &block) + def self.create_with_barcode!(*args, &) attributes = args.extract_options!.symbolize_keys barcode, prefix = extract_barcode(args, attributes) @@ -94,7 +94,7 @@ def self.create_with_barcode!(*args, &block) # this is to control the order of barcode addition so that it gets set as the 'primary' barcode foreign_barcode = attributes.delete(:foreign_barcode) - tube = create!(attributes.merge(sanger_barcode: { prefix:, number: barcode }), &block) + tube = create!(attributes.merge(sanger_barcode: { prefix:, number: barcode }), &) tube.foreign_barcode = foreign_barcode if foreign_barcode tube.reload diff --git a/app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb b/app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb index 52a6242dbc..e4dc731db5 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb @@ -12,8 +12,8 @@ def initialize(manifest_types = {}) yield self if block_given? end - def each(&block) - manifest_types.each(&block) + def each(&) + manifest_types.each(&) end # Hash version of the manifest_types.yml config file diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/data.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/data.rb index 23d32450c8..b9679f9487 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/data.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/data.rb @@ -41,8 +41,8 @@ def initialize(file) # rubocop:todo Metrics/MethodLength @data ||= [] end - def each(&block) - data.each(&block) + def each(&) + data.each(&) end def file_extension diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb index 4c65c2f855..53bb975a3b 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb @@ -23,8 +23,8 @@ def initialize(data, columns, cache = SampleManifestAsset) @items = create_rows(cache) end - def each(&block) - items.each(&block) + def each(&) + items.each(&) end # Return values for rows for a particular column number diff --git a/app/sequencescape_excel/sequencescape_excel/list.rb b/app/sequencescape_excel/sequencescape_excel/list.rb index be22382037..32890f3c36 100644 --- a/app/sequencescape_excel/sequencescape_excel/list.rb +++ b/app/sequencescape_excel/sequencescape_excel/list.rb @@ -104,8 +104,8 @@ def initialize ## # relates to each value i.e. each object that is added. - def each(&block) - values.each(&block) + def each(&) + values.each(&) end def values diff --git a/app/sequencescape_excel/sequencescape_excel/range_list.rb b/app/sequencescape_excel/sequencescape_excel/range_list.rb index 1f1c7318d8..e462bcd8a7 100644 --- a/app/sequencescape_excel/sequencescape_excel/range_list.rb +++ b/app/sequencescape_excel/sequencescape_excel/range_list.rb @@ -19,8 +19,8 @@ def initialize(ranges_data = {}) @ranges = create(ranges_data) end - def each(&block) - ranges.each(&block) + def each(&) + ranges.each(&) end ## diff --git a/app/uploaders/polymorphic_uploader.rb b/app/uploaders/polymorphic_uploader.rb index 6f067a5c55..3548e7f937 100644 --- a/app/uploaders/polymorphic_uploader.rb +++ b/app/uploaders/polymorphic_uploader.rb @@ -77,7 +77,7 @@ def destroy_file end class PolymorphicUploader < CarrierWave::Uploader::Base - def initialize(*args, &block) + def initialize(*args, &) super end diff --git a/config/initializers/api_routing.rb b/config/initializers/api_routing.rb index 124889b59e..1c711641e4 100644 --- a/config/initializers/api_routing.rb +++ b/config/initializers/api_routing.rb @@ -2,10 +2,10 @@ # TODO: Fix these module ApiRouting # Assets have a couple of extra actions that are always present: namely 'parents' and 'children' - def asset(*entities, &block) + def asset(*entities, &) options = entities.extract_options! entities.push({ member: { parents: :get, children: :get } }.merge(options)) - model(*entities, &block) + model(*entities, &) end # Models exposed through the API are assumed to always be read only, unless otherwise specified. Nested diff --git a/features/support/step_definitions/api_steps.rb b/features/support/step_definitions/api_steps.rb index 11c997ce8b..18145ced59 100644 --- a/features/support/step_definitions/api_steps.rb +++ b/features/support/step_definitions/api_steps.rb @@ -46,10 +46,10 @@ def walk_hash_structure(hash_data, &block) end end -def assert_json_equal(expected, received, &block) +def assert_json_equal(expected, received, &) assert_hash_equal( - walk_hash_structure(decode_json(expected, 'Expected'), &block), - walk_hash_structure(decode_json(received, 'Received'), &block), + walk_hash_structure(decode_json(expected, 'Expected'), &), + walk_hash_structure(decode_json(received, 'Received'), &), 'Differs when decoded' ) end diff --git a/features/support/step_definitions/submission_steps.rb b/features/support/step_definitions/submission_steps.rb index 035bc9df6c..e55202d686 100644 --- a/features/support/step_definitions/submission_steps.rb +++ b/features/support/step_definitions/submission_steps.rb @@ -139,9 +139,9 @@ def submission_in_state(state, attributes = {}) 'Illumina-B HiSeq Paired end sequencing' => SENSIBLE_DEFAULTS_HISEQ }.freeze -def with_request_type_scope(name, &block) +def with_request_type_scope(name, &) request_type = RequestType.find_by(name:) or raise StandardError, "Cannot find request type #{name.inspect}" - with_scope("#request_type_options_for_#{request_type.id}", &block) + with_scope("#request_type_options_for_#{request_type.id}", &) end When /^I fill in "([^"]+)" with "([^"]+)" for the "([^"]+)" request type$/ do |name, value, type| diff --git a/lib/accession/accession/submission.rb b/lib/accession/accession/submission.rb index b2ec709b9a..d7df065e8d 100644 --- a/lib/accession/accession/submission.rb +++ b/lib/accession/accession/submission.rb @@ -73,8 +73,8 @@ def initialize(accessionables) end end - def each(&block) - files.each(&block) + def each(&) + files.each(&) end def open diff --git a/lib/accession/accession/tag_list.rb b/lib/accession/accession/tag_list.rb index eba8db0f00..d2eff93c67 100644 --- a/lib/accession/accession/tag_list.rb +++ b/lib/accession/accession/tag_list.rb @@ -24,8 +24,8 @@ def initialize(tags = {}) yield self if block_given? end - def each(&block) - tags.each(&block) + def each(&) + tags.each(&) end def required_for(service) diff --git a/lib/authenticated_test_helper.rb b/lib/authenticated_test_helper.rb index d4d106f8f6..0f33e7433a 100644 --- a/lib/authenticated_test_helper.rb +++ b/lib/authenticated_test_helper.rb @@ -40,8 +40,8 @@ def assert_difference(object, method = nil, difference = 1) assert_equal initial_value + difference, object.send(method), "#{object}##{method}" end - def assert_no_difference(object, method, &block) - assert_difference object, method, 0, &block + def assert_no_difference(object, method, &) + assert_difference(object, method, 0, &) end # Assert the block redirects to the login diff --git a/lib/capybara_failure_logger.rb b/lib/capybara_failure_logger.rb index 5495b4d441..c6fc96aecd 100644 --- a/lib/capybara_failure_logger.rb +++ b/lib/capybara_failure_logger.rb @@ -24,13 +24,13 @@ def self.log_failure(name, page, &block) log_js(name, page, &block) end - def self.log_screenshot(name, page, &block) + def self.log_screenshot(name, page, &) return unless page.respond_to?(:save_screenshot) page.save_screenshot("#{name}.png") filename = "#{Capybara.save_path}/#{name}.png" yield "📸 Screenshot saved to #{filename}" - output_image(filename, &block) + output_image(filename, &) rescue Capybara::NotSupportedByDriverError yield 'Could not save screenshot - Unsupported by this webdriver' end diff --git a/lib/eventful_record.rb b/lib/eventful_record.rb index a78ac30c25..135c01ed3c 100644 --- a/lib/eventful_record.rb +++ b/lib/eventful_record.rb @@ -22,17 +22,17 @@ def #{name}(*args) end end - def has_many_lab_events(&block) - has_many(:lab_events, -> { order(created_at: :asc, id: :asc) }, as: :eventful, dependent: :destroy, &block) + def has_many_lab_events(&) + has_many(:lab_events, -> { order(created_at: :asc, id: :asc) }, as: :eventful, dependent: :destroy, &) end - def has_one_event_with_family(event_family, &block) + def has_one_event_with_family(event_family, &) has_one( :"#{event_family}_event", lambda { order(id: :desc).where(family: event_family) }, class_name: 'Event', as: :eventful, - &block + & ) end end diff --git a/lib/informatics/test/helpers/authentication_helper.rb b/lib/informatics/test/helpers/authentication_helper.rb index 26dce88c76..8f4a2347a0 100644 --- a/lib/informatics/test/helpers/authentication_helper.rb +++ b/lib/informatics/test/helpers/authentication_helper.rb @@ -40,8 +40,8 @@ def assert_difference(object, method = nil, difference = 1) assert_equal initial_value + difference, object.send(method), "#{object}##{method}" end - def assert_no_difference(object, method, &block) - assert_difference object, method, 0, &block + def assert_no_difference(object, method, &) + assert_difference(object, method, 0, &) end # Assert the block redirects to the login diff --git a/lib/mbrave_tags_creator.rb b/lib/mbrave_tags_creator.rb index a1c3cda285..32985c22b1 100644 --- a/lib/mbrave_tags_creator.rb +++ b/lib/mbrave_tags_creator.rb @@ -26,9 +26,9 @@ def initialize(params) @yaml_contents = {} end - def log_line(&block) + def log_line(&) # We want to enforce that logs go to STDOUT while printing the barcodes - self.class.log_line(&block) + self.class.log_line(&) end def self.log_line diff --git a/spec/lib/mock_parser.rb b/spec/lib/mock_parser.rb index b647bcdb5a..2b8e07af61 100644 --- a/spec/lib/mock_parser.rb +++ b/spec/lib/mock_parser.rb @@ -27,7 +27,7 @@ def assay_version '1.0' end - def each_well_and_parameters(&block) - @data.each(&block) + def each_well_and_parameters(&) + @data.each(&) end end diff --git a/test/unit/tag_qc/qcable_statemachine_checks.rb b/test/unit/tag_qc/qcable_statemachine_checks.rb index cf967ba00c..8d5e25b2bd 100644 --- a/test/unit/tag_qc/qcable_statemachine_checks.rb +++ b/test/unit/tag_qc/qcable_statemachine_checks.rb @@ -2,9 +2,9 @@ module QcableStatemachineChecks class StatemachineHelper - def initialize(owner, target, &block) + def initialize(owner, target, &) @owner, @target = owner, target - instance_eval(&block) + instance_eval(&) end # rubocop:todo Metrics/MethodLength @@ -46,7 +46,7 @@ def check_event(name, options) # rubocop:todo Metrics/AbcSize # rubocop:enable Metrics/MethodLength end - def state_machine(state_machined_class, &block) - StatemachineHelper.new(self, state_machined_class, &block) + def state_machine(state_machined_class, &) + StatemachineHelper.new(self, state_machined_class, &) end end diff --git a/test/unit/task_test_base.rb b/test/unit/task_test_base.rb index f96455df58..1065b48701 100644 --- a/test/unit/task_test_base.rb +++ b/test/unit/task_test_base.rb @@ -11,10 +11,10 @@ def expected_partial(name) end end - def task_instance_for(task_module, &block) + def task_instance_for(task_module, &) object = Object.new object.class_eval { include task_module } - object.class_eval(&block) + object.class_eval(&) object end end From 8f0e74082d51c716fc51a8860c9435c1f19db1c8 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 23 Sep 2024 17:44:16 +0100 Subject: [PATCH 114/158] style: rubocop Style/ArgumentsForwarding bundle exec rubocop -a --- .rubocop_todo.yml | 60 ------------------- .../endpoint/basic_handler/actions/factory.rb | 4 +- .../endpoint/basic_handler/actions/guards.rb | 4 +- .../basic_handler/actions/inner_action.rb | 4 +- app/api/core/service.rb | 4 +- app/helpers/application_helper.rb | 4 +- app/models/attributable.rb | 4 +- app/models/comments_proxy/base.rb | 4 +- app/models/metadata.rb | 4 +- features/support/cucumber_github_formatter.rb | 4 +- .../support/step_definitions/api_steps.rb | 4 +- lib/authenticated_test_helper.rb | 4 +- .../test/helpers/authentication_helper.rb | 4 +- 13 files changed, 24 insertions(+), 84 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 72df599763..64fe380d3c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1829,66 +1829,6 @@ Security/Open: Exclude: - 'app/api/core/io/json/stream.rb' -# Offense count: 167 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames. -# RedundantRestArgumentNames: args, arguments -# RedundantKeywordRestArgumentNames: kwargs, options, opts -# RedundantBlockArgumentNames: blk, block, proc -Style/ArgumentsForwarding: - Exclude: - - 'app/api/core/endpoint/base.rb' - - 'app/api/core/endpoint/basic_handler/actions.rb' - - 'app/api/core/endpoint/basic_handler/actions/bound.rb' - - 'app/api/core/endpoint/basic_handler/actions/bound/handler.rb' - - 'app/api/core/endpoint/basic_handler/actions/factory.rb' - - 'app/api/core/endpoint/basic_handler/actions/guards.rb' - - 'app/api/core/endpoint/basic_handler/actions/inner_action.rb' - - 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb' - - 'app/api/core/endpoint/basic_handler/associations/has_many.rb' - - 'app/api/core/endpoint/basic_handler/associations/has_many/handler.rb' - - 'app/api/core/io/json/grammar.rb' - - 'app/api/core/service.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/assets_helper.rb' - - 'app/helpers/bootstrap_helper.rb' - - 'app/helpers/descriptor_javascript_helper.rb' - - 'app/models/aliquot/aliquotable.rb' - - 'app/models/api/base.rb' - - 'app/models/attributable.rb' - - 'app/models/comments_proxy/base.rb' - - 'app/models/metadata.rb' - - 'app/models/metadata/builder_base.rb' - - 'app/models/metadata/form_builder.rb' - - 'app/models/parsers/cardinal_pbmc_count_parser.rb' - - 'app/models/plate.rb' - - 'app/models/presenters/batch_submenu_presenter.rb' - - 'app/models/request_type.rb' - - 'app/models/sample_manifest/core_behaviour.rb' - - 'app/models/strip_tube.rb' - - 'app/models/study_report/study_details.rb' - - 'app/models/submission/presenter_skeleton.rb' - - 'app/models/tube.rb' - - 'app/sample_manifest_excel/sample_manifest_excel/manifest_type_list.rb' - - 'app/sample_manifest_excel/sample_manifest_excel/upload/data.rb' - - 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb' - - 'app/sequencescape_excel/sequencescape_excel/list.rb' - - 'app/sequencescape_excel/sequencescape_excel/range_list.rb' - - 'config/initializers/api_routing.rb' - - 'features/support/cucumber_github_formatter.rb' - - 'features/support/step_definitions/api_steps.rb' - - 'features/support/step_definitions/submission_steps.rb' - - 'lib/accession/accession/submission.rb' - - 'lib/accession/accession/tag_list.rb' - - 'lib/authenticated_test_helper.rb' - - 'lib/capybara_failure_logger.rb' - - 'lib/eventful_record.rb' - - 'lib/informatics/test/helpers/authentication_helper.rb' - - 'lib/mbrave_tags_creator.rb' - - 'spec/lib/mock_parser.rb' - - 'test/unit/tag_qc/qcable_statemachine_checks.rb' - - 'test/unit/task_test_base.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/ArrayIntersect: diff --git a/app/api/core/endpoint/basic_handler/actions/factory.rb b/app/api/core/endpoint/basic_handler/actions/factory.rb index 8f75e21849..bc80fdb6c2 100644 --- a/app/api/core/endpoint/basic_handler/actions/factory.rb +++ b/app/api/core/endpoint/basic_handler/actions/factory.rb @@ -16,8 +16,8 @@ def separate(associations, _) end end - def core_path(*args) - super(@name, *args) + def core_path(*) + super(@name, *) end end diff --git a/app/api/core/endpoint/basic_handler/actions/guards.rb b/app/api/core/endpoint/basic_handler/actions/guards.rb index f3bd969630..3475b16979 100644 --- a/app/api/core/endpoint/basic_handler/actions/guards.rb +++ b/app/api/core/endpoint/basic_handler/actions/guards.rb @@ -50,8 +50,8 @@ def method_missing(name, ...) protected :method_missing end - def check_authorisation!(*args) - accessible_action?(*args) or + def check_authorisation!(*) + accessible_action?(*) or raise ::Core::Service::UnsupportedAction, 'requested action is not supported on this resource' end private :check_authorisation! diff --git a/app/api/core/endpoint/basic_handler/actions/inner_action.rb b/app/api/core/endpoint/basic_handler/actions/inner_action.rb index 676556581a..b018b4fdc1 100644 --- a/app/api/core/endpoint/basic_handler/actions/inner_action.rb +++ b/app/api/core/endpoint/basic_handler/actions/inner_action.rb @@ -46,8 +46,8 @@ def _#{name}(request, response) end private :declare_action - def core_path(*args) - super(@options[:to], *args) + def core_path(*) + super(@options[:to], *) end private :core_path end diff --git a/app/api/core/service.rb b/app/api/core/service.rb index a0ab319f8f..b122aed9ab 100644 --- a/app/api/core/service.rb +++ b/app/api/core/service.rb @@ -126,9 +126,9 @@ class Request delegate :user, to: :service - def initialize(identifier, *args, &) + def initialize(identifier, *, &) @identifier, @started_at = identifier, Time.zone.now - super(*args, &) + super(*, &) @ability = Core::Abilities.create(self) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index abdbc4f2c3..008a8f882a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -243,7 +243,7 @@ def tab(name, target: nil, active: false, id: nil) #
# yield #
- def tab_pane(name, id: nil, tab_id: nil, active: false, &block) + def tab_pane(name, id: nil, tab_id: nil, active: false, &) tab_id ||= "#{name}-tab".parameterize id ||= name.parameterize active_class = active ? 'active' : '' @@ -252,7 +252,7 @@ def tab_pane(name, id: nil, tab_id: nil, active: false, &block) id:, role: 'tabpanel', aria_labelledby: tab_id, - &block + & ) end diff --git a/app/models/attributable.rb b/app/models/attributable.rb index c68f5799ff..0e78320148 100644 --- a/app/models/attributable.rb +++ b/app/models/attributable.rb @@ -28,8 +28,8 @@ def self.included(base) end end - def attribute_details_for(*args) - self.class.attribute_details_for(*args) + def attribute_details_for(*) + self.class.attribute_details_for(*) end def instance_defaults diff --git a/app/models/comments_proxy/base.rb b/app/models/comments_proxy/base.rb index e6ec2cfb6f..e7597bc071 100644 --- a/app/models/comments_proxy/base.rb +++ b/app/models/comments_proxy/base.rb @@ -38,8 +38,8 @@ def comment_assn end # We're using group above, resulting in size and count returning a hash, not a count. - def size(*args) - comment_assn.size(*args).length + def size(*) + comment_assn.size(*).length end def count(*_args) diff --git a/app/models/metadata.rb b/app/models/metadata.rb index 6601fe536a..488385afe4 100644 --- a/app/models/metadata.rb +++ b/app/models/metadata.rb @@ -117,8 +117,8 @@ class Base < ApplicationRecord # This ensures that the default values are stored within the DB, meaning that this information will be # preserved for the future, unlike the original properties information which didn't store values when # nil which lead to us having to guess. - def initialize(attributes = {}, *args, &) - super(self.class.defaults.merge(attributes.try(:symbolize_keys) || {}), *args, &) + def initialize(attributes = {}, *, &) + super(self.class.defaults.merge(attributes.try(:symbolize_keys) || {}), *, &) end before_validation :merge_instance_defaults, on: :create diff --git a/features/support/cucumber_github_formatter.rb b/features/support/cucumber_github_formatter.rb index c18bff70bd..dacdcfa772 100644 --- a/features/support/cucumber_github_formatter.rb +++ b/features/support/cucumber_github_formatter.rb @@ -3,8 +3,8 @@ # This mostly comes from https://github.com/duderman/cucumber_github_formatter # but we patch puts to ensure we can use it with the progress formatter module CucumberGithubFormatter::Patch - def puts(*args) - super('', *args) + def puts(*) + super('', *) end end diff --git a/features/support/step_definitions/api_steps.rb b/features/support/step_definitions/api_steps.rb index 18145ced59..6c1d44e120 100644 --- a/features/support/step_definitions/api_steps.rb +++ b/features/support/step_definitions/api_steps.rb @@ -27,10 +27,10 @@ def recursive_diff(h1, h2) # rubocop:todo Metrics/CyclomaticComplexity end # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity -def assert_hash_equal(h1, h2, *args) +def assert_hash_equal(h1, h2, *) d1 = recursive_diff(h1, h2) d2 = recursive_diff(h2, h1) - assert_equal(d1, d2, *args) + assert_equal(d1, d2, *) end def walk_hash_structure(hash_data, &block) diff --git a/lib/authenticated_test_helper.rb b/lib/authenticated_test_helper.rb index 0f33e7433a..dfbcbeaaec 100644 --- a/lib/authenticated_test_helper.rb +++ b/lib/authenticated_test_helper.rb @@ -81,10 +81,10 @@ def check raise NotImplementedError end - def method_missing(method, *args) + def method_missing(method, *) @controller.reset! authenticate - @controller.send(method, *args) + @controller.send(method, *) check end end diff --git a/lib/informatics/test/helpers/authentication_helper.rb b/lib/informatics/test/helpers/authentication_helper.rb index 8f4a2347a0..44b340afc4 100644 --- a/lib/informatics/test/helpers/authentication_helper.rb +++ b/lib/informatics/test/helpers/authentication_helper.rb @@ -81,10 +81,10 @@ def check raise NotImplementedError end - def method_missing(method, *args) + def method_missing(method, *) @controller.reset! authenticate - @controller.send(method, *args) + @controller.send(method, *) check end end From d3db5483c21149c4bf9b861f4465b72bb21ef849 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 23 Sep 2024 18:14:26 +0100 Subject: [PATCH 115/158] style: prettier --- .rubocop.yml | 1 - app/api/model_extensions/order.rb | 3 +- app/helpers/application_helper.rb | 8 +- app/helpers/compound_sample_helper.rb | 5 +- app/helpers/submissions_helper.rb | 10 +- app/heron/factories/tube_rack_status.rb | 4 +- app/models/add_spiked_in_control_task.rb | 7 +- app/models/aliquot.rb | 6 +- app/models/attributable/association.rb | 7 +- app/models/broadcast_event/qc_assay.rb | 4 +- app/models/bulk_transfer.rb | 8 +- app/models/cherrypick_task.rb | 7 +- app/models/event/sample_logistics_qc_event.rb | 8 +- app/models/labwhere_reception.rb | 15 +-- app/models/library_creation_request.rb | 8 +- app/models/location_report.rb | 9 +- app/models/phi_x/stock.rb | 8 +- app/models/pick_list.rb | 4 +- app/models/plate/quad_creator.rb | 3 +- app/models/plate/sample_tube_factory.rb | 3 +- app/models/pooling.rb | 7 +- app/models/qc_report.rb | 7 +- app/models/qc_result_factory.rb | 12 +- app/models/request/library_creation.rb | 8 +- .../sample_manifest/shared_tube_behaviour.rb | 6 +- app/models/sample_manifest/uploader.rb | 3 +- app/models/set_descriptors_task.rb | 14 +-- app/models/state_changer/mx_tube.rb | 4 +- app/models/state_changer/standard_plate.rb | 4 +- app/models/tag_layout_template.rb | 13 +-- app/models/tasks/set_descriptors_handler.rb | 8 +- .../sample_manifest_excel/download.rb | 11 +- .../sequencescape_excel/formula.rb | 8 +- .../sequencescape_excel/range.rb | 7 +- .../uat_actions/generate_tagged_plates.rb | 11 +- db/seeds/0001_tube_purposes.rb | 4 +- db/seeds/0001_workflows.rb | 6 +- db/seeds/3000_library_types_setup.rb | 10 +- ...97_change_request_type_on_request_steps.rb | 7 +- ...equest_xml_exception_on_nil_study_steps.rb | 9 +- ..._descriptors_etc_to_table_columns_steps.rb | 8 +- .../step_definitions/65192392_tag_qc_steps.rb | 12 +- ...9309_pulldown_cherrypick_pipeline_steps.rb | 3 +- ...splay_submitted_at_inbox_pipeline_steps.rb | 3 +- .../step_definitions/genotyping_steps.rb | 13 +-- .../support/step_definitions/order_steps.rb | 3 +- .../support/step_definitions/plate_steps.rb | 15 +-- .../step_definitions/sample_manifest_steps.rb | 6 +- .../step_definitions/submission_steps.rb | 4 +- .../step_definitions/tag_layout_steps.rb | 5 +- .../support/step_definitions/uuid_steps.rb | 6 +- lib/label_printer/label_printer/print_job.rb | 6 +- ...ipeline_request_information_type_loader.rb | 4 +- lib/tasks/benchmark_plate_transfer.rake | 4 +- lib/tasks/limber.rake | 12 +- ...gister_auto_imported_samples_as_stock.rake | 3 +- spec/api/state_change_spec.rb | 11 +- spec/api/submission_pool_spec.rb | 30 ++--- .../custom_metadatum_collection_factories.rb | 6 +- spec/factories/pipelines_factories.rb | 8 +- spec/factories/plate_factories.rb | 5 +- spec/factories/request_type_factories.rb | 8 +- spec/factories/sample_manifest_factories.rb | 4 +- spec/factories/shared_traits.rb | 4 +- spec/factories/tube_factories.rb | 4 +- spec/features/assets/asset_submission_spec.rb | 4 +- .../features/batches/failing_requests_spec.rb | 5 +- .../cherrypick/cherrypick_pipeline_spec.rb | 14 ++- .../following_a_sequencing_pipeline_spec.rb | 4 +- .../viewing_request_comments_spec.rb | 4 +- ...r_for_manifests_with_tag_sequences_spec.rb | 27 +---- spec/insdc/import_countries_spec.rb | 4 +- spec/lib/label_printer/batch_plate_spec.rb | 6 +- spec/lib/label_printer/swipecard_spec.rb | 4 +- .../tag_layout_templates_loader_spec.rb | 8 +- spec/models/api/library_tube_io_spec.rb | 4 +- spec/models/api/well_io_spec.rb | 4 +- spec/models/broadcast_event/lab_event_spec.rb | 4 +- .../broadcast_event/pool_released_spec.rb | 12 +- .../cherrypick_task/control_locator_spec.rb | 9 +- spec/models/linear_submission_spec.rb | 11 +- spec/models/location_report_spec.rb | 6 +- spec/models/orders/order_spec.rb | 9 +- spec/models/phi_x/stock_spec.rb | 4 +- spec/models/pooling_spec.rb | 7 +- spec/models/sample_manifest/generator_spec.rb | 4 +- spec/models/sample_manifest_spec.rb | 5 +- spec/models/sample_spec.rb | 4 +- spec/models/sequencing_request_spec.rb | 16 +-- spec/models/specific_tube_creations_spec.rb | 8 +- .../state_changer/initial_stock_tube_spec.rb | 9 +- spec/models/state_changer/input_plate_spec.rb | 8 +- spec/models/state_changer/mx_tube_spec.rb | 9 +- .../qcable_library_plate_spec.rb | 8 +- .../state_changer/standard_plate_spec.rb | 8 +- spec/models/state_changer/stock_tube_spec.rb | 9 +- spec/models/std_library_request_spec.rb | 11 +- .../submission/submission_creator_spec.rb | 4 +- spec/models/tag_layout_spec.rb | 13 +-- spec/models/tag_layout_template_spec.rb | 8 +- spec/models/tasks/cherrypick_task_spec.rb | 4 +- spec/models/tasks/plate_template_task_spec.rb | 6 +- .../transfer_request_collection_spec.rb | 23 +--- spec/models/transfer_request_spec.rb | 6 +- spec/models/well_spec.rb | 6 +- spec/requests/api/v2/receptacles_spec.rb | 9 +- spec/requests/api/v2/wells_spec.rb | 9 +- .../upload/processor_spec.rb | 106 +++--------------- .../upload/upload_spec.rb | 4 +- spec/sample_manifest_excel/worksheet_spec.rb | 24 +--- spec/sequencescape_excel/range_spec.rb | 9 +- .../specialised_field_spec.rb | 94 ++++------------ spec/shared_contexts/limber_shared_context.rb | 16 +-- .../generate_sample_manifest_spec.rb | 18 +-- spec/uat_actions/plate_information_spec.rb | 65 ++--------- test/controllers/batches_controller_test.rb | 10 +- test/lib/label_printer/print_job_test.rb | 6 +- test/unit/import_fluidigm_data_test.rb | 8 +- 118 files changed, 224 insertions(+), 947 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d9dc181618..7e0eae89de 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -208,6 +208,5 @@ Rails/ThreeStateBooleanColumn: RSpec/ExpectInHook: Enabled: false - # New in Ruby 3.2 upgrade # Added to Rubocop Todo and handling from there diff --git a/app/api/model_extensions/order.rb b/app/api/model_extensions/order.rb index 7214664bf1..dfd6299b71 100644 --- a/app/api/model_extensions/order.rb +++ b/app/api/model_extensions/order.rb @@ -71,8 +71,7 @@ def <<(associated) end end - scope :that_submitted_asset_id, - ->(asset_id) { where(submitted_assets: { asset_id: }).joins(:submitted_assets) } + scope :that_submitted_asset_id, ->(asset_id) { where(submitted_assets: { asset_id: }).joins(:submitted_assets) } validate :extended_validation def extended_validation diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 008a8f882a..0aed9f9530 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -247,13 +247,7 @@ def tab_pane(name, id: nil, tab_id: nil, active: false, &) tab_id ||= "#{name}-tab".parameterize id ||= name.parameterize active_class = active ? 'active' : '' - tag.div( - class: ['tab-pane', 'fade', 'show', active_class], - id:, - role: 'tabpanel', - aria_labelledby: tab_id, - & - ) + tag.div(class: ['tab-pane', 'fade', 'show', active_class], id:, role: 'tabpanel', aria_labelledby: tab_id, &) end def display_boolean_results(result) diff --git a/app/helpers/compound_sample_helper.rb b/app/helpers/compound_sample_helper.rb index bea665f86e..99095f780c 100644 --- a/app/helpers/compound_sample_helper.rb +++ b/app/helpers/compound_sample_helper.rb @@ -22,9 +22,6 @@ def find_compound_sample_for_component_samples(component_samples) # Generates the compound sample def create_compound_sample(study, component_samples) - study.samples.create!( - name: SangerSampleId.generate_sanger_sample_id!(study.abbreviation), - component_samples: - ) + study.samples.create!(name: SangerSampleId.generate_sanger_sample_id!(study.abbreviation), component_samples:) end end diff --git a/app/helpers/submissions_helper.rb b/app/helpers/submissions_helper.rb index 203f8786c9..8eac8eb73d 100644 --- a/app/helpers/submissions_helper.rb +++ b/app/helpers/submissions_helper.rb @@ -38,15 +38,7 @@ def studies_select(form, studies) # rubocop:todo Metrics/MethodLength 'Please select a Study for this Submission...' end - form.collection_select( - :study_id, - studies, - :id, - :name, - { prompt: }, - disabled: true, - class: 'study_id custom-select' - ) + form.collection_select(:study_id, studies, :id, :name, { prompt: }, disabled: true, class: 'study_id custom-select') end def projects_select(form, projects) # rubocop:todo Metrics/MethodLength diff --git a/app/heron/factories/tube_rack_status.rb b/app/heron/factories/tube_rack_status.rb index 755f985dce..e70edd093a 100644 --- a/app/heron/factories/tube_rack_status.rb +++ b/app/heron/factories/tube_rack_status.rb @@ -15,9 +15,7 @@ class TubeRackStatus def save return false unless valid? - ActiveRecord::Base.transaction do - @tube_rack_status = ::TubeRackStatus.create!(barcode:, status:, messages:) - end + ActiveRecord::Base.transaction { @tube_rack_status = ::TubeRackStatus.create!(barcode:, status:, messages:) } true end diff --git a/app/models/add_spiked_in_control_task.rb b/app/models/add_spiked_in_control_task.rb index 34c5735100..27531a7fc8 100644 --- a/app/models/add_spiked_in_control_task.rb +++ b/app/models/add_spiked_in_control_task.rb @@ -30,12 +30,7 @@ def can_process?(batch) end def do_task(workflows_controller, params, user) - Tasks::AddSpikedInControlHandler::Handler.new( - controller: workflows_controller, - params:, - task: self, - user: - ).perform + Tasks::AddSpikedInControlHandler::Handler.new(controller: workflows_controller, params:, task: self, user:).perform end def fields_for(requests) diff --git a/app/models/aliquot.rb b/app/models/aliquot.rb index a9c9ea889b..adec8d3a57 100644 --- a/app/models/aliquot.rb +++ b/app/models/aliquot.rb @@ -115,11 +115,7 @@ def aliquot_index_value end def created_with_request_options - { - fragment_size_required_from: insert_size_from, - fragment_size_required_to: insert_size_to, - library_type: - } + { fragment_size_required_from: insert_size_from, fragment_size_required_to: insert_size_to, library_type: } end # Validating the uniqueness of tags in rails was causing issues, as it was resulting the in the diff --git a/app/models/attributable/association.rb b/app/models/attributable/association.rb index 9974444d2f..7404f97c9f 100644 --- a/app/models/attributable/association.rb +++ b/app/models/attributable/association.rb @@ -71,12 +71,7 @@ def selection_options(_) end def to_field_info(*_args) - FieldInfo.new( - display_name:, - key: assignable_attribute_name, - kind:, - selection: selection_options(nil) - ) + FieldInfo.new(display_name:, key: assignable_attribute_name, kind:, selection: selection_options(nil)) end def configure(target) # rubocop:todo Metrics/MethodLength diff --git a/app/models/broadcast_event/qc_assay.rb b/app/models/broadcast_event/qc_assay.rb index 49413f3128..edb0b119f5 100644 --- a/app/models/broadcast_event/qc_assay.rb +++ b/app/models/broadcast_event/qc_assay.rb @@ -13,9 +13,7 @@ def self.generate_events(qc_assay) .qc_results .distinct .pluck(:assay_type, :assay_version) - .map do |assay_type, assay_version| - create!(seed: qc_assay, properties: { assay_type:, assay_version: }) - end + .map { |assay_type, assay_version| create!(seed: qc_assay, properties: { assay_type:, assay_version: }) } end has_subjects(:sample) { |_qc_assay, event| event.samples } diff --git a/app/models/bulk_transfer.rb b/app/models/bulk_transfer.rb index 08b075259b..f2c93a50c5 100644 --- a/app/models/bulk_transfer.rb +++ b/app/models/bulk_transfer.rb @@ -42,13 +42,7 @@ class BulkTransfer < ApplicationRecord def build_transfers! ActiveRecord::Base.transaction do each_transfer do |source, destination, transfers| - Transfer::BetweenPlates.create!( - source:, - destination:, - user:, - transfers:, - bulk_transfer_id: id - ) + Transfer::BetweenPlates.create!(source:, destination:, user:, transfers:, bulk_transfer_id: id) end end end diff --git a/app/models/cherrypick_task.rb b/app/models/cherrypick_task.rb index 1e5375cddb..7fb4b9ce50 100644 --- a/app/models/cherrypick_task.rb +++ b/app/models/cherrypick_task.rb @@ -22,12 +22,7 @@ class CherrypickTask < Task # rubocop:todo Metrics/ClassLength # @return [CherrypickTask::ControlLocator] A generator of control locations # def new_control_locator(batch_id, total_wells, num_control_wells, wells_to_leave_free: DEFAULT_WELLS_TO_LEAVE_FREE) - CherrypickTask::ControlLocator.new( - batch_id:, - total_wells:, - num_control_wells:, - wells_to_leave_free: - ) + CherrypickTask::ControlLocator.new(batch_id:, total_wells:, num_control_wells:, wells_to_leave_free:) end # diff --git a/app/models/event/sample_logistics_qc_event.rb b/app/models/event/sample_logistics_qc_event.rb index 8c7daa49a4..045f50481f 100644 --- a/app/models/event/sample_logistics_qc_event.rb +++ b/app/models/event/sample_logistics_qc_event.rb @@ -10,12 +10,6 @@ def self.create_gel_qc_for_asset!(asset, result, user) end def self.gel_qc_message(asset, message, family, user) - create!( - eventful: asset, - message:, - content: Date.today.to_s, - family:, - created_by: user ? user.login : nil - ) + create!(eventful: asset, message:, content: Date.today.to_s, family:, created_by: user ? user.login : nil) end end diff --git a/app/models/labwhere_reception.rb b/app/models/labwhere_reception.rb index d2567f517e..7470b5cf3b 100644 --- a/app/models/labwhere_reception.rb +++ b/app/models/labwhere_reception.rb @@ -47,12 +47,7 @@ def save # rubocop:todo Metrics/AbcSize return false unless valid? begin - scan = - LabWhereClient::Scan.create( - location_barcode:, - user_code:, - labware_barcodes: asset_barcodes - ) + scan = LabWhereClient::Scan.create(location_barcode:, user_code:, labware_barcodes: asset_barcodes) unless scan.valid? # Prepend the errors with 'Labwhere' to make it clear where the error came from @@ -69,13 +64,7 @@ def save # rubocop:todo Metrics/AbcSize assets.each do |asset| asset.events.create_scanned_into_lab!(location_barcode, user.login) - BroadcastEvent::LabwareReceived.create!( - seed: asset, - user:, - properties: { - location_barcode: - } - ) + BroadcastEvent::LabwareReceived.create!(seed: asset, user:, properties: { location_barcode: }) end valid? diff --git a/app/models/library_creation_request.rb b/app/models/library_creation_request.rb index 57faf4e65e..5c7eb85c9b 100644 --- a/app/models/library_creation_request.rb +++ b/app/models/library_creation_request.rb @@ -43,12 +43,6 @@ def on_started # @return [Hash] A hash of aliquot attributes # def aliquot_attributes - { - study_id: initial_study_id, - project_id: initial_project_id, - library_type:, - insert_size:, - request_id: id - } + { study_id: initial_study_id, project_id: initial_project_id, library_type:, insert_size:, request_id: id } end end diff --git a/app/models/location_report.rb b/app/models/location_report.rb index ab725c1d14..95c2e7c522 100644 --- a/app/models/location_report.rb +++ b/app/models/location_report.rb @@ -176,14 +176,7 @@ def generate_study_cols_for_row(cur_study) end def search_for_plates_by_selection - params = { - faculty_sponsor_ids:, - study_id:, - start_date:, - end_date:, - plate_purpose_ids:, - barcodes: - } + params = { faculty_sponsor_ids:, study_id:, start_date:, end_date:, plate_purpose_ids:, barcodes: } Plate.search_for_plates(params) end diff --git a/app/models/phi_x/stock.rb b/app/models/phi_x/stock.rb index 67c7e68c36..b826157cf7 100644 --- a/app/models/phi_x/stock.rb +++ b/app/models/phi_x/stock.rb @@ -62,13 +62,7 @@ def generate_stocks # rubocop:todo Metrics/AbcSize .stock_purpose .create!(name: "#{name} ##{index + 1}") do |tube| tube.receptacle.qc_results.build(key: 'molarity', value: concentration, units: 'nM') - tube.receptacle.aliquots.build( - sample: phi_x_sample, - tag: i7_tag, - tag2: i5_tag, - library: tube, - study_id: - ) + tube.receptacle.aliquots.build(sample: phi_x_sample, tag: i7_tag, tag2: i5_tag, library: tube, study_id:) end end end diff --git a/app/models/pick_list.rb b/app/models/pick_list.rb index d5a4b5656e..48cb4f8e10 100644 --- a/app/models/pick_list.rb +++ b/app/models/pick_list.rb @@ -44,9 +44,7 @@ def pick_attributes=(picks) def pick_attributes orders.flat_map do |order| - order.assets.map do |source_receptacle| - { source_receptacle:, study: order.study, project: order.project } - end + order.assets.map { |source_receptacle| { source_receptacle:, study: order.study, project: order.project } } end end diff --git a/app/models/plate/quad_creator.rb b/app/models/plate/quad_creator.rb index e262039845..615960c18a 100644 --- a/app/models/plate/quad_creator.rb +++ b/app/models/plate/quad_creator.rb @@ -71,8 +71,7 @@ def creation end def transfer_request_collection - @transfer_request_collection ||= - TransferRequestCollection.new(user:, transfer_requests_attributes:) + @transfer_request_collection ||= TransferRequestCollection.new(user:, transfer_requests_attributes:) end def transfer_requests_attributes diff --git a/app/models/plate/sample_tube_factory.rb b/app/models/plate/sample_tube_factory.rb index 1d391a6742..57ff2afeb1 100644 --- a/app/models/plate/sample_tube_factory.rb +++ b/app/models/plate/sample_tube_factory.rb @@ -14,8 +14,7 @@ def create_child_sample_tube(well) def create_sample_tubes_and_print_barcodes(barcode_printer) sample_tubes = create_sample_tubes - print_job = - LabelPrinter::PrintJob.new(barcode_printer.name, LabelPrinter::Label::PlateToTubes, sample_tubes:) + print_job = LabelPrinter::PrintJob.new(barcode_printer.name, LabelPrinter::Label::PlateToTubes, sample_tubes:) print_job.execute sample_tubes diff --git a/app/models/pooling.rb b/app/models/pooling.rb index 13d8cdebe3..d4351bc351 100644 --- a/app/models/pooling.rb +++ b/app/models/pooling.rb @@ -68,12 +68,7 @@ def print_job_required? def print_job @print_job ||= - LabelPrinter::PrintJob.new( - barcode_printer, - LabelPrinter::Label::MultiplexedTube, - assets: target_assets, - count: - ) + LabelPrinter::PrintJob.new(barcode_printer, LabelPrinter::Label::MultiplexedTube, assets: target_assets, count:) end def message diff --git a/app/models/qc_report.rb b/app/models/qc_report.rb index 5585535723..4e15876b3b 100644 --- a/app/models/qc_report.rb +++ b/app/models/qc_report.rb @@ -99,12 +99,7 @@ def generate_report # rubocop:todo Metrics/AbcSize ActiveRecord::Base.transaction do assets.each do |asset| criteria = product_criteria.assess(asset, connected_wells[asset.id]) - QcMetric.create!( - asset:, - qc_decision: criteria.qc_decision, - metrics: criteria.metrics, - qc_report: self - ) + QcMetric.create!(asset:, qc_decision: criteria.qc_decision, metrics: criteria.metrics, qc_report: self) end end end diff --git a/app/models/qc_result_factory.rb b/app/models/qc_result_factory.rb index d2624947f4..fe5237c59e 100644 --- a/app/models/qc_result_factory.rb +++ b/app/models/qc_result_factory.rb @@ -59,17 +59,7 @@ def initialize(attributes = {}) super(attributes) @asset = build_asset - @qc_result = - QcResult.new( - asset:, - key:, - value:, - units:, - cv:, - assay_type:, - assay_version:, - qc_assay: - ) + @qc_result = QcResult.new(asset:, key:, value:, units:, cv:, assay_type:, assay_version:, qc_assay:) end def message_id diff --git a/app/models/request/library_creation.rb b/app/models/request/library_creation.rb index c63c8473da..cda3e0f283 100644 --- a/app/models/request/library_creation.rb +++ b/app/models/request/library_creation.rb @@ -63,13 +63,7 @@ def fragment_size_required_to # @return [Hash] A hash of aliquot attributes # def aliquot_attributes - { - study_id: initial_study_id, - project_id: initial_project_id, - library_type:, - insert_size:, - request_id: id - } + { study_id: initial_study_id, project_id: initial_project_id, library_type:, insert_size:, request_id: id } end include Request::CustomerResponsibility diff --git a/app/models/sample_manifest/shared_tube_behaviour.rb b/app/models/sample_manifest/shared_tube_behaviour.rb index 56443dd002..2f13c1f0f3 100644 --- a/app/models/sample_manifest/shared_tube_behaviour.rb +++ b/app/models/sample_manifest/shared_tube_behaviour.rb @@ -26,11 +26,7 @@ def generate_tubes(tube_purpose, number_of_tubes = count) # rubocop:todo Metrics Array.new(number_of_tubes) do tube = tube_purpose.create! sanger_sample_id = SangerSampleId.generate_sanger_sample_id!(study_abbreviation, sanger_ids.shift) - SampleManifestAsset.create!( - sanger_sample_id:, - asset: tube.receptacle, - sample_manifest: @manifest - ) + SampleManifestAsset.create!(sanger_sample_id:, asset: tube.receptacle, sample_manifest: @manifest) tube end diff --git a/app/models/sample_manifest/uploader.rb b/app/models/sample_manifest/uploader.rb index fadb3ba3b7..2f3db1df36 100644 --- a/app/models/sample_manifest/uploader.rb +++ b/app/models/sample_manifest/uploader.rb @@ -23,8 +23,7 @@ def initialize(file, configuration, user, override) @user = user @override = override @tag_group = create_tag_group - @upload = - SampleManifestExcel::Upload::Base.new(file:, column_list: self.configuration.columns.all, override:) + @upload = SampleManifestExcel::Upload::Base.new(file:, column_list: self.configuration.columns.all, override:) end def run! diff --git a/app/models/set_descriptors_task.rb b/app/models/set_descriptors_task.rb index 7eb585aacf..6c14aa6397 100644 --- a/app/models/set_descriptors_task.rb +++ b/app/models/set_descriptors_task.rb @@ -17,21 +17,11 @@ def can_process?(batch) end def render_task(workflows_controller, params, user) - Tasks::SetDescriptorsHandler::Handler.new( - controller: workflows_controller, - params:, - task: self, - user: - ).render + Tasks::SetDescriptorsHandler::Handler.new(controller: workflows_controller, params:, task: self, user:).render end def do_task(workflows_controller, params, user) - Tasks::SetDescriptorsHandler::Handler.new( - controller: workflows_controller, - params:, - task: self, - user: - ).perform + Tasks::SetDescriptorsHandler::Handler.new(controller: workflows_controller, params:, task: self, user:).perform end # diff --git a/app/models/state_changer/mx_tube.rb b/app/models/state_changer/mx_tube.rb index 5fb6b44da6..9600afc584 100644 --- a/app/models/state_changer/mx_tube.rb +++ b/app/models/state_changer/mx_tube.rb @@ -13,9 +13,7 @@ def associated_requests end def generate_events_for(orders) - orders.each do |order_id| - BroadcastEvent::PoolReleased.create!(seed: labware, user:, properties: { order_id: }) - end + orders.each { |order_id| BroadcastEvent::PoolReleased.create!(seed: labware, user:, properties: { order_id: }) } end def transfer_requests diff --git a/app/models/state_changer/standard_plate.rb b/app/models/state_changer/standard_plate.rb index 6d1ea1069b..467216c1bd 100644 --- a/app/models/state_changer/standard_plate.rb +++ b/app/models/state_changer/standard_plate.rb @@ -43,9 +43,7 @@ def pending_orders end def generate_events_for(orders) - orders.each do |order_id| - BroadcastEvent::LibraryStart.create!(seed: labware, user:, properties: { order_id: }) - end + orders.each { |order_id| BroadcastEvent::LibraryStart.create!(seed: labware, user:, properties: { order_id: }) } end def update_transfer_requests diff --git a/app/models/tag_layout_template.rb b/app/models/tag_layout_template.rb index 6fc2343458..ebc2011800 100644 --- a/app/models/tag_layout_template.rb +++ b/app/models/tag_layout_template.rb @@ -54,21 +54,12 @@ def walking_algorithm_class end def tag_layout_attributes - { - tag_group:, - tag2_group:, - direction_algorithm:, - walking_algorithm: - } + { tag_group:, tag2_group:, direction_algorithm:, walking_algorithm: } end def record_template_use(plate, enforce_uniqueness) plate.submissions.each do |submission| - TagLayout::TemplateSubmission.create!( - submission:, - tag_layout_template: self, - enforce_uniqueness: - ) + TagLayout::TemplateSubmission.create!(submission:, tag_layout_template: self, enforce_uniqueness:) end end end diff --git a/app/models/tasks/set_descriptors_handler.rb b/app/models/tasks/set_descriptors_handler.rb index 5b46b95156..1dce3cf6d5 100644 --- a/app/models/tasks/set_descriptors_handler.rb +++ b/app/models/tasks/set_descriptors_handler.rb @@ -32,13 +32,7 @@ def params end def process_request(request) - LabEvent.create!( - batch:, - description: @task.name, - descriptors: descriptors(request), - user:, - eventful: request - ) + LabEvent.create!(batch:, description: @task.name, descriptors: descriptors(request), user:, eventful: request) # Some receptacles are flagged as 'resource'. There are 43 of these in the production database, # all are from 2009 - 2010. diff --git a/app/sample_manifest_excel/sample_manifest_excel/download.rb b/app/sample_manifest_excel/sample_manifest_excel/download.rb index c0a75b28b1..b50b059809 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/download.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/download.rb @@ -18,16 +18,9 @@ def initialize(sample_manifest, column_list, range_list) return unless valid? - @ranges_worksheet = - SequencescapeExcel::Worksheet::RangesWorksheet.new(ranges: range_list, workbook:, password:) + @ranges_worksheet = SequencescapeExcel::Worksheet::RangesWorksheet.new(ranges: range_list, workbook:, password:) @data_worksheet = - Worksheet::DataWorksheet.new( - workbook:, - columns: column_list, - sample_manifest:, - ranges: range_list, - password: - ) + Worksheet::DataWorksheet.new(workbook:, columns: column_list, sample_manifest:, ranges: range_list, password:) end def password diff --git a/app/sequencescape_excel/sequencescape_excel/formula.rb b/app/sequencescape_excel/sequencescape_excel/formula.rb index 4cd48ffd15..be249aee3b 100644 --- a/app/sequencescape_excel/sequencescape_excel/formula.rb +++ b/app/sequencescape_excel/sequencescape_excel/formula.rb @@ -53,13 +53,7 @@ def to_s end def to_h - { - type:, - first_cell_reference:, - absolute_reference:, - operator:, - operand: - } + { type:, first_cell_reference:, absolute_reference:, operator:, operand: } end def inspect diff --git a/app/sequencescape_excel/sequencescape_excel/range.rb b/app/sequencescape_excel/sequencescape_excel/range.rb index 46a56ec5ff..601316b50e 100644 --- a/app/sequencescape_excel/sequencescape_excel/range.rb +++ b/app/sequencescape_excel/sequencescape_excel/range.rb @@ -136,12 +136,7 @@ def static? # Return a list of references which are generally used together in other # classes of the module. def references - { - first_cell_reference:, - reference:, - fixed_reference:, - absolute_reference: - } + { first_cell_reference:, reference:, fixed_reference:, absolute_reference: } end private diff --git a/app/uat_actions/uat_actions/generate_tagged_plates.rb b/app/uat_actions/uat_actions/generate_tagged_plates.rb index e38784ca50..07bda90818 100644 --- a/app/uat_actions/uat_actions/generate_tagged_plates.rb +++ b/app/uat_actions/uat_actions/generate_tagged_plates.rb @@ -70,16 +70,7 @@ def self.default end def perform - super do |plate| - TagLayout.create!( - user:, - plate:, - direction:, - walking_by:, - tag_group:, - tag2_group: - ) - end + super { |plate| TagLayout.create!(user:, plate:, direction:, walking_by:, tag_group:, tag2_group:) } end private diff --git a/db/seeds/0001_tube_purposes.rb b/db/seeds/0001_tube_purposes.rb index 4fd87963e0..f9ec941a4c 100644 --- a/db/seeds/0001_tube_purposes.rb +++ b/db/seeds/0001_tube_purposes.rb @@ -10,7 +10,5 @@ 'Stock MX' => %w[Tube::StockMx StockMultiplexedLibraryTube], 'Stock library' => %w[Tube::Purpose StockLibraryTube], 'Legacy MX tube' => %w[IlluminaHtp::MxTubePurpose MultiplexedLibraryTube] - }.each do |name, (type, asset_type)| - type.constantize.create!(name:, barcode_printer_type:, target_type: asset_type) - end + }.each { |name, (type, asset_type)| type.constantize.create!(name:, barcode_printer_type:, target_type: asset_type) } end diff --git a/db/seeds/0001_workflows.rb b/db/seeds/0001_workflows.rb index fc092c1522..731e891c0f 100644 --- a/db/seeds/0001_workflows.rb +++ b/db/seeds/0001_workflows.rb @@ -1478,10 +1478,6 @@ def add_4000_information_types_to(pipeline) ] if read_lengths.present? - RequestType::Validator.create!( - request_type:, - request_option: 'read_length', - valid_options: read_lengths - ) + RequestType::Validator.create!(request_type:, request_option: 'read_length', valid_options: read_lengths) end end diff --git a/db/seeds/3000_library_types_setup.rb b/db/seeds/3000_library_types_setup.rb index d308724714..b88e633444 100644 --- a/db/seeds/3000_library_types_setup.rb +++ b/db/seeds/3000_library_types_setup.rb @@ -198,11 +198,7 @@ def self.existing_defaults_for(request_type) ] if read_lengths.present? - RequestType::Validator.create!( - request_type:, - request_option: 'read_length', - valid_options: read_lengths - ) + RequestType::Validator.create!(request_type:, request_option: 'read_length', valid_options: read_lengths) end end @@ -233,9 +229,7 @@ def self.existing_defaults_for(request_type) %i[illumina_c_multiplexed_library_creation illumina_c_library_creation].each do |request_class_symbol| request_type = RequestType.find_by!(key: request_class_symbol.to_s) - library_types.each do |library_type| - LibraryTypesRequestType.create!(request_type:, library_type:, is_default: false) - end + library_types.each { |library_type| LibraryTypesRequestType.create!(request_type:, library_type:, is_default: false) } end libs_ribozero = diff --git a/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb b/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb index cee9022934..701695b60a 100644 --- a/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb +++ b/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb @@ -6,12 +6,7 @@ library_tube = FactoryBot.create :empty_library_tube request_type = RequestType.find_by(name: 'Illumina-B Paired end sequencing') request = - FactoryBot.create(:request, - asset: library_tube, - target_asset: lane, - state: 'pending', - project:, - request_type:) + FactoryBot.create(:request, asset: library_tube, target_asset: lane, state: 'pending', project:, request_type:) project.update!(enforce_quotas: true) end diff --git a/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb b/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb index 17a3d02fa0..df3a12070c 100644 --- a/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb +++ b/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb @@ -5,12 +5,5 @@ project = FactoryBot.create(:project) request_type = RequestType.find_by(key: 'library_creation') request = - FactoryBot.create( - :request, - id: request_id, - study:, - project:, - request_type:, - asset: FactoryBot.create(:sample_tube) - ) + FactoryBot.create(:request, id: request_id, study:, project:, request_type:, asset: FactoryBot.create(:sample_tube)) end diff --git a/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb b/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb index 5cec2259fc..e0e2f39994 100644 --- a/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb +++ b/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb @@ -7,13 +7,7 @@ def create_request(request_type, study, project, asset, target_asset, additional request = FactoryBot.create( :request_with_submission, - additional_options.merge( - study:, - project:, - asset:, - target_asset:, - request_type: - ) + additional_options.merge(study:, project:, asset:, target_asset:, request_type:) ) request.id = additional_options[:id] if additional_options.key?(:id) # Force ID hack! diff --git a/features/support/step_definitions/65192392_tag_qc_steps.rb b/features/support/step_definitions/65192392_tag_qc_steps.rb index 7c50c5999e..6c7a6d469f 100644 --- a/features/support/step_definitions/65192392_tag_qc_steps.rb +++ b/features/support/step_definitions/65192392_tag_qc_steps.rb @@ -111,16 +111,8 @@ reporter_plate = qcb.qcables.first.asset tag_plate.update!(plate_purpose: PlatePurpose.find_by(name: 'Tag PCR')) - Transfer::BetweenPlates.create!( - user:, - source: reporter_plate, - destination: tag_plate, - transfers: { - 'A1' => 'A1' - } - ) - stc = - SpecificTubeCreation.create!(parent: tag_plate, child_purposes: [Tube::Purpose.find_by(name: 'Tag MX')], user:) + Transfer::BetweenPlates.create!(user:, source: reporter_plate, destination: tag_plate, transfers: { 'A1' => 'A1' }) + stc = SpecificTubeCreation.create!(parent: tag_plate, child_purposes: [Tube::Purpose.find_by(name: 'Tag MX')], user:) batch = Batch .new(pipeline: Pipeline.find_by(name: 'MiSeq sequencing')) diff --git a/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb b/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb index 374b5b986e..178e658ef5 100644 --- a/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb +++ b/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb @@ -38,8 +38,7 @@ Given(/^I have a plate "([^"]*)" with the following wells:$/) do |plate_barcode, well_details| plate = FactoryBot.create :plate, barcode: plate_barcode well_details.hashes.each do |well_detail| - well = - Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate:) + well = Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate:) well.well_attribute.update!( concentration: well_detail[:measured_concentration], measured_volume: well_detail[:measured_volume] diff --git a/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb b/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb index b6c03e0327..a40295ce45 100644 --- a/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb +++ b/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb @@ -6,8 +6,7 @@ request_type = pipeline.request_types.detect { |rt| !rt.deprecated } metadata = FactoryBot.create :"request_metadata_for_#{request_type.key}" asset = FactoryBot.create(asset_type) - request = - FactoryBot.create :request_with_submission, request_type:, asset:, request_metadata: metadata + request = FactoryBot.create :request_with_submission, request_type:, asset:, request_metadata: metadata request.asset.plate = FactoryBot.create(:plate) if request.asset.plate.nil? if request.asset.is_a?(Well) request.asset.save! diff --git a/features/support/step_definitions/genotyping_steps.rb b/features/support/step_definitions/genotyping_steps.rb index 95020b45f7..6e30ec746c 100644 --- a/features/support/step_definitions/genotyping_steps.rb +++ b/features/support/step_definitions/genotyping_steps.rb @@ -32,10 +32,7 @@ FactoryBot .create(:well, plate:, map_id: index) .tap do |well| - well.aliquots.create!( - sample: FactoryBot.create(:sample, name: "Sample_#{plate_barcode}_#{index}"), - study: - ) + well.aliquots.create!(sample: FactoryBot.create(:sample, name: "Sample_#{plate_barcode}_#{index}"), study:) end end end @@ -112,13 +109,7 @@ asset_group = AssetGroup.find_by(name: asset_group_name) submission_template = SubmissionTemplate.find_by(name: 'Cherrypick') - order = - submission_template.create_with_submission!( - study:, - project:, - user: User.last, - assets: asset_group.assets - ) + order = submission_template.create_with_submission!(study:, project:, user: User.last, assets: asset_group.assets) order.submission.built! step('1 pending delayed jobs are processed') end diff --git a/features/support/step_definitions/order_steps.rb b/features/support/step_definitions/order_steps.rb index 814471d6af..2c2edf30c5 100644 --- a/features/support/step_definitions/order_steps.rb +++ b/features/support/step_definitions/order_steps.rb @@ -5,8 +5,7 @@ end Given /^I have an order created with the following details based on the template "([^"]+)":$/ do |name, details| - template = SubmissionTemplate.find_by(name:) or - raise StandardError, "Cannot find submission template #{name.inspect}" + template = SubmissionTemplate.find_by(name:) or raise StandardError, "Cannot find submission template #{name.inspect}" order_attributes = details.rows_hash.map do |k, v| v = diff --git a/features/support/step_definitions/plate_steps.rb b/features/support/step_definitions/plate_steps.rb index fb9413dae9..42f0ad14df 100644 --- a/features/support/step_definitions/plate_steps.rb +++ b/features/support/step_definitions/plate_steps.rb @@ -38,8 +38,7 @@ if machine_barcode.start_with?('SQPD') FactoryBot.create :plate, sanger_barcode: Barcode.build_sequencescape22({ barcode: machine_barcode }) else - FactoryBot.create :plate, - sanger_barcode: Barcode.build_sanger_code39({ machine_barcode:, format: 'DN' }) + FactoryBot.create :plate, sanger_barcode: Barcode.build_sanger_code39({ machine_barcode:, format: 'DN' }) end end @@ -133,14 +132,7 @@ /^a full plate called "([^"]*)" exists with purpose "([^"]*)" and barcode "([^"]*)"$/ ) do |name, purpose_name, barcode| purpose = Purpose.find_by(name: purpose_name) || FactoryBot.create(:plate_purpose, name: purpose_name) - FactoryBot.create( - :full_plate, - well_factory: :untagged_well, - name:, - purpose:, - barcode:, - well_count: 16 - ) + FactoryBot.create(:full_plate, well_factory: :untagged_well, name:, purpose:, barcode:, well_count: 16) end Given /^a "([^"]+)" plate called "([^"]+)" exists with barcode "([^"]+)"$/ do |name, plate_name, barcode| @@ -213,8 +205,7 @@ # plate = FactoryBot.create :plate, :barcode => plate_barcode plate = Uuid.find_by(external_id: uuid).resource well_details.hashes.each do |well_detail| - well = - Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate:) + well = Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate:) well.well_attribute.update!( concentration: well_detail[:measured_concentration], measured_volume: well_detail[:measured_volume] diff --git a/features/support/step_definitions/sample_manifest_steps.rb b/features/support/step_definitions/sample_manifest_steps.rb index 425797c4af..66ef3ce5e3 100644 --- a/features/support/step_definitions/sample_manifest_steps.rb +++ b/features/support/step_definitions/sample_manifest_steps.rb @@ -121,8 +121,7 @@ def instance.next! Then /^the sample reference genomes should be:$/ do |table| table.hashes.each do |expected_data| sanger_sample_id = expected_data[:sanger_sample_id] - sample = Sample.find_by(sanger_sample_id:) or - raise StandardError, "Could not find sample #{sanger_sample_id}" + sample = Sample.find_by(sanger_sample_id:) or raise StandardError, "Could not find sample #{sanger_sample_id}" assert_equal(expected_data[:reference_genome], sample.sample_metadata.reference_genome.name) end end @@ -171,8 +170,7 @@ def instance.next! Given /^a manifest has been created for "([^"]*)"$/ do |study_name| study = Study.find_by!(name: study_name) supplier = Supplier.find_by!(name: 'Test supplier name') - sample_manifest = - FactoryBot.create :sample_manifest, study:, supplier:, user: User.find_by(first_name: 'john') + sample_manifest = FactoryBot.create :sample_manifest, study:, supplier:, user: User.find_by(first_name: 'john') sample_manifest.generate Delayed::Worker.new.work_off visit(url_for(sample_manifest)) diff --git a/features/support/step_definitions/submission_steps.rb b/features/support/step_definitions/submission_steps.rb index e55202d686..95fb6ed354 100644 --- a/features/support/step_definitions/submission_steps.rb +++ b/features/support/step_definitions/submission_steps.rb @@ -94,9 +94,7 @@ def submission_in_state(state, attributes = {}) study = Study.first or raise StandardError, 'There are no studies!' submission = - FactoryHelp.submission( - { asset_group_name: 'Faked to prevent empty asset errors' }.merge(attributes).merge(study:) - ) + FactoryHelp.submission({ asset_group_name: 'Faked to prevent empty asset errors' }.merge(attributes).merge(study:)) submission.state = state submission.save(validate: false) end diff --git a/features/support/step_definitions/tag_layout_steps.rb b/features/support/step_definitions/tag_layout_steps.rb index f0be615cf6..2b6df54a99 100644 --- a/features/support/step_definitions/tag_layout_steps.rb +++ b/features/support/step_definitions/tag_layout_steps.rb @@ -127,10 +127,7 @@ def pool_by_strategy(source, destination, pooling_strategy) # rubocop:todo Metri .zip(wells_for_destination) .each do |w| TransferRequest.create!(asset: w.first, target_asset: w.last, submission_id:) - FactoryBot.create :request_without_submission, - asset: w.first, - target_asset: w.last, - submission_id: + FactoryBot.create :request_without_submission, asset: w.first, target_asset: w.last, submission_id: end end end diff --git a/features/support/step_definitions/uuid_steps.rb b/features/support/step_definitions/uuid_steps.rb index 5aa850b2f7..0c5922b675 100644 --- a/features/support/step_definitions/uuid_steps.rb +++ b/features/support/step_definitions/uuid_steps.rb @@ -57,8 +57,7 @@ def set_uuid_for(object, uuid_value) # rubocop:todo Layout/LineLength Given /^the UUID for the (#{SINGULAR_MODELS_BASED_ON_NAME_REGEXP}) "([^"]+)" is "([^"]+)"$/o do |model, name, uuid_value| # rubocop:enable Layout/LineLength - object = model.gsub(/\s+/, '_').classify.constantize.find_by(name:) or - raise "Cannot find #{model} #{name.inspect}" + object = model.gsub(/\s+/, '_').classify.constantize.find_by(name:) or raise "Cannot find #{model} #{name.inspect}" set_uuid_for(object, uuid_value) end @@ -67,8 +66,7 @@ def set_uuid_for(object, uuid_value) # rubocop:todo Layout/LineLength Given /^the UUID for the receptacle in (#{SINGULAR_MODELS_BASED_ON_NAME_REGEXP}) "([^"]+)" is "([^"]+)"$/o do |model, name, uuid_value| # rubocop:enable Layout/LineLength - object = model.gsub(/\s+/, '_').classify.constantize.find_by(name:) or - raise "Cannot find #{model} #{name.inspect}" + object = model.gsub(/\s+/, '_').classify.constantize.find_by(name:) or raise "Cannot find #{model} #{name.inspect}" set_uuid_for(object.receptacle, uuid_value) end diff --git a/lib/label_printer/label_printer/print_job.rb b/lib/label_printer/label_printer/print_job.rb index 6e6d873306..85e5215496 100644 --- a/lib/label_printer/label_printer/print_job.rb +++ b/lib/label_printer/label_printer/print_job.rb @@ -31,11 +31,7 @@ def execute # rubocop:todo Metrics/MethodLength end def build_attributes - @build_attributes ||= { - printer_name:, - label_template_name:, - labels: labels_attribute - } + @build_attributes ||= { printer_name:, label_template_name:, labels: labels_attribute } end # returns: a list of labels diff --git a/lib/record_loader/pipeline_request_information_type_loader.rb b/lib/record_loader/pipeline_request_information_type_loader.rb index c5dee02e29..ed6deee940 100644 --- a/lib/record_loader/pipeline_request_information_type_loader.rb +++ b/lib/record_loader/pipeline_request_information_type_loader.rb @@ -13,10 +13,10 @@ class PipelineRequestInformationTypeLoader < ApplicationRecordLoader def create_or_update!(_name, options) pipeline = Pipeline.find_by!(name: options['pipeline_name']) req_inf_type = RequestInformationType.find_by!(key: options['request_information_type_key']) - PipelineRequestInformationType.create_with( + PipelineRequestInformationType.create_with(pipeline:, request_information_type: req_inf_type).find_or_create_by!( pipeline:, request_information_type: req_inf_type - ).find_or_create_by!(pipeline:, request_information_type: req_inf_type) + ) end end end diff --git a/lib/tasks/benchmark_plate_transfer.rake b/lib/tasks/benchmark_plate_transfer.rake index e5217c6cdb..12c68ae99f 100644 --- a/lib/tasks/benchmark_plate_transfer.rake +++ b/lib/tasks/benchmark_plate_transfer.rake @@ -4,9 +4,7 @@ namespace :benchmark do $stdout.puts 'Preparing' stock = Purpose.find_by(name: 'Shear').create! sample = Sample.find_or_create_by(name: 'test_sample') - stock.wells.each do |w| - w.aliquots.create!(sample:, study_id: Study.find_or_create_by(name: 'test_study').id) - end + stock.wells.each { |w| w.aliquots.create!(sample:, study_id: Study.find_or_create_by(name: 'test_study').id) } user = User.find_or_create_by(login: 'test_user') targets = [] diff --git a/lib/tasks/limber.rake b/lib/tasks/limber.rake index a4b4ebf96c..fb0dabac6f 100644 --- a/lib/tasks/limber.rake +++ b/lib/tasks/limber.rake @@ -141,11 +141,7 @@ namespace :limber do catalogue_name = (params[:catalogue_name] || prefix) catalogue = ProductCatalogue.create_with(selection_behaviour: 'SingleProduct').find_or_create_by!(name: catalogue_name) - Limber::Helper::TemplateConstructor.new( - prefix:, - catalogue:, - sequencing_keys: params[:sequencing_list] - ).build! + Limber::Helper::TemplateConstructor.new(prefix:, catalogue:, sequencing_keys: params[:sequencing_list]).build! unless params[:omit_library_templates] Limber::Helper::LibraryOnlyTemplateConstructor.new(prefix:, catalogue:).build! Limber::Helper::LibraryAndMultiplexingTemplateConstructor.new(prefix:, catalogue:).build! @@ -237,11 +233,7 @@ namespace :limber do Limber::Helper::LibraryOnlyTemplateConstructor.new(prefix: 'GBS', catalogue: gbs_catalogue).build! catalogue = ProductCatalogue.create_with(selection_behaviour: 'SingleProduct').find_or_create_by!(name: 'Generic') - Limber::Helper::TemplateConstructor.new( - prefix: 'Multiplexing', - catalogue:, - sequencing_keys: base_list - ).build! + Limber::Helper::TemplateConstructor.new(prefix: 'Multiplexing', catalogue:, sequencing_keys: base_list).build! ## Bespoke Pipelines ## generic_pcr = diff --git a/lib/tasks/register_auto_imported_samples_as_stock.rake b/lib/tasks/register_auto_imported_samples_as_stock.rake index d4889f019d..930b940b6e 100644 --- a/lib/tasks/register_auto_imported_samples_as_stock.rake +++ b/lib/tasks/register_auto_imported_samples_as_stock.rake @@ -36,8 +36,7 @@ namespace :auto_imported_samples do labware = labware_samples.uniq # 890 in training 2020-07-07 puts "labware count: #{labware.count}" - receptacles = - Receptacle.where(labware:).joins(:aliquots).where("aliquots.study_id IN (#{relevant_study_ids})") + receptacles = Receptacle.where(labware:).joins(:aliquots).where("aliquots.study_id IN (#{relevant_study_ids})") # 78,507 in training 2020-07-08 (85,440 before join with aliquots) puts "receptacles count: #{receptacles.count}" diff --git a/spec/api/state_change_spec.rb b/spec/api/state_change_spec.rb index ebfcd7cad7..63a52826d2 100644 --- a/spec/api/state_change_spec.rb +++ b/spec/api/state_change_spec.rb @@ -68,16 +68,7 @@ end shared_examples 'a failed state_change_endpoint' do - let(:payload) do - { - state_change: { - user: user.uuid, - target: target_plate.uuid, - target_state:, - reason: - } - }.to_json - end + let(:payload) { { state_change: { user: user.uuid, target: target_plate.uuid, target_state:, reason: } }.to_json } before { api_request :post, subject, payload } diff --git a/spec/api/submission_pool_spec.rb b/spec/api/submission_pool_spec.rb index 9f4f5b25bd..27b37f5c47 100644 --- a/spec/api/submission_pool_spec.rb +++ b/spec/api/submission_pool_spec.rb @@ -40,9 +40,7 @@ let(:plate) { create :input_plate, well_count: 2 } before do - plate.wells.each do |well| - create :library_creation_request, asset: well, submission:, request_type: - end + plate.wells.each { |well| create :library_creation_request, asset: well, submission:, request_type: } create :tag2_layout_template_submission, submission:, tag2_layout_template: end @@ -72,11 +70,7 @@ before do plate.wells.each do |well| - create :library_creation_request, - asset: well, - submission:, - request_type:, - state: 'cancelled' + create :library_creation_request, asset: well, submission:, request_type:, state: 'cancelled' end end @@ -103,9 +97,7 @@ let(:plate) { create :input_plate, well_count: 2 } before do - plate.wells.each do |well| - create :library_creation_request, asset: well, submission:, request_type: - end + plate.wells.each { |well| create :library_creation_request, asset: well, submission:, request_type: } create :tag_layout_template_submission, submission:, tag_layout_template: end @@ -135,12 +127,8 @@ let(:plate_b) { create :input_plate, well_count: 2 } before do - plate.wells.each do |well| - create :library_creation_request, asset: well, submission:, request_type: - end - plate_b.wells.each do |well| - create :library_creation_request, asset: well, submission:, request_type: - end + plate.wells.each { |well| create :library_creation_request, asset: well, submission:, request_type: } + plate_b.wells.each { |well| create :library_creation_request, asset: well, submission:, request_type: } end let(:response_body) do @@ -165,17 +153,13 @@ context 'a multi plate submission and a used template on children' do let(:plate_b) do plate = create :input_plate, well_count: 2 - plate.wells.each do |well| - create :library_creation_request, asset: well, submission:, request_type: - end + plate.wells.each { |well| create :library_creation_request, asset: well, submission:, request_type: } plate end let(:plate) { create :target_plate, well_count: 2, parent: plate_b, submission: } - before do - create :tag2_layout_template_submission, submission:, tag2_layout_template: - end + before { create :tag2_layout_template_submission, submission:, tag2_layout_template: } let(:response_body) do "{ diff --git a/spec/factories/custom_metadatum_collection_factories.rb b/spec/factories/custom_metadatum_collection_factories.rb index 69a67db414..1bb188cc59 100644 --- a/spec/factories/custom_metadatum_collection_factories.rb +++ b/spec/factories/custom_metadatum_collection_factories.rb @@ -9,11 +9,7 @@ transient { metadatum_count { 5 } } after(:create) do |custom_metadatum_collection, evaluator| - create_list( - :custom_metadatum, - evaluator.metadatum_count, - custom_metadatum_collection: - ) + create_list(:custom_metadatum, evaluator.metadatum_count, custom_metadatum_collection:) end end end diff --git a/spec/factories/pipelines_factories.rb b/spec/factories/pipelines_factories.rb index d70c8e14d9..8c58d05b2a 100644 --- a/spec/factories/pipelines_factories.rb +++ b/spec/factories/pipelines_factories.rb @@ -210,9 +210,7 @@ factory :fluidigm_pipeline_workflow, class: 'Workflow' do name { generate :lab_workflow_name } - after(:build) do |workflow| - workflow.pipeline = build(:fluidigm_pipeline, workflow:) unless workflow.pipeline - end + after(:build) { |workflow| workflow.pipeline = build(:fluidigm_pipeline, workflow:) unless workflow.pipeline } tasks { [build(:fluidigm_template_task, workflow: nil), build(:cherrypick_task, workflow: nil)] } end @@ -220,9 +218,7 @@ factory :cherrypick_pipeline_workflow, class: 'Workflow' do name { generate :lab_workflow_name } - after(:build) do |workflow| - workflow.pipeline = build(:cherrypick_pipeline, workflow:) unless workflow.pipeline - end + after(:build) { |workflow| workflow.pipeline = build(:cherrypick_pipeline, workflow:) unless workflow.pipeline } tasks { [build(:plate_template_task, workflow: nil), build(:cherrypick_task, workflow: nil)] } end diff --git a/spec/factories/plate_factories.rb b/spec/factories/plate_factories.rb index b31939cc97..7dab007c59 100644 --- a/spec/factories/plate_factories.rb +++ b/spec/factories/plate_factories.rb @@ -92,10 +92,7 @@ outer_request = well_hash[well.map_description].requests.detect { |r| r.submission_id == evaluator.submission.id } - create :transfer_request, - asset: well_hash[well.map_description], - target_asset: well, - outer_request: + create :transfer_request, asset: well_hash[well.map_description], target_asset: well, outer_request: end end end diff --git a/spec/factories/request_type_factories.rb b/spec/factories/request_type_factories.rb index ea378584ae..dfcf2a8691 100644 --- a/spec/factories/request_type_factories.rb +++ b/spec/factories/request_type_factories.rb @@ -114,13 +114,7 @@ request_class { SequencingRequest } after(:build) do |request_type, ev| - srv = - create( - :sequencing_request_type_validator, - request_type:, - options: ev.read_lengths, - default: ev.default - ) + srv = create(:sequencing_request_type_validator, request_type:, options: ev.read_lengths, default: ev.default) request_type.request_type_validators << srv end end diff --git a/spec/factories/sample_manifest_factories.rb b/spec/factories/sample_manifest_factories.rb index a2fb97ef8f..c91ed7bfab 100644 --- a/spec/factories/sample_manifest_factories.rb +++ b/spec/factories/sample_manifest_factories.rb @@ -91,9 +91,7 @@ .plates .flat_map(&:wells) .each do |well| - evaluator.num_rows_per_well.times do - create(:sample_manifest_asset, asset: well, sample_manifest:) - end + evaluator.num_rows_per_well.times { create(:sample_manifest_asset, asset: well, sample_manifest:) } end end end diff --git a/spec/factories/shared_traits.rb b/spec/factories/shared_traits.rb index 0b1705b761..1c9dff6dc7 100644 --- a/spec/factories/shared_traits.rb +++ b/spec/factories/shared_traits.rb @@ -26,9 +26,7 @@ transient { uuid { SecureRandom.uuid } } # Using an after build as I need access to both the transient and the resource. - after(:build) do |resource, context| - resource.uuid_object = build(:uuid, external_id: context.uuid, resource:) - end + after(:build) { |resource, context| resource.uuid_object = build(:uuid, external_id: context.uuid, resource:) } after(:create) { |resource, _context| resource.uuid_object.save! } end diff --git a/spec/factories/tube_factories.rb b/spec/factories/tube_factories.rb index b20fbe6b08..4de36eb927 100644 --- a/spec/factories/tube_factories.rb +++ b/spec/factories/tube_factories.rb @@ -165,9 +165,7 @@ prep_kit_barcode { 999 } smrt_cells_available { 1 } end - pac_bio_library_tube_metadata_attributes do - { prep_kit_barcode:, smrt_cells_available: } - end + pac_bio_library_tube_metadata_attributes { { prep_kit_barcode:, smrt_cells_available: } } after(:build) { |t, evaluator| t.receptacle.aliquots << evaluator.aliquot } end diff --git a/spec/features/assets/asset_submission_spec.rb b/spec/features/assets/asset_submission_spec.rb index da96644282..d19d31bdd2 100644 --- a/spec/features/assets/asset_submission_spec.rb +++ b/spec/features/assets/asset_submission_spec.rb @@ -11,9 +11,7 @@ let(:original_request_type) { request_types.first } let(:selected_request_type) { original_request_type } let(:selected_read_length) { '76' } - let!(:original_request) do - create(request_factory, study:, project:, asset:, request_type: original_request_type) - end + let!(:original_request) { create(request_factory, study:, project:, asset:, request_type: original_request_type) } shared_examples 'it allows additional sequencing' do it 'request additional sequencing' do diff --git a/spec/features/batches/failing_requests_spec.rb b/spec/features/batches/failing_requests_spec.rb index 685aefb232..24551594ab 100644 --- a/spec/features/batches/failing_requests_spec.rb +++ b/spec/features/batches/failing_requests_spec.rb @@ -6,10 +6,7 @@ describe 'Batches controller', :js do let(:request_count) { 3 } let(:batch) do - create :cherrypick_batch, - request_count:, - state: 'released', - request_factory: :passed_cherrypick_request + create :cherrypick_batch, request_count:, state: 'released', request_factory: :passed_cherrypick_request end let(:user) { create :admin } diff --git a/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb b/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb index dbf46240f2..2f7db1ddbe 100644 --- a/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb +++ b/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb @@ -45,12 +45,14 @@ def initialize_plates(plates) plates.each do |plate| plate.wells.each_with_index do |well, index| # create the requests for cherrypicking - create(:cherrypick_request, - asset: well, - request_type: pipeline.request_types.first, - submission:, - study:, - project:) + create( + :cherrypick_request, + asset: well, + request_type: pipeline.request_types.first, + submission:, + study:, + project: + ) # create a concentration value on the wells if required next unless concentrations_required diff --git a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb index 8319ef15a1..eee0c81663 100644 --- a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb +++ b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb @@ -113,9 +113,7 @@ end context 'when a batch has been created' do - let(:batch) do - create :batch, pipeline:, requests: pipeline.requests, state: 'released', updated_at: 1.day.ago - end + let(:batch) { create :batch, pipeline:, requests: pipeline.requests, state: 'released', updated_at: 1.day.ago } let!(:flowcell_message) { Messenger.create!(target: batch, template: 'FlowcellIO', root: 'flowcell') } diff --git a/spec/features/pipelines/viewing_request_comments_spec.rb b/spec/features/pipelines/viewing_request_comments_spec.rb index 8915bda6dc..b76f65a804 100644 --- a/spec/features/pipelines/viewing_request_comments_spec.rb +++ b/spec/features/pipelines/viewing_request_comments_spec.rb @@ -8,9 +8,7 @@ let(:pipeline_name) { pipeline.name } let(:submission) { create :submission } let(:tube) { create :multiplexed_library_tube } - let(:request) do - create :sequencing_request, asset: tube, request_type: pipeline.request_types.first, submission: - end + let(:request) { create :sequencing_request, asset: tube, request_type: pipeline.request_types.first, submission: } before do create :comment, commentable: tube, description: 'An excellent tube' diff --git a/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb b/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb index 4e4772c341..5a8c3446e8 100644 --- a/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb +++ b/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb @@ -123,9 +123,7 @@ end context 'duplicate cgap foreign barcodes' do - let(:download) do - build(:test_download_tubes_cgap, columns:, validation_errors: [:sample_tube_id_duplicates]) - end + let(:download) { build(:test_download_tubes_cgap, columns:, validation_errors: [:sample_tube_id_duplicates]) } it 'validation errors' do login_user(user) @@ -194,11 +192,7 @@ context 'cgap foreign barcodes' do let(:download) do - build( - :test_download_tubes_cgap, - columns:, - manifest_type: 'tube_multiplexed_library_with_tag_sequences' - ) + build(:test_download_tubes_cgap, columns:, manifest_type: 'tube_multiplexed_library_with_tag_sequences') end it 'upload' do @@ -347,12 +341,7 @@ context 'invalid' do context 'upload' do let(:download) do - build( - :test_download_tubes, - columns:, - manifest_type: 'tube_multiplexed_library', - validation_errors: %i[tags] - ) + build(:test_download_tubes, columns:, manifest_type: 'tube_multiplexed_library', validation_errors: %i[tags]) end it 'validation errors' do @@ -486,11 +475,7 @@ context 'unrecognised cgap foreign barcodes' do let(:download) do - build( - :test_download_plates_cgap, - columns:, - validation_errors: [:sample_plate_id_unrecognised_foreign] - ) + build(:test_download_plates_cgap, columns:, validation_errors: [:sample_plate_id_unrecognised_foreign]) end it 'validation errors' do @@ -503,9 +488,7 @@ end context 'duplicate cgap foreign barcodes' do - let(:download) do - build(:test_download_plates_cgap, columns:, validation_errors: [:sample_plate_id_duplicates]) - end + let(:download) { build(:test_download_plates_cgap, columns:, validation_errors: [:sample_plate_id_duplicates]) } it 'validation errors' do login_user(user) diff --git a/spec/insdc/import_countries_spec.rb b/spec/insdc/import_countries_spec.rb index 35fc5207f7..9c2209dd6a 100644 --- a/spec/insdc/import_countries_spec.rb +++ b/spec/insdc/import_countries_spec.rb @@ -3,9 +3,7 @@ require 'rails_helper' RSpec.describe Insdc::ImportCountries do - subject(:importer) do - described_class.new(ena_root:, sample_checklist:, priorities:) - end + subject(:importer) { described_class.new(ena_root:, sample_checklist:, priorities:) } before do # The File api is used heavily internally, and we're going to be mocking it a diff --git a/spec/lib/label_printer/batch_plate_spec.rb b/spec/lib/label_printer/batch_plate_spec.rb index c6229d2d83..2923e98b33 100644 --- a/spec/lib/label_printer/batch_plate_spec.rb +++ b/spec/lib/label_printer/batch_plate_spec.rb @@ -65,8 +65,7 @@ let(:batch) { create :batch } let(:study) { create :study } let(:request1) do - order = - create(:order, order_role: OrderRole.new(role: 'test_role'), study:, assets: [create(:empty_sample_tube)]) + order = create(:order, order_role: OrderRole.new(role: 'test_role'), study:, assets: [create(:empty_sample_tube)]) create( :well_request, asset: create(:well_with_sample_and_plate), @@ -75,8 +74,7 @@ ) end let(:request2) do - order = - create(:order, order_role: OrderRole.new(role: 'test_role'), study:, assets: [create(:empty_sample_tube)]) + order = create(:order, order_role: OrderRole.new(role: 'test_role'), study:, assets: [create(:empty_sample_tube)]) create( :well_request, asset: create(:well_with_sample_and_plate), diff --git a/spec/lib/label_printer/swipecard_spec.rb b/spec/lib/label_printer/swipecard_spec.rb index 13f9cecbd2..466a15ffd6 100644 --- a/spec/lib/label_printer/swipecard_spec.rb +++ b/spec/lib/label_printer/swipecard_spec.rb @@ -17,9 +17,7 @@ ) end let(:labels_attribute) { [{ left_text: user.login, barcode: swipecard, label_name: 'main' }] } - let(:build_attributes) do - { printer_name: barcode_printer.name, label_template_name:, labels: labels_attribute } - end + let(:build_attributes) { { printer_name: barcode_printer.name, label_template_name:, labels: labels_attribute } } it 'builds correct attributes' do # This hash is sent to the printmybarcode service. diff --git a/spec/lib/record_loader/tag_layout_templates_loader_spec.rb b/spec/lib/record_loader/tag_layout_templates_loader_spec.rb index 13de085ca1..0531d49e01 100644 --- a/spec/lib/record_loader/tag_layout_templates_loader_spec.rb +++ b/spec/lib/record_loader/tag_layout_templates_loader_spec.rb @@ -17,13 +17,7 @@ def a_new_record_loader context 'with tag_layout_template_basic selected' do let(:selected_files) { 'tag_layout_template_basic' } let(:expected_attributes) do - { - name: 'Tag Layout 1', - tag_group:, - tag2_group:, - direction: 'column', - walking_by: 'wells of plate' - } + { name: 'Tag Layout 1', tag_group:, tag2_group:, direction: 'column', walking_by: 'wells of plate' } end let!(:tag_group) { create :tag_group, name: 'group 1' } diff --git a/spec/models/api/library_tube_io_spec.rb b/spec/models/api/library_tube_io_spec.rb index 3efa4bd318..f1a5da8609 100644 --- a/spec/models/api/library_tube_io_spec.rb +++ b/spec/models/api/library_tube_io_spec.rb @@ -3,9 +3,7 @@ require 'rails_helper' RSpec.describe Api::LibraryTubeIO do - subject do - create :empty_library_tube, public_name: 'ABC', closed: false, aliquots:, volume: 12.0, concentration: 8.0 - end + subject { create :empty_library_tube, public_name: 'ABC', closed: false, aliquots:, volume: 12.0, concentration: 8.0 } let(:sample) { create :sample } let(:tag) { create :tag } diff --git a/spec/models/api/well_io_spec.rb b/spec/models/api/well_io_spec.rb index bbe46cbaad..036d472ff7 100644 --- a/spec/models/api/well_io_spec.rb +++ b/spec/models/api/well_io_spec.rb @@ -6,9 +6,7 @@ context 'with one sample' do # As of the current records, the 'description' and 'asset_size' attributes can uniquely identify a map. subject do - create :well_with_sample_and_without_plate, - map: Map.find_by(description: 'A1', asset_size: plate.size), - plate: + create :well_with_sample_and_without_plate, map: Map.find_by(description: 'A1', asset_size: plate.size), plate: end let(:plate) { create :plate, barcode: 'SQPD-1' } diff --git a/spec/models/broadcast_event/lab_event_spec.rb b/spec/models/broadcast_event/lab_event_spec.rb index 7e15c6f725..ff7cd24d4c 100644 --- a/spec/models/broadcast_event/lab_event_spec.rb +++ b/spec/models/broadcast_event/lab_event_spec.rb @@ -5,9 +5,7 @@ require 'rails_helper' RSpec.describe BroadcastEvent::LabEvent, :broadcast_event do - subject do - described_class.create!(seed: lab_event, user:, created_at: Time.zone.parse('2018-01-12T13:37:03+00:00')) - end + subject { described_class.create!(seed: lab_event, user:, created_at: Time.zone.parse('2018-01-12T13:37:03+00:00')) } let(:json) { JSON.parse(subject.to_json) } let(:eventful) { request } diff --git a/spec/models/broadcast_event/pool_released_spec.rb b/spec/models/broadcast_event/pool_released_spec.rb index 173fb84ef2..ac93053c81 100644 --- a/spec/models/broadcast_event/pool_released_spec.rb +++ b/spec/models/broadcast_event/pool_released_spec.rb @@ -15,18 +15,10 @@ let(:submission) { create :library_submission } let(:order) { submission.orders.first } let(:request1) do - create :multiplex_request, - asset: source_plate.wells.first, - target_asset: tube.receptacle, - state: 'passed', - order: + create :multiplex_request, asset: source_plate.wells.first, target_asset: tube.receptacle, state: 'passed', order: end let(:request2) do - create :multiplex_request, - asset: source_plate.wells.last, - target_asset: tube.receptacle, - state: 'passed', - order: + create :multiplex_request, asset: source_plate.wells.last, target_asset: tube.receptacle, state: 'passed', order: end let(:library_request) { create :library_request, target_asset: source_plate.wells.first } diff --git a/spec/models/cherrypick_task/control_locator_spec.rb b/spec/models/cherrypick_task/control_locator_spec.rb index 7680ad9249..30b980c99e 100644 --- a/spec/models/cherrypick_task/control_locator_spec.rb +++ b/spec/models/cherrypick_task/control_locator_spec.rb @@ -3,14 +3,7 @@ require 'rails_helper' RSpec.describe CherrypickTask::ControlLocator do - let(:instance) do - described_class.new( - batch_id:, - total_wells:, - num_control_wells:, - wells_to_leave_free: - ) - end + let(:instance) { described_class.new(batch_id:, total_wells:, num_control_wells:, wells_to_leave_free:) } shared_examples 'an invalid ControlLocator' do |plate_number, error = 'More controls than free wells'| it 'throws a "More controls than free wells" exception' do diff --git a/spec/models/linear_submission_spec.rb b/spec/models/linear_submission_spec.rb index 18b12d266b..2b6a3c6001 100644 --- a/spec/models/linear_submission_spec.rb +++ b/spec/models/linear_submission_spec.rb @@ -133,16 +133,7 @@ [library_creation_stage1.id, library_creation_stage2.id, mx_request_type.id, sequencing_request_type.id] end let(:assets) { create_list(:untagged_well, 2) } - let(:basic_options) do - { - study:, - project:, - user:, - request_types: request_type_option, - request_options:, - assets: - } - end + let(:basic_options) { { study:, project:, user:, request_types: request_type_option, request_options:, assets: } } let(:submission) { create(:linear_submission, basic_options).submission.tap(&:built!) } it 'builds the submission' do diff --git a/spec/models/location_report_spec.rb b/spec/models/location_report_spec.rb index f449acebb2..53d6853f49 100644 --- a/spec/models/location_report_spec.rb +++ b/spec/models/location_report_spec.rb @@ -239,11 +239,7 @@ [plate_2.machine_barcode.to_s, 'Shelf 2', locn_prefix], [plate_3.machine_barcode.to_s, 'Shelf 3', locn_prefix] ].each do |lw_barcode, lw_locn_name, lw_locn_parentage| - stub_lwclient_labware_find_by_bc( - lw_barcode:, - lw_locn_name:, - lw_locn_parentage: - ) + stub_lwclient_labware_find_by_bc(lw_barcode:, lw_locn_name:, lw_locn_parentage:) end plate_1_custom_metadatum diff --git a/spec/models/orders/order_spec.rb b/spec/models/orders/order_spec.rb index 8993c0be82..1ba21ada23 100644 --- a/spec/models/orders/order_spec.rb +++ b/spec/models/orders/order_spec.rb @@ -15,14 +15,7 @@ # don't want to trigger this behaviour accidentally if someone forgets to # specify a study. - subject(:order) do - build :order, - assets:, - autodetect_studies:, - autodetect_projects:, - study: nil, - project: nil - end + subject(:order) { build :order, assets:, autodetect_studies:, autodetect_projects:, study: nil, project: nil } let(:assets) { [tube] } let(:tube) { create :sample_tube, aliquots: } diff --git a/spec/models/phi_x/stock_spec.rb b/spec/models/phi_x/stock_spec.rb index e0f515cdca..8fe4476867 100644 --- a/spec/models/phi_x/stock_spec.rb +++ b/spec/models/phi_x/stock_spec.rb @@ -49,9 +49,7 @@ context 'with valid data' do subject(:save) { phi_x_stock.save } - let(:phi_x_stock) do - build :phi_x_stock, number: 2, name: 'Example', concentration: '0.8', tags:, study_id: - end + let(:phi_x_stock) { build :phi_x_stock, number: 2, name: 'Example', concentration: '0.8', tags:, study_id: } let(:tags) { 'Single' } let(:study_id) { build_stubbed(:study).id } diff --git a/spec/models/pooling_spec.rb b/spec/models/pooling_spec.rb index 5e1ab770ec..a40a679db3 100644 --- a/spec/models/pooling_spec.rb +++ b/spec/models/pooling_spec.rb @@ -12,12 +12,7 @@ let(:stock_mx_tube_required) { false } let(:barcode_printer_option) { nil } let(:pooling) do - described_class.new( - barcodes:, - stock_mx_tube_required:, - barcode_printer: barcode_printer_option, - count: 1 - ) + described_class.new(barcodes:, stock_mx_tube_required:, barcode_printer: barcode_printer_option, count: 1) end context 'without source assets' do diff --git a/spec/models/sample_manifest/generator_spec.rb b/spec/models/sample_manifest/generator_spec.rb index 5159ad37eb..4e434b28cd 100644 --- a/spec/models/sample_manifest/generator_spec.rb +++ b/spec/models/sample_manifest/generator_spec.rb @@ -26,9 +26,7 @@ let(:configuration) { SampleManifestExcel.configuration } let(:template) { 'plate_full' } - let(:attributes) do - { template:, study_id: study.id, supplier_id: supplier.id, count: '4' }.with_indifferent_access - end + let(:attributes) { { template:, study_id: study.id, supplier_id: supplier.id, count: '4' }.with_indifferent_access } after(:all) { SampleManifestExcel.reset! } diff --git a/spec/models/sample_manifest_spec.rb b/spec/models/sample_manifest_spec.rb index 656db31715..45d2363e9c 100644 --- a/spec/models/sample_manifest_spec.rb +++ b/spec/models/sample_manifest_spec.rb @@ -358,10 +358,7 @@ describe '#pools' do let(:manifest) do - create :plate_sample_manifest_with_manifest_assets, - study:, - asset_type: 'plate', - num_samples_per_well: + create :plate_sample_manifest_with_manifest_assets, study:, asset_type: 'plate', num_samples_per_well: end context 'when there is only one sample per well' do diff --git a/spec/models/sample_spec.rb b/spec/models/sample_spec.rb index eccaf012e9..cc92050c0a 100644 --- a/spec/models/sample_spec.rb +++ b/spec/models/sample_spec.rb @@ -136,9 +136,7 @@ end it 'can have a priority' do - %w[backlog surveillance priority].each do |priority| - expect(build(:sample, priority:).priority).to eq(priority) - end + %w[backlog surveillance priority].each { |priority| expect(build(:sample, priority:).priority).to eq(priority) } end end diff --git a/spec/models/sequencing_request_spec.rb b/spec/models/sequencing_request_spec.rb index 6ec0f0b195..4329e06b95 100644 --- a/spec/models/sequencing_request_spec.rb +++ b/spec/models/sequencing_request_spec.rb @@ -169,22 +169,10 @@ context 'when compound samples are necessary because each aliquot does not have a unique tag combination' do context 'when there is one tag combination' do let(:aliquot1) do - create :aliquot, - sample: samples[0], - tag_id: tags[0].id, - tag2_id: tags[1].id, - tag_depth: 1, - study:, - project: + create :aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, study:, project: end let(:aliquot2) do - create :aliquot, - sample: samples[1], - tag_id: tags[0].id, - tag2_id: tags[1].id, - tag_depth: 2, - study:, - project: + create :aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, study:, project: end it 'creates a compound sample and transfers an aliquot of it' do diff --git a/spec/models/specific_tube_creations_spec.rb b/spec/models/specific_tube_creations_spec.rb index d60e45b793..c68af8e778 100644 --- a/spec/models/specific_tube_creations_spec.rb +++ b/spec/models/specific_tube_creations_spec.rb @@ -72,9 +72,7 @@ let(:names) { %w[example_1 example_2] } let(:purpose_count) { 2 } let(:tube_attributes) { names.map { |name| { name: } } } - let(:creation_parameters) do - { user:, child_purposes: [child_purpose] * purpose_count, parent:, tube_attributes: } - end + let(:creation_parameters) { { user:, child_purposes: [child_purpose] * purpose_count, parent:, tube_attributes: } } it_behaves_like 'a specific tube creator' end @@ -86,9 +84,7 @@ let(:purpose_count) { 1 } let(:foreign_barcode) { 'FD00000001' } let(:tube_attributes) { [{ name: names[0], foreign_barcode: }] } - let(:creation_parameters) do - { user:, child_purposes: [child_purpose], parent:, tube_attributes: } - end + let(:creation_parameters) { { user:, child_purposes: [child_purpose], parent:, tube_attributes: } } describe '#save' do include_context 'with common test setup' diff --git a/spec/models/state_changer/initial_stock_tube_spec.rb b/spec/models/state_changer/initial_stock_tube_spec.rb index a855e0188a..2f670fd3c8 100644 --- a/spec/models/state_changer/initial_stock_tube_spec.rb +++ b/spec/models/state_changer/initial_stock_tube_spec.rb @@ -4,14 +4,7 @@ require 'spec_helper' RSpec.describe StateChanger::InitialStockTube do - let(:state_changer) do - described_class.new( - labware:, - target_state:, - user:, - customer_accepts_responsibility: - ) - end + let(:state_changer) { described_class.new(labware:, target_state:, user:, customer_accepts_responsibility:) } let(:user) { build_stubbed :user } let(:customer_accepts_responsibility) { false } diff --git a/spec/models/state_changer/input_plate_spec.rb b/spec/models/state_changer/input_plate_spec.rb index 23f28eaf92..65b89d38d5 100644 --- a/spec/models/state_changer/input_plate_spec.rb +++ b/spec/models/state_changer/input_plate_spec.rb @@ -6,13 +6,7 @@ RSpec.describe StateChanger::InputPlate do let(:state_changer) do - described_class.new( - labware: input_plate, - target_state:, - user:, - contents:, - customer_accepts_responsibility: - ) + described_class.new(labware: input_plate, target_state:, user:, contents:, customer_accepts_responsibility:) end let(:user) { build_stubbed :user } let(:contents) { [] } diff --git a/spec/models/state_changer/mx_tube_spec.rb b/spec/models/state_changer/mx_tube_spec.rb index 81ad9b4710..f8eb6cc017 100644 --- a/spec/models/state_changer/mx_tube_spec.rb +++ b/spec/models/state_changer/mx_tube_spec.rb @@ -4,14 +4,7 @@ require 'spec_helper' RSpec.describe StateChanger::MxTube do - let(:state_changer) do - described_class.new( - labware:, - target_state:, - user:, - customer_accepts_responsibility: - ) - end + let(:state_changer) { described_class.new(labware:, target_state:, user:, customer_accepts_responsibility:) } let(:user) { build_stubbed :user } let(:customer_accepts_responsibility) { false } diff --git a/spec/models/state_changer/qcable_library_plate_spec.rb b/spec/models/state_changer/qcable_library_plate_spec.rb index 2ec8e3327e..7fa9f8ea9f 100644 --- a/spec/models/state_changer/qcable_library_plate_spec.rb +++ b/spec/models/state_changer/qcable_library_plate_spec.rb @@ -5,13 +5,7 @@ RSpec.describe StateChanger::QcableLibraryPlate do let(:state_changer) do - described_class.new( - labware:, - target_state: 'passed', - user:, - contents:, - customer_accepts_responsibility: - ) + described_class.new(labware:, target_state: 'passed', user:, contents:, customer_accepts_responsibility:) end let(:labware) { instance_double('Plate', wells: [well]) } # rubocop:todo RSpec/VerifiedDoubleReference let(:well) { instance_double('Well', aliquots: [aliquot]) } # rubocop:todo RSpec/VerifiedDoubleReference diff --git a/spec/models/state_changer/standard_plate_spec.rb b/spec/models/state_changer/standard_plate_spec.rb index 6a3421bfdf..94c1a49363 100644 --- a/spec/models/state_changer/standard_plate_spec.rb +++ b/spec/models/state_changer/standard_plate_spec.rb @@ -5,13 +5,7 @@ RSpec.describe StateChanger::StandardPlate do let(:state_changer) do - described_class.new( - labware: target_plate, - target_state:, - user:, - contents:, - customer_accepts_responsibility: - ) + described_class.new(labware: target_plate, target_state:, user:, contents:, customer_accepts_responsibility:) end let(:user) { build_stubbed :user } let(:contents) { [] } diff --git a/spec/models/state_changer/stock_tube_spec.rb b/spec/models/state_changer/stock_tube_spec.rb index 4c5680edca..9bea2f435e 100644 --- a/spec/models/state_changer/stock_tube_spec.rb +++ b/spec/models/state_changer/stock_tube_spec.rb @@ -4,14 +4,7 @@ require 'spec_helper' RSpec.describe StateChanger::StockTube do - let(:state_changer) do - described_class.new( - labware:, - target_state:, - user:, - customer_accepts_responsibility: - ) - end + let(:state_changer) { described_class.new(labware:, target_state:, user:, customer_accepts_responsibility:) } let(:user) { build_stubbed :user } let(:customer_accepts_responsibility) { false } diff --git a/spec/models/std_library_request_spec.rb b/spec/models/std_library_request_spec.rb index 46694a31a1..ceedb0a024 100644 --- a/spec/models/std_library_request_spec.rb +++ b/spec/models/std_library_request_spec.rb @@ -17,9 +17,7 @@ end describe '#request_metadata' do - subject do - build :library_request, request_metadata_attributes:, request_type: - end + subject { build :library_request, request_metadata_attributes:, request_type: } let(:fragment_size_required_from) { 1 } let(:fragment_size_required_to) { 20 } @@ -27,12 +25,7 @@ let(:pcr_cycles) { 8 } let(:request_metadata_attributes) do - { - fragment_size_required_from:, - fragment_size_required_to:, - library_type:, - pcr_cycles: - } + { fragment_size_required_from:, fragment_size_required_to:, library_type:, pcr_cycles: } end let(:request_type) { create :library_creation_request_type } diff --git a/spec/models/submission/submission_creator_spec.rb b/spec/models/submission/submission_creator_spec.rb index d2aff207d2..c70afbdf55 100644 --- a/spec/models/submission/submission_creator_spec.rb +++ b/spec/models/submission/submission_creator_spec.rb @@ -9,9 +9,7 @@ context 'a full template' do let(:library_type) { create :library_type } - let(:library_creation_request_type) do - create(:library_request_type, :with_library_types, library_type:) - end + let(:library_creation_request_type) { create(:library_request_type, :with_library_types, library_type:) } let(:template) do create :submission_template, request_types: [library_creation_request_type, create(:sequencing_request_type)] end diff --git a/spec/models/tag_layout_spec.rb b/spec/models/tag_layout_spec.rb index 0476597a57..39c37c75a9 100644 --- a/spec/models/tag_layout_spec.rb +++ b/spec/models/tag_layout_spec.rb @@ -41,18 +41,7 @@ def generate_tag_layout(plate, tag_type = :tag) end context 'layouts' do - before do - create( - :tag_layout, - plate:, - user:, - tag_group:, - tag2_group:, - walking_by:, - direction:, - initial_tag: - ) - end + before { create(:tag_layout, plate:, user:, tag_group:, tag2_group:, walking_by:, direction:, initial_tag:) } context 'by_column' do let(:direction) { 'column' } diff --git a/spec/models/tag_layout_template_spec.rb b/spec/models/tag_layout_template_spec.rb index 297b06eed6..df287dc940 100644 --- a/spec/models/tag_layout_template_spec.rb +++ b/spec/models/tag_layout_template_spec.rb @@ -7,13 +7,7 @@ # templates. The actual layout of tags is carried out by the tag layouts themselves, # and is tested there. describe TagLayoutTemplate do - let(:template) do - build :tag_layout_template, - direction_algorithm:, - walking_algorithm:, - tag2_group:, - tags: ['AAA'] - end + let(:template) { build :tag_layout_template, direction_algorithm:, walking_algorithm:, tag2_group:, tags: ['AAA'] } describe '#create!' do subject { template.create!(plate:, user:) } diff --git a/spec/models/tasks/cherrypick_task_spec.rb b/spec/models/tasks/cherrypick_task_spec.rb index 2d38d77456..91974f4d1b 100644 --- a/spec/models/tasks/cherrypick_task_spec.rb +++ b/spec/models/tasks/cherrypick_task_spec.rb @@ -7,9 +7,7 @@ RSpec.describe CherrypickTask do let!(:plate) { create :plate_with_untagged_wells, sample_count: 4 } let(:control_plate) { create :control_plate, sample_count: 2 } - let(:requests) do - plate.wells.in_column_major_order.map { |w| create(:cherrypick_request, asset: w, submission:) } - end + let(:requests) { plate.wells.in_column_major_order.map { |w| create(:cherrypick_request, asset: w, submission:) } } let(:template) { create(:plate_template, size: 6) } let(:robot) { instance_double('Robot', max_beds: 2) } # rubocop:todo RSpec/VerifiedDoubleReference let(:purpose) { create :purpose } diff --git a/spec/models/tasks/plate_template_task_spec.rb b/spec/models/tasks/plate_template_task_spec.rb index bc33eaf0e4..d961cf2772 100644 --- a/spec/models/tasks/plate_template_task_spec.rb +++ b/spec/models/tasks/plate_template_task_spec.rb @@ -77,11 +77,7 @@ describe '#do_task' do let(:params) do - ActionController::Parameters.new( - workflow_id: workflow.id, - file:, - plate_purpose_id: create(:plate_purpose).id - ) + ActionController::Parameters.new(workflow_id: workflow.id, file:, plate_purpose_id: create(:plate_purpose).id) end it 'does stuff' do diff --git a/spec/models/transfer_request_collection_spec.rb b/spec/models/transfer_request_collection_spec.rb index fb287f045e..349f8b8025 100644 --- a/spec/models/transfer_request_collection_spec.rb +++ b/spec/models/transfer_request_collection_spec.rb @@ -10,9 +10,7 @@ let(:target_asset) { create :empty_library_tube } context 'with a single transfer' do - let(:creation_attributes) do - { user:, transfer_requests_attributes: [{ asset:, target_asset: }] } - end + let(:creation_attributes) { { user:, transfer_requests_attributes: [{ asset:, target_asset: }] } } context 'and no outer requests' do describe '#save' do @@ -68,12 +66,7 @@ context 'specifying submission' do let(:creation_attributes) do - { - user:, - transfer_requests_attributes: [ - { asset:, target_asset:, submission: outer_request.submission } - ] - } + { user:, transfer_requests_attributes: [{ asset:, target_asset:, submission: outer_request.submission }] } end before { expect(subject.save).to be true } @@ -111,12 +104,7 @@ context 'specifying submission' do let(:creation_attributes) do - { - user:, - transfer_requests_attributes: [ - { asset:, target_asset:, submission: outer_request.submission } - ] - } + { user:, transfer_requests_attributes: [{ asset:, target_asset:, submission: outer_request.submission }] } end it 'is invalid' do @@ -126,10 +114,7 @@ context 'specifying outer_request' do let(:creation_attributes) do - { - user:, - transfer_requests_attributes: [{ asset:, target_asset:, outer_request: }] - } + { user:, transfer_requests_attributes: [{ asset:, target_asset:, outer_request: }] } end before { expect(subject.save).to be true } diff --git a/spec/models/transfer_request_spec.rb b/spec/models/transfer_request_spec.rb index 7b72c4a7fc..f6640d201e 100644 --- a/spec/models/transfer_request_spec.rb +++ b/spec/models/transfer_request_spec.rb @@ -252,9 +252,9 @@ let!(:target_asset) { create :well, aliquots: [aliquot_1] } it 'raises an exception' do - expect do - described_class.create!(asset: aliquot_2.receptacle.reload, target_asset:) - end.to raise_error(Aliquot::TagClash) + expect do described_class.create!(asset: aliquot_2.receptacle.reload, target_asset:) end.to raise_error( + Aliquot::TagClash + ) end end end diff --git a/spec/models/well_spec.rb b/spec/models/well_spec.rb index ef5b10e02c..f1d7ec5382 100644 --- a/spec/models/well_spec.rb +++ b/spec/models/well_spec.rb @@ -282,11 +282,7 @@ minimum_volume = 10 maximum_volume = 50 robot_minimum_picking_volume = 1.0 - @source_well.well_attribute.update!( - concentration: measured_concentration, - measured_volume:, - current_volume: - ) + @source_well.well_attribute.update!(concentration: measured_concentration, measured_volume:, current_volume:) @target_well.volume_to_cherrypick_by_nano_grams( minimum_volume, maximum_volume, diff --git a/spec/requests/api/v2/receptacles_spec.rb b/spec/requests/api/v2/receptacles_spec.rb index 5f46f3f5be..8d1ff75143 100644 --- a/spec/requests/api/v2/receptacles_spec.rb +++ b/spec/requests/api/v2/receptacles_spec.rb @@ -40,14 +40,7 @@ let(:coverage) { 100 } let(:diluent_volume) { 50.0 } - let(:receptacle) do - create :receptacle, - pcr_cycles:, - submit_for_sequencing:, - sub_pool:, - coverage:, - diluent_volume: - end + let(:receptacle) { create :receptacle, pcr_cycles:, submit_for_sequencing:, sub_pool:, coverage:, diluent_volume: } before { api_get "#{base_endpoint}/#{receptacle.id}" } diff --git a/spec/requests/api/v2/wells_spec.rb b/spec/requests/api/v2/wells_spec.rb index a2342943e5..32911cc516 100644 --- a/spec/requests/api/v2/wells_spec.rb +++ b/spec/requests/api/v2/wells_spec.rb @@ -31,14 +31,7 @@ let(:coverage) { 100 } let(:diluent_volume) { 50.0 } - let(:well) do - create :well, - pcr_cycles:, - submit_for_sequencing:, - sub_pool:, - coverage:, - diluent_volume: - end + let(:well) { create :well, pcr_cycles:, submit_for_sequencing:, sub_pool:, coverage:, diluent_volume: } describe '#get' do before { api_get "#{base_endpoint}/#{well.id}" } diff --git a/spec/sample_manifest_excel/upload/processor_spec.rb b/spec/sample_manifest_excel/upload/processor_spec.rb index 71fadee0a7..8b8b445aa5 100644 --- a/spec/sample_manifest_excel/upload/processor_spec.rb +++ b/spec/sample_manifest_excel/upload/processor_spec.rb @@ -48,12 +48,7 @@ def cell(row, column) cell(rows.last, columns[:insert_size_to]).value = '1000' download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) expect(processor.substitutions[0]).to include('insert_size_from' => 100) @@ -68,12 +63,7 @@ def cell(row, column) cell(rows.last, columns[:i7]).value = i7_tag1 download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) expect(processor).to be_downstream_aliquots_updated @@ -87,12 +77,7 @@ def cell(row, column) cell(rows.last, columns[:i7]).value = 'ATAGATAGATAG' download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) expect(processor).to be_aliquots_updated @@ -102,12 +87,7 @@ def cell(row, column) it 'will not update the aliquots downstream if there is nothing to update' do download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) expect(processor.substitutions.compact).to be_empty @@ -121,12 +101,7 @@ def cell(row, column) cell(rows.last, columns[:insert_size_to]).value = '1000' download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) @@ -142,12 +117,7 @@ def cell(row, column) cell(rows.last, columns[:chromium_tag_well]).value = chromium_tag1 download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) expect(processor.substitutions.compact.length).to eq(8) @@ -165,12 +135,7 @@ def cell(row, column) cell(rows.last, columns[:chromium_tag_well]).value = chromium_tag1 download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) @@ -230,12 +195,7 @@ def cell(row, column) context 'when updating sample data' do let(:reupload) do - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override:) end let(:processor) { described_class.new(reupload) } @@ -259,12 +219,7 @@ def cell(row, column) context 'when override is false' do let(:override) { false } let(:reupload) do - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override:) end let(:processor) { described_class.new(reupload) } @@ -527,12 +482,7 @@ def cell(row, column) cell(11, 8).value = '1000' download.save(new_test_file_name) reupload = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor.substitutions[0]).to include('insert_size_from' => 100) @@ -551,12 +501,7 @@ def cell(row, column) cell(11, 3).value = tag_index1 download.save(new_test_file_name) reupload = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).to be_downstream_aliquots_updated @@ -565,12 +510,7 @@ def cell(row, column) it 'will not update the aliquots downstream if there is nothing to update' do download.save(new_test_file_name) reupload = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor.substitutions.compact).to be_empty @@ -700,12 +640,7 @@ def cell(row, column) it 'will update the samples if samples data has changed and override is set true' do reupload = - SampleManifestExcel::Upload::Base.new( - file: new_test_file, - column_list:, - start_row: 9, - override: true - ) + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(reupload.rows).to be_all(&:sample_updated?) @@ -717,8 +652,7 @@ def cell(row, column) end it 'will not update the samples if samples data has changed and override is set false' do - reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) + reupload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(reupload.rows).not_to be_all(&:sample_updated?) @@ -749,8 +683,7 @@ def cell(row, column) cell(10, 0).value = 'CGAP-00000' cell(11, 0).value = 'CGAP-00000' download.save(new_test_file_name) - reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) + reupload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -760,8 +693,7 @@ def cell(row, column) cell(9, 0).value = 'CGAP-00000' cell(10, 0).value = 'CGAP-11111' download.save(new_test_file_name) - reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) + reupload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -785,8 +717,7 @@ def cell(row, column) row1 = download.worksheet.first_row - 1 cell(row1, col1).value = nil download.save(new_test_file_name) - reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) + reupload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -802,8 +733,7 @@ def cell(row, column) cell(row1, col1).value = 'Destroy after 2 years' cell(row2, col1).value = 'Long term storage' download.save(new_test_file_name) - reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) + reupload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid diff --git a/spec/sample_manifest_excel/upload/upload_spec.rb b/spec/sample_manifest_excel/upload/upload_spec.rb index 83a67fdc94..4e737e7c5b 100644 --- a/spec/sample_manifest_excel/upload/upload_spec.rb +++ b/spec/sample_manifest_excel/upload/upload_spec.rb @@ -150,9 +150,7 @@ context 'library tube with tag sequences' do let!(:columns) { SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup } - let!(:download) do - build(:test_download_tubes, columns:, manifest_type: 'tube_library_with_tag_sequences') - end + let!(:download) { build(:test_download_tubes, columns:, manifest_type: 'tube_library_with_tag_sequences') } before { download.save(test_file_name) } diff --git a/spec/sample_manifest_excel/worksheet_spec.rb b/spec/sample_manifest_excel/worksheet_spec.rb index ba2aabec9e..8187f13e01 100644 --- a/spec/sample_manifest_excel/worksheet_spec.rb +++ b/spec/sample_manifest_excel/worksheet_spec.rb @@ -38,9 +38,7 @@ def save_file it 'be Plates for any plate based manifest' do column_list = SampleManifestExcel.configuration.columns.plate_full.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest:) - ) + SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) expect(worksheet.type).to eq('Plates') end @@ -48,9 +46,7 @@ def save_file sample_manifest = create(:tube_sample_manifest, asset_type: '1dtube') column_list = SampleManifestExcel.configuration.columns.tube_full.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest:) - ) + SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) expect(worksheet.type).to eq('Tubes') end @@ -58,9 +54,7 @@ def save_file sample_manifest = create(:tube_sample_manifest, asset_type: '1dtube') column_list = SampleManifestExcel.configuration.columns.tube_extraction.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest:) - ) + SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) expect(worksheet.type).to eq('Tubes') end @@ -68,9 +62,7 @@ def save_file sample_manifest = create(:tube_sample_manifest, asset_type: 'library') column_list = SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest:) - ) + SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) expect(worksheet.type).to eq('Tubes') end @@ -78,9 +70,7 @@ def save_file sample_manifest = create(:tube_sample_manifest_with_tubes_and_manifest_assets, asset_type: 'multiplexed_library') column_list = SampleManifestExcel.configuration.columns.tube_multiplexed_library_with_tag_sequences.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest:) - ) + SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) expect(worksheet.type).to eq('Tubes') end @@ -88,9 +78,7 @@ def save_file sample_manifest = create(:tube_rack_manifest) column_list = SampleManifestExcel.configuration.columns.tube_rack_default.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new( - options.merge(columns: column_list, sample_manifest:) - ) + SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) expect(worksheet.type).to eq('Tube Racks') end end diff --git a/spec/sequencescape_excel/range_spec.rb b/spec/sequencescape_excel/range_spec.rb index 39a2aefad2..579476a3fd 100644 --- a/spec/sequencescape_excel/range_spec.rb +++ b/spec/sequencescape_excel/range_spec.rb @@ -6,14 +6,7 @@ let(:options) { %w[option1 option2 option3] } it 'is comparable' do - attributes = { - options:, - first_column: 4, - first_row: 5, - last_column: 8, - last_row: 10, - worksheet_name: 'Sheet1' - } + attributes = { options:, first_column: 4, first_row: 5, last_column: 8, last_row: 10, worksheet_name: 'Sheet1' } # rubocop:todo RSpec/IdenticalEqualityAssertion expect(described_class.new(attributes)).to eq(described_class.new(attributes)) diff --git a/spec/sequencescape_excel/specialised_field_spec.rb b/spec/sequencescape_excel/specialised_field_spec.rb index 94c422295d..a708324385 100644 --- a/spec/sequencescape_excel/specialised_field_spec.rb +++ b/spec/sequencescape_excel/specialised_field_spec.rb @@ -8,16 +8,10 @@ let(:asset2) { create(:untagged_well, map:) } let(:sample_manifest) { create :sample_manifest } let(:sample_manifest_asset) do - create :sample_manifest_asset, - asset:, - sanger_sample_id: sample.sanger_sample_id, - sample_manifest: + create :sample_manifest_asset, asset:, sanger_sample_id: sample.sanger_sample_id, sample_manifest: end let(:sample_manifest_asset2) do - create :sample_manifest_asset, - asset: asset2, - sanger_sample_id: sample2.sanger_sample_id, - sample_manifest: + create :sample_manifest_asset, asset: asset2, sanger_sample_id: sample2.sanger_sample_id, sample_manifest: end let!(:library_type) { create(:library_type) } let!(:reference_genome) { create(:reference_genome, name: 'new one') } @@ -68,9 +62,7 @@ def self.name describe SequencescapeExcel::SpecialisedField::LibraryType do it 'will not be valid without a persisted library type' do expect(described_class.new(value: library_type.name, sample_manifest_asset:)).to be_valid - expect( - described_class.new(value: 'A new library type', sample_manifest_asset:) - ).not_to be_valid + expect(described_class.new(value: 'A new library type', sample_manifest_asset:)).not_to be_valid end it 'will add the the value to the aliquot' do @@ -96,17 +88,12 @@ def self.name end it 'will not be valid without a persisted reference genome if a value is provided' do - expect( - described_class.new(value: reference_genome.name, sample_manifest_asset:) - ).to be_valid - expect( - described_class.new(value: 'A new reference genome', sample_manifest_asset:) - ).not_to be_valid + expect(described_class.new(value: reference_genome.name, sample_manifest_asset:)).to be_valid + expect(described_class.new(value: 'A new reference genome', sample_manifest_asset:)).not_to be_valid end it 'will add reference genome to sample_metadata' do - specialised_field = - described_class.new(value: reference_genome.name, sample_manifest_asset:) + specialised_field = described_class.new(value: reference_genome.name, sample_manifest_asset:) specialised_field.update expect(sample_manifest_asset.sample.sample_metadata.reference_genome).to eq(reference_genome) end @@ -293,10 +280,7 @@ def self.name it 'will not be valid unless the value matches the well description' do expect(described_class.new(value: 'well', sample_manifest_asset:)).not_to be_valid expect( - described_class.new( - value: sample_manifest_asset.asset.map_description, - sample_manifest_asset: - ) + described_class.new(value: sample_manifest_asset.asset.map_description, sample_manifest_asset:) ).to be_valid end end @@ -422,10 +406,7 @@ def self.name describe 'linking' do let!(:sf_tag_group) do - SequencescapeExcel::SpecialisedField::TagGroup.new( - value: tag_group_name, - sample_manifest_asset: - ) + SequencescapeExcel::SpecialisedField::TagGroup.new(value: tag_group_name, sample_manifest_asset:) end let!(:sf_tag_index) { described_class.new(value: tag_index, sample_manifest_asset:) } @@ -514,10 +495,7 @@ def self.name describe 'linking' do let!(:sf_tag2_group) do - SequencescapeExcel::SpecialisedField::Tag2Group.new( - value: tag2_group_name, - sample_manifest_asset: - ) + SequencescapeExcel::SpecialisedField::Tag2Group.new(value: tag2_group_name, sample_manifest_asset:) end let!(:sf_tag2_index) { described_class.new(value: tag2_index, sample_manifest_asset:) } @@ -577,9 +555,7 @@ def self.name let(:adapter_type) { create :adapter_type, name: 'Other' } it 'will not be valid' do - expect( - described_class.new(value: tag_group_name, sample_manifest_asset:) - ).not_to be_valid + expect(described_class.new(value: tag_group_name, sample_manifest_asset:)).not_to be_valid end end @@ -603,10 +579,7 @@ def self.name describe 'linking' do let(:sf_tag_group) do - SequencescapeExcel::SpecialisedField::ChromiumTagGroup.new( - value: tag_group_name, - sample_manifest_asset: - ) + SequencescapeExcel::SpecialisedField::ChromiumTagGroup.new(value: tag_group_name, sample_manifest_asset:) end let(:sf_tag_well) { described_class.new(value: tag_well, sample_manifest_asset:) } @@ -648,9 +621,7 @@ def self.name let(:dual_index_tag_well) { 'A1' } describe 'dual index tag set' do - let(:sf_dual_index_tag_set) do - described_class.new(value: dual_index_tag_set.name, sample_manifest_asset:) - end + let(:sf_dual_index_tag_set) { described_class.new(value: dual_index_tag_set.name, sample_manifest_asset:) } it 'will add the value' do expect(sf_dual_index_tag_set.value).to eq(dual_index_tag_set.name) @@ -670,9 +641,7 @@ def self.name end context 'when the tag set name is unknown' do - let(:sf_dual_index_tag_set) do - described_class.new(value: 'bananas', sample_manifest_asset:) - end + let(:sf_dual_index_tag_set) { described_class.new(value: 'bananas', sample_manifest_asset:) } it 'will be not be valid' do expect(sf_dual_index_tag_set).not_to be_valid @@ -695,9 +664,7 @@ def self.name end describe SequencescapeExcel::SpecialisedField::DualIndexTagWell do - let(:sf_dual_index_tag_well) do - described_class.new(value: dual_index_tag_well, sample_manifest_asset:) - end + let(:sf_dual_index_tag_well) { described_class.new(value: dual_index_tag_well, sample_manifest_asset:) } let(:sf_dual_index_tag_set) do SequencescapeExcel::SpecialisedField::DualIndexTagSet.new( value: dual_index_tag_set.name, @@ -777,9 +744,7 @@ def self.name it 'will not be valid without a persisted primer panel' do expect(described_class.new(value: primer_panel.name, sample_manifest_asset:)).to be_valid - expect( - described_class.new(value: 'A new primer panel', sample_manifest_asset:) - ).not_to be_valid + expect(described_class.new(value: 'A new primer panel', sample_manifest_asset:)).not_to be_valid end it 'will be valid if blank' do @@ -872,14 +837,9 @@ def self.name describe SequencescapeExcel::SpecialisedField::BioscanControlType do let(:sample_supplier_name) { 'CONTROL_test_01' } let!(:bs_supplier_name) do - SequencescapeExcel::SpecialisedField::BioscanSupplierName.new( - value: sample_supplier_name, - sample_manifest_asset: - ) - end - let!(:sf_well) do - SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) + SequencescapeExcel::SpecialisedField::BioscanSupplierName.new(value: sample_supplier_name, sample_manifest_asset:) end + let!(:sf_well) { SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) } # test value matches to the enum in the sample model # for Bioscan we have three types of control @@ -931,9 +891,7 @@ def self.name end context 'when pcr positive in H12' do - let!(:bs_well) do - SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) - end + let!(:bs_well) { SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) } it 'will be invalid' do control_type_sf = described_class.new(value: 'pcr positive', sample_manifest_asset:) @@ -944,9 +902,7 @@ def self.name end context 'when pcr positive not in H12' do - let!(:bs_well) do - SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset:) - end + let!(:bs_well) { SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset:) } it 'will be valid' do control_type_sf = described_class.new(value: 'pcr positive', sample_manifest_asset:) @@ -957,9 +913,7 @@ def self.name end context 'when lysate negative in H12' do - let!(:bs_well) do - SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) - end + let!(:bs_well) { SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) } it 'will be valid' do control_type_sf = described_class.new(value: 'lysate negative', sample_manifest_asset:) @@ -970,9 +924,7 @@ def self.name end context 'when lysate negative not in H12' do - let!(:bs_well) do - SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset:) - end + let!(:bs_well) { SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset:) } it 'will be invalid' do control_type_sf = described_class.new(value: 'lysate negative', sample_manifest_asset:) @@ -1016,9 +968,7 @@ def self.name end it 'will be valid if the value matches one of the expected values' do - expect( - described_class.new(value: 'Long term storage', sample_manifest_asset:) - ).to be_valid + expect(described_class.new(value: 'Long term storage', sample_manifest_asset:)).to be_valid end it 'will create labware custom metadata on the labware and set the retention instruction choice' do diff --git a/spec/shared_contexts/limber_shared_context.rb b/spec/shared_contexts/limber_shared_context.rb index 080c96725c..444939fa31 100644 --- a/spec/shared_contexts/limber_shared_context.rb +++ b/spec/shared_contexts/limber_shared_context.rb @@ -38,13 +38,15 @@ let(:build_library_requests) do input_plate.wells.each do |well| - create_list(:library_request, - requests_per_well, - request_type: library_request_type, - asset: well, - submission: target_submission, - state: library_state, - order:) + create_list( + :library_request, + requests_per_well, + request_type: library_request_type, + asset: well, + submission: target_submission, + state: library_state, + order: + ) create :library_request, request_type: library_request_type, asset: well, diff --git a/spec/uat_actions/generate_sample_manifest_spec.rb b/spec/uat_actions/generate_sample_manifest_spec.rb index d3fb5b3d45..afe0ee14f4 100644 --- a/spec/uat_actions/generate_sample_manifest_spec.rb +++ b/spec/uat_actions/generate_sample_manifest_spec.rb @@ -68,14 +68,7 @@ end describe '#create_sample_manifest' do - let(:manifest) do - create :sample_manifest, - study:, - supplier:, - count:, - asset_type:, - purpose: - end + let(:manifest) { create :sample_manifest, study:, supplier:, count:, asset_type:, purpose: } it 'sets the created sample manifest' do allow(SampleManifest).to receive(:create!).and_return(manifest) @@ -85,14 +78,7 @@ end describe '#generate_manifest' do - let(:manifest) do - create :sample_manifest, - study:, - supplier:, - count:, - asset_type:, - purpose: - end + let(:manifest) { create :sample_manifest, study:, supplier:, count:, asset_type:, purpose: } it 'create tubes(s)' do expect { uat_action.generate_manifest(manifest) }.to change(SampleTube, :count).by(count).and change { diff --git a/spec/uat_actions/plate_information_spec.rb b/spec/uat_actions/plate_information_spec.rb index 9151085b5a..175e041fe4 100644 --- a/spec/uat_actions/plate_information_spec.rb +++ b/spec/uat_actions/plate_information_spec.rb @@ -63,11 +63,7 @@ let(:submission) { create :submission } let(:request_type) { create :library_creation_request_type } let(:report) do - { - plate_barcode:, - wells_with_aliquots: 'A1, B1, C1', - wells_with_active_requests_as_source: 'A1, C1' - } + { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: 'A1, C1' } end before do @@ -75,20 +71,10 @@ plate_wells = plate.wells.with_contents - req1 = - create :library_creation_request, - asset: plate_wells.first, - submission:, - request_type:, - state: 'started' + req1 = create :library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'started' plate_wells.first.requests_as_source << req1 - req2 = - create :library_creation_request, - asset: plate_wells.last, - submission:, - request_type:, - state: 'started' + req2 = create :library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'started' plate_wells.last.requests_as_source << req2 end @@ -106,29 +92,17 @@ let(:uat_action) { described_class.new(parameters) } let(:submission) { create :submission } let(:request_type) { create :library_creation_request_type } - let(:report) do - { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } - end + let(:report) { { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } } before do plate = create :plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode plate_wells = plate.wells.with_contents - req1 = - create :library_creation_request, - asset: plate_wells.first, - submission:, - request_type:, - state: 'passed' + req1 = create :library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'passed' plate_wells.first.requests_as_source << req1 - req2 = - create :library_creation_request, - asset: plate_wells.last, - submission:, - request_type:, - state: 'passed' + req2 = create :library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'passed' plate_wells.last.requests_as_source << req2 end @@ -148,11 +122,7 @@ let(:submission2) { create :submission } let(:request_type) { create :library_creation_request_type } let(:report) do - { - plate_barcode:, - wells_with_aliquots: 'A1, B1, C1', - wells_with_active_requests_as_source: 'A1, C1' - } + { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: 'A1, C1' } end before do @@ -160,28 +130,13 @@ plate_wells = plate.wells.with_contents - req1 = - create :library_creation_request, - asset: plate_wells.first, - submission:, - request_type:, - state: 'passed' + req1 = create :library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'passed' plate_wells.first.requests_as_source << req1 - req2 = - create :library_creation_request, - asset: plate_wells.second, - submission:, - request_type:, - state: 'passed' + req2 = create :library_creation_request, asset: plate_wells.second, submission:, request_type:, state: 'passed' plate_wells.second.requests_as_source << req2 - req3 = - create :library_creation_request, - asset: plate_wells.last, - submission:, - request_type:, - state: 'passed' + req3 = create :library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'passed' plate_wells.last.requests_as_source << req3 req4 = diff --git a/test/controllers/batches_controller_test.rb b/test/controllers/batches_controller_test.rb index 89d5590d41..3738950a45 100644 --- a/test/controllers/batches_controller_test.rb +++ b/test/controllers/batches_controller_test.rb @@ -554,10 +554,12 @@ class BatchesControllerTest < ActionController::TestCase order = create(:order, order_role:, study:, assets: [asset], project:) request = - create(:well_request, - asset: (create :well_with_sample_and_plate), - target_asset: (create :well_with_sample_and_plate), - order:) + create( + :well_request, + asset: (create :well_with_sample_and_plate), + target_asset: (create :well_with_sample_and_plate), + order: + ) @batch = create :batch @batch.requests << request diff --git a/test/lib/label_printer/print_job_test.rb b/test/lib/label_printer/print_job_test.rb index 55255047bf..063223c7bf 100644 --- a/test/lib/label_printer/print_job_test.rb +++ b/test/lib/label_printer/print_job_test.rb @@ -29,11 +29,7 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength label_name: 'main_label' } ] - @attributes = { - printer_name: barcode_printer.name, - label_template_name:, - labels: labels_attributes - } + @attributes = { printer_name: barcode_printer.name, label_template_name:, labels: labels_attributes } @print_job = LabelPrinter::PrintJob.new( barcode_printer.name, diff --git a/test/unit/import_fluidigm_data_test.rb b/test/unit/import_fluidigm_data_test.rb index c3bf1ce504..7ff92bd50a 100644 --- a/test/unit/import_fluidigm_data_test.rb +++ b/test/unit/import_fluidigm_data_test.rb @@ -39,13 +39,7 @@ def create_stock_plate(barcode) def create_plate_with_fluidigm(_barcode, fluidigm_barcode, stock_plate) fgp = create :fluidigm_96_purpose - plate_target = - create(:plate, - size: 96, - purpose: fgp, - well_count: 1, - well_factory: :empty_well, - fluidigm_barcode:) + plate_target = create(:plate, size: 96, purpose: fgp, well_count: 1, well_factory: :empty_well, fluidigm_barcode:) well_target = plate_target.wells.first From ab14b6fafcbb568babc3998b780d714f464f2209 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 24 Sep 2024 09:54:57 +0100 Subject: [PATCH 116/158] build: update rubocop todo rubocop --auto-gen-config --no-exclude-limit --- .rubocop_todo.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 64fe380d3c..dcddddb54e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-23 14:09:39 UTC using RuboCop version 1.66.1. +# on 2024-09-23 17:15:55 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -204,11 +204,12 @@ Lint/NonLocalExitFromIterator: - 'app/api/core/io/json/grammar.rb' - 'app/models/create_asset_request.rb' -# Offense count: 6 +# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). Lint/RedundantCopDisableDirective: Exclude: - 'app/controllers/npg_actions/assets_controller.rb' + - 'app/helpers/submissions_helper.rb' - 'app/heron/factories/event.rb' - 'app/models/barcode/format_handlers.rb' - 'app/models/illumina_htp/initial_stock_tube_purpose.rb' @@ -667,7 +668,7 @@ RSpec/EmptyExampleGroup: - 'spec/models/pulldown/requests_spec.rb' - 'spec/models/tag_substitutions_spec.rb' -# Offense count: 387 +# Offense count: 380 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: @@ -1835,6 +1836,17 @@ Style/ArrayIntersect: Exclude: - 'test/unit/flexible_submission_test.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# AllowedMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'spec/models/transfer_request_spec.rb' + # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowOnConstant, AllowOnSelfClass. @@ -1991,12 +2003,11 @@ Style/GlobalStdStream: - 'config/environments/production.rb' - 'lib/tasks/limber_dev.rake' -# Offense count: 43 +# Offense count: 41 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: Exclude: - - 'app/bulk_submission_excel/bulk_submission_excel/download.rb' - 'app/controllers/assets_controller.rb' - 'app/controllers/orders_controller.rb' - 'app/controllers/plates_controller.rb' @@ -2019,7 +2030,6 @@ Style/GuardClause: - 'app/models/presenters/grouped_pipeline_inbox_presenter.rb' - 'app/models/pulldown/requests/bait_library_request.rb' - 'app/models/qc_file.rb' - - 'app/models/request.rb' - 'app/models/robot_property.rb' - 'app/models/sample_manifest.rb' - 'app/models/study.rb' @@ -2473,6 +2483,12 @@ Style/SingleArgumentDig: - 'app/heron/factories/sample.rb' - 'spec/requests/api/v2/heron/plates_spec.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/SingleLineDoEndBlock: + Exclude: + - 'spec/models/transfer_request_spec.rb' + # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowModifier. From bc6a11b460a1fa4d5e3e52b33b54bbeca166c921 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 24 Sep 2024 10:08:12 +0100 Subject: [PATCH 117/158] style: repair "easy" cops bundle exec rubocop -a yarn prettier --write . bundle exec rubocop -a --- .rubocop_todo.yml | 166 ------------------ Gemfile | 4 +- app/controllers/admin/studies_controller.rb | 2 +- .../bulk_submissions_controller.rb | 24 ++- app/controllers/studies_controller.rb | 12 +- app/helpers/application_helper.rb | 4 +- app/models/asset_barcode.rb | 4 +- app/models/barcode/format_handlers.rb | 2 +- app/models/map.rb | 6 +- app/models/parsers/bioanalysis_csv_parser.rb | 8 +- app/models/plate/creator_parameters.rb | 2 +- app/models/qc_report.rb | 48 +++-- app/models/qc_result_factory.rb | 2 +- app/models/request.rb | 4 +- app/models/request/change_decision.rb | 14 +- app/models/sequencing_pipeline.rb | 4 +- app/models/study.rb | 8 +- app/models/submission/project_validation.rb | 10 +- app/models/tag_substitution/substitution.rb | 4 +- app/models/user.rb | 2 +- .../api/v2/shared_behaviour/labware.rb | 6 +- .../worksheet/test_worksheet.rb | 2 +- app/views/batches/released.xml.builder | 2 +- app/views/samples/show.xml.builder | 2 +- app/views/studies/show.xml.builder | 19 +- .../support/step_definitions/api_steps.rb | 12 +- .../support/step_definitions/debug_steps.rb | 2 +- .../step_definitions/web_form_steps.rb | 2 +- .../support/step_definitions/web_steps.rb | 2 +- .../support/step_definitions/xml_steps.rb | 2 +- lib/accession/accession/sample.rb | 2 +- lib/eventful_mailer.rb | 12 +- lib/lab_where_client.rb | 2 +- .../label_printer/label/robot_beds.rb | 2 +- lib/manifest_util.rb | 2 +- lib/psd_formatter.rb | 2 +- lib/submission_serializer.rb | 2 +- lib/tasks/limber.rake | 2 +- spec/features/pooling_spec.rb | 12 +- .../lab/stock_stamping_spec.rb | 2 +- spec/models/qc_report_spec.rb | 2 +- spec/models/transfer_request_spec.rb | 4 +- spec/spec_helper.rb | 2 +- test/lib/label_printer/plate_creator_test.rb | 10 +- test/lib/label_printer/plate_to_tube_test.rb | 4 +- test/lib/label_printer/print_job_test.rb | 2 +- .../sample_manifest_multiplex_test.rb | 4 +- .../sample_manifest_plate_test.rb | 6 +- .../sample_manifest_tube_test.rb | 4 +- test/lib/label_printer/shared_tests.rb | 2 +- test/unit/custom_metadatum_collection_test.rb | 6 +- 51 files changed, 144 insertions(+), 323 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index dcddddb54e..ae5a9f3f4c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,14 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. -# Include: **/*.gemfile, **/Gemfile, **/gems.rb -Bundler/OrderedGems: - Exclude: - - 'Gemfile' - # Offense count: 21 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedMethods, AllowedPatterns. @@ -82,12 +74,6 @@ Lint/DuplicateMethods: - 'lib/accession/accession/tag.rb' - 'lib/label_printer/label_printer/label.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Lint/DuplicateRegexpCharacterClassElement: - Exclude: - - 'app/models/barcode/format_handlers.rb' - # Offense count: 66 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: @@ -826,19 +812,6 @@ RSpec/ExampleWording: - 'spec/sequencescape_excel/validation_spec.rb' - 'spec/sequencescape_excel/worksheet_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -RSpec/ExpectActual: - Exclude: - - 'spec/models/qc_report_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: implicit, each, example -RSpec/HookArgument: - Exclude: - - 'spec/spec_helper.rb' # Offense count: 248 # Configuration parameters: AssignmentOnly. @@ -1836,23 +1809,7 @@ Style/ArrayIntersect: Exclude: - 'test/unit/flexible_submission_test.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces -# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object -# FunctionalMethods: let, let!, subject, watch -# AllowedMethods: lambda, proc, it -Style/BlockDelimiters: - Exclude: - - 'spec/models/transfer_request_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowOnConstant, AllowOnSelfClass. -Style/CaseEquality: - Exclude: - - 'app/models/parsers/bioanalysis_csv_parser.rb' # Offense count: 14 Style/ClassVars: @@ -1903,13 +1860,6 @@ Style/EmptyCaseCondition: - 'app/models/request/change_decision.rb' - 'app/models/request_type.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, EnforcedStyle, AllowComments. -# SupportedStyles: empty, nil, both -Style/EmptyElse: - Exclude: - - 'app/controllers/requests/comments_controller.rb' # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). @@ -2132,12 +2082,6 @@ Style/MissingRespondToMissing: - 'lib/informatics/test/helpers/authentication_helper.rb' - 'lib/validateable.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMethodComparison, ComparisonsThreshold. -Style/MultipleComparison: - Exclude: - - 'app/helpers/application_helper.rb' # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). @@ -2167,21 +2111,7 @@ Style/NestedParenthesizedCalls: - 'app/models/parsers/bioanalysis_csv_parser.rb' - 'lib/label_printer/label_printer/pmb_client.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, MinBodyLength. -# SupportedStyles: skip_modifier_ifs, always -Style/Next: - Exclude: - - 'app/views/studies/show.xml.builder' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: predicate, comparison -Style/NilComparison: - Exclude: - - 'app/models/parsers/bioanalysis_csv_parser.rb' # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -2356,84 +2286,6 @@ Style/RedundantArgument: - 'features/support/step_definitions/samples_steps.rb' - 'spec/features/shared_examples/cherrypicking.rb' -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantBegin: - Exclude: - - 'app/controllers/bulk_submissions_controller.rb' - - 'app/controllers/studies_controller.rb' - - 'app/models/qc_report.rb' - - 'app/models/request/change_decision.rb' - - 'app/models/submission/project_validation.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantException: - Exclude: - - 'app/models/request.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantFreeze: - Exclude: - - 'lib/psd_formatter.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantInterpolationUnfreeze: - Exclude: - - 'app/models/tag_substitution/substitution.rb' - -# Offense count: 60 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantParentheses: - Exclude: - - 'app/controllers/admin/studies_controller.rb' - - 'app/models/asset_barcode.rb' - - 'app/models/map.rb' - - 'app/models/parsers/bioanalysis_csv_parser.rb' - - 'app/models/plate/creator_parameters.rb' - - 'app/models/qc_result_factory.rb' - - 'app/models/sequencing_pipeline.rb' - - 'app/models/study.rb' - - 'app/models/user.rb' - - 'app/resources/api/v2/shared_behaviour/labware.rb' - - 'app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb' - - 'app/views/samples/show.xml.builder' - - 'app/views/studies/show.xml.builder' - - 'features/support/step_definitions/debug_steps.rb' - - 'lib/accession/accession/sample.rb' - - 'lib/eventful_mailer.rb' - - 'lib/label_printer/label_printer/label/robot_beds.rb' - - 'lib/manifest_util.rb' - - 'lib/submission_serializer.rb' - - 'lib/tasks/limber.rake' - - 'spec/features/pooling_spec.rb' - - 'spec/features/sample_logistics/lab/stock_stamping_spec.rb' - - 'test/lib/label_printer/plate_creator_test.rb' - - 'test/lib/label_printer/plate_to_tube_test.rb' - - 'test/lib/label_printer/print_job_test.rb' - - 'test/lib/label_printer/sample_manifest_multiplex_test.rb' - - 'test/lib/label_printer/sample_manifest_plate_test.rb' - - 'test/lib/label_printer/sample_manifest_tube_test.rb' - - 'test/lib/label_printer/shared_tests.rb' - - 'test/unit/custom_metadatum_collection_test.rb' - -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantRegexpEscape: - Exclude: - - 'features/support/step_definitions/api_steps.rb' - - 'features/support/step_definitions/web_form_steps.rb' - - 'features/support/step_definitions/web_steps.rb' - - 'features/support/step_definitions/xml_steps.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Exclude: - - 'lib/lab_where_client.rb' # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). @@ -2466,12 +2318,6 @@ Style/SafeNavigation: - 'lib/event_factory.rb' - 'test/unit/qc_report_file_test.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/SelfAssignment: - Exclude: - - 'app/helpers/application_helper.rb' - - 'app/views/batches/released.xml.builder' # Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -2483,11 +2329,6 @@ Style/SingleArgumentDig: - 'app/heron/factories/sample.rb' - 'spec/requests/api/v2/heron/plates_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/SingleLineDoEndBlock: - Exclude: - - 'spec/models/transfer_request_spec.rb' # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). @@ -2600,13 +2441,6 @@ Style/SymbolProc: - 'app/models/tasks/plate_transfer_handler.rb' - 'db/seeds/0001_workflows.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, AllowSafeAssignment. -# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex -Style/TernaryParentheses: - Exclude: - - 'app/models/parsers/bioanalysis_csv_parser.rb' # Offense count: 9 # This cop supports unsafe autocorrection (--autocorrect-all). diff --git a/Gemfile b/Gemfile index ddabb89cad..2c312bb0ba 100644 --- a/Gemfile +++ b/Gemfile @@ -146,12 +146,12 @@ end group :development, :linting do # Enforces coding styles and detects some bad practices gem 'rubocop', require: false + gem 'rubocop-capybara', require: false + gem 'rubocop-factory_bot', require: false gem 'rubocop-performance', require: false gem 'rubocop-rails', require: false gem 'rubocop-rspec', require: false gem 'rubocop-rspec_rails', require: false - gem 'rubocop-capybara', require: false - gem 'rubocop-factory_bot', require: false gem 'prettier_print', require: false gem 'syntax_tree', require: false diff --git a/app/controllers/admin/studies_controller.rb b/app/controllers/admin/studies_controller.rb index c7ed458f2e..06616c4b8d 100644 --- a/app/controllers/admin/studies_controller.rb +++ b/app/controllers/admin/studies_controller.rb @@ -42,7 +42,7 @@ def filter # rubocop:todo Metrics/CyclomaticComplexity unless params[:filter].nil? if params[:filter][:by] == 'unallocated manager' - @studies = Study.select { |p| p.name.include?(params[:q]) && !(p.roles.map(&:name).include?('manager')) } + @studies = Study.select { |p| p.name.include?(params[:q]) && !p.roles.map(&:name).include?('manager') } end end diff --git a/app/controllers/bulk_submissions_controller.rb b/app/controllers/bulk_submissions_controller.rb index 8b524c0630..098dacf7a1 100644 --- a/app/controllers/bulk_submissions_controller.rb +++ b/app/controllers/bulk_submissions_controller.rb @@ -23,21 +23,19 @@ def new # rubocop:todo Metrics/MethodLength def create # rubocop:todo Metrics/AbcSize - begin - @bulk_submission = BulkSubmission.new(params.fetch(:bulk_submission, {})) - if @bulk_submission.valid? - flash.now[:notice] = 'File was processed successfully' - sub_ids, @sub_details = @bulk_submission.completed_submissions - @these_subs = Submission.find(sub_ids) - else - flash.now[:error] = 'There was a problem with your upload' - render action: 'new' - end - rescue ActiveRecord::RecordInvalid => e - flash.now[:error] = 'There was a problem when building your submissions' - @bulk_submission.errors.add(:base, e.message) + @bulk_submission = BulkSubmission.new(params.fetch(:bulk_submission, {})) + if @bulk_submission.valid? + flash.now[:notice] = 'File was processed successfully' + sub_ids, @sub_details = @bulk_submission.completed_submissions + @these_subs = Submission.find(sub_ids) + else + flash.now[:error] = 'There was a problem with your upload' render action: 'new' end + rescue ActiveRecord::RecordInvalid => e + flash.now[:error] = 'There was a problem when building your submissions' + @bulk_submission.errors.add(:base, e.message) + render action: 'new' end # rubocop:enable Metrics/MethodLength diff --git a/app/controllers/studies_controller.rb b/app/controllers/studies_controller.rb index 49afb40407..b5695abb3f 100644 --- a/app/controllers/studies_controller.rb +++ b/app/controllers/studies_controller.rb @@ -370,13 +370,11 @@ def studies_from_scope(scope) # rubocop:todo Metrics/CyclomaticComplexity # rubocop:enable Metrics/AbcSize, Metrics/MethodLength def rescue_validation - begin - yield - rescue ActiveRecord::RecordInvalid - Rails.logger.warn "Failed to update attributes: #{@study.errors.map { |error| error.to_s }}" # rubocop:disable Style/SymbolProc - flash.now[:error] = 'Failed to update attributes for study!' - render action: 'edit', id: @study.id - end + yield + rescue ActiveRecord::RecordInvalid + Rails.logger.warn "Failed to update attributes: #{@study.errors.map { |error| error.to_s }}" # rubocop:disable Style/SymbolProc + flash.now[:error] = 'Failed to update attributes for study!' + render action: 'edit', id: @study.id end end # rubocop:enable Metrics/ClassLength diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0aed9f9530..0b92c65c93 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -253,7 +253,7 @@ def tab_pane(name, id: nil, tab_id: nil, active: false, &) def display_boolean_results(result) return 'NA' if result.blank? - if result == 'pass' || result == '1' || result == 'true' + if %w[pass 1 true].include?(result) icon('far', 'check-circle', title: result) else icon('fas', 'exclamation-circle', class: 'text-danger', title: result) @@ -264,7 +264,7 @@ def sorted_requests_for_search(requests) sorted_requests = requests.select { |r| r.pipeline_id.nil? } new_requests = requests - sorted_requests new_requests.sort_by(&:pipeline_id) - requests = requests + sorted_requests + requests += sorted_requests end # Creates a label that is hidden from the view so that testing is easier diff --git a/app/models/asset_barcode.rb b/app/models/asset_barcode.rb index 18fb5e6301..5bb7be6b32 100644 --- a/app/models/asset_barcode.rb +++ b/app/models/asset_barcode.rb @@ -13,10 +13,10 @@ class AssetBarcode < ApplicationRecord # @note The returned string does NOT include the prefix. # @return [String] The number component of the new barcode in string format. def self.new_barcode(prefix = Tube.default_prefix) - barcode = (AssetBarcode.create!).id + barcode = AssetBarcode.create!.id while Barcode.find_by(barcode: SBCF::SangerBarcode.from_prefix_and_number(prefix, barcode).human_barcode) - barcode = (AssetBarcode.create!).id + barcode = AssetBarcode.create!.id end barcode.to_s diff --git a/app/models/barcode/format_handlers.rb b/app/models/barcode/format_handlers.rb index 59429e8b1c..3ccaad49a3 100644 --- a/app/models/barcode/format_handlers.rb +++ b/app/models/barcode/format_handlers.rb @@ -172,7 +172,7 @@ class Sequencescape22 < BaseRegExBarcode class Infinium < BaseRegExBarcode # Based on ALL existing examples (bar what appears to be accidental usage of the sanger barcode in 5 cases) # eg. WG0000001-DNA and WG0000001-BCD - self.format = /\A(?WG)(?[0-9]{7})-(?[DNA|BCD]{3})\z/ + self.format = /\A(?WG)(?[0-9]{7})-(?[DNA|BC]{3})\z/ end # Fluidigm barcodes are externally generated barcodes present on fluidigm plates. They are ten digits long. diff --git a/app/models/map.rb b/app/models/map.rb index 8248ddc2ce..de6b912a4b 100644 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -99,13 +99,13 @@ def self.plate_length(plate_size) def self.vertical_position_to_description(well_position, length) desc_letter = (((well_position - 1) % length) + 65).chr desc_number = ((well_position - 1) / length) + 1 - (desc_letter + (desc_number.to_s)) + (desc_letter + desc_number.to_s) end def self.horizontal_position_to_description(well_position, width) desc_letter = (((well_position - 1) / width) + 65).chr desc_number = ((well_position - 1) % width) + 1 - (desc_letter + (desc_number.to_s)) + (desc_letter + desc_number.to_s) end def self.horizontal_to_vertical(well_position, plate_size) @@ -147,7 +147,7 @@ def alternate_position(well_position, size, *dimensions) module Sequential def self.location_from_row_and_column(row, column, width, size) digit_count = Math.log10(size + 1).ceil - "S%0#{digit_count}d" % [((row) * width) + column] + "S%0#{digit_count}d" % [(row * width) + column] end def self.location_from_index(index, size) diff --git a/app/models/parsers/bioanalysis_csv_parser.rb b/app/models/parsers/bioanalysis_csv_parser.rb index 33cbe25434..62c06f473e 100644 --- a/app/models/parsers/bioanalysis_csv_parser.rb +++ b/app/models/parsers/bioanalysis_csv_parser.rb @@ -42,7 +42,7 @@ def table_content_hash(group) # rubocop:todo Metrics/AbcSize end def build_range(range) - range = range == nil ? [0, content.length - 1] : range.dup + range = range.nil? ? [0, content.length - 1] : range.dup range.push(content.length - 1) if (range.length == 1) range end @@ -63,7 +63,7 @@ def get_groups(regexp, range = nil) # rubocop:todo Metrics/CyclomaticComplexity group_contents.each_with_index do |line, pos| if line[0].present? && line[0].match(regexp) && group.empty? group.push(pos) - elsif (line.empty? && group.one?) + elsif line.empty? && group.one? group.push(pos - 1) end @@ -71,7 +71,7 @@ def get_groups(regexp, range = nil) # rubocop:todo Metrics/CyclomaticComplexity groups.push [group[0] + range[0], group[1] + range[0]] group = [] end - groups.push [group[0] + range[0], pos + range[0]] if ((group.length == 1) && (pos == (group_contents.length - 1))) + groups.push [group[0] + range[0], pos + range[0]] if (group.length == 1) && (pos == (group_contents.length - 1)) end groups end @@ -115,7 +115,7 @@ def parse_samples groups .each_with_index .map do |group, pos| - next_index = (pos == (groups.length - 1)) ? @content.length - 1 : groups[pos + 1][0] - 1 + next_index = pos == (groups.length - 1) ? @content.length - 1 : groups[pos + 1][0] - 1 [group[0], next_index] end .reduce({}) { |memo, group| memo.merge(parse_sample group) } diff --git a/app/models/plate/creator_parameters.rb b/app/models/plate/creator_parameters.rb index 17c48bb544..3bde66a60b 100644 --- a/app/models/plate/creator_parameters.rb +++ b/app/models/plate/creator_parameters.rb @@ -22,7 +22,7 @@ def plate_dilution_factor(plate) end def params_has_dilution_factor?(params) - (!params[:dilution_factor].nil?) && (!params[:dilution_factor].to_s.empty?) + !params[:dilution_factor].nil? && !params[:dilution_factor].to_s.empty? end def plate_parameters(_plate, parent_plate = nil) # rubocop:todo Metrics/MethodLength diff --git a/app/models/qc_report.rb b/app/models/qc_report.rb index 4e15876b3b..ae151675e5 100644 --- a/app/models/qc_report.rb +++ b/app/models/qc_report.rb @@ -82,34 +82,32 @@ module ReportBehaviour # You can trigger a synchronous report manually by calling #generate! # rubocop:todo Metrics/MethodLength def generate_report # rubocop:todo Metrics/AbcSize - begin - study.each_well_for_qc_report_in_batches( - exclude_existing, - product_criteria, - (plate_purposes.empty? ? nil : plate_purposes) - ) do |assets| - # If there are some wells of interest, we get them in a list - connected_wells = Well.hash_stock_with_targets(assets, product_criteria.target_plate_purposes) - - # This transaction is inside the block as otherwise large reports experience issues - # with high memory usage. In the event that an exception is raised the most - # recent set of decisions will be rolled back, and the report will be re-queued. - # The rescue event clears out the remaining metrics, this avoids the risk of duplicate - # metric on complete reports (Although wont help if, say, the database connection fails) - ActiveRecord::Base.transaction do - assets.each do |asset| - criteria = product_criteria.assess(asset, connected_wells[asset.id]) - QcMetric.create!(asset:, qc_decision: criteria.qc_decision, metrics: criteria.metrics, qc_report: self) - end + study.each_well_for_qc_report_in_batches( + exclude_existing, + product_criteria, + (plate_purposes.empty? ? nil : plate_purposes) + ) do |assets| + # If there are some wells of interest, we get them in a list + connected_wells = Well.hash_stock_with_targets(assets, product_criteria.target_plate_purposes) + + # This transaction is inside the block as otherwise large reports experience issues + # with high memory usage. In the event that an exception is raised the most + # recent set of decisions will be rolled back, and the report will be re-queued. + # The rescue event clears out the remaining metrics, this avoids the risk of duplicate + # metric on complete reports (Although wont help if, say, the database connection fails) + ActiveRecord::Base.transaction do + assets.each do |asset| + criteria = product_criteria.assess(asset, connected_wells[asset.id]) + QcMetric.create!(asset:, qc_decision: criteria.qc_decision, metrics: criteria.metrics, qc_report: self) end end - generation_complete! - rescue => e - # If something goes wrong, requeue the report and re-raise the exception - qc_metrics.clear - requeue! - raise e end + generation_complete! + rescue => e + # If something goes wrong, requeue the report and re-raise the exception + qc_metrics.clear + requeue! + raise e end # rubocop:enable Metrics/MethodLength diff --git a/app/models/qc_result_factory.rb b/app/models/qc_result_factory.rb index fe5237c59e..bfcddfcbe8 100644 --- a/app/models/qc_result_factory.rb +++ b/app/models/qc_result_factory.rb @@ -63,7 +63,7 @@ def initialize(attributes = {}) end def message_id - "Asset identifier - #{(asset_identifier || 'blank')}" + "Asset identifier - #{asset_identifier || 'blank'}" end def parent_plate diff --git a/app/models/request.rb b/app/models/request.rb index 79be045ba3..a55884b01c 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -366,7 +366,7 @@ def current_request_event end def project_id=(project_id) - raise RuntimeError, 'Initial project already set' if initial_project_id + raise 'Initial project already set' if initial_project_id self.initial_project_id = project_id end @@ -386,7 +386,7 @@ def project=(project) end def study_id=(study_id) - raise RuntimeError, 'Initial study already set' if initial_study_id + raise 'Initial study already set' if initial_study_id self.initial_study_id = study_id end diff --git a/app/models/request/change_decision.rb b/app/models/request/change_decision.rb index 2ad3a401ce..f8f039553c 100644 --- a/app/models/request/change_decision.rb +++ b/app/models/request/change_decision.rb @@ -57,15 +57,13 @@ def execute! private def perform_decision_change! - begin - ActiveRecord::Base.transaction do - perform_decision_change_request_state! if state_change? - perform_decision_change_asset_qc_state! unless asset_qc_state_absent? - end - rescue ActiveRecord::RecordInvalid => e - reload_objects - raise InvalidDecision, self + ActiveRecord::Base.transaction do + perform_decision_change_request_state! if state_change? + perform_decision_change_asset_qc_state! unless asset_qc_state_absent? end + rescue ActiveRecord::RecordInvalid => e + reload_objects + raise InvalidDecision, self end def reload_objects diff --git a/app/models/sequencing_pipeline.rb b/app/models/sequencing_pipeline.rb index 095e0bc15f..64d922ce5e 100644 --- a/app/models/sequencing_pipeline.rb +++ b/app/models/sequencing_pipeline.rb @@ -16,7 +16,7 @@ def request_actions end def is_read_length_consistent_for_batch?(batch) # rubocop:todo Metrics/AbcSize - if (batch.requests.size == 0) || (batch.requests.first.request_metadata.nil?) + if (batch.requests.size == 0) || batch.requests.first.request_metadata.nil? # No requests selected or the pipeline doesn't contain metadata to check return true end @@ -33,7 +33,7 @@ def is_read_length_consistent_for_batch?(batch) # rubocop:todo Metrics/AbcSize end def is_flowcell_type_consistent_for_batch?(batch) # rubocop:todo Metrics/AbcSize - if (batch.requests.size == 0) || (batch.requests.first.request_metadata.nil?) + if (batch.requests.size == 0) || batch.requests.first.request_metadata.nil? # No requests selected or the pipeline doesn't contain metadata to check return true end diff --git a/app/models/study.rb b/app/models/study.rb index 15bb2d513a..d28cd044b0 100644 --- a/app/models/study.rb +++ b/app/models/study.rb @@ -517,10 +517,8 @@ def approved? end def ethical_approval_required? - ( - study_metadata.contains_human_dna == Study::YES && study_metadata.contaminated_human_dna == Study::NO && - study_metadata.commercially_available == Study::NO - ) + study_metadata.contains_human_dna == Study::YES && study_metadata.contaminated_human_dna == Study::NO && + study_metadata.commercially_available == Study::NO end def accession_service @@ -535,7 +533,7 @@ def accession_service end def send_samples_to_service? - accession_service.no_study_accession_needed || ((!study_metadata.never_release?) && accession_number?) + accession_service.no_study_accession_needed || (!study_metadata.never_release? && accession_number?) end def validate_ena_required_fields! diff --git a/app/models/submission/project_validation.rb b/app/models/submission/project_validation.rb index cf45681a21..16814b94ed 100644 --- a/app/models/submission/project_validation.rb +++ b/app/models/submission/project_validation.rb @@ -45,12 +45,10 @@ def multiplier_for(request_type) private :multiplier_for def submittable? - begin - @checking_project = true - valid? - ensure - @checking_project = false - end + @checking_project = true + valid? + ensure + @checking_project = false end # Hack to be able to build order diff --git a/app/models/tag_substitution/substitution.rb b/app/models/tag_substitution/substitution.rb index 82d39165b1..108b13bb72 100644 --- a/app/models/tag_substitution/substitution.rb +++ b/app/models/tag_substitution/substitution.rb @@ -124,10 +124,10 @@ def substitute_tags # @param oligo_index [Hash] A hash of oligo sequences indexed by oligo id. # # @return [String] A description of the substitution - def comment(oligo_index) # rubocop:todo Metrics/AbcSize + def comment(oligo_index) return '' unless updated? - comment = +"Sample #{sample_id}:" + comment = "Sample #{sample_id}:" if substitute_tag? comment << " Tag changed from #{oligo_index[original_tag_id]} to #{oligo_index[substitute_tag_id]};" end diff --git a/app/models/user.rb b/app/models/user.rb index 4663d0e643..d6a19f5c17 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -93,7 +93,7 @@ def study_and_project_roles end def logout_path - configatron.authentication == 'sanger-sso' ? (configatron.sso_logout_url).to_s : '/logout' + configatron.authentication == 'sanger-sso' ? configatron.sso_logout_url.to_s : '/logout' end def profile_incomplete? diff --git a/app/resources/api/v2/shared_behaviour/labware.rb b/app/resources/api/v2/shared_behaviour/labware.rb index 6f0858fa1d..5ad2156de4 100644 --- a/app/resources/api/v2/shared_behaviour/labware.rb +++ b/app/resources/api/v2/shared_behaviour/labware.rb @@ -57,11 +57,9 @@ module Labware filter :purpose_id, apply: ->(records, value, _options) { records.where(plate_purpose_id: value) } filter :without_children, apply: ->(records, _value, _options) { records.without_children } filter :created_at_gt, - apply: - (lambda { |records, value, _options| records.where('labware.created_at > ?', value[0].to_date) }) + apply: lambda { |records, value, _options| records.where('labware.created_at > ?', value[0].to_date) } filter :updated_at_gt, - apply: - (lambda { |records, value, _options| records.where('labware.updated_at > ?', value[0].to_date) }) + apply: lambda { |records, value, _options| records.where('labware.updated_at > ?', value[0].to_date) } filter :include_used, apply: ->(records, value, _options) { records.include_labware_with_children(value) } end diff --git a/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb b/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb index deeb1ae204..5c53de9ffc 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb @@ -236,7 +236,7 @@ def add_data # rubocop:todo Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/AbcSize def add_cell_data(column, row_num, partial) # rubocop:todo Metrics/CyclomaticComplexity if partial && empty_row?(row_num) - (data[column.name] || dynamic_attributes[row_num][column.name]) unless empty_columns.include?(column.name) + data[column.name] || dynamic_attributes[row_num][column.name] unless empty_columns.include?(column.name) elsif validation_errors.include?(:insert_size_from) && column.name == 'insert_size_from' && row_num == computed_first_row nil diff --git a/app/views/batches/released.xml.builder b/app/views/batches/released.xml.builder index 8a764a2bb1..dbaeda68ad 100644 --- a/app/views/batches/released.xml.builder +++ b/app/views/batches/released.xml.builder @@ -7,7 +7,7 @@ xml.batches do |batches| batch.lanes do |lanes| count = 0 b.items.ordered.each do |item| - count = count + 1 + count += 1 lanes.lane('position' => count) do |lane| if item.resource? lane.control('id' => item.ident, 'name' => item.name, 'request_id' => item.request) diff --git a/app/views/samples/show.xml.builder b/app/views/samples/show.xml.builder index e3480fb9f8..dcf2fb68ee 100644 --- a/app/views/samples/show.xml.builder +++ b/app/views/samples/show.xml.builder @@ -28,7 +28,7 @@ xml.sample(api_data) do xml.property do # NOTE: The display text is targeted at HTML, so contains escaped entities, which we must unescape for XML. xml.name(REXML::Text.unnormalize(attribute.to_field_info.display_name)) - if (attribute.to_field_info.display_name == 'Reference Genome') && (value.blank?) + if (attribute.to_field_info.display_name == 'Reference Genome') && value.blank? xml.value(nil) else xml.value(value) diff --git a/app/views/studies/show.xml.builder b/app/views/studies/show.xml.builder index 0cc8551463..41e5ab6358 100644 --- a/app/views/studies/show.xml.builder +++ b/app/views/studies/show.xml.builder @@ -8,15 +8,14 @@ xml.study(api_data) do |study| %w[followers managers owners].each do |type_of_user| users, singular_user = @study.send(type_of_user), type_of_user.singularize - unless users.empty? - study.tag!(type_of_user) do |users_tag| - users.each do |user| - users_tag.tag!(singular_user) do |user_tag| - user_tag.login(user.login) - user_tag.email(user.email) - user_tag.name(user.name) - user_tag.id(user.id) - end + next if users.empty? + study.tag!(type_of_user) do |users_tag| + users.each do |user| + users_tag.tag!(singular_user) do |user_tag| + user_tag.login(user.login) + user_tag.email(user.email) + user_tag.name(user.name) + user_tag.id(user.id) end end end @@ -38,7 +37,7 @@ xml.study(api_data) do |study| @study.study_metadata.association_value_pairs.each do |attribute, value| descriptors.descriptor do |descriptor| descriptor.name(attribute.to_field_info.display_name) - if (attribute.to_field_info.display_name == 'Reference Genome') && (value.blank?) + if (attribute.to_field_info.display_name == 'Reference Genome') && value.blank? descriptor.value(nil) else descriptor.value(value) diff --git a/features/support/step_definitions/api_steps.rb b/features/support/step_definitions/api_steps.rb index 6c1d44e120..fd4c1e6a01 100644 --- a/features/support/step_definitions/api_steps.rb +++ b/features/support/step_definitions/api_steps.rb @@ -92,28 +92,28 @@ def api_request(action, path, body) # rubocop:todo Metrics/AbcSize step("I am using version \"#{Core::Service::API_VERSION}\" of the API") end -When %r{^I (GET|PUT|POST|DELETE) the API path "(\/[^"]*)"$} do |action, path| +When %r{^I (GET|PUT|POST|DELETE) the API path "(/[^"]*)"$} do |action, path| api_request(action, path, nil) end -When %r{^I (POST|PUT) the following JSON to the API path "(\/[^"]*)":$} do |action, path, serialized_json| +When %r{^I (POST|PUT) the following JSON to the API path "(/[^"]*)":$} do |action, path, serialized_json| api_request(action, path, serialized_json) end -When %r{^I GET the "([^"]+)" from the API path "(\/[^"]*)"$} do |content_type, path| +When %r{^I GET the "([^"]+)" from the API path "(/[^"]*)"$} do |content_type, path| api_request('GET', path, nil) { |headers| headers.merge!('HTTP_ACCEPT' => content_type) } end -When %r{^I (POST|PUT) the following "([^"]+)" to the API path "(\/[^"]*)":$} do |action, content_type, path, body| +When %r{^I (POST|PUT) the following "([^"]+)" to the API path "(/[^"]*)":$} do |action, content_type, path, body| api_request(action, path, body) { |headers| headers.merge!('CONTENT_TYPE' => content_type) } end -When %r{^I make an authorised (GET|DELETE) (?:(?:for|of) )?the API path "(\/[^"]*)"$} do |action, path| +When %r{^I make an authorised (GET|DELETE) (?:(?:for|of) )?the API path "(/[^"]*)"$} do |action, path| api_request(action, path, nil) { |headers| headers['HTTP_X_SEQUENCESCAPE_CLIENT_ID'] = 'cucumber' } end # rubocop:todo Layout/LineLength -When %r{^I make an authorised (POST|PUT) with the following JSON to the API path "(\/[^"]*)":$} do |action, path, serialized_json| +When %r{^I make an authorised (POST|PUT) with the following JSON to the API path "(/[^"]*)":$} do |action, path, serialized_json| # rubocop:enable Layout/LineLength api_request(action, path, serialized_json) { |headers| headers['HTTP_X_SEQUENCESCAPE_CLIENT_ID'] = 'cucumber' } end diff --git a/features/support/step_definitions/debug_steps.rb b/features/support/step_definitions/debug_steps.rb index 8370928c08..d4d9015cff 100644 --- a/features/support/step_definitions/debug_steps.rb +++ b/features/support/step_definitions/debug_steps.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Then /^log "([^"]+)" for debugging$/ do |message| - Rails.logger.debug("#{('=' * 19)} #{message} #{('=' * 19)}") + Rails.logger.debug("#{'=' * 19} #{message} #{'=' * 19}") end Then /^launch the debugger$/ do diff --git a/features/support/step_definitions/web_form_steps.rb b/features/support/step_definitions/web_form_steps.rb index 512f7557ed..a4ae33933d 100644 --- a/features/support/step_definitions/web_form_steps.rb +++ b/features/support/step_definitions/web_form_steps.rb @@ -72,7 +72,7 @@ def locate_labeled_field_type(label_text, field_type) # rubocop:todo Metrics/Cyc end # rubocop:todo Layout/LineLength -Then %r{^I should see the (required )?select field "([^"]+)" with options "([^"]+(?:\/[^"]+)+)"$} do |required, field, options| +Then %r{^I should see the (required )?select field "([^"]+)" with options "([^"]+(?:/[^"]+)+)"$} do |required, field, options| # rubocop:enable Layout/LineLength assert_label_exists(field, required) element = locate_labeled_field_type(field, 'select') diff --git a/features/support/step_definitions/web_steps.rb b/features/support/step_definitions/web_steps.rb index 455722d372..a520831f5c 100644 --- a/features/support/step_definitions/web_steps.rb +++ b/features/support/step_definitions/web_steps.rb @@ -98,7 +98,7 @@ def with_scope(locator) with_scope(selector) { expect(page).not_to have_text(text) } end -Then %r{^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$} do |regexp, selector| +Then %r{^(?:|I )should not see /([^\/]*)/(?: within "([^"]*)")?$} do |regexp, selector| regexp = Regexp.new(regexp) with_scope(selector) { assert page.has_no_xpath?('//*', text: regexp) } end diff --git a/features/support/step_definitions/xml_steps.rb b/features/support/step_definitions/xml_steps.rb index d0662b1454..bf2c6cb904 100644 --- a/features/support/step_definitions/xml_steps.rb +++ b/features/support/step_definitions/xml_steps.rb @@ -49,7 +49,7 @@ def assert_xml_strings_equal(str1, str2) page.driver.get(path_to(page_name), nil, 'HTTP_ACCEPT' => 'application/xml') end -When %r{^I (POST|PUT) the following XML to "(\/[^"]+)":$} do |action, path, xml| +When %r{^I (POST|PUT) the following XML to "(/[^"]+)":$} do |action, path, xml| page.driver.send( action.downcase, path.to_s, diff --git a/lib/accession/accession/sample.rb b/lib/accession/accession/sample.rb index dd5e1924e0..72549ca54a 100644 --- a/lib/accession/accession/sample.rb +++ b/lib/accession/accession/sample.rb @@ -36,7 +36,7 @@ def name end def title - @title ||= (sample.sample_metadata.sample_public_name || sample.sanger_sample_id) + @title ||= sample.sample_metadata.sample_public_name || sample.sanger_sample_id end # rubocop:todo Metrics/MethodLength diff --git a/lib/eventful_mailer.rb b/lib/eventful_mailer.rb index d9b4d20526..aa105d6858 100644 --- a/lib/eventful_mailer.rb +++ b/lib/eventful_mailer.rb @@ -6,7 +6,7 @@ def confirm_event(receiver, eventful, message, content, _milestone, sent_at = Ti @message = message @content = content mail( - from: (configatron.sequencescape_email).to_s, + from: configatron.sequencescape_email.to_s, subject: "#{configatron.mail_prefix} #{eventful.class} #{eventful.id}: #{message}", bcc: receiver, sent_on: sent_at @@ -20,7 +20,7 @@ def update_event(receiver, study, title, content, sent_at = Time.zone.now) @message = title @content = content mail( - from: (configatron.sequencescape_email).to_s, + from: configatron.sequencescape_email.to_s, subject: "#{configatron.mail_prefix} Study #{study.id}: #{title}", bcc: receiver, sent_on: sent_at @@ -34,7 +34,7 @@ def confirm_sample_event(receiver, eventful, message, content, _milestone, sent_ @message = message @content = content mail( - from: (configatron.sequencescape_email).to_s, + from: configatron.sequencescape_email.to_s, subject: "#{configatron.mail_prefix} #{eventful.class} #{eventful.id}: #{message}", bcc: receiver, sent_on: sent_at @@ -46,7 +46,7 @@ def notify_request_fail(receiver, item, request, message, sent_at = Time.zone.no @request = request @message = message mail( - from: (configatron.sequencescape_email).to_s, + from: configatron.sequencescape_email.to_s, subject: "#{configatron.mail_prefix} Request failure for item #{item.id}", bcc: receiver, sent_on: sent_at @@ -56,7 +56,7 @@ def notify_request_fail(receiver, item, request, message, sent_at = Time.zone.no def fail_attempt(receiver, request, sent_at = Time.zone.now) @request = request mail( - from: (configatron.sequencescape_email).to_s, + from: configatron.sequencescape_email.to_s, subject: "#{configatron.mail_prefix} Attempt fail for #{request.id}", bcc: receiver, sent_on: sent_at @@ -70,7 +70,7 @@ def confirm_external_release_event(receiver, eventful, message, content, _milest @message = message @content = content mail( - from: (configatron.sequencescape_email).to_s, + from: configatron.sequencescape_email.to_s, subject: "#{configatron.mail_prefix} #{eventful.class} #{eventful.id}: #{message}", bcc: receiver, sent_on: sent_at diff --git a/lib/lab_where_client.rb b/lib/lab_where_client.rb index 774d3278f2..65f1b54aa1 100644 --- a/lib/lab_where_client.rb +++ b/lib/lab_where_client.rb @@ -34,7 +34,7 @@ def post(instance, target, payload) rescue Errno::ECONNREFUSED, RestClient::NotFound => e raise LabwhereException.new(e), 'LabWhere service is down', e.backtrace rescue RestClient::UnprocessableEntity => e - return parse_json(e.response) + parse_json(e.response) end def put(instance, target, payload) diff --git a/lib/label_printer/label_printer/label/robot_beds.rb b/lib/label_printer/label_printer/label/robot_beds.rb index f2558c2cd5..5393e343ed 100644 --- a/lib/label_printer/label_printer/label/robot_beds.rb +++ b/lib/label_printer/label_printer/label/robot_beds.rb @@ -13,7 +13,7 @@ def top_right(bed) end def bottom_right(bed) - (bed.ean13_barcode).to_s + bed.ean13_barcode.to_s end end end diff --git a/lib/manifest_util.rb b/lib/manifest_util.rb index e810d7a622..efecc71f60 100644 --- a/lib/manifest_util.rb +++ b/lib/manifest_util.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module ManifestUtil def is_end_of_header?(row, pos) - ((pos != (row.length - 1)) && row[pos].blank? && row[pos + 1].blank?) + (pos != (row.length - 1)) && row[pos].blank? && row[pos + 1].blank? end def filter_end_of_header(header_row) diff --git a/lib/psd_formatter.rb b/lib/psd_formatter.rb index 4d661bdf6d..ca93e7a8dd 100644 --- a/lib/psd_formatter.rb +++ b/lib/psd_formatter.rb @@ -4,7 +4,7 @@ require 'ostruct' class PsdFormatter < Syslog::Logger::Formatter - LINE_FORMAT = "(thread-%s) [%s] %5s -- : %s\n".freeze + LINE_FORMAT = "(thread-%s) [%s] %5s -- : %s\n" def initialize(deployment_info) # below line is included because it was unknown whether diff --git a/lib/submission_serializer.rb b/lib/submission_serializer.rb index 8fdf5716e3..9bc81ba9e6 100644 --- a/lib/submission_serializer.rb +++ b/lib/submission_serializer.rb @@ -85,7 +85,7 @@ def self.construct!(hash) # rubocop:todo Metrics/CyclomaticComplexity end sp[:request_type_ids_list] = ensp[:request_types].map do |rtk| - [(RequestType.find_by(key: rtk).try(:id) || raise(StandardError, "Could not find #{rtk}"))] + [RequestType.find_by(key: rtk).try(:id) || raise(StandardError, "Could not find #{rtk}")] end sp[:order_role_id] = OrderRole.find_or_create_by(role: ensp[:order_role]).id if ensp[:order_role] diff --git a/lib/tasks/limber.rake b/lib/tasks/limber.rake index fb0dabac6f..d0511d2f74 100644 --- a/lib/tasks/limber.rake +++ b/lib/tasks/limber.rake @@ -138,7 +138,7 @@ namespace :limber do # rubocop:todo Metrics/BlockLength ActiveRecord::Base.transaction do st_params.each do |prefix, params| - catalogue_name = (params[:catalogue_name] || prefix) + catalogue_name = params[:catalogue_name] || prefix catalogue = ProductCatalogue.create_with(selection_behaviour: 'SingleProduct').find_or_create_by!(name: catalogue_name) Limber::Helper::TemplateConstructor.new(prefix:, catalogue:, sequencing_keys: params[:sequencing_list]).build! diff --git a/spec/features/pooling_spec.rb b/spec/features/pooling_spec.rb index 3b59d8bad4..ca91ab56f4 100644 --- a/spec/features/pooling_spec.rb +++ b/spec/features/pooling_spec.rb @@ -23,10 +23,10 @@ expect(page).to have_content 'Source assets were not scanned or were not found in Sequencescape' fill_in('asset_scan', with: '1234567890123').send_keys(:return) expect(find('.barcode_list')).to have_content '1234567890123' - fill_in('asset_scan', with: (empty_lb_tube1.ean13_barcode).to_s).send_keys(:return) - fill_in('asset_scan', with: (empty_lb_tube2.ean13_barcode).to_s).send_keys(:return) - fill_in('asset_scan', with: (untagged_lb_tube1.ean13_barcode).to_s).send_keys(:return) - fill_in('asset_scan', with: (untagged_lb_tube2.ean13_barcode).to_s).send_keys(:return) + fill_in('asset_scan', with: empty_lb_tube1.ean13_barcode.to_s).send_keys(:return) + fill_in('asset_scan', with: empty_lb_tube2.ean13_barcode.to_s).send_keys(:return) + fill_in('asset_scan', with: untagged_lb_tube1.ean13_barcode.to_s).send_keys(:return) + fill_in('asset_scan', with: untagged_lb_tube2.ean13_barcode.to_s).send_keys(:return) click_on 'Transfer' expect(page).to have_content 'Source assets with barcode(s) 1234567890123 were not found in Sequencescape' @@ -54,8 +54,8 @@ first('a', text: 'Remove from list').click first('a', text: 'Remove from list').click expect(page).to have_content 'Scanned: 1' - fill_in('asset_scan', with: (tagged_lb_tube1.ean13_barcode).to_s).send_keys(:return) - fill_in('asset_scan', with: (tagged_lb_tube2.ean13_barcode).to_s).send_keys(:return) + fill_in('asset_scan', with: tagged_lb_tube1.ean13_barcode.to_s).send_keys(:return) + fill_in('asset_scan', with: tagged_lb_tube2.ean13_barcode.to_s).send_keys(:return) check 'Create stock multiplexed tube' click_on 'Transfer' expect(page).to have_content 'Samples were transferred successfully' diff --git a/spec/features/sample_logistics/lab/stock_stamping_spec.rb b/spec/features/sample_logistics/lab/stock_stamping_spec.rb index e0d6fdfa40..7cb038a96c 100644 --- a/spec/features/sample_logistics/lab/stock_stamping_spec.rb +++ b/spec/features/sample_logistics/lab/stock_stamping_spec.rb @@ -40,7 +40,7 @@ click_button 'Generate TECAN file' expect(page).to have_content('Stamping of stock') - select((barcode_printer.name).to_s, from: 'barcode_printer_list') + select(barcode_printer.name.to_s, from: 'barcode_printer_list') click_button 'Print label' expect(page).to have_content('Printmybarcode service is down') diff --git a/spec/models/qc_report_spec.rb b/spec/models/qc_report_spec.rb index a6e17582c7..106e027a8d 100644 --- a/spec/models/qc_report_spec.rb +++ b/spec/models/qc_report_spec.rb @@ -53,7 +53,7 @@ qc_report.qc_metrics.each do |metric| expect(metric.qc_decision).to eq('passed') expect(metric.proceed).to be_nil - expect(total_micrograms: 100, comment: '', sanger_sample_id: 'TEST1').to eq(metric.metrics) + expect(metric.metrics).to eq(total_micrograms: 100, comment: '', sanger_sample_id: 'TEST1') end end end diff --git a/spec/models/transfer_request_spec.rb b/spec/models/transfer_request_spec.rb index f6640d201e..bbfdc5080a 100644 --- a/spec/models/transfer_request_spec.rb +++ b/spec/models/transfer_request_spec.rb @@ -252,7 +252,9 @@ let!(:target_asset) { create :well, aliquots: [aliquot_1] } it 'raises an exception' do - expect do described_class.create!(asset: aliquot_2.receptacle.reload, target_asset:) end.to raise_error( + expect do + described_class.create!(asset: aliquot_2.receptacle.reload, target_asset:) +end.to raise_error( Aliquot::TagClash ) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b99d202beb..a080a1c64a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -88,7 +88,7 @@ DatabaseCleaner.clean_with(:truncation) end - config.around(:each) { |example| DatabaseCleaner.cleaning { example.run } } + config.around { |example| DatabaseCleaner.cleaning { example.run } } # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest diff --git a/test/lib/label_printer/plate_creator_test.rb b/test/lib/label_printer/plate_creator_test.rb index 99d4e2592a..f99f00e3d2 100644 --- a/test/lib/label_printer/plate_creator_test.rb +++ b/test/lib/label_printer/plate_creator_test.rb @@ -39,11 +39,11 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength options = { plate_purpose:, plates:, user_login: user } @plate_label = LabelPrinter::Label::PlateCreator.new(options) @label = { - top_left: (Date.today.strftime('%e-%^b-%Y')).to_s, - bottom_left: (plate1.human_barcode).to_s, - top_right: (purpose_name).to_s, + top_left: Date.today.strftime('%e-%^b-%Y').to_s, + bottom_left: plate1.human_barcode.to_s, + top_right: purpose_name.to_s, bottom_right: "#{user} #{study_abbreviation}", - top_far_right: (parent_barcode).to_s, + top_far_right: parent_barcode.to_s, barcode: plate1.machine_barcode, label_name: 'main_label' } @@ -56,6 +56,6 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength test 'should return the correct specific values' do assert_equal purpose_name, plate_label.top_right(plate1) assert_equal "#{user} #{study_abbreviation}", plate_label.bottom_right(plate1) - assert_equal (parent_barcode).to_s, plate_label.top_far_right(plate1) + assert_equal parent_barcode.to_s, plate_label.top_far_right(plate1) end end diff --git a/test/lib/label_printer/plate_to_tube_test.rb b/test/lib/label_printer/plate_to_tube_test.rb index d17311aeda..f9b775aefc 100644 --- a/test/lib/label_printer/plate_to_tube_test.rb +++ b/test/lib/label_printer/plate_to_tube_test.rb @@ -18,9 +18,9 @@ def setup # rubocop:todo Metrics/AbcSize options = { sample_tubes: } @tube_label = LabelPrinter::Label::PlateToTubes.new(options) @label = { - first_line: (asset_name).to_s, + first_line: asset_name.to_s, second_line: barcode1, - third_line: (Date.today.strftime('%e-%^b-%Y')).to_s, + third_line: Date.today.strftime('%e-%^b-%Y').to_s, round_label_top_line: prefix, round_label_bottom_line: barcode1, barcode: tube1.machine_barcode, diff --git a/test/lib/label_printer/print_job_test.rb b/test/lib/label_printer/print_job_test.rb index 063223c7bf..6013187aec 100644 --- a/test/lib/label_printer/print_job_test.rb +++ b/test/lib/label_printer/print_job_test.rb @@ -20,7 +20,7 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength @label_template_name = barcode_printer.barcode_printer_type.label_template_name @labels_attributes = [ { - top_left: (Date.today.strftime('%e-%^b-%Y')).to_s, + top_left: Date.today.strftime('%e-%^b-%Y').to_s, bottom_left: plate.human_barcode.to_s, top_right: plate_purpose.name.to_s, bottom_right: 'user WTCCC', diff --git a/test/lib/label_printer/sample_manifest_multiplex_test.rb b/test/lib/label_printer/sample_manifest_multiplex_test.rb index 53a2b01e3d..a2af73cb14 100644 --- a/test/lib/label_printer/sample_manifest_multiplex_test.rb +++ b/test/lib/label_printer/sample_manifest_multiplex_test.rb @@ -22,9 +22,9 @@ def setup # rubocop:todo Metrics/AbcSize @tube_label = LabelPrinter::Label::SampleManifestMultiplex.new(options) @label = { - first_line: (study_abbreviation).to_s, + first_line: study_abbreviation.to_s, second_line: barcode1, - third_line: (Date.today.strftime('%e-%^b-%Y')).to_s, + third_line: Date.today.strftime('%e-%^b-%Y').to_s, round_label_top_line: prefix, round_label_bottom_line: barcode1, barcode: tube1.machine_barcode, diff --git a/test/lib/label_printer/sample_manifest_plate_test.rb b/test/lib/label_printer/sample_manifest_plate_test.rb index d7985c3b94..8881b6ce87 100644 --- a/test/lib/label_printer/sample_manifest_plate_test.rb +++ b/test/lib/label_printer/sample_manifest_plate_test.rb @@ -35,12 +35,12 @@ class SampleManifestPlateTest < ActiveSupport::TestCase options = { sample_manifest: manifest, only_first_label: false, purpose: @purpose } @plate_label = LabelPrinter::Label::SampleManifestPlate.new(options) @label = { - top_left: (Date.today.strftime('%e-%^b-%Y')).to_s, - bottom_left: (plate1.human_barcode).to_s, + top_left: Date.today.strftime('%e-%^b-%Y').to_s, + bottom_left: plate1.human_barcode.to_s, top_right: purpose.name, bottom_right: "#{study_abbreviation} #{barcode1}", top_far_right: nil, - barcode: (plate1.machine_barcode).to_s, + barcode: plate1.machine_barcode.to_s, label_name: 'main_label' } end diff --git a/test/lib/label_printer/sample_manifest_tube_test.rb b/test/lib/label_printer/sample_manifest_tube_test.rb index 567d4cbcf0..92f3ac423f 100644 --- a/test/lib/label_printer/sample_manifest_tube_test.rb +++ b/test/lib/label_printer/sample_manifest_tube_test.rb @@ -22,9 +22,9 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength options = { sample_manifest: @manifest, only_first_label: false } @tube_label = LabelPrinter::Label::SampleManifestTube.new(options) @label = { - first_line: (manifest.study.abbreviation).to_s, + first_line: manifest.study.abbreviation.to_s, second_line: barcode1, - third_line: (Date.today.strftime('%e-%^b-%Y')).to_s, + third_line: Date.today.strftime('%e-%^b-%Y').to_s, round_label_top_line: prefix, round_label_bottom_line: barcode1, barcode: tube1.machine_barcode, diff --git a/test/lib/label_printer/shared_tests.rb b/test/lib/label_printer/shared_tests.rb index 5f106e1c9a..778cb93a2c 100644 --- a/test/lib/label_printer/shared_tests.rb +++ b/test/lib/label_printer/shared_tests.rb @@ -7,7 +7,7 @@ module SharedTubeTests def self.included(base) # rubocop:todo Metrics/AbcSize base.class_eval do test 'should return the correct values' do - assert_equal (barcode1).to_s, tube_label.second_line(tube1) + assert_equal barcode1.to_s, tube_label.second_line(tube1) assert_equal prefix, tube_label.round_label_top_line(tube1) assert_equal barcode1, tube_label.round_label_bottom_line(tube1) assert_match barcode1, tube_label.barcode(tube1) diff --git a/test/unit/custom_metadatum_collection_test.rb b/test/unit/custom_metadatum_collection_test.rb index b05569e424..b9b6dc6507 100644 --- a/test/unit/custom_metadatum_collection_test.rb +++ b/test/unit/custom_metadatum_collection_test.rb @@ -13,13 +13,13 @@ class CustomMetadatumCollectionTest < ActiveSupport::TestCase test 'should be able to create metadata' do custom_metadatum_collection = - create(:custom_metadatum_collection, metadata: ({ 'Key1' => 'Value1', 'Key2' => 'Value2' })) + create(:custom_metadatum_collection, metadata: { 'Key1' => 'Value1', 'Key2' => 'Value2' }) assert_equal 2, custom_metadatum_collection.custom_metadata.length assert_equal 'Key1', custom_metadatum_collection.custom_metadata.first.key end test 'should be able to create metadata and check if it is valid' do - custom_metadatum_collection = build(:custom_metadatum_collection, metadata: ({ 'Key1' => 'Value1', 'Key2' => '' })) + custom_metadatum_collection = build(:custom_metadatum_collection, metadata: { 'Key1' => 'Value1', 'Key2' => '' }) assert_not custom_metadatum_collection.valid? end @@ -31,7 +31,7 @@ class CustomMetadatumCollectionTest < ActiveSupport::TestCase test 'should update metadata' do custom_metadatum_collection = - create(:custom_metadatum_collection, metadata: ({ 'Key1' => 'Value1', 'Key2' => 'Value2' })) + create(:custom_metadatum_collection, metadata: { 'Key1' => 'Value1', 'Key2' => 'Value2' }) custom_metadatum_collection.update(metadata: { 'Key1' => 'New value', 'Key3' => 'Value3' }) assert_equal 2, custom_metadatum_collection.custom_metadata.length assert_equal 'New value', custom_metadatum_collection.custom_metadata.first.value From 89596655fa6f15a7c53f6718ffc7240f12df04eb Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 24 Sep 2024 11:28:59 +0100 Subject: [PATCH 118/158] style: decide not to fix a rubocop-prettier conflict --- .rubocop_todo.yml | 9 +++++++++ spec/models/transfer_request_spec.rb | 6 ++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ae5a9f3f4c..9ac8ddab86 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2024,6 +2024,15 @@ Style/HashEachMethods: - 'spec/sequencescape_excel/range_list_spec.rb' - 'test/unit/fluidigm_file_test.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never, either, consistent, either_consistent +Style/HashSyntax: + Exclude: + - 'spec/models/transfer_request_spec.rb' + # Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). Style/IdenticalConditionalBranches: diff --git a/spec/models/transfer_request_spec.rb b/spec/models/transfer_request_spec.rb index bbfdc5080a..77199bfc9b 100644 --- a/spec/models/transfer_request_spec.rb +++ b/spec/models/transfer_request_spec.rb @@ -253,10 +253,8 @@ it 'raises an exception' do expect do - described_class.create!(asset: aliquot_2.receptacle.reload, target_asset:) -end.to raise_error( - Aliquot::TagClash - ) + described_class.create!(asset: aliquot_2.receptacle.reload, target_asset: target_asset) + end.to raise_error(Aliquot::TagClash) end end end From abecb92e0a0deb0beaa627549f775efd989a527f Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 24 Sep 2024 11:31:06 +0100 Subject: [PATCH 119/158] build: update rubocop todo rubocop --auto-gen-config --no-exclude-limit --- .rubocop_todo.yml | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9ac8ddab86..a0a8de3756 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-23 17:15:55 UTC using RuboCop version 1.66.1. +# on 2024-09-24 09:17:48 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -812,7 +812,6 @@ RSpec/ExampleWording: - 'spec/sequencescape_excel/validation_spec.rb' - 'spec/sequencescape_excel/worksheet_spec.rb' - # Offense count: 248 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: @@ -1738,6 +1737,12 @@ Rails/LexicallyScopedActionFilter: - 'app/controllers/projects_controller.rb' - 'app/controllers/sdb/sample_manifests_controller.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/NegateInclude: + Exclude: + - 'app/controllers/admin/studies_controller.rb' + # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Include. @@ -1809,7 +1814,12 @@ Style/ArrayIntersect: Exclude: - 'test/unit/flexible_submission_test.rb' - +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowOnConstant, AllowOnSelfClass. +Style/CaseEquality: + Exclude: + - 'app/models/parsers/bioanalysis_csv_parser.rb' # Offense count: 14 Style/ClassVars: @@ -1860,6 +1870,13 @@ Style/EmptyCaseCondition: - 'app/models/request/change_decision.rb' - 'app/models/request_type.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, EnforcedStyle, AllowComments. +# SupportedStyles: empty, nil, both +Style/EmptyElse: + Exclude: + - 'app/controllers/requests/comments_controller.rb' # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). @@ -2091,7 +2108,6 @@ Style/MissingRespondToMissing: - 'lib/informatics/test/helpers/authentication_helper.rb' - 'lib/validateable.rb' - # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). Style/NegatedIfElseCondition: @@ -2120,8 +2136,6 @@ Style/NestedParenthesizedCalls: - 'app/models/parsers/bioanalysis_csv_parser.rb' - 'lib/label_printer/label_printer/pmb_client.rb' - - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IncludeSemanticChanges. @@ -2250,7 +2264,7 @@ Style/ParallelAssignment: - 'test/unit/messaging/hash_generation_test.rb' - 'test/unit/tag_qc/qcable_statemachine_checks.rb' -# Offense count: 4 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. Style/ParenthesesAroundCondition: @@ -2295,7 +2309,6 @@ Style/RedundantArgument: - 'features/support/step_definitions/samples_steps.rb' - 'spec/features/shared_examples/cherrypicking.rb' - # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. @@ -2327,7 +2340,6 @@ Style/SafeNavigation: - 'lib/event_factory.rb' - 'test/unit/qc_report_file_test.rb' - # Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SingleArgumentDig: @@ -2338,7 +2350,6 @@ Style/SingleArgumentDig: - 'app/heron/factories/sample.rb' - 'spec/requests/api/v2/heron/plates_spec.rb' - # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowModifier. @@ -2450,7 +2461,6 @@ Style/SymbolProc: - 'app/models/tasks/plate_transfer_handler.rb' - 'db/seeds/0001_workflows.rb' - # Offense count: 9 # This cop supports unsafe autocorrection (--autocorrect-all). Style/ZeroLengthPredicate: From f923f1ecfe04222e9d6d5928255c28924bfabc67 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Tue, 24 Sep 2024 13:19:35 +0100 Subject: [PATCH 120/158] build: update actions --- .github/workflows/lint.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c9ee4b626e..4c46e241de 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,7 +12,7 @@ jobs: RUBOCOP_CACHE_ROOT: ".rubocop-cache" BUNDLE_WITHOUT: "cucumber deployment profile development default test" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -20,14 +20,14 @@ jobs: # Establish a cache of rubocop cache to improve performance # ${{ env.RUBOCOP_CACHE_ROOT }} - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" cache: "yarn" - name: Set up yarn - run: yarn + run: yarn install - name: Cache cops - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ${{ env.RUBOCOP_CACHE_ROOT }} @@ -46,13 +46,14 @@ jobs: # and parallel to try and improve speed - name: Run rubocop run: bundle exec rubocop --extra-details --display-style-guide --parallel --format github --format progress + eslint: name: EsLint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" cache: "yarn" From f1ac524b6ab2d623d7488cb00a6d47f8abcea4ce Mon Sep 17 00:00:00 2001 From: yoldas Date: Tue, 24 Sep 2024 14:30:29 +0100 Subject: [PATCH 121/158] Add task to remove duplicate asset_links records --- .../support/remove_duplicate_asset_links.rake | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/tasks/support/remove_duplicate_asset_links.rake diff --git a/lib/tasks/support/remove_duplicate_asset_links.rake b/lib/tasks/support/remove_duplicate_asset_links.rake new file mode 100644 index 0000000000..1dc86b569c --- /dev/null +++ b/lib/tasks/support/remove_duplicate_asset_links.rake @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +namespace :support do + # This task needs to be executed before creating the unique-together index on + # the ancestor_id and descendant_id columns of the asset_links table. The + # index creation will be done using a migration. If there are already + # duplicate records, the migration will fail. This task fixes that by finding + # all the duplicate asset links and removes all but the most recently created + # one. The task accepts an argument to save the removed duplicates to a file, + # which can be used to restore the duplicates if necessary. + desc 'Remove duplicate asset links' + task remove_duplicate_asset_links: :environment do |_t, args| + csv_file_path = args.extras.first # Positional argument. + if csv_file_path.nil? + puts "Usage: rake 'support:remove_duplicate_asset_links[csv_file_path]'" + exit 1 + end + + duplicates_removed = 0 + + ActiveRecord::Base.transaction do + CSV.open(Rails.root.join(csv_file_path), 'w') do |csv| + csv << AssetLink.column_names # Write the headers + AssetLink + .group(:ancestor_id, :descendant_id) + .having('count(*) > 1') + .each do |link| + duplicates = + AssetLink + .where(ancestor_id: link.ancestor_id, descendant_id: link.descendant_id) + .order(created_at: :desc) + .offset(1) # Except the most recent one. + duplicates.each { |duplicate| csv << duplicate.attributes.values } + duplicates.delete_all + duplicates_removed += duplicates.size + end + end + end + + Rails.logger.info("Removed #{duplicates_removed} duplicate asset links.") + puts "Deleted records have been exported to #{csv_file_path}" + end +end From ecd4b1657ed5085732afcf76b787041569509c29 Mon Sep 17 00:00:00 2001 From: yoldas Date: Tue, 24 Sep 2024 14:31:07 +0100 Subject: [PATCH 122/158] Add test for remove_duplicate_asset_links task --- .../remove_duplicate_asset_links_spec.rb | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 spec/tasks/support/remove_duplicate_asset_links_spec.rb diff --git a/spec/tasks/support/remove_duplicate_asset_links_spec.rb b/spec/tasks/support/remove_duplicate_asset_links_spec.rb new file mode 100644 index 0000000000..4904be6587 --- /dev/null +++ b/spec/tasks/support/remove_duplicate_asset_links_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'support:remove_duplicate_asset_links', type: :task do + let(:load_tasks) { Rails.application.load_tasks } + let(:task_reenable) { Rake::Task[self.class.top_level_description].reenable } + let(:task_invoke) { Rake::Task[self.class.top_level_description].invoke(csv_file_path) } + let(:csv_file_path) { Rails.root.join('tmp/deleted_asset_links.csv').to_s } + let(:links) { create_list(:asset_link, 5) } + let(:duplicate_links) do + links.map do |link| + duplicate = AssetLink.new(ancestor: link.ancestor, descendant: link.descendant, created_at: 1.day.ago) + duplicate.save!(validate: false) + duplicate + end + end + + before do + load_tasks # Load tasks directly in the test to avoid intermittent CI failures + task_reenable # Allows the task to be invoked again + links + duplicate_links + end + + after { File.delete(csv_file_path) if File.exist?(csv_file_path) } + + it 'removes all duplicate links except the most recently created ones' do + expect(AssetLink.count).to eq(links.size + duplicate_links.size) + task_invoke + expect(AssetLink.count).to eq(links.size) # most recent links should be kept + expect(AssetLink.exists?(links.first.id)).to be true + expect(AssetLink.exists?(duplicate_links.first.id)).to be false + end + + it 'exports the removed duplicates to a CSV file' do + task_invoke + expect(File.exist?(csv_file_path)).to be true + csv = CSV.read(csv_file_path) + expect(csv.size).to eq(links.size + 1) # With header. + expect(csv.first).to eq(AssetLink.column_names) + (1..duplicate_links).size { |i| expect(csv[i]).to eq(duplicate_links[i - 1].attributes.values.map(&:to_s)) } + end +end From 010614d82b144b3e29eb408646cbeb367b844ef0 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Tue, 24 Sep 2024 14:45:51 +0100 Subject: [PATCH 123/158] Making some refactorings --- .../populate_number_of_samples_per_pool.rake | 23 ++++++--- ...populate_numer_of_samples_per_pool_spec.rb | 47 +++++++++++++++---- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/lib/tasks/populate_number_of_samples_per_pool.rake b/lib/tasks/populate_number_of_samples_per_pool.rake index 8df86b1042..8799f3f5a8 100644 --- a/lib/tasks/populate_number_of_samples_per_pool.rake +++ b/lib/tasks/populate_number_of_samples_per_pool.rake @@ -1,22 +1,31 @@ # frozen_string_literal: true + +# Run the rake task with the following command: +# bundle exec rake number_of_samples_per_pool:populate[20,1] +# The rake task will populate the number of samples per pool column in the request_metadata table +# for a given submission ID. namespace :number_of_samples_per_pool do desc 'Populate number of samples per pool column in request_metadata table for a given submission ID' task :populate, %i[samples_per_pool submission_id] => :environment do |_, args| - # TODO: Replace it with the pre-determined number of samples per pool - args.with_defaults(samples_per_pool: 96) + args.with_defaults(samples_per_pool: nil, submission_id: nil) + if args[:samples_per_pool].nil? + raise StandardError, + 'Please provide the number of samples per pool to populate + in request_metadata table.' + end if args[:submission_id].nil? - puts 'Please provide a submission_id to populate the number of samples per pool column.' - return + raise StandardError, + 'Please provide a submission_id to populate + the number of samples per pool column.' end - puts "Populating number of samples per pool column with #{args[:samples_per_pool]} in request_metadata - table for submission: #{args[:submission_id]}..." + puts "Populating number of samples per pool column with #{args[:samples_per_pool]} + in request_metadata table for submission: #{args[:submission_id]}..." ActiveRecord::Base.transaction do saved_count = 0 - # Find request_metadata for each request Request::Metadata .joins(:request) .where(requests: { submission_id: args[:submission_id] }) diff --git a/spec/lib/populate_numer_of_samples_per_pool_spec.rb b/spec/lib/populate_numer_of_samples_per_pool_spec.rb index 2c6d8fe701..1b3ee70817 100644 --- a/spec/lib/populate_numer_of_samples_per_pool_spec.rb +++ b/spec/lib/populate_numer_of_samples_per_pool_spec.rb @@ -10,27 +10,54 @@ def run_rake_task_with_args(task_name, *args) Rake.application.invoke_task("#{task_name}[#{args.join(',')}]") end - shared_examples 'populating number of samples per pool' do - it 'populates number of samples per pool' do + context 'when number of samples per pool rake task is invoked' do + before do + Rake.application.rake_require 'tasks/populate_number_of_samples_per_pool' + Rake::Task.define_task(:environment) + end + + it 'populating number of samples per pool' do submission = create(:submission) tube = create(:tube) request = create(:well_request, asset: tube, submission: submission) # Execute - run_rake_task_with_args('number_of_samples_per_pool:populate', 96, submission.reload.id) + run_rake_task_with_args('number_of_samples_per_pool:populate', 20, submission.reload.id) # Verify - expect(request.reload.request_metadata.number_of_samples_per_pool).to eq(96) + expect(request.reload.request_metadata.number_of_samples_per_pool).to eq(20) end - end - context 'when all okay, populates number of samples per pool' do - before do - Rake.application.rake_require 'tasks/populate_number_of_samples_per_pool' - Rake::Task.define_task(:environment) + it 'does not populate number of samples per pool when submission_id is nil' do + error_message = nil + + # Execute + begin + run_rake_task_with_args('number_of_samples_per_pool:populate', 20, nil) + rescue StandardError => e + error_message = e.message + end + + # Verify + expect(error_message).to eq('Please provide a submission_id to populate the number of samples per pool column.') end - it_behaves_like 'populating number of samples per pool' + it 'does not populate number of samples per pool when samples_per_pool is nil' do + submission = create(:submission) + create(:tube) + error_message = nil + + # Execute + begin + run_rake_task_with_args('number_of_samples_per_pool:populate', nil, submission.reload.id) + rescue StandardError => e + error_message = e.message + end + + # Verify + expect(error_message).to + eq('Please provide the number of samples per pool to populate in request_metadata table.') + end end end # rubocop:enable RSpec/DescribeClass From 9eafba75113b6a65f1899995d07da46f8c6c3cd3 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Tue, 24 Sep 2024 14:49:40 +0100 Subject: [PATCH 124/158] Making some refactorings --- lib/tasks/populate_number_of_samples_per_pool.rake | 8 ++------ spec/lib/populate_numer_of_samples_per_pool_spec.rb | 13 +++++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/tasks/populate_number_of_samples_per_pool.rake b/lib/tasks/populate_number_of_samples_per_pool.rake index 8799f3f5a8..f465118d1b 100644 --- a/lib/tasks/populate_number_of_samples_per_pool.rake +++ b/lib/tasks/populate_number_of_samples_per_pool.rake @@ -11,14 +11,10 @@ namespace :number_of_samples_per_pool do args.with_defaults(samples_per_pool: nil, submission_id: nil) if args[:samples_per_pool].nil? - raise StandardError, - 'Please provide the number of samples per pool to populate - in request_metadata table.' + raise StandardError, 'Number of samples per pool is missing' end if args[:submission_id].nil? - raise StandardError, - 'Please provide a submission_id to populate - the number of samples per pool column.' + raise StandardError, 'Submission ID is missing' end puts "Populating number of samples per pool column with #{args[:samples_per_pool]} diff --git a/spec/lib/populate_numer_of_samples_per_pool_spec.rb b/spec/lib/populate_numer_of_samples_per_pool_spec.rb index 1b3ee70817..3686ce8d97 100644 --- a/spec/lib/populate_numer_of_samples_per_pool_spec.rb +++ b/spec/lib/populate_numer_of_samples_per_pool_spec.rb @@ -11,6 +11,8 @@ def run_rake_task_with_args(task_name, *args) end context 'when number of samples per pool rake task is invoked' do + let(:samples_per_pool) { 20 } + before do Rake.application.rake_require 'tasks/populate_number_of_samples_per_pool' Rake::Task.define_task(:environment) @@ -22,10 +24,10 @@ def run_rake_task_with_args(task_name, *args) request = create(:well_request, asset: tube, submission: submission) # Execute - run_rake_task_with_args('number_of_samples_per_pool:populate', 20, submission.reload.id) + run_rake_task_with_args('number_of_samples_per_pool:populate', samples_per_pool, submission.reload.id) # Verify - expect(request.reload.request_metadata.number_of_samples_per_pool).to eq(20) + expect(request.reload.request_metadata.number_of_samples_per_pool).to eq(samples_per_pool) end it 'does not populate number of samples per pool when submission_id is nil' do @@ -33,13 +35,13 @@ def run_rake_task_with_args(task_name, *args) # Execute begin - run_rake_task_with_args('number_of_samples_per_pool:populate', 20, nil) + run_rake_task_with_args('number_of_samples_per_pool:populate', samples_per_pool, nil) rescue StandardError => e error_message = e.message end # Verify - expect(error_message).to eq('Please provide a submission_id to populate the number of samples per pool column.') + expect(error_message).to eq('Submission ID is missing') end it 'does not populate number of samples per pool when samples_per_pool is nil' do @@ -55,8 +57,7 @@ def run_rake_task_with_args(task_name, *args) end # Verify - expect(error_message).to - eq('Please provide the number of samples per pool to populate in request_metadata table.') + expect(error_message).to eq('Number of samples per pool is missing') end end end From e25beaf5f2cddf04b2a048a959c5bf704f18c2db Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Tue, 24 Sep 2024 14:50:28 +0100 Subject: [PATCH 125/158] Linting --- lib/tasks/populate_number_of_samples_per_pool.rake | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/tasks/populate_number_of_samples_per_pool.rake b/lib/tasks/populate_number_of_samples_per_pool.rake index f465118d1b..9e779feaee 100644 --- a/lib/tasks/populate_number_of_samples_per_pool.rake +++ b/lib/tasks/populate_number_of_samples_per_pool.rake @@ -10,12 +10,8 @@ namespace :number_of_samples_per_pool do task :populate, %i[samples_per_pool submission_id] => :environment do |_, args| args.with_defaults(samples_per_pool: nil, submission_id: nil) - if args[:samples_per_pool].nil? - raise StandardError, 'Number of samples per pool is missing' - end - if args[:submission_id].nil? - raise StandardError, 'Submission ID is missing' - end + raise StandardError, 'Number of samples per pool is missing' if args[:samples_per_pool].nil? + raise StandardError, 'Submission ID is missing' if args[:submission_id].nil? puts "Populating number of samples per pool column with #{args[:samples_per_pool]} in request_metadata table for submission: #{args[:submission_id]}..." From d1ff735b94389531c80aa299c96e798592e5d65d Mon Sep 17 00:00:00 2001 From: yoldas Date: Tue, 24 Sep 2024 18:09:42 +0100 Subject: [PATCH 126/158] Removed the recovery procedure as it is wrong to restore duplicates; the file will be used for auditing purposes instead --- lib/tasks/support/remove_duplicate_asset_links.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/support/remove_duplicate_asset_links.rake b/lib/tasks/support/remove_duplicate_asset_links.rake index 1dc86b569c..489b1eeb0b 100644 --- a/lib/tasks/support/remove_duplicate_asset_links.rake +++ b/lib/tasks/support/remove_duplicate_asset_links.rake @@ -6,8 +6,8 @@ namespace :support do # index creation will be done using a migration. If there are already # duplicate records, the migration will fail. This task fixes that by finding # all the duplicate asset links and removes all but the most recently created - # one. The task accepts an argument to save the removed duplicates to a file, - # which can be used to restore the duplicates if necessary. + # one. The task requires an argument to save the removed duplicates to a file + # for auditing purposes. desc 'Remove duplicate asset links' task remove_duplicate_asset_links: :environment do |_t, args| csv_file_path = args.extras.first # Positional argument. From 97ea6b7104df105dcf21574fc87ba41b02ccb450 Mon Sep 17 00:00:00 2001 From: yoldas Date: Wed, 25 Sep 2024 03:13:54 +0100 Subject: [PATCH 127/158] Test writing deleted records to CSV --- spec/tasks/support/remove_duplicate_asset_links_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/tasks/support/remove_duplicate_asset_links_spec.rb b/spec/tasks/support/remove_duplicate_asset_links_spec.rb index 4904be6587..aaa6dfc18d 100644 --- a/spec/tasks/support/remove_duplicate_asset_links_spec.rb +++ b/spec/tasks/support/remove_duplicate_asset_links_spec.rb @@ -37,8 +37,11 @@ task_invoke expect(File.exist?(csv_file_path)).to be true csv = CSV.read(csv_file_path) - expect(csv.size).to eq(links.size + 1) # With header. + expect(csv.size).to eq(duplicate_links.size + 1) # With header. expect(csv.first).to eq(AssetLink.column_names) - (1..duplicate_links).size { |i| expect(csv[i]).to eq(duplicate_links[i - 1].attributes.values.map(&:to_s)) } + (1..duplicate_links.size).each do |i| + expected_row = duplicate_links[i - 1].attributes.values.map { |value| value&.to_s } + expect(csv[i]).to eq(expected_row) + end end end From d1fc1c8dd89e89dac81829194cc27f097ec2a4b0 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Wed, 25 Sep 2024 10:19:30 +0100 Subject: [PATCH 128/158] added columns for num samples per pool and cells per chip well to bulk submission --- app/models/bulk_submission.rb | 8 +++- config/bulk_submission_excel/columns.yml | 40 +++++++++++++++++++ .../conditional_formattings.yml | 40 +++++++++++++++++++ 3 files changed, 86 insertions(+), 2 deletions(-) diff --git a/app/models/bulk_submission.rb b/app/models/bulk_submission.rb index 755c184a92..0a23364032 100644 --- a/app/models/bulk_submission.rb +++ b/app/models/bulk_submission.rb @@ -228,7 +228,9 @@ def process # rubocop:todo Metrics/CyclomaticComplexity 'pre-capture group', 'gigabases expected', 'priority', - 'flowcell type' + 'flowcell type', + 'scrna core number of samples per pool', + 'scrna core cells per chip well' ].freeze ALIAS_FIELDS = { 'plate barcode' => 'barcode', 'tube barcode' => 'barcode' }.freeze @@ -325,7 +327,9 @@ def extract_request_options(details) ['pre-capture plex level', 'pre_capture_plex_level'], ['gigabases expected', 'gigabases_expected'], ['primer panel', 'primer_panel_name'], - ['flowcell type', 'requested_flowcell_type'] + ['flowcell type', 'requested_flowcell_type'], + ['scrna core number of samples per pool', 'number_of_samples_per_pool'], + ['scrna core cells per chip well', 'cells_per_chip_well'] ].each do |source_key, target_key| assign_value_if_source_present(details, source_key, request_options, target_key) end diff --git a/config/bulk_submission_excel/columns.yml b/config/bulk_submission_excel/columns.yml index b9ca72c5f9..dc9a63ab64 100644 --- a/config/bulk_submission_excel/columns.yml +++ b/config/bulk_submission_excel/columns.yml @@ -269,3 +269,43 @@ requested_flowcell_type: conditional_formattings: empty_cell: is_error: +number_of_samples_per_pool: + heading: scRNA Core Number of Samples per Pool + attribute: :number_of_samples_per_pool + unlocked: true + type: :integer + validation: + options: + type: :whole + operator: :between + formula1: "5" + formula2: "25" + allowBlank: true + showInputMessage: true + promptTitle: "Samples per Pool" + prompt: "The requested number of samples per pool (between 5 and 25 inclusive)" + conditional_formattings: + empty_cell: + is_text: + is_num_samples_per_pool_in_valid_range: + is_num_samples_per_pool_outside_valid_range: +cells_per_chip_well: + heading: scRNA Core Cells per Chip Well + attribute: :cells_per_chip_well + unlocked: true + type: :integer + validation: + options: + type: :whole + operator: :between + formula1: "12000" + formula2: "90000" + allowBlank: true + showInputMessage: true + promptTitle: "Cells per Chip Well" + prompt: "The number of cells per chip well (between 12,000 and 90,000 inclusive)" + conditional_formattings: + empty_cell: + is_text: + is_num_cells_per_chip_well_in_valid_range: + is_num_cells_per_chip_well_outside_valid_range: diff --git a/config/bulk_submission_excel/conditional_formattings.yml b/config/bulk_submission_excel/conditional_formattings.yml index 939fb024b0..4ce4122128 100644 --- a/config/bulk_submission_excel/conditional_formattings.yml +++ b/config/bulk_submission_excel/conditional_formattings.yml @@ -53,3 +53,43 @@ number_greater_than_one: operator: :lessThan formula: "1" priority: 2 +is_num_samples_per_pool_in_valid_range: + style: + bg_color: "00FF00" + type: :dxf + options: + type: :cellIs + operator: :between + formula1: "5" + formula2: "25" + priority: 2 +is_num_samples_per_pool_outside_valid_range: + style: + bg_color: "FF0000" + type: :dxf + options: + type: :cellIs + operator: :notBetween + formula1: "5" + formula2: "25" + priority: 2 +is_num_cells_per_chip_well_in_valid_range: + style: + bg_color: "00FF00" + type: :dxf + options: + type: :cellIs + operator: :between + formula1: "12000" + formula2: "90000" + priority: 2 +is_num_cells_per_chip_well_outside_valid_range: + style: + bg_color: "FF0000" + type: :dxf + options: + type: :cellIs + operator: :notBetween + formula1: "12000" + formula2: "90000" + priority: 2 From 0e0477ba92e53bd29c9ec07a0264f51deb98392e Mon Sep 17 00:00:00 2001 From: yoldas Date: Wed, 25 Sep 2024 18:23:04 +0100 Subject: [PATCH 129/158] Eager let links and duplicate links --- spec/tasks/support/remove_duplicate_asset_links_spec.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/tasks/support/remove_duplicate_asset_links_spec.rb b/spec/tasks/support/remove_duplicate_asset_links_spec.rb index aaa6dfc18d..215544ea42 100644 --- a/spec/tasks/support/remove_duplicate_asset_links_spec.rb +++ b/spec/tasks/support/remove_duplicate_asset_links_spec.rb @@ -7,8 +7,8 @@ let(:task_reenable) { Rake::Task[self.class.top_level_description].reenable } let(:task_invoke) { Rake::Task[self.class.top_level_description].invoke(csv_file_path) } let(:csv_file_path) { Rails.root.join('tmp/deleted_asset_links.csv').to_s } - let(:links) { create_list(:asset_link, 5) } - let(:duplicate_links) do + let!(:links) { create_list(:asset_link, 5) } + let!(:duplicate_links) do links.map do |link| duplicate = AssetLink.new(ancestor: link.ancestor, descendant: link.descendant, created_at: 1.day.ago) duplicate.save!(validate: false) @@ -19,8 +19,6 @@ before do load_tasks # Load tasks directly in the test to avoid intermittent CI failures task_reenable # Allows the task to be invoked again - links - duplicate_links end after { File.delete(csv_file_path) if File.exist?(csv_file_path) } From 4ca9912d43ead339bdcc2c5414e68a073662982c Mon Sep 17 00:00:00 2001 From: yoldas Date: Wed, 25 Sep 2024 23:11:17 +0100 Subject: [PATCH 130/158] Clear tasks before loading and reenabling --- .../support/remove_duplicate_asset_links_spec.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/spec/tasks/support/remove_duplicate_asset_links_spec.rb b/spec/tasks/support/remove_duplicate_asset_links_spec.rb index 215544ea42..6890285fd1 100644 --- a/spec/tasks/support/remove_duplicate_asset_links_spec.rb +++ b/spec/tasks/support/remove_duplicate_asset_links_spec.rb @@ -3,22 +3,26 @@ require 'rails_helper' RSpec.describe 'support:remove_duplicate_asset_links', type: :task do + let(:clear_tasks) { Rake.application.clear } let(:load_tasks) { Rails.application.load_tasks } let(:task_reenable) { Rake::Task[self.class.top_level_description].reenable } let(:task_invoke) { Rake::Task[self.class.top_level_description].invoke(csv_file_path) } - let(:csv_file_path) { Rails.root.join('tmp/deleted_asset_links.csv').to_s } - let!(:links) { create_list(:asset_link, 5) } - let!(:duplicate_links) do + let(:csv_file_path) { 'tmp/deleted_asset_links.csv' } + let(:links) { create_list(:asset_link, 5) } + let(:duplicate_links) do links.map do |link| duplicate = AssetLink.new(ancestor: link.ancestor, descendant: link.descendant, created_at: 1.day.ago) - duplicate.save!(validate: false) + duplicate.save!(validate: false) # Needs to be saved without validation duplicate end end before do - load_tasks # Load tasks directly in the test to avoid intermittent CI failures - task_reenable # Allows the task to be invoked again + clear_tasks + load_tasks + task_reenable + links + duplicate_links end after { File.delete(csv_file_path) if File.exist?(csv_file_path) } From 5e21ead887dad28a4ab2bbb2887f77819b120dca Mon Sep 17 00:00:00 2001 From: yoldas Date: Wed, 25 Sep 2024 23:14:34 +0100 Subject: [PATCH 131/158] Use the same path conversion as the task --- spec/tasks/support/remove_duplicate_asset_links_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/tasks/support/remove_duplicate_asset_links_spec.rb b/spec/tasks/support/remove_duplicate_asset_links_spec.rb index 6890285fd1..f071dc0534 100644 --- a/spec/tasks/support/remove_duplicate_asset_links_spec.rb +++ b/spec/tasks/support/remove_duplicate_asset_links_spec.rb @@ -38,7 +38,7 @@ it 'exports the removed duplicates to a CSV file' do task_invoke expect(File.exist?(csv_file_path)).to be true - csv = CSV.read(csv_file_path) + csv = CSV.read(Rails.root.join(csv_file_path)) expect(csv.size).to eq(duplicate_links.size + 1) # With header. expect(csv.first).to eq(AssetLink.column_names) (1..duplicate_links.size).each do |i| From 91617b9e751612737254ff1abea7174bd010676a Mon Sep 17 00:00:00 2001 From: yoldas Date: Wed, 25 Sep 2024 23:17:05 +0100 Subject: [PATCH 132/158] Prevent already initialised constant warnings --- lib/tasks/insdc/import_countries.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/insdc/import_countries.rake b/lib/tasks/insdc/import_countries.rake index ea5a119aab..d159e2bdd7 100644 --- a/lib/tasks/insdc/import_countries.rake +++ b/lib/tasks/insdc/import_countries.rake @@ -1,14 +1,14 @@ # frozen_string_literal: true # Control the defaults to use. Please remember to update sample_checklist if necessary -INSDC_COUNTRIES_DEFAULTS = { +INSDC_COUNTRIES_DEFAULTS ||= { ena_root: 'https://www.ebi.ac.uk/ena/browser/api/xml/', sample_checklist: 'ERC000011' }.freeze # Sets the default priorities. Resisting the temptation to put this in a yaml file for now. # Higher priorities are sorted towards the top of the list -INSDC_COUNTRIES_PRIORITIES = { +INSDC_COUNTRIES_PRIORITIES ||= { 'not provided' => 2, 'United Kingdom' => 1, 'not applicable' => -1, From a55d3a121f36e1545aa9565bdaf2572e6c021b76 Mon Sep 17 00:00:00 2001 From: yoldas Date: Wed, 25 Sep 2024 23:24:31 +0100 Subject: [PATCH 133/158] Define INSDC constants unless defined --- lib/tasks/insdc/import_countries.rake | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/tasks/insdc/import_countries.rake b/lib/tasks/insdc/import_countries.rake index d159e2bdd7..f17d4f454c 100644 --- a/lib/tasks/insdc/import_countries.rake +++ b/lib/tasks/insdc/import_countries.rake @@ -1,20 +1,24 @@ # frozen_string_literal: true # Control the defaults to use. Please remember to update sample_checklist if necessary -INSDC_COUNTRIES_DEFAULTS ||= { - ena_root: 'https://www.ebi.ac.uk/ena/browser/api/xml/', - sample_checklist: 'ERC000011' -}.freeze +unless defined?(INSDC_COUNTRIES_DEFAULTS) + INSDC_COUNTRIES_DEFAULTS = { + ena_root: 'https://www.ebi.ac.uk/ena/browser/api/xml/', + sample_checklist: 'ERC000011' + }.freeze +end # Sets the default priorities. Resisting the temptation to put this in a yaml file for now. # Higher priorities are sorted towards the top of the list -INSDC_COUNTRIES_PRIORITIES ||= { - 'not provided' => 2, - 'United Kingdom' => 1, - 'not applicable' => -1, - 'not collected' => -1, - 'restricted access' => -1 -}.freeze +unless defined?(INSDC_COUNTRIES_PRIORITIES) + INSDC_COUNTRIES_PRIORITIES = { + 'not provided' => 2, + 'United Kingdom' => 1, + 'not applicable' => -1, + 'not collected' => -1, + 'restricted access' => -1 + }.freeze +end namespace :insdc do namespace :countries do From b3f8bd2df2c1fb732ac501895c6437c5ae6ba87c Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 26 Sep 2024 11:10:49 +0100 Subject: [PATCH 134/158] build: fix rubocop exclusions and todos not merging --- .rubocop.yml | 27 ++++++++++++++++----------- README.md | 9 +++++++++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7e0eae89de..c9f477e957 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,17 +8,10 @@ require: - rubocop-rspec - rubocop-rspec_rails -RSpec/AggregateExamples: - # Aggregate examples can be useful, but the cop gets into nasty battles with - # other Spec cops, and is only really of value in expensive tests. - Enabled: false -# Added exclude because api and feature specs do not have a specific class. -RSpec/DescribeClass: - Exclude: - - "spec/requests/**/*.rb" - - "spec/api/**/*.rb" - - "spec/features/**/*.rb" - - "spec/views/**/*.rb" +inherit_mode: + merge: + - Exclude + AllCops: NewCops: enable Exclude: @@ -33,6 +26,18 @@ AllCops: - node_modules/**/* - tmp/**/* +RSpec/AggregateExamples: + # Aggregate examples can be useful, but the cop gets into nasty battles with + # other Spec cops, and is only really of value in expensive tests. + Enabled: false +# Added exclude because api and feature specs do not have a specific class. +RSpec/DescribeClass: + Exclude: + - "spec/requests/**/*.rb" + - "spec/api/**/*.rb" + - "spec/features/**/*.rb" + - "spec/views/**/*.rb" + Rails/SkipsModelValidations: Exclude: - "db/migrate/*.rb" diff --git a/README.md b/README.md index b8cb7e3c5c..a42a5be9d9 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,15 @@ Rubocop is used for linting. bundle exec rubocop ``` +Note that permanent `Exclude`s should be defined in `.rubocop.yml`, with 'temporary' ones +(automatically) listed in `.rubocop_todo.yml`. + +To update `.rubocop_todo.yml`, execute + +```shell +rubocop --auto-gen-config --no-exclude-limit +``` + Prettier is used for formatting. ```shell From 3602b9a5172ff9de75c72dc0e77ef2408b120fb4 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 26 Sep 2024 11:54:27 +0100 Subject: [PATCH 135/158] style: fix Metrics/MethodLength warnings --- .rubocop_todo.yml | 7 ++----- app/models/plate/quad_creator.rb | 2 +- app/models/tag_group/form_object.rb | 2 +- .../sample_manifest_excel/upload/processor/plate.rb | 4 ++-- app/uat_actions/uat_actions/test_submission.rb | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a0a8de3756..bf0c2416ad 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-24 09:17:48 UTC using RuboCop version 1.66.1. +# on 2024-09-26 10:53:24 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -327,16 +327,13 @@ Metrics/CyclomaticComplexity: Exclude: - 'lib/limber/helper.rb' -# Offense count: 9 +# Offense count: 7 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Exclude: - 'app/controllers/tag_layout_templates_controller.rb' - 'app/jobs/export_pool_xp_to_traction_job.rb' - 'app/models/plate/quad_creator.rb' - - 'app/models/tag_group/form_object.rb' - - 'app/sample_manifest_excel/sample_manifest_excel/upload/processor/plate.rb' - - 'app/uat_actions/uat_actions/test_submission.rb' - 'app/uat_actions/uat_actions/tube_submission.rb' - 'app/validators/novaseqx_pe_validator.rb' - 'lib/record_loader/application_record_loader.rb' diff --git a/app/models/plate/quad_creator.rb b/app/models/plate/quad_creator.rb index 615960c18a..ff283262a3 100644 --- a/app/models/plate/quad_creator.rb +++ b/app/models/plate/quad_creator.rb @@ -38,7 +38,7 @@ def target_purpose_id private - def all_parents_acceptable # rubocop:todo Metrics/MethodLength + def all_parents_acceptable @parents.each do |location, parent| case parent when Plate, TubeRack diff --git a/app/models/tag_group/form_object.rb b/app/models/tag_group/form_object.rb index b38479634b..5a9ccbd69a 100644 --- a/app/models/tag_group/form_object.rb +++ b/app/models/tag_group/form_object.rb @@ -62,7 +62,7 @@ def check_entered_oligos # rubocop:todo Metrics/AbcSize # rubocop:enable Metrics/MethodLength - def persist! # rubocop:todo Metrics/AbcSize + def persist! # rubocop:todo Metrics/AbcSize, Metrics/MethodLength success = TagGroup.transaction do @tag_group = TagGroup.new(name:, adapter_type_id:) diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/processor/plate.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/processor/plate.rb index fd4df3a5fd..ceb3432c99 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/processor/plate.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/processor/plate.rb @@ -100,9 +100,9 @@ def non_matching_retention_instructions_for_plates end [nil, nil] end - # rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength - def check_row_retention_value(row, plate_barcode, retention_instructions) + + def check_row_retention_value(row, plate_barcode, retention_instructions) # rubocop:todo Metrics/MethodLength # if present the column is mandatory row_retention_value = row.value('retention_instruction') return 'Value cannot be blank.' if row_retention_value.nil? diff --git a/app/uat_actions/uat_actions/test_submission.rb b/app/uat_actions/uat_actions/test_submission.rb index 11b5d6b55f..7f701ca6b5 100644 --- a/app/uat_actions/uat_actions/test_submission.rb +++ b/app/uat_actions/uat_actions/test_submission.rb @@ -219,7 +219,7 @@ def order_request_options default_request_options.merge(custom_request_options) end - def default_request_options + def default_request_options # rubocop:todo Metrics/MethodLength submission_template .input_field_infos .each_with_object({}) do |ifi, options| From b425d1d22844b53a568265d76efe6d560e72874f Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 26 Sep 2024 12:04:43 +0100 Subject: [PATCH 136/158] build: re-enable rubocop-capybara and rubocop-factory_bot --- .rubocop.yml | 2 + .rubocop_todo.yml | 74 +++++++++- .../support/step_definitions/web_steps.rb | 2 +- spec/api/api_root_spec.rb | 4 +- spec/api/asset_audit_spec.rb | 6 +- spec/api/dilution_plate_purpose_spec.rb | 4 +- spec/api/extraction_attributes_spec.rb | 44 +++--- spec/api/labware_spec.rb | 4 +- spec/api/multiplexed_library_tube_spec.rb | 6 +- spec/api/plate_purpose_spec.rb | 8 +- spec/api/plate_spec.rb | 6 +- spec/api/qcable_creator_spec.rb | 6 +- spec/api/receptacle_spec.rb | 4 +- spec/api/request_types_spec.rb | 4 +- spec/api/specific_tube_creation_spec.rb | 12 +- spec/api/state_change_spec.rb | 6 +- spec/api/submission_pool_spec.rb | 44 +++--- spec/api/tag_layout_template_spec.rb | 12 +- spec/api/transfer_request_collection_spec.rb | 10 +- spec/api/tube_creation_spec.rb | 10 +- spec/api/tube_purpose_spec.rb | 4 +- spec/api/well_spec.rb | 4 +- spec/api/work_completion_spec.rb | 6 +- spec/bulk_submission_excel/download_spec.rb | 2 +- .../admin/primer_panels_controller_spec.rb | 2 +- ...ort_pool_xp_to_traction_controller_spec.rb | 6 +- .../api/v2/heron/plates_controller_spec.rb | 2 +- .../v2/heron/tube_racks_controller_spec.rb | 2 +- .../downloads_controller_spec.rb | 2 +- .../driver_files_controller_spec.rb | 16 +-- .../lab_searches_controller_spec.rb | 6 +- .../labwhere_receptions_controller_spec.rb | 8 +- .../controllers/messengers_controller_spec.rb | 4 +- .../npg_actions/assets_controller_spec.rb | 22 +-- spec/controllers/parents_controller_spec.rb | 6 +- .../phi_x/spiked_buffers_controller_spec.rb | 4 +- .../phi_x/stocks_controller_spec.rb | 4 +- spec/controllers/phi_xes_controller_spec.rb | 2 +- .../receptacles_controller_spec.rb | 8 +- .../report_fails_controller_spec.rb | 8 +- .../robot_verifications_controller_spec.rb | 20 +-- spec/controllers/samples_controller_spec.rb | 8 +- spec/controllers/searches_controller_spec.rb | 20 +-- .../sequenom_qc_plates_controller_spec.rb | 4 +- .../studies/information_controller_spec.rb | 10 +- spec/controllers/studies_controller_spec.rb | 8 +- .../submissions_controller_spec.rb | 56 ++++---- spec/controllers/tag_sets_controller_spec.rb | 6 +- .../tube_rack_summaries_controller_spec.rb | 4 +- spec/factories/aliquots.rb | 4 +- spec/factories/asset_groups.rb | 4 +- spec/factories/batch_factories.rb | 4 +- spec/factories/lanes.rb | 2 +- spec/factories/lib_pcr_xp_factories.rb | 6 +- spec/factories/phix_factories.rb | 2 +- spec/factories/pipelines_factories.rb | 26 ++-- spec/factories/plate_factories.rb | 14 +- spec/factories/poly_metadata_factories.rb | 2 +- .../product_and_catalogue_factories.rb | 4 +- spec/factories/project_metadata.rb | 2 +- spec/factories/projects.rb | 2 +- spec/factories/pulldown_factories.rb | 6 +- spec/factories/purpose_factories.rb | 18 +-- spec/factories/request_factories.rb | 12 +- spec/factories/request_type_factories.rb | 6 +- spec/factories/robot_factories.rb | 4 +- spec/factories/roles.rb | 6 +- .../test_download_plates.rb | 2 +- spec/factories/sample_manifest_factories.rb | 6 +- spec/factories/samples.rb | 2 +- spec/factories/study_factories.rb | 10 +- spec/factories/study_reports.rb | 2 +- spec/factories/submission_factories.rb | 6 +- spec/factories/tag2_layout_factories.rb | 2 +- spec/factories/tube_factories.rb | 28 ++-- spec/factories/user_factories.rb | 2 +- spec/factories/user_query_factories.rb | 2 +- spec/factories/well_factories.rb | 8 +- spec/factories/z_tag_qc_factories.rb | 10 +- .../features/admin/add_a_primer_panel_spec.rb | 4 +- spec/features/admin/add_a_printer_spec.rb | 2 +- .../admin/changing_user_roles_spec.rb | 14 +- spec/features/asset_information_spec.rb | 8 +- spec/features/assets/asset_submission_spec.rb | 18 +-- spec/features/assets/show_plate_spec.rb | 4 +- .../upload_and_retrieve_qc_file_spec.rb | 4 +- .../features/batches/failing_requests_spec.rb | 6 +- spec/features/batches/sort_requests_spec.rb | 6 +- spec/features/contact_us_spec.rb | 2 +- spec/features/creating_a_quad_stamp_spec.rb | 10 +- ...enerate_a_bulk_submission_template_spec.rb | 12 +- ...ncorrect_submission_id_on_transfer_spec.rb | 32 ++--- spec/features/lab_view_spec.rb | 4 +- .../looking_up_labware_history_spec.rb | 8 +- .../labware/retention_instruction_spec.rb | 20 +-- spec/features/labware_information_spec.rb | 8 +- spec/features/labwhere_reception_spec.rb | 4 +- .../patient_consent_withdrawl_spec.rb | 22 +-- .../perform_a_tag_substitution_spec.rb | 50 +++---- ..._for_fluidigm_pipeline_micro_litre_spec.rb | 26 ++-- .../cherrypick/cherrypick_pipeline_spec.rb | 46 +++---- .../pipelines/creating_an_empty_batch_spec.rb | 8 +- .../following_a_sequencing_pipeline_spec.rb | 28 ++-- ...line_with_compound_sample_creation_spec.rb | 26 ++-- .../viewing_request_comments_spec.rb | 16 +-- spec/features/plate_qc_display_spec.rb | 4 +- spec/features/pooling_spec.rb | 16 +-- spec/features/receptacle_information_spec.rb | 4 +- spec/features/retrospective_failure_spec.rb | 28 ++-- .../lab/stock_stamping_spec.rb | 12 +- .../sample_manifests/create_manifest_spec.rb | 20 +-- .../track_sample_manifest_updates_spec.rb | 10 +- ...r_for_manifests_with_tag_sequences_spec.rb | 8 +- spec/features/shared_examples/sequencing.rb | 2 +- ...ransfers_on_repools_starts_repools_spec.rb | 10 +- .../studies/change_study_roles_spec.rb | 6 +- spec/features/studies/create_study_spec.rb | 12 +- spec/features/studies/edit_study_spec.rb | 6 +- spec/features/studies/manage_study_spec.rb | 6 +- spec/features/studies/qc_reports_spec.rb | 2 +- .../studies/view_study_properties_spec.rb | 2 +- .../studies/view_study_request_links_spec.rb | 8 +- .../submissions/bulk_submissions_spec.rb | 14 +- spec/features/tag_group_spec.rb | 4 +- spec/features/tag_layout_template_spec.rb | 2 +- spec/features/tag_set_spec.rb | 8 +- spec/helpers/assets_helper_spec.rb | 32 ++--- spec/helpers/batches_helper_spec.rb | 6 +- spec/helpers/deprecation_helper_spec.rb | 2 +- .../heron/factories/concerns/contents_spec.rb | 2 +- .../heron/factories/concerns/eventful_spec.rb | 2 +- spec/heron/factories/event_spec.rb | 2 +- spec/heron/factories/plate_from_rack_spec.rb | 2 +- spec/heron/factories/sample_spec.rb | 6 +- spec/insdc/import_countries_spec.rb | 4 +- .../export_pool_xp_to_traction_job_spec.rb | 8 +- spec/lib/accession/sample_spec.rb | 2 +- spec/lib/label_printer/asset_labels_spec.rb | 10 +- spec/lib/label_printer/asset_redirect_spec.rb | 12 +- spec/lib/label_printer/batch_plate_spec.rb | 4 +- .../sample_manifest_plate_double_spec.rb | 2 +- ...ne_request_information_type_loader_spec.rb | 6 +- .../plate_purpose_loader_spec.rb | 2 +- .../record_loader/request_type_loader_spec.rb | 6 +- .../robot_property_loader_spec.rb | 4 +- .../record_loader/tag_group_loader_spec.rb | 2 +- .../tag_layout_templates_loader_spec.rb | 4 +- spec/mailers/user_query_mailer_spec.rb | 2 +- spec/models/ability_spec.rb | 56 ++++---- spec/models/aliquot_spec.rb | 50 +++---- spec/models/api/aliquot_io_spec.rb | 18 +-- spec/models/api/asset_link_io_spec.rb | 6 +- spec/models/api/batch_io_spec.rb | 8 +- spec/models/api/batch_request_io_spec.rb | 4 +- spec/models/api/lane_io_spec.rb | 2 +- spec/models/api/library_tube_io_spec.rb | 9 +- spec/models/api/messages/flowcell_io_spec.rb | 18 +-- .../api/messages/pac_bio_run_io_spec.rb | 10 +- .../messages/pac_bio_run_with_tag2_io_spec.rb | 10 +- spec/models/api/messages/qc_result_io_spec.rb | 8 +- .../messages/well_stock_resource_io_spec.rb | 10 +- .../api/multiplexed_library_tube_io_spec.rb | 2 +- spec/models/api/order_io_spec.rb | 10 +- .../api/pac_bio_library_tube_io_spec.rb | 4 +- spec/models/api/plate_io_spec.rb | 8 +- spec/models/api/plate_purpose_io_spec.rb | 2 +- spec/models/api/project_io_spec.rb | 8 +- ...lldown_multiplexed_library_tube_io_spec.rb | 2 +- spec/models/api/reference_genome_io_spec.rb | 2 +- spec/models/api/request_io_spec.rb | 14 +- spec/models/api/sample_io_spec.rb | 12 +- spec/models/api/sample_tube_io_spec.rb | 4 +- spec/models/api/study_io_spec.rb | 10 +- spec/models/api/study_sample_io_spec.rb | 6 +- spec/models/api/submission_io_spec.rb | 4 +- spec/models/api/tag_io_spec.rb | 2 +- spec/models/api/well_io_spec.rb | 10 +- spec/models/bait_library_type_spec.rb | 6 +- spec/models/barcode_spec.rb | 20 +-- spec/models/batch_spec.rb | 10 +- .../helpers/external_subjects_spec.rb | 2 +- spec/models/broadcast_event/lab_event_spec.rb | 14 +- .../plate_cherrypicked_spec.rb | 2 +- .../broadcast_event/pool_released_spec.rb | 16 +-- spec/models/broadcast_event/qc_assay_spec.rb | 14 +- spec/models/bulk_submission_spec.rb | 30 ++-- spec/models/cherrypick_request_spec.rb | 6 +- spec/models/comment_spec.rb | 52 +++---- spec/models/external_release_event_spec.rb | 18 +-- spec/models/flowcell_type_spec.rb | 4 +- .../initial_stock_tube_purpose_spec.rb | 42 +++--- .../illumina_htp/requests/gbs_request_spec.rb | 2 +- .../requests/heron_request_spec.rb | 2 +- .../requests/heron_tailed_request_spec.rb | 2 +- spec/models/insdc/country_spec.rb | 18 +-- spec/models/lab_event_spec.rb | 2 +- spec/models/labware_spec.rb | 6 +- spec/models/lane_spec.rb | 10 +- spec/models/library_type_spec.rb | 12 +- spec/models/linear_submission_spec.rb | 49 +++---- spec/models/location_report_spec.rb | 22 +-- spec/models/lot_type_spec.rb | 6 +- spec/models/orders/automated_order_spec.rb | 10 +- spec/models/orders/order_spec.rb | 38 +++--- spec/models/orders/shared_order_specs.rb | 8 +- spec/models/phi_x/spiked_buffer_spec.rb | 22 +-- spec/models/phi_x/stock_spec.rb | 6 +- spec/models/pick_list_spec.rb | 12 +- spec/models/plate/quad_creator_spec.rb | 18 +-- spec/models/plate/sample_tube_factory_spec.rb | 4 +- .../plate_purpose/additional_input_spec.rb | 6 +- spec/models/plate_purpose/input_spec.rb | 20 +-- spec/models/plate_purpose_spec.rb | 2 +- spec/models/plate_spec.rb | 22 +-- spec/models/plate_type_spec.rb | 10 +- spec/models/plate_volume_spec.rb | 4 +- spec/models/pooling_spec.rb | 16 +-- spec/models/primer_panel_spec.rb | 2 +- .../requests/isc_library_request_spec.rb | 2 +- spec/models/qc_report_spec.rb | 62 ++++----- spec/models/qc_result/qc_result_spec.rb | 6 +- spec/models/racked_tube_spec.rb | 16 +-- spec/models/receptacle_spec.rb | 42 +++--- .../sample_compound_aliquot_transfer_spec.rb | 54 ++++---- spec/models/request/traction/grid_ion_spec.rb | 8 +- spec/models/request_event_spec.rb | 2 +- spec/models/request_information_type_spec.rb | 8 +- spec/models/request_spec.rb | 88 ++++++------ .../validator/library_type_validator_spec.rb | 8 +- spec/models/request_type_spec.rb | 4 +- spec/models/robot/pick_data_spec.rb | 28 ++-- .../verification/source_dest_beds_spec.rb | 18 +-- .../source_dest_control_beds_spec.rb | 26 ++-- spec/models/sample/metadata_spec.rb | 8 +- spec/models/sample_manifest/uploader_spec.rb | 2 +- spec/models/sample_manifest_spec.rb | 18 +-- spec/models/sample_spec.rb | 16 +-- spec/models/sequencing_request_spec.rb | 46 +++---- spec/models/specific_tube_creations_spec.rb | 4 +- .../state_changer/initial_stock_tube_spec.rb | 14 +- spec/models/state_changer/input_plate_spec.rb | 2 +- spec/models/state_changer/mx_tube_spec.rb | 14 +- .../state_changer/qcable_labware_spec.rb | 6 +- .../qcable_library_plate_spec.rb | 2 +- .../state_changer/standard_plate_spec.rb | 24 ++-- spec/models/state_changer/stock_tube_spec.rb | 8 +- spec/models/std_library_request_spec.rb | 8 +- spec/models/stock_stamper_spec.rb | 12 +- spec/models/study_spec.rb | 38 +++--- .../submission/submission_creator_spec.rb | 6 +- spec/models/submission_spec.rb | 34 ++--- spec/models/tag2_layout_spec.rb | 8 +- spec/models/tag2_layout_template_spec.rb | 8 +- spec/models/tag_group/adapter_type_spec.rb | 6 +- spec/models/tag_group_spec.rb | 4 +- spec/models/tag_layout_spec.rb | 30 ++-- spec/models/tag_layout_template_spec.rb | 12 +- spec/models/tag_substitutions_spec.rb | 72 +++++----- spec/models/tasks/cherrypick_task_spec.rb | 20 +-- spec/models/tasks/plate_template_task_spec.rb | 10 +- .../set_descriptors_handler/handler_spec.rb | 4 +- spec/models/transfer/between_plates_spec.rb | 6 +- .../transfer/from_plate_to_tube_spec.rb | 4 +- .../transfer_request_collection_spec.rb | 24 ++-- spec/models/transfer_request_spec.rb | 107 +++++++-------- spec/models/tube_purpose_spec.rb | 2 +- spec/models/tube_rack_spec.rb | 42 +++--- spec/models/tube_spec.rb | 32 ++--- spec/models/user_query_spec.rb | 2 +- spec/models/user_spec.rb | 24 ++-- spec/models/well_attribute_spec.rb | 4 +- spec/models/well_spec.rb | 46 +++---- spec/models/work_completion_spec.rb | 18 +-- spec/models/work_order_spec.rb | 10 +- spec/models/work_order_type_spec.rb | 4 +- spec/models/working_dilution_plate_spec.rb | 4 +- spec/requests/api/v2/aliquots_spec.rb | 2 +- spec/requests/api/v2/asset_audits_spec.rb | 2 +- spec/requests/api/v2/comments_spec.rb | 6 +- .../v2/custom_metadatum_collections_spec.rb | 6 +- spec/requests/api/v2/labware_spec.rb | 4 +- spec/requests/api/v2/lanes_spec.rb | 2 +- spec/requests/api/v2/lot_types_spec.rb | 2 +- spec/requests/api/v2/lots_spec.rb | 2 +- spec/requests/api/v2/orders_spec.rb | 2 +- spec/requests/api/v2/pick_lists_spec.rb | 12 +- spec/requests/api/v2/plate_purposes_spec.rb | 2 +- spec/requests/api/v2/plate_templates_spec.rb | 2 +- spec/requests/api/v2/plates_spec.rb | 12 +- spec/requests/api/v2/poly_metadata_spec.rb | 6 +- .../requests/api/v2/pre_capture_pools_spec.rb | 2 +- spec/requests/api/v2/primer_panels_spec.rb | 2 +- spec/requests/api/v2/purposes_spec.rb | 2 +- spec/requests/api/v2/qcables_spec.rb | 2 +- spec/requests/api/v2/receptacles_spec.rb | 2 +- spec/requests/api/v2/request_types_spec.rb | 2 +- spec/requests/api/v2/requests_spec.rb | 2 +- spec/requests/api/v2/sample_metadata_spec.rb | 2 +- spec/requests/api/v2/studies_spec.rb | 2 +- spec/requests/api/v2/submissions_spec.rb | 2 +- spec/requests/api/v2/tag_groups_spec.rb | 2 +- .../api/v2/tag_layout_templates_spec.rb | 2 +- .../requests/api/v2/transfer_requests_spec.rb | 2 +- .../api/v2/transfers/transfers_spec.rb | 4 +- spec/requests/api/v2/tube_racks_spec.rb | 2 +- spec/requests/api/v2/tubes_spec.rb | 2 +- spec/requests/api/v2/users_spec.rb | 4 +- spec/requests/api/v2/volume_update_spec.rb | 2 +- spec/requests/api/v2/wells_spec.rb | 2 +- spec/requests/api/v2/work_orders_spec.rb | 20 +-- spec/requests/pick_lists_request_spec.rb | 6 +- spec/requests/plate_picks_request_spec.rb | 16 +-- spec/requests/qc_files_spec.rb | 2 +- spec/requests/users_request_spec.rb | 2 +- .../resources/api/v2/aliquot_resource_spec.rb | 2 +- .../api/v2/barcode_printer_resource_spec.rb | 2 +- .../resources/api/v2/comment_resource_spec.rb | 2 +- ...stom_metadatum_collection_resource_spec.rb | 2 +- .../resources/api/v2/labware_resource_spec.rb | 2 +- spec/resources/api/v2/lane_resource_spec.rb | 2 +- spec/resources/api/v2/lot_resource_spec.rb | 2 +- .../api/v2/lot_type_resource_spec.rb | 2 +- spec/resources/api/v2/order_resource_spec.rb | 2 +- .../api/v2/pick_list_resource_spec.rb | 2 +- spec/resources/api/v2/plate_resource_spec.rb | 2 +- .../api/v2/plate_template_resource_spec.rb | 2 +- .../api/v2/poly_metadatum_resource_spec.rb | 2 +- .../api/v2/pre_capture_pool_resource_spec.rb | 2 +- .../api/v2/primer_panel_resource_spec.rb | 2 +- .../resources/api/v2/project_resource_spec.rb | 2 +- .../resources/api/v2/purpose_resource_spec.rb | 2 +- spec/resources/api/v2/qcable_resource_spec.rb | 2 +- .../api/v2/receptacle_resource_spec.rb | 2 +- .../resources/api/v2/request_resource_spec.rb | 6 +- .../api/v2/request_type_resource_spec.rb | 2 +- spec/resources/api/v2/sample_resource_spec.rb | 2 +- .../api/v2/state_change_resource_spec.rb | 2 +- spec/resources/api/v2/study_resource_spec.rb | 2 +- .../api/v2/submission_resource_spec.rb | 2 +- .../v2/submission_template_resource_spec.rb | 2 +- .../api/v2/tag_group_resource_spec.rb | 2 +- .../v2/tag_layout_template_resource_spec.rb | 2 +- spec/resources/api/v2/tag_resource_spec.rb | 2 +- .../api/v2/transfer_request_resource_spec.rb | 2 +- .../api/v2/transfer_template_resource_spec.rb | 2 +- .../v2/transfers/transfer_resource_spec.rb | 2 +- .../api/v2/tube_purpose_resource_spec.rb | 2 +- .../api/v2/tube_rack_resource_spec.rb | 6 +- spec/resources/api/v2/tube_resource_spec.rb | 2 +- spec/resources/api/v2/user_resource_spec.rb | 2 +- spec/resources/api/v2/well_resource_spec.rb | 6 +- .../upload/processor_spec.rb | 4 +- spec/sample_manifest_excel/upload/row_spec.rb | 4 +- .../upload/upload_spec.rb | 2 +- spec/sample_manifest_excel/worksheet_spec.rb | 2 +- spec/sequencescape_excel/range_spec.rb | 4 +- .../specialised_field_spec.rb | 42 +++--- spec/sequencescape_excel/worksheet_spec.rb | 6 +- spec/shared_contexts/it_requires_login.rb | 8 +- spec/shared_contexts/limber_shared_context.rb | 20 +-- .../generate_plate_concentrations_spec.rb | 2 +- spec/uat_actions/generate_qc_results_spec.rb | 4 +- .../generate_sample_manifest_spec.rb | 4 +- .../generate_spiked_buffer_tube_spec.rb | 2 +- .../generate_tag_layout_template_spec.rb | 4 +- spec/uat_actions/plate_information_spec.rb | 46 +++---- spec/uat_actions/test_submission_spec.rb | 4 +- spec/validators/novaseqx_pe_validator_spec.rb | 4 +- .../labware/retention_instruction_spec.rb | 6 +- spec/views/labware/show_chromium_chip_spec.rb | 6 +- spec/views/labware/show_html_erb_spec.rb | 20 +-- .../views/report_fails/index_html_erb_spec.rb | 2 +- spec/views/samples/edit_html_erb_spec.rb | 4 +- spec/views/samples/index_html_erb_spec.rb | 4 +- spec/views/samples/show_html_erb_spec.rb | 4 +- .../tube_rack_summaries/show_html_erb_spec.rb | 8 +- test/controllers/admin_controller_test.rb | 2 +- .../admin_programs_controller_test.rb | 8 +- .../admin_projects_controller_test.rb | 10 +- .../admin_roles_controller_test.rb | 2 +- .../admin_studies_controller_test.rb | 8 +- .../admin_users_controller_test.rb | 8 +- .../controllers/api/submissions_controller.rb | 12 +- .../authentication_controller_test.rb | 6 +- test/controllers/batches_controller_test.rb | 64 ++++----- test/controllers/labware_controller_test.rb | 12 +- test/controllers/pipelines_controller_test.rb | 14 +- .../plate_summaries_controller_test.rb | 10 +- test/controllers/plates_controller_test.rb | 22 +-- test/controllers/projects_controller_test.rb | 6 +- test/controllers/qc_files_controller_test.rb | 2 +- .../controllers/qc_reports_controller_test.rb | 8 +- .../receptacles_controller_test.rb | 8 +- .../requests_comments_controller_test.rb | 6 +- test/controllers/requests_controller_test.rb | 26 ++-- test/controllers/robots_controller_test.rb | 4 +- .../sample_manifests_controller_test.rb | 8 +- test/controllers/samples_controller_test.rb | 6 +- .../studies_asset_groups_controller_test.rb | 12 +- .../studies_events_controller_test.rb | 4 +- .../studies_sample_controller_test.rb | 2 +- test/controllers/workflows_controller_test.rb | 38 +++--- test/functional/external_validator_test.rb | 2 +- test/functional/pre_cap_groups_test.rb | 14 +- test/lib/label_printer/batch_tube_test.rb | 12 +- .../labels_multiplication_test.rb | 8 +- test/lib/label_printer/plate_creator_test.rb | 12 +- test/lib/label_printer/plate_to_tube_test.rb | 4 +- test/lib/label_printer/print_job_test.rb | 4 +- .../sample_manifest_multiplex_test.rb | 2 +- .../sample_manifest_plate_test.rb | 4 +- .../sample_manifest_tube_test.rb | 2 +- test/performance/plate_creation_test.rb | 2 +- test/performance/state_change_test.rb | 6 +- .../transfer_request_collection_test.rb | 2 +- .../performance/work_completion_tubes_test.rb | 74 +++++----- test/performance/work_completions_test.rb | 26 ++-- test/shoulda_macros/sanger_macros.rb | 4 +- .../sanger_macros/resource_test.rb | 22 +-- test/unit/accession_service_test.rb | 22 +-- test/unit/aliquot_indexer_test.rb | 18 +-- test/unit/aliquot_receptacle_test.rb | 2 +- test/unit/asset_group_test.rb | 26 ++-- test/unit/asset_link_test.rb | 4 +- test/unit/barcode_printer_test.rb | 6 +- test/unit/batch_test.rb | 128 +++++++++--------- test/unit/cherrypick_task_test.rb | 2 +- test/unit/data_release_test.rb | 2 +- test/unit/event_factory_test.rb | 36 ++--- test/unit/event_test.rb | 22 +-- test/unit/eventful_entry_test.rb | 4 +- test/unit/flexible_submission_test.rb | 66 ++++----- test/unit/import_fluidigm_data_test.rb | 12 +- test/unit/lab_interface/workflow_test.rb | 8 +- .../unit/lib_pool_norm_tube_generator_test.rb | 2 +- test/unit/library_tube_test.rb | 6 +- test/unit/messaging/messenger_creator_test.rb | 8 +- test/unit/multiplexed_library_tube_test.rb | 6 +- test/unit/parsers/quant_parser_test.rb | 8 +- test/unit/pipeline_test.rb | 20 +-- test/unit/plate_creator_test.rb | 12 +- test/unit/plate_owner_test.rb | 6 +- test/unit/plate_template_test.rb | 6 +- test/unit/plate_test.rb | 32 ++--- .../product_catalogue/library_driven_test.rb | 46 +++---- test/unit/product_catalogue_test.rb | 10 +- test/unit/product_criteria/advanced_test.rb | 18 +-- test/unit/product_criteria/basic_test.rb | 12 +- test/unit/product_criteria_test.rb | 14 +- test/unit/product_test.rb | 16 +-- test/unit/purpose_test.rb | 2 +- test/unit/qc_file_test.rb | 2 +- test/unit/qc_metric_test.rb | 12 +- test/unit/qc_report_file_test.rb | 36 ++--- test/unit/qc_report_presenter_test.rb | 14 +- test/unit/qc_report_test.rb | 58 ++++---- test/unit/sample_test.rb | 56 ++++---- test/unit/sample_tube_test.rb | 8 +- test/unit/stock_library_tube_test.rb | 2 +- .../stock_multiplexed_library_tube_test.rb | 2 +- test/unit/submission_template_test.rb | 8 +- test/unit/tag_qc/lot_test.rb | 6 +- test/unit/tag_qc/plate_conversion_test.rb | 10 +- test/unit/tag_qc/qc_decision_test.rb | 10 +- test/unit/tag_qc/qcable_test.rb | 14 +- test/unit/tag_qc/stamp_test.rb | 12 +- test/unit/tasks/plate_transfer_task_test.rb | 14 +- .../between_tubes_by_submission_test.rb | 18 +-- test/unit/tube_test.rb | 2 +- test/unit/user_test.rb | 24 ++-- 470 files changed, 2681 insertions(+), 2602 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c9f477e957..fe48e19f14 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,6 +7,8 @@ require: - rubocop-rails - rubocop-rspec - rubocop-rspec_rails + - rubocop-capybara + - rubocop-factory_bot inherit_mode: merge: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bf0c2416ad..a4a7859d6c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,83 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-26 10:53:24 UTC using RuboCop version 1.66.1. +# on 2024-09-26 11:14:55 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 157 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: link_or_button, strict +Capybara/ClickLinkOrButtonStyle: + Exclude: + - 'features/support/step_definitions/authentication_steps.rb' + - 'features/support/step_definitions/bulk_submission_steps.rb' + - 'features/support/step_definitions/contact_steps.rb' + - 'features/support/step_definitions/web_steps.rb' + - 'spec/features/admin/changing_user_roles_spec.rb' + - 'spec/features/assets/asset_submission_spec.rb' + - 'spec/features/assets/upload_and_retrieve_qc_file_spec.rb' + - 'spec/features/batches/failing_requests_spec.rb' + - 'spec/features/batches/sort_requests_spec.rb' + - 'spec/features/contact_us_spec.rb' + - 'spec/features/create_printer_spec.rb' + - 'spec/features/creating_a_quad_stamp_spec.rb' + - 'spec/features/lab_view_spec.rb' + - 'spec/features/labware/looking_up_labware_history_spec.rb' + - 'spec/features/labware/retention_instruction_spec.rb' + - 'spec/features/location_reports/location_reports_spec.rb' + - 'spec/features/perform_a_tag_substitution_spec.rb' + - 'spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb' + - 'spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb' + - 'spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb' + - 'spec/features/pipelines/viewing_request_comments_spec.rb' + - 'spec/features/sample_logistics/lab/stock_stamping_spec.rb' + - 'spec/features/sample_manifests/create_manifest_spec.rb' + - 'spec/features/sample_manifests/track_sample_manifest_updates_spec.rb' + - 'spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb' + - 'spec/features/shared_examples/cherrypicking.rb' + - 'spec/features/studies/accession_all_samples_spec.rb' + - 'spec/features/studies/change_study_roles_spec.rb' + - 'spec/features/studies/create_study_spec.rb' + - 'spec/features/studies/edit_study_spec.rb' + - 'spec/features/studies/manage_study_spec.rb' + - 'spec/features/studies/qc_reports_spec.rb' + - 'spec/features/studies/view_study_properties_spec.rb' + - 'spec/features/studies/view_study_request_links_spec.rb' + - 'spec/features/submissions/bulk_submissions_spec.rb' + - 'spec/support/user_login.rb' + +# Offense count: 62 +# Configuration parameters: Include. +# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb +FactoryBot/FactoryAssociationWithStrategy: + Exclude: + - 'spec/factories/accession/samples.rb' + - 'spec/factories/accession/submissions.rb' + - 'spec/factories/aliquots.rb' + - 'spec/factories/batch_factories.rb' + - 'spec/factories/lib_pcr_xp_factories.rb' + - 'spec/factories/phix_factories.rb' + - 'spec/factories/pipelines_factories.rb' + - 'spec/factories/plate_barcode_factories.rb' + - 'spec/factories/plate_factories.rb' + - 'spec/factories/poly_metadata_factories.rb' + - 'spec/factories/purpose_factories.rb' + - 'spec/factories/request_factories.rb' + - 'spec/factories/request_type_factories.rb' + - 'spec/factories/roles.rb' + - 'spec/factories/sample_manifest_excel/test_download_plates.rb' + - 'spec/factories/sample_manifest_factories.rb' + - 'spec/factories/submission_factories.rb' + - 'spec/factories/tag_set_factories.rb' + - 'spec/factories/tube_factories.rb' + - 'spec/factories/tube_rack.rb' + - 'spec/factories/user_factories.rb' + - 'spec/factories/user_query_factories.rb' + - 'spec/factories/well_factories.rb' + - 'spec/factories/z_tag_qc_factories.rb' + # Offense count: 21 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedMethods, AllowedPatterns. diff --git a/features/support/step_definitions/web_steps.rb b/features/support/step_definitions/web_steps.rb index a520831f5c..9988603faa 100644 --- a/features/support/step_definitions/web_steps.rb +++ b/features/support/step_definitions/web_steps.rb @@ -95,7 +95,7 @@ def with_scope(locator) end Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector| - with_scope(selector) { expect(page).not_to have_text(text) } + with_scope(selector) { expect(page).to have_no_text(text) } end Then %r{^(?:|I )should not see /([^\/]*)/(?: within "([^"]*)")?$} do |regexp, selector| diff --git a/spec/api/api_root_spec.rb b/spec/api/api_root_spec.rb index da190b2974..34acd6b3e9 100644 --- a/spec/api/api_root_spec.rb +++ b/spec/api/api_root_spec.rb @@ -7,7 +7,7 @@ subject { '/api/1/' } describe '#get' do - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } let(:response_body) do '{ @@ -389,7 +389,7 @@ end describe '#get unauthorized' do - let(:user) { create :user } + let(:user) { create(:user) } let(:response_body) do '{ diff --git a/spec/api/asset_audit_spec.rb b/spec/api/asset_audit_spec.rb index dd373e957d..be4e969006 100644 --- a/spec/api/asset_audit_spec.rb +++ b/spec/api/asset_audit_spec.rb @@ -4,8 +4,8 @@ require 'support/barcode_helper' describe '/api/1/asset_audits' do - let(:authorised_app) { create :api_application } - let(:labware) { create :tube } + let(:authorised_app) { create(:api_application) } + let(:labware) { create(:tube) } describe '#post' do subject(:resources) { '/api/1/asset_audits' } @@ -166,7 +166,7 @@ describe '#get' do subject(:resource) { "/api/1/#{asset_audit.uuid}" } - let(:asset_audit) { create :asset_audit } + let(:asset_audit) { create(:asset_audit) } let(:response_body) do { diff --git a/spec/api/dilution_plate_purpose_spec.rb b/spec/api/dilution_plate_purpose_spec.rb index 5957019da7..953a7d7f60 100644 --- a/spec/api/dilution_plate_purpose_spec.rb +++ b/spec/api/dilution_plate_purpose_spec.rb @@ -4,10 +4,10 @@ require 'support/barcode_helper' describe '/api/1/plate-purpose-uuid' do - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } let(:uuid) { '00000000-1111-2222-3333-444444444444' } - before { create :dilution_plate_purpose, :uuidable, uuid:, name: 'Example purpose' } + before { create(:dilution_plate_purpose, :uuidable, uuid:, name: 'Example purpose') } describe '#get' do subject(:url) { '/api/1/' + uuid } diff --git a/spec/api/extraction_attributes_spec.rb b/spec/api/extraction_attributes_spec.rb index 64cac47b4f..1ce7611d9c 100644 --- a/spec/api/extraction_attributes_spec.rb +++ b/spec/api/extraction_attributes_spec.rb @@ -6,14 +6,14 @@ describe '#post' do subject { "/api/1/#{target_plate.uuid}/extraction_attributes" } - let(:user) { create :user, login: 'test' } - let(:authorised_app) { create :api_application } - let(:target_plate) { create :plate_with_empty_wells } + let(:user) { create(:user, login: 'test') } + let(:authorised_app) { create(:api_application) } + let(:target_plate) { create(:plate_with_empty_wells) } let(:response_code) { 201 } it 'supports attributes update on a plate' do - sample_tube = create :sample_tube + sample_tube = create(:sample_tube) payload = "{ \"extraction_attribute\":{ @@ -29,8 +29,8 @@ end describe '#racking' do - let(:sample_tube) { create :sample_tube } - let(:sample_tube2) { create :sample_tube } + let(:sample_tube) { create(:sample_tube) } + let(:sample_tube2) { create(:sample_tube) } let(:source_tube1_uuid) { sample_tube.uuid } let(:source_tube2_uuid) { sample_tube2.uuid } @@ -67,7 +67,7 @@ context 'with a plate with wells' do subject { "/api/1/#{target_plate.uuid}/extraction_attributes" } - let(:target_plate) { create :plate_with_tagged_wells } + let(:target_plate) { create(:plate_with_tagged_wells) } let(:taget_well_a1) { target_plate.wells.located_at('A1').first } let(:taget_well_b1) { target_plate.wells.located_at('B1').first } @@ -78,8 +78,8 @@ end context 'when tubes contain the same samples as the wells' do - let(:sample_tube) { create :sample_tube, sample: taget_well_a1.samples.first } - let(:sample_tube2) { create :sample_tube, sample: taget_well_b1.samples.first } + let(:sample_tube) { create(:sample_tube, sample: taget_well_a1.samples.first) } + let(:sample_tube2) { create(:sample_tube, sample: taget_well_b1.samples.first) } it 'does not rack without error a tube in the well if the well already contains the sample for this tube' do authorized_api_request :post, subject, payload @@ -94,9 +94,9 @@ describe '#reracking' do subject { "/api/1/#{target_plate.uuid}/extraction_attributes" } - let(:previous_plate) { create :plate_with_tagged_wells } - let(:previous_plate2) { create :plate_with_tagged_wells } - let(:target_plate) { create :plate_with_empty_wells } + let(:previous_plate) { create(:plate_with_tagged_wells) } + let(:previous_plate2) { create(:plate_with_tagged_wells) } + let(:target_plate) { create(:plate_with_empty_wells) } let(:well1) { previous_plate.wells.first } let(:well2) { previous_plate2.wells.first } @@ -133,7 +133,7 @@ # rubocop:enable Layout/LineLength subject { "/api/1/#{target_plate.uuid}/extraction_attributes" } - let(:target_plate) { create :plate_with_tagged_wells } + let(:target_plate) { create(:plate_with_tagged_wells) } let(:well1) { target_plate.wells[0] } let(:well2) { target_plate.wells[1] } let(:well3) { target_plate.wells[2] } @@ -212,10 +212,10 @@ end describe '#racking + #reracking' do - let(:previous_plate) { create :plate_with_tagged_wells } - let(:previous_plate2) { create :plate_with_tagged_wells } - let(:sample_tube) { create :sample_tube } - let(:sample_tube2) { create :sample_tube } + let(:previous_plate) { create(:plate_with_tagged_wells) } + let(:previous_plate2) { create(:plate_with_tagged_wells) } + let(:sample_tube) { create(:sample_tube) } + let(:sample_tube2) { create(:sample_tube) } let(:well1) { previous_plate.wells.first } let(:well2) { previous_plate2.wells.first } @@ -254,12 +254,12 @@ end context 'in different requests' do - let(:second_plate) { create :plate_with_tagged_wells } + let(:second_plate) { create(:plate_with_tagged_wells) } let(:first_plate_subject) { "/api/1/#{first_plate.uuid}/extraction_attributes" } let(:second_plate_subject) { "/api/1/#{second_plate.uuid}/extraction_attributes" } - let(:sample_tube) { create :sample_tube } - let(:sample_tube2) { create :sample_tube } + let(:sample_tube) { create(:sample_tube) } + let(:sample_tube2) { create(:sample_tube) } let(:well1) { first_plate.wells.located_at('A1').first } let(:well2) { first_plate.wells.located_at('B1').first } @@ -294,7 +294,7 @@ end context 'with 2 plates with samples already' do - let(:first_plate) { create :plate_with_tagged_wells } + let(:first_plate) { create(:plate_with_tagged_wells) } context 'when performing a rerack from a position and then try to rack back' do it 'reracks to the second plate but fails to rack into the first plate' do @@ -333,7 +333,7 @@ end context 'with a first empty plate and second full plate' do - let(:first_plate) { create :plate_with_empty_wells } + let(:first_plate) { create(:plate_with_empty_wells) } it 'racks to the first plate and reracks to the second plate' do authorized_api_request :post, first_plate_subject, payload_rack diff --git a/spec/api/labware_spec.rb b/spec/api/labware_spec.rb index df81b2a8c1..f52d4f9301 100644 --- a/spec/api/labware_spec.rb +++ b/spec/api/labware_spec.rb @@ -4,12 +4,12 @@ require 'support/barcode_helper' describe '/api/1/labware-uuid' do - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } let(:uuid) { labware.uuid } let(:custom_metadata_uuid) { collection.uuid } let(:purpose_uuid) { '00000000-1111-2222-3333-666666666666' } - let!(:labware) { create :labware } + let!(:labware) { create(:labware) } describe '#get' do subject(:url) { '/api/1/' + uuid } diff --git a/spec/api/multiplexed_library_tube_spec.rb b/spec/api/multiplexed_library_tube_spec.rb index 993b003276..05396c14d3 100644 --- a/spec/api/multiplexed_library_tube_spec.rb +++ b/spec/api/multiplexed_library_tube_spec.rb @@ -4,13 +4,13 @@ require 'support/barcode_helper' describe '/api/1/multiplexed-library-tube-uuid' do - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } let(:uuid) { tube.uuid } let(:custom_metadata_uuid) { collection.uuid } let(:purpose_uuid) { '00000000-1111-2222-3333-666666666666' } - let(:purpose) { create :tube_purpose, :uuidable, uuid: purpose_uuid, name: 'Example purpose' } - let(:tube) { create :multiplexed_library_tube, purpose:, volume: 8.76000000 } + let(:purpose) { create(:tube_purpose, :uuidable, uuid: purpose_uuid, name: 'Example purpose') } + let(:tube) { create(:multiplexed_library_tube, purpose:, volume: 8.76000000) } let(:collection) { create(:custom_metadatum_collection, asset: tube) } before do diff --git a/spec/api/plate_purpose_spec.rb b/spec/api/plate_purpose_spec.rb index e4ccaba86b..16de8752a7 100644 --- a/spec/api/plate_purpose_spec.rb +++ b/spec/api/plate_purpose_spec.rb @@ -6,8 +6,8 @@ describe '/api/1/plate_purposes' do subject { '/api/1/plate_purposes' } - let(:authorised_app) { create :api_application } - let(:parent_purpose) { create :plate_purpose } + let(:authorised_app) { create(:api_application) } + let(:parent_purpose) { create(:plate_purpose) } describe '#post' do let(:payload) do @@ -46,10 +46,10 @@ end describe '/api/1/plate-purpose-uuid' do - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } let(:uuid) { '00000000-1111-2222-3333-444444444444' } - before { create :plate_purpose, :uuidable, uuid:, name: 'Example purpose' } + before { create(:plate_purpose, :uuidable, uuid:, name: 'Example purpose') } describe '#get' do subject { '/api/1/' + uuid } diff --git a/spec/api/plate_spec.rb b/spec/api/plate_spec.rb index 621d980c96..d90404c29a 100644 --- a/spec/api/plate_spec.rb +++ b/spec/api/plate_spec.rb @@ -6,10 +6,10 @@ describe '/api/1/plate-uuid' do subject { '/api/1/' + uuid } - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } let(:uuid) { plate.uuid } - let(:plate) { create :plate, barcode: 'SQPD-1' } + let(:plate) { create(:plate, barcode: 'SQPD-1') } before { custom_metadata_collection } @@ -131,7 +131,7 @@ end let(:stock_plate) { create(:full_stock_plate, barcode: 'SQPD-2') } - let(:plate) { create :plate, parents: [stock_plate], barcode: 'SQPD-1' } + let(:plate) { create(:plate, parents: [stock_plate], barcode: 'SQPD-1') } let(:response_code) { 200 } it 'supports resource reading' do diff --git a/spec/api/qcable_creator_spec.rb b/spec/api/qcable_creator_spec.rb index af505b750f..a5ccde7327 100644 --- a/spec/api/qcable_creator_spec.rb +++ b/spec/api/qcable_creator_spec.rb @@ -5,9 +5,9 @@ describe '/api/1/qcable_creators' do subject { '/api/1/qcable_creators' } - let(:authorised_app) { create :api_application } - let(:user) { create :user } - let(:lot) { create :tag2_lot } + let(:authorised_app) { create(:api_application) } + let(:user) { create(:user) } + let(:lot) { create(:tag2_lot) } let(:barcodes) { %w[CGAP-1 CGAP-2 CGAP-3 CGAP-4 CGAP-5] } describe '#post' do diff --git a/spec/api/receptacle_spec.rb b/spec/api/receptacle_spec.rb index 4576d39feb..afe5dd313b 100644 --- a/spec/api/receptacle_spec.rb +++ b/spec/api/receptacle_spec.rb @@ -4,12 +4,12 @@ require 'support/barcode_helper' describe '/api/1/receptacle-uuid' do - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } let(:uuid) { receptacle.uuid } let(:custom_metadata_uuid) { collection.uuid } let(:purpose_uuid) { '00000000-1111-2222-3333-666666666666' } - let(:receptacle) { create :receptacle } + let(:receptacle) { create(:receptacle) } describe '#get' do subject(:url) { '/api/1/' + uuid } diff --git a/spec/api/request_types_spec.rb b/spec/api/request_types_spec.rb index 89a99a75b3..8dde9e0540 100644 --- a/spec/api/request_types_spec.rb +++ b/spec/api/request_types_spec.rb @@ -4,10 +4,10 @@ require 'support/barcode_helper' describe '/api/1/request-type-uuid' do - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } let(:uuid) { '00000000-1111-2222-3333-444444444444' } - before { create :request_type, :uuidable, uuid:, name: 'Sequencing by colour' } + before { create(:request_type, :uuidable, uuid:, name: 'Sequencing by colour') } describe '#get' do subject(:url) { '/api/1/' + uuid } diff --git a/spec/api/specific_tube_creation_spec.rb b/spec/api/specific_tube_creation_spec.rb index d24608dcf2..fb9b4495c6 100644 --- a/spec/api/specific_tube_creation_spec.rb +++ b/spec/api/specific_tube_creation_spec.rb @@ -3,17 +3,17 @@ require 'rails_helper' describe 'TubeCreation endpoints' do - let(:authorised_app) { create :api_application } - let(:user) { create :user } + let(:authorised_app) { create(:api_application) } + let(:user) { create(:user) } describe 'Creating a tube' do let(:endpoint) { '/api/1/specific_tube_creations' } - let(:parent_plate) { create :plate, well_count: 5 } - let!(:stock_plate) { create :full_stock_plate, well_count: parent_plate.wells.count } + let(:parent_plate) { create(:plate, well_count: 5) } + let!(:stock_plate) { create(:full_stock_plate, well_count: parent_plate.wells.count) } let!(:submission) { Submission.create!(user:) } - let(:child_purpose) { create :tube_purpose } + let(:child_purpose) { create(:tube_purpose) } before do AssetLink.create!(ancestor: stock_plate, descendant: parent_plate) @@ -125,7 +125,7 @@ def construct_expected_response_body(new_tube_creation) } end - let!(:parent_tube) { create :tube } + let!(:parent_tube) { create(:tube) } let(:payload) do { specific_tube_creation: { diff --git a/spec/api/state_change_spec.rb b/spec/api/state_change_spec.rb index 63a52826d2..c565555f05 100644 --- a/spec/api/state_change_spec.rb +++ b/spec/api/state_change_spec.rb @@ -8,9 +8,9 @@ include_context 'a limber target plate with submissions' - let(:authorised_app) { create :api_application } - let(:parent_purpose) { create :plate_purpose } - let(:user) { create :user } + let(:authorised_app) { create(:api_application) } + let(:parent_purpose) { create(:plate_purpose) } + let(:user) { create(:user) } shared_examples 'a state_change_endpoint' do let(:response_code) { 201 } diff --git a/spec/api/submission_pool_spec.rb b/spec/api/submission_pool_spec.rb index 27b37f5c47..f6c509f063 100644 --- a/spec/api/submission_pool_spec.rb +++ b/spec/api/submission_pool_spec.rb @@ -5,14 +5,14 @@ require_relative 'shared_examples' describe '/api/1/plate-uuid/submission_pools' do - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } let(:uuid) { plate.uuid } let(:custom_metadata_uuid) { collection.uuid } let(:purpose_uuid) { '00000000-1111-2222-3333-666666666666' } - let(:submission) { create :submission } - let(:tag2_layout_template) { create :tag2_layout_template } - let(:tag_layout_template) { create :tag_layout_template } - let(:request_type) { create :library_creation_request_type } + let(:submission) { create(:submission) } + let(:tag2_layout_template) { create(:tag2_layout_template) } + let(:tag_layout_template) { create(:tag_layout_template) } + let(:request_type) { create(:library_creation_request_type) } describe '#get' do subject { '/api/1/' + uuid + '/submission_pools' } @@ -20,7 +20,7 @@ let(:response_code) { 200 } context 'a plate without submissions' do - let(:plate) { create :plate } + let(:plate) { create(:plate) } let(:response_body) do "{ \"actions\": { @@ -37,11 +37,11 @@ end context 'a submission and a used tag 2 template' do - let(:plate) { create :input_plate, well_count: 2 } + let(:plate) { create(:input_plate, well_count: 2) } before do - plate.wells.each { |well| create :library_creation_request, asset: well, submission:, request_type: } - create :tag2_layout_template_submission, submission:, tag2_layout_template: + plate.wells.each { |well| create(:library_creation_request, asset: well, submission:, request_type:) } + create(:tag2_layout_template_submission, submission:, tag2_layout_template:) end let(:response_body) do @@ -66,11 +66,11 @@ end context 'a submission with canceleld requests' do - let(:plate) { create :input_plate, well_count: 2 } + let(:plate) { create(:input_plate, well_count: 2) } before do plate.wells.each do |well| - create :library_creation_request, asset: well, submission:, request_type:, state: 'cancelled' + create(:library_creation_request, asset: well, submission:, request_type:, state: 'cancelled') end end @@ -94,11 +94,11 @@ end context 'a submission and a used tag template' do - let(:plate) { create :input_plate, well_count: 2 } + let(:plate) { create(:input_plate, well_count: 2) } before do - plate.wells.each { |well| create :library_creation_request, asset: well, submission:, request_type: } - create :tag_layout_template_submission, submission:, tag_layout_template: + plate.wells.each { |well| create(:library_creation_request, asset: well, submission:, request_type:) } + create(:tag_layout_template_submission, submission:, tag_layout_template:) end let(:response_body) do @@ -123,12 +123,12 @@ end context 'a multi plate submission' do - let(:plate) { create :input_plate, well_count: 2 } - let(:plate_b) { create :input_plate, well_count: 2 } + let(:plate) { create(:input_plate, well_count: 2) } + let(:plate_b) { create(:input_plate, well_count: 2) } before do - plate.wells.each { |well| create :library_creation_request, asset: well, submission:, request_type: } - plate_b.wells.each { |well| create :library_creation_request, asset: well, submission:, request_type: } + plate.wells.each { |well| create(:library_creation_request, asset: well, submission:, request_type:) } + plate_b.wells.each { |well| create(:library_creation_request, asset: well, submission:, request_type:) } end let(:response_body) do @@ -152,14 +152,14 @@ context 'a multi plate submission and a used template on children' do let(:plate_b) do - plate = create :input_plate, well_count: 2 - plate.wells.each { |well| create :library_creation_request, asset: well, submission:, request_type: } + plate = create(:input_plate, well_count: 2) + plate.wells.each { |well| create(:library_creation_request, asset: well, submission:, request_type:) } plate end - let(:plate) { create :target_plate, well_count: 2, parent: plate_b, submission: } + let(:plate) { create(:target_plate, well_count: 2, parent: plate_b, submission:) } - before { create :tag2_layout_template_submission, submission:, tag2_layout_template: } + before { create(:tag2_layout_template_submission, submission:, tag2_layout_template:) } let(:response_body) do "{ diff --git a/spec/api/tag_layout_template_spec.rb b/spec/api/tag_layout_template_spec.rb index 9ad4d41da1..b0681f8efd 100644 --- a/spec/api/tag_layout_template_spec.rb +++ b/spec/api/tag_layout_template_spec.rb @@ -8,8 +8,8 @@ subject { '/api/1/tag_layout_templates' } - let(:authorised_app) { create :api_application } - let(:user) { create :user } + let(:authorised_app) { create(:api_application) } + let(:user) { create(:user) } describe '#get' do describe 'with valid tag layout template' do @@ -48,7 +48,7 @@ end let(:response_code) { 200 } - let!(:example_template) { create :tag_layout_template, tags: ['', ''] } + let!(:example_template) { create(:tag_layout_template, tags: ['', '']) } let(:example_template_uuid) { example_template.uuid } let(:example_group) { example_template.tag_group } @@ -78,7 +78,7 @@ end let(:response_code) { 200 } - let!(:example_template) { create :tag_layout_template, tags: ['', ''] } + let!(:example_template) { create(:tag_layout_template, tags: ['', '']) } before do example_template.enabled = false @@ -96,7 +96,7 @@ describe '/api/1/template-uuid' do subject { "/api/1/#{example_template.uuid}" } - let(:example_template) { create :entire_plate_tag_layout_template, name: 'Test Example', tags: %w[AAA TTT] } + let(:example_template) { create(:entire_plate_tag_layout_template, name: 'Test Example', tags: %w[AAA TTT]) } let(:example_tag_group) { example_template.tag_group } describe '#get' do @@ -131,7 +131,7 @@ end describe '#post' do - let(:target) { create :plate } + let(:target) { create(:plate) } let(:payload) { "{\"tag_layout\":{ \"plate\": \"#{target.uuid}\", \"user\": \"#{user.uuid}\"}}" } let(:response_body) do diff --git a/spec/api/transfer_request_collection_spec.rb b/spec/api/transfer_request_collection_spec.rb index 699f75d514..5d4f011208 100644 --- a/spec/api/transfer_request_collection_spec.rb +++ b/spec/api/transfer_request_collection_spec.rb @@ -8,12 +8,12 @@ subject { '/api/1/transfer_request_collection' } - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } - let(:asset) { create :tagged_well } - let(:target_asset) { create :empty_library_tube, barcode: 898 } - let(:user) { create :user } - let(:submission) { create :submission } + let(:asset) { create(:tagged_well) } + let(:target_asset) { create(:empty_library_tube, barcode: 898) } + let(:user) { create(:user) } + let(:submission) { create(:submission) } describe '#post' do let(:payload) do diff --git a/spec/api/tube_creation_spec.rb b/spec/api/tube_creation_spec.rb index b7f3f9b9fc..cca098f4da 100644 --- a/spec/api/tube_creation_spec.rb +++ b/spec/api/tube_creation_spec.rb @@ -3,17 +3,17 @@ require 'rails_helper' describe 'TubeCreation endpoints' do - let(:authorised_app) { create :api_application } - let(:user) { create :user } + let(:authorised_app) { create(:api_application) } + let(:user) { create(:user) } describe 'Creating a tube' do let(:endpoint) { '/api/1/tube_creations' } - let(:parent_plate) { create :plate, well_count: 5 } - let!(:stock_plate) { create :full_stock_plate, well_count: parent_plate.wells.count } + let(:parent_plate) { create(:plate, well_count: 5) } + let!(:stock_plate) { create(:full_stock_plate, well_count: parent_plate.wells.count) } let!(:submission) { Submission.create!(user:) } - let(:child_purpose) { create :tube_purpose } + let(:child_purpose) { create(:tube_purpose) } before do AssetLink.create!(ancestor: stock_plate, descendant: parent_plate) diff --git a/spec/api/tube_purpose_spec.rb b/spec/api/tube_purpose_spec.rb index 9b5fe7ba18..777c790e34 100644 --- a/spec/api/tube_purpose_spec.rb +++ b/spec/api/tube_purpose_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe '/api/1/tube/purposes' do - let(:authorised_app) { create :api_application } - let(:parent_purpose) { create :plate_purpose } + let(:authorised_app) { create(:api_application) } + let(:parent_purpose) { create(:plate_purpose) } let(:payload) do '{ diff --git a/spec/api/well_spec.rb b/spec/api/well_spec.rb index 66f8527da7..8664b0fa03 100644 --- a/spec/api/well_spec.rb +++ b/spec/api/well_spec.rb @@ -4,12 +4,12 @@ require 'support/barcode_helper' describe '/api/1/well-uuid' do - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } let(:uuid) { well.uuid } let(:custom_metadata_uuid) { collection.uuid } let(:purpose_uuid) { '00000000-1111-2222-3333-666666666666' } - let(:well) { create :well_with_sample_and_plate } + let(:well) { create(:well_with_sample_and_plate) } let(:sample) { well.samples.first } before { well } diff --git a/spec/api/work_completion_spec.rb b/spec/api/work_completion_spec.rb index ff0ed12b98..6811384bd8 100644 --- a/spec/api/work_completion_spec.rb +++ b/spec/api/work_completion_spec.rb @@ -8,9 +8,9 @@ subject { '/api/1/work_completions' } - let(:authorised_app) { create :api_application } - let(:parent_purpose) { create :plate_purpose } - let(:user) { create :user } + let(:authorised_app) { create(:api_application) } + let(:parent_purpose) { create(:plate_purpose) } + let(:user) { create(:user) } describe '#post' do let(:payload) do diff --git a/spec/bulk_submission_excel/download_spec.rb b/spec/bulk_submission_excel/download_spec.rb index 148d19b0f0..c9dda3438e 100644 --- a/spec/bulk_submission_excel/download_spec.rb +++ b/spec/bulk_submission_excel/download_spec.rb @@ -30,7 +30,7 @@ let(:columns) { configuration.columns.all.dup } let(:ranges) { configuration.ranges.dup } let(:assets) { create(:plate_with_untagged_wells).wells } - let(:submission_template) { create :libray_and_sequencing_template } + let(:submission_template) { create(:libray_and_sequencing_template) } after { File.delete(test_file) if File.exist?(test_file) } diff --git a/spec/controllers/admin/primer_panels_controller_spec.rb b/spec/controllers/admin/primer_panels_controller_spec.rb index 4e0d508df0..856f29f85f 100644 --- a/spec/controllers/admin/primer_panels_controller_spec.rb +++ b/spec/controllers/admin/primer_panels_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Admin::PrimerPanelsController do - let(:primer_panel) { create :primer_panel } + let(:primer_panel) { create(:primer_panel) } context 'as admin' do before { session[:user] = create :admin } diff --git a/spec/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller_spec.rb b/spec/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller_spec.rb index 47799f5963..d2254540d4 100644 --- a/spec/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller_spec.rb +++ b/spec/controllers/api/v2/bioscan/export_pool_xp_to_traction_controller_spec.rb @@ -7,8 +7,8 @@ let(:tube_purpose_name) { 'LBSN-9216 Lib PCR Pool XP' } let(:requested_barcode) { tube.human_barcode } - let(:tube_purpose) { create :tube_purpose, name: tube_purpose_name } - let(:tube) { create :multiplexed_library_tube, purpose: tube_purpose } + let(:tube_purpose) { create(:tube_purpose, name: tube_purpose_name) } + let(:tube) { create(:multiplexed_library_tube, purpose: tube_purpose) } let(:params) do { @@ -22,7 +22,7 @@ end before do - create :transfer_request, state: tube_state, target_asset: tube.receptacle + create(:transfer_request, state: tube_state, target_asset: tube.receptacle) post api_v2_bioscan_export_pool_xp_to_traction_index_path, params: end diff --git a/spec/controllers/api/v2/heron/plates_controller_spec.rb b/spec/controllers/api/v2/heron/plates_controller_spec.rb index ed9c91dbe7..12a54e4a90 100644 --- a/spec/controllers/api/v2/heron/plates_controller_spec.rb +++ b/spec/controllers/api/v2/heron/plates_controller_spec.rb @@ -7,7 +7,7 @@ include BarcodeHelper let(:stock_plate_purpose) { PlatePurpose.stock_plate_purpose } - let(:study) { create :study, name: 'Study 1' } + let(:study) { create(:study, name: 'Study 1') } before { mock_plate_barcode_service } diff --git a/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb b/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb index d9b3cbc7c1..e14eb5731e 100644 --- a/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb +++ b/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb @@ -7,7 +7,7 @@ include BarcodeHelper let!(:purpose_96) { create(:tube_rack_purpose, target_type: 'TubeRack', size: 96) } - let(:study) { create :study, name: 'Study 1' } + let(:study) { create(:study, name: 'Study 1') } before { mock_plate_barcode_service } diff --git a/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb b/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb index 7baac5bead..71eef6edae 100644 --- a/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb +++ b/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb @@ -3,7 +3,7 @@ RSpec.describe BulkSubmissionExcel::DownloadsController, type: :controller do subject(:downloads_controller) { described_class.new } - let(:submission) { create :submission } + let(:submission) { create(:submission) } before do session[:user] = create :admin diff --git a/spec/controllers/driver_files_controller_spec.rb b/spec/controllers/driver_files_controller_spec.rb index 46846d4f17..8cb489f93f 100644 --- a/spec/controllers/driver_files_controller_spec.rb +++ b/spec/controllers/driver_files_controller_spec.rb @@ -3,28 +3,28 @@ require 'rails_helper' RSpec.describe DriverFilesController do - let(:current_user) { create :user } + let(:current_user) { create(:user) } describe '#show' do - let(:robot) { create :full_robot, generation_behaviour_value: 'Tecan' } + let(:robot) { create(:full_robot, generation_behaviour_value: 'Tecan') } let(:time) { Time.zone.local(2010, 7, 12, 10, 25, 0) } - let(:source_plate) { create :plate, well_count: 1 } - let(:destination_plate) { create :plate, well_count: 1, well_factory: :picked_well } - let(:pipeline) { create :cherrypick_pipeline } + let(:source_plate) { create(:plate, well_count: 1) } + let(:destination_plate) { create(:plate, well_count: 1, well_factory: :picked_well) } + let(:pipeline) { create(:cherrypick_pipeline) } let(:transfers) { { source_plate.wells[0] => destination_plate.wells.first } } let(:requests) do - create_list :cherrypick_request, + create_list(:cherrypick_request, 1, asset: source_plate.wells.first, target_asset: destination_plate.wells.first, request_type: pipeline.request_types.first, - state: 'passed' + state: 'passed') end - let(:batch) { create :batch, requests:, pipeline:, user: current_user } + let(:batch) { create(:batch, requests:, pipeline:, user: current_user) } before do get :show, params: { batch_id: batch.id, robot_id: robot.id, pick_number: 1 }, session: { user: current_user.id } diff --git a/spec/controllers/lab_searches_controller_spec.rb b/spec/controllers/lab_searches_controller_spec.rb index dab4055114..4a10643ecf 100644 --- a/spec/controllers/lab_searches_controller_spec.rb +++ b/spec/controllers/lab_searches_controller_spec.rb @@ -3,14 +3,14 @@ require 'rails_helper' RSpec.describe LabSearchesController do - let(:current_user) { create :user } + let(:current_user) { create(:user) } it_behaves_like 'it requires login' context 'searching (when logged in)' do let!(:asset) { create(:sample_tube, name: 'FindMeAsset') } let!(:other_asset) { create(:sample_tube) } - let!(:batch) { create :batch, user: current_user } + let!(:batch) { create(:batch, user: current_user) } describe '#new' do before { get :new, params: { q: query }, session: { user: current_user.id } } @@ -65,7 +65,7 @@ end context 'with a plate barcode' do - let(:asset) { create :plate } + let(:asset) { create(:plate) } let(:query) { asset.human_barcode } it 'finds the asset' do diff --git a/spec/controllers/labwhere_receptions_controller_spec.rb b/spec/controllers/labwhere_receptions_controller_spec.rb index 7c0954029c..160324a7da 100644 --- a/spec/controllers/labwhere_receptions_controller_spec.rb +++ b/spec/controllers/labwhere_receptions_controller_spec.rb @@ -4,10 +4,10 @@ describe LabwhereReceptionsController do context 'Sample Reception' do - let(:user) { create :user, barcode: 'ID48601I', swipecard_code: '02face' } - let(:plate) { create :plate } - let(:plate_2) { create :plate } - let(:sample_tube) { create :sample_tube, barcode: 1 } + let(:user) { create(:user, barcode: 'ID48601I', swipecard_code: '02face') } + let(:plate) { create(:plate) } + let(:plate_2) { create(:plate) } + let(:sample_tube) { create(:sample_tube, barcode: 1) } shared_examples 'a reception' do before do diff --git a/spec/controllers/messengers_controller_spec.rb b/spec/controllers/messengers_controller_spec.rb index d5159278dd..478559df71 100644 --- a/spec/controllers/messengers_controller_spec.rb +++ b/spec/controllers/messengers_controller_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' RSpec.describe MessengersController do - let(:user) { create :user } - let(:messenger) { create :messenger } + let(:user) { create(:user) } + let(:messenger) { create(:messenger) } before { session[:user] = user.id } diff --git a/spec/controllers/npg_actions/assets_controller_spec.rb b/spec/controllers/npg_actions/assets_controller_spec.rb index 16cdc0db8e..8b0424b77a 100644 --- a/spec/controllers/npg_actions/assets_controller_spec.rb +++ b/spec/controllers/npg_actions/assets_controller_spec.rb @@ -3,35 +3,35 @@ require 'rails_helper' RSpec.describe NpgActions::AssetsController, type: :request do - let(:user) { create :user, password: 'password' } + let(:user) { create(:user, password: 'password') } - let(:lane) { create :lane_with_stock_plate, name: 'NPG_Action_Lane_Test', qc_state: 'passed', external_release: 1 } - let(:study) { create :study } - let(:pipeline) { create :sequencing_pipeline } - let(:batch) { create :sequencing_batch, state: 'started', qc_state: 'qc_manual' } + let(:lane) { create(:lane_with_stock_plate, name: 'NPG_Action_Lane_Test', qc_state: 'passed', external_release: 1) } + let(:study) { create(:study) } + let(:pipeline) { create(:sequencing_pipeline) } + let(:batch) { create(:sequencing_batch, state: 'started', qc_state: 'qc_manual') } let(:valid_seq_request) do - create :sequencing_request_with_assets, + create(:sequencing_request_with_assets, batch:, request_type: batch.pipeline.request_types.first, study:, target_asset: lane, - state: 'passed' + state: 'passed') end let(:cancelled_seq_request) do - create :sequencing_request_with_assets, + create(:sequencing_request_with_assets, batch:, request_type: batch.pipeline.request_types.first, study:, target_asset: lane, - state: 'cancelled' + state: 'cancelled') end let(:failed_seq_request) do - create :sequencing_request_with_assets, + create(:sequencing_request_with_assets, batch:, request_type: batch.pipeline.request_types.first, study:, target_asset: lane, - state: 'failed' + state: 'failed') end before { post '/login', params: { login: user.login, password: 'password' } } diff --git a/spec/controllers/parents_controller_spec.rb b/spec/controllers/parents_controller_spec.rb index b7ac6868c8..2a7544557a 100644 --- a/spec/controllers/parents_controller_spec.rb +++ b/spec/controllers/parents_controller_spec.rb @@ -3,16 +3,16 @@ require 'rails_helper' RSpec.describe ParentsController do - let(:current_user) { create :user } + let(:current_user) { create(:user) } it_behaves_like 'it requires login', 'show', parent: :receptacle describe '#show' do - let(:child) { create :lane } + let(:child) { create(:lane) } let(:parents) { create_list(:library_tube, parent_number).map(&:receptacle) } before do - parents.each { |parent| create :sequencing_request, target_asset: child, asset: parent } + parents.each { |parent| create(:sequencing_request, target_asset: child, asset: parent) } child.reload get :show, params: { receptacle_id: child.id }, session: { user: current_user.id } end diff --git a/spec/controllers/phi_x/spiked_buffers_controller_spec.rb b/spec/controllers/phi_x/spiked_buffers_controller_spec.rb index ba17b3ee01..b805b9903b 100644 --- a/spec/controllers/phi_x/spiked_buffers_controller_spec.rb +++ b/spec/controllers/phi_x/spiked_buffers_controller_spec.rb @@ -4,8 +4,8 @@ RSpec.describe PhiX::SpikedBuffersController, :phi_x do describe 'POST create' do - let(:current_user) { create :user } - let(:library_tube) { create :phi_x_stock_tube, name: 'PhiX Stock' } + let(:current_user) { create(:user) } + let(:library_tube) { create(:phi_x_stock_tube, name: 'PhiX Stock') } before { post :create, params: { phi_x_spiked_buffer: form_parameters }, session: { user: current_user.id } } diff --git a/spec/controllers/phi_x/stocks_controller_spec.rb b/spec/controllers/phi_x/stocks_controller_spec.rb index 912fe76a3e..2531891dd2 100644 --- a/spec/controllers/phi_x/stocks_controller_spec.rb +++ b/spec/controllers/phi_x/stocks_controller_spec.rb @@ -4,8 +4,8 @@ RSpec.describe PhiX::StocksController, :phi_x do describe 'POST create' do - let(:current_user) { create :user } - let(:study) { create :study } + let(:current_user) { create(:user) } + let(:study) { create(:study) } before { post :create, params: { phi_x_stock: form_parameters }, session: { user: current_user.id } } diff --git a/spec/controllers/phi_xes_controller_spec.rb b/spec/controllers/phi_xes_controller_spec.rb index 0e38077378..da8ca5edea 100644 --- a/spec/controllers/phi_xes_controller_spec.rb +++ b/spec/controllers/phi_xes_controller_spec.rb @@ -4,7 +4,7 @@ RSpec.describe PhiXesController, :phi_x do describe 'GET show' do - let(:current_user) { create :user } + let(:current_user) { create(:user) } before { get :show, session: { user: current_user.id } } diff --git a/spec/controllers/receptacles_controller_spec.rb b/spec/controllers/receptacles_controller_spec.rb index 9b8710e970..2062f406a3 100644 --- a/spec/controllers/receptacles_controller_spec.rb +++ b/spec/controllers/receptacles_controller_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' RSpec.describe ReceptaclesController do - let(:current_user) { create :user } + let(:current_user) { create(:user) } let!(:tube) { create(:sample_tube).receptacle } - let!(:lane) { create :lane } - let!(:well) { create :untagged_well, study: } - let(:study) { create :study } + let!(:lane) { create(:lane) } + let!(:well) { create(:untagged_well, study:) } + let(:study) { create(:study) } it_behaves_like 'it requires login' diff --git a/spec/controllers/report_fails_controller_spec.rb b/spec/controllers/report_fails_controller_spec.rb index adf1d1a89b..a23aeb7fb0 100644 --- a/spec/controllers/report_fails_controller_spec.rb +++ b/spec/controllers/report_fails_controller_spec.rb @@ -4,10 +4,10 @@ describe ReportFailsController do context 'with Report Fails' do - let(:user) { create :user, barcode: 'ID48601I', swipecard_code: '02face' } - let(:plate) { create :plate } - let(:plate_2) { create :plate } - let(:sample_tube) { create :sample_tube, barcode: 1 } + let(:user) { create(:user, barcode: 'ID48601I', swipecard_code: '02face') } + let(:plate) { create(:plate) } + let(:plate_2) { create(:plate) } + let(:sample_tube) { create(:sample_tube, barcode: 1) } shared_examples 'a successful failure event' do before do diff --git a/spec/controllers/robot_verifications_controller_spec.rb b/spec/controllers/robot_verifications_controller_spec.rb index 1008231ff9..f712bacae7 100644 --- a/spec/controllers/robot_verifications_controller_spec.rb +++ b/spec/controllers/robot_verifications_controller_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' RSpec.describe RobotVerificationsController do - let(:user) { create :user, barcode: 'ID41440E', swipecard_code: '1234567' } - let(:batch) { create :batch, barcode: '6262' } + let(:user) { create(:user, barcode: 'ID41440E', swipecard_code: '1234567') } + let(:batch) { create(:batch, barcode: '6262') } let(:robot) do - create :robot_with_verification_behaviour, barcode: '1', number_of_sources: 4, number_of_destinations: 1 + create(:robot_with_verification_behaviour, barcode: '1', number_of_sources: 4, number_of_destinations: 1) end - let(:plate) { create :plate, barcode: 'SQPD-142334' } + let(:plate) { create(:plate, barcode: 'SQPD-142334') } before { session[:user] = user.id } @@ -67,9 +67,9 @@ expected_layout[1].each_with_index do |(barcode, _sort_number), index| source_plate = create(:plate, barcode:) position = Map.for_position_on_plate(index + 1, 96, source_plate.asset_shape).first - well = create :well, map: position, plate: source_plate + well = create(:well, map: position, plate: source_plate) target_well = create(:well, map: position, plate:) - well_request = create :request, state: 'passed', asset: well, target_asset: target_well + well_request = create(:request, state: 'passed', asset: well, target_asset: target_well) batch.requests << well_request end robot.save @@ -239,10 +239,10 @@ end describe '#submission' do - let(:well) { create :well, plate: } - let(:well_request) { create :request, state: 'passed' } - let(:source_plate) { create :plate, barcode: 'SQPD-1234' } - let(:target_well) { create :well, plate: source_plate } + let(:well) { create(:well, plate:) } + let(:well_request) { create(:request, state: 'passed') } + let(:source_plate) { create(:plate, barcode: 'SQPD-1234') } + let(:target_well) { create(:well, plate: source_plate) } before do well_request.asset = well diff --git a/spec/controllers/samples_controller_spec.rb b/spec/controllers/samples_controller_spec.rb index b71e8c5bc8..b8d745f0d0 100644 --- a/spec/controllers/samples_controller_spec.rb +++ b/spec/controllers/samples_controller_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' RSpec.describe SamplesController do - let(:sample) { create :sample } - let(:current_user) { create :user } + let(:sample) { create(:sample) } + let(:current_user) { create(:user) } it_behaves_like 'it requires login' @@ -64,10 +64,10 @@ context 'when consent withdrawn starts off true' do let(:sample) do - create :sample, + create(:sample, consent_withdrawn: true, date_of_consent_withdrawn: Time.zone.today, - user_id_of_consent_withdrawn: current_user.id + user_id_of_consent_withdrawn: current_user.id) end context 'when changing withdraw consent' do diff --git a/spec/controllers/searches_controller_spec.rb b/spec/controllers/searches_controller_spec.rb index a1461b292b..be2b40d32f 100644 --- a/spec/controllers/searches_controller_spec.rb +++ b/spec/controllers/searches_controller_spec.rb @@ -3,25 +3,25 @@ require 'rails_helper' RSpec.describe SearchesController do - let(:current_user) { create :user } + let(:current_user) { create(:user) } it_behaves_like 'it requires login' context 'searching (when logged in)' do - let!(:study) { create :study, name: 'FindMeStudy' } - let!(:study2) { create :study, name: 'Another study' } - let!(:sample) { create :sample, name: 'FindMeSample' } + let!(:study) { create(:study, name: 'FindMeStudy') } + let!(:study2) { create(:study, name: 'Another study') } + let!(:sample) { create(:sample, name: 'FindMeSample') } let!(:asset) { create(:sample_tube, name: 'FindMeAsset') } let!(:other_asset) { create(:sample_tube) } - let!(:asset_group_to_find) { create :asset_group, name: 'FindMeAssetGroup', study: } - let!(:asset_group_to_not_find) { create :asset_group, name: 'IgnoreAssetGroup' } + let!(:asset_group_to_find) { create(:asset_group, name: 'FindMeAssetGroup', study:) } + let!(:asset_group_to_not_find) { create(:asset_group, name: 'IgnoreAssetGroup') } - let!(:submission) { create :submission, name: 'FindMe' } - let!(:ignore_submission) { create :submission, name: 'IgnoreMeSub' } + let!(:submission) { create(:submission, name: 'FindMe') } + let!(:ignore_submission) { create(:submission, name: 'IgnoreMeSub') } - let!(:sample_with_supplier_name) { create :sample, sample_metadata_attributes: { supplier_name: 'FindMe' } } + let!(:sample_with_supplier_name) { create(:sample, sample_metadata_attributes: { supplier_name: 'FindMe' }) } let!(:sample_with_accession_number) do - create :sample, sample_metadata_attributes: { sample_ebi_accession_number: 'FindMe' } + create(:sample, sample_metadata_attributes: { sample_ebi_accession_number: 'FindMe' }) end describe '#index' do diff --git a/spec/controllers/sequenom_qc_plates_controller_spec.rb b/spec/controllers/sequenom_qc_plates_controller_spec.rb index baa03245c6..37d71dab35 100644 --- a/spec/controllers/sequenom_qc_plates_controller_spec.rb +++ b/spec/controllers/sequenom_qc_plates_controller_spec.rb @@ -4,10 +4,10 @@ RSpec.describe SequenomQcPlatesController, :phi_x do describe 'GET index' do - let(:current_user) { create :user } + let(:current_user) { create(:user) } before do - create_list :sequenom_qc_plate, 2 + create_list(:sequenom_qc_plate, 2) get :index, session: { user: current_user.id } end diff --git a/spec/controllers/studies/information_controller_spec.rb b/spec/controllers/studies/information_controller_spec.rb index b6466ef5b0..12d45029d4 100644 --- a/spec/controllers/studies/information_controller_spec.rb +++ b/spec/controllers/studies/information_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Studies::InformationController do - let(:study) { create :study } + let(:study) { create(:study) } let(:user) { create(:user) } before { session[:user] = user.id } @@ -20,10 +20,10 @@ end describe '#show with requests' do - let(:request_type1) { create :request_type } - let(:request_type2) { create :request_type } - let(:request_type3) { create :request_type } - let(:well) { create :untagged_well, study: } + let(:request_type1) { create(:request_type) } + let(:request_type2) { create(:request_type) } + let(:request_type3) { create(:request_type) } + let(:well) { create(:untagged_well, study:) } before do request_type3 diff --git a/spec/controllers/studies_controller_spec.rb b/spec/controllers/studies_controller_spec.rb index 49f16a1d1b..81cf178756 100644 --- a/spec/controllers/studies_controller_spec.rb +++ b/spec/controllers/studies_controller_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' RSpec.describe StudiesController do - let(:data_release_study_type) { create :data_release_study_type, name: 'genomic sequencing' } - let(:reference_genome) { create :reference_genome } - let(:study) { create :study } + let(:data_release_study_type) { create(:data_release_study_type, name: 'genomic sequencing') } + let(:reference_genome) { create(:reference_genome) } + let(:study) { create(:study) } let(:program) { create(:program) } let(:user) { create(:owner) } @@ -202,7 +202,7 @@ end describe '#grant_role' do - let(:user) { create :admin } + let(:user) { create(:admin) } before do session[:user] = user.id diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index 697b26739c..df4ce5a6fb 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -5,13 +5,13 @@ RSpec.describe SubmissionsController do render_views - let(:request_type) { create :well_request_type } + let(:request_type) { create(:well_request_type) } it_behaves_like 'it requires login' context 'Submissions controller' do before do - @user = create :user + @user = create(:user) @controller = described_class.new @request = ActionController::TestRequest.create(@controller) @@ -24,11 +24,11 @@ @asset_shape = AssetShape.default @asset_size = 96 - @plate = build :plate, barcode: 'SQPD-123456' + @plate = build(:plate, barcode: 'SQPD-123456') %w[A1 A2 A3 B1 B2 B3 C1 C2 C3].each do |location| well = - build :well_with_sample_and_without_plate, - map: Map.find_by(description: location, asset_shape: @asset_shape, asset_size: @asset_size) + build(:well_with_sample_and_without_plate, + map: Map.find_by(description: location, asset_shape: @asset_shape, asset_size: @asset_size)) @plate.wells << well end build( @@ -37,8 +37,8 @@ plate: @plate ) @plate.save - @study = create :study, name: 'A study' - @project = create :project, name: 'A project' + @study = create(:study, name: 'A study') + @project = create(:project, name: 'A project') submission_template_hash = { name: 'Cherrypicking for Pulldown', submission_class_name: 'LinearSubmission', @@ -154,11 +154,11 @@ context 'with a more recent plate' do before do - @new_plate = create :plate, plate_purpose: @plate.purpose + @new_plate = create(:plate, plate_purpose: @plate.purpose) @well = - create :well, + create(:well, map: Map.find_by(description: 'A1', asset_shape: @asset_shape, asset_size: @asset_size), - plate: @new_plate + plate: @new_plate) create(:aliquot, sample: Sample.find_by(name: @samples.first), receptacle: @well) post( :create, @@ -198,11 +198,11 @@ context 'by sample name and working dilution' do before do @order_count = Order.count - @wd_plate = create :working_dilution_plate + @wd_plate = create(:working_dilution_plate) %w[A1 A2 A3 B1 B2 B3 C1 C2 C3].each do |location| well = - create :empty_well, - map: Map.find_by(description: location, asset_shape: @asset_shape, asset_size: @asset_size) + create(:empty_well, + map: Map.find_by(description: location, asset_shape: @asset_shape, asset_size: @asset_size)) well.aliquots.create(sample: @plate.wells.located_at(location).first.aliquots.first.sample) @wd_plate.wells << well end @@ -292,17 +292,17 @@ context 'A submission with clashing orders' do before do @shared_template = 'shared_template' - @sample = create :sample - @asset_a = create :sample_tube, sample: @sample - @asset_b = create :sample_tube, sample: @sample - @secondary_submission = create :submission + @sample = create(:sample) + @asset_a = create(:sample_tube, sample: @sample) + @asset_b = create(:sample_tube, sample: @sample) + @secondary_submission = create(:submission) @secondary_order = - create :order, + create(:order, assets: [@asset_b.receptacle], template_name: @shared_template, - submission: @secondary_submission - @submission = create :submission - @order = create :order, assets: [@asset_a.receptacle], template_name: @shared_template, submission: @submission + submission: @secondary_submission) + @submission = create(:submission) + @order = create(:order, assets: [@asset_a.receptacle], template_name: @shared_template, submission: @submission) end it 'warn the user about duplicates' do @@ -318,11 +318,11 @@ context 'A submission with not ready samples' do before do @shared_template = 'shared_template' - sample_manifest = create :tube_sample_manifest_with_samples + sample_manifest = create(:tube_sample_manifest_with_samples) @samples_names = sample_manifest.samples.map(&:name).join(', ') - @submission = create :submission + @submission = create(:submission) @order = - create :order, assets: sample_manifest.labware, template_name: @shared_template, submission: @submission + create(:order, assets: sample_manifest.labware, template_name: @shared_template, submission: @submission) end it 'warn the user about not ready samples' do @@ -337,10 +337,10 @@ context 'A submission without warnings' do before do @shared_template = 'shared_template' - @sample = create :sample - @asset_a = create :sample_tube, sample: @sample - @submission = create :submission - @order = create :order, assets: [@asset_a.receptacle], template_name: @shared_template, submission: @submission + @sample = create(:sample) + @asset_a = create(:sample_tube, sample: @sample) + @submission = create(:submission) + @order = create(:order, assets: [@asset_a.receptacle], template_name: @shared_template, submission: @submission) end it 'not warn the user about duplicates or samples' do diff --git a/spec/controllers/tag_sets_controller_spec.rb b/spec/controllers/tag_sets_controller_spec.rb index 9c9b934bf6..eb0c799752 100644 --- a/spec/controllers/tag_sets_controller_spec.rb +++ b/spec/controllers/tag_sets_controller_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' RSpec.describe TagSetsController do - let(:current_user) { create :user } - let(:tag_set) { create :tag_set } + let(:current_user) { create(:user) } + let(:tag_set) { create(:tag_set) } it_behaves_like 'it requires login' @@ -21,7 +21,7 @@ end describe '#show' do - let(:tag_set) { create :tag_set } + let(:tag_set) { create(:tag_set) } before { get :show, params: { id: tag_set.id } } diff --git a/spec/controllers/tube_rack_summaries_controller_spec.rb b/spec/controllers/tube_rack_summaries_controller_spec.rb index e4ce67a7bb..31c2d6ba73 100644 --- a/spec/controllers/tube_rack_summaries_controller_spec.rb +++ b/spec/controllers/tube_rack_summaries_controller_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' RSpec.describe TubeRackSummariesController do - let(:current_user) { create :user } + let(:current_user) { create(:user) } describe '#show' do - let(:tube_rack) { create :tube_rack } + let(:tube_rack) { create(:tube_rack) } before { get :show, params: { id: tube_rack.primary_barcode.barcode }, session: { user: current_user.id } } diff --git a/spec/factories/aliquots.rb b/spec/factories/aliquots.rb index d3b102b6c8..592aaaef1d 100644 --- a/spec/factories/aliquots.rb +++ b/spec/factories/aliquots.rb @@ -27,7 +27,7 @@ end factory :library_aliquot do - library { build :library_tube } + library { build(:library_tube) } library_type { 'Standard' } bait_library primer_panel @@ -41,7 +41,7 @@ end sample { PhiX.sample } - library { build :library_tube } + library { build(:library_tube) } tag { PhiX.find_tag(tag_option, :i7_oligo) } tag2 { PhiX.find_tag(tag_option, :i5_oligo) } study { nil } diff --git a/spec/factories/asset_groups.rb b/spec/factories/asset_groups.rb index 4411d565ea..4dd707122b 100644 --- a/spec/factories/asset_groups.rb +++ b/spec/factories/asset_groups.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :asset_group do - name { |_a| generate :asset_group_name } + name { |_a| generate(:asset_group_name) } study transient do @@ -11,7 +11,7 @@ asset_attributes { {} } end - assets { create_list asset_type, asset_count, asset_attributes } + assets { create_list(asset_type, asset_count, asset_attributes) } end factory :asset_group_asset do diff --git a/spec/factories/batch_factories.rb b/spec/factories/batch_factories.rb index bf831f4cd5..250f5e46b5 100644 --- a/spec/factories/batch_factories.rb +++ b/spec/factories/batch_factories.rb @@ -57,11 +57,11 @@ after(:build) do |batch, evaluator| evaluator.assets.each_with_index.each do |asset, index| - create :pac_bio_sequencing_request, + create(:pac_bio_sequencing_request, asset:, target_asset: evaluator.target_plate.wells[index], request_type: batch.pipeline.request_types.first, - batch: + batch:) end end end diff --git a/spec/factories/lanes.rb b/spec/factories/lanes.rb index b085fca5f9..4669ddcee3 100644 --- a/spec/factories/lanes.rb +++ b/spec/factories/lanes.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :lane, traits: [:with_sample_builder] do - name { generate :asset_name } + name { generate(:asset_name) } external_release { nil } factory(:empty_lane) diff --git a/spec/factories/lib_pcr_xp_factories.rb b/spec/factories/lib_pcr_xp_factories.rb index 1b43825d01..bb14f9f9c5 100644 --- a/spec/factories/lib_pcr_xp_factories.rb +++ b/spec/factories/lib_pcr_xp_factories.rb @@ -42,14 +42,14 @@ end factory :lib_pool_tube, class: 'StockMultiplexedLibraryTube' do - name { |_a| FactoryBot.generate :asset_name } + name { |_a| FactoryBot.generate(:asset_name) } purpose factory: %i[illumina_htp_initial_stock_tube_purpose] after(:create) { |tube| create(:transfer_request, target_asset: tube) } end factory :lib_pool_norm_tube, class: 'MultiplexedLibraryTube' do - transient { parent_tube { create :lib_pool_tube } } - name { generate :asset_name } + transient { parent_tube { create(:lib_pool_tube) } } + name { generate(:asset_name) } purpose factory: %i[illumina_htp_mx_tube_purpose] after(:create) { |tube, factory| create(:transfer_request, asset: factory.parent_tube, target_asset: tube) } end diff --git a/spec/factories/phix_factories.rb b/spec/factories/phix_factories.rb index a7ca5df21e..c1db5d0074 100644 --- a/spec/factories/phix_factories.rb +++ b/spec/factories/phix_factories.rb @@ -17,7 +17,7 @@ name { 'PhiX Spiked Buffer' } concentration { '9.2' } parent_barcode { parent.machine_barcode } - parent { create :phi_x_stock_tube } + parent { create(:phi_x_stock_tube) } volume { '10.0' } number { '1' } end diff --git a/spec/factories/pipelines_factories.rb b/spec/factories/pipelines_factories.rb index 8c58d05b2a..4e64b55b5e 100644 --- a/spec/factories/pipelines_factories.rb +++ b/spec/factories/pipelines_factories.rb @@ -11,7 +11,7 @@ end factory :labware do - name { generate :asset_name } + name { generate(:asset_name) } end factory :plate_creator_purpose, class: 'Plate::Creator::PurposeRelationship' do |_t| @@ -20,7 +20,7 @@ end factory :plate_creator, class: 'Plate::Creator' do - name { generate :plate_creator_name } + name { generate(:plate_creator_name) } end factory :control do @@ -48,7 +48,7 @@ end factory :pipeline do - name { generate :pipeline_name } + name { generate(:pipeline_name) } active { true } transient do @@ -77,7 +77,7 @@ factory :cherrypick_pipeline do transient { request_type { build(:cherrypick_request_type) } } - name { generate :pipeline_name } + name { generate(:pipeline_name) } active { true } max_size { 3000 } summary { true } @@ -92,7 +92,7 @@ end factory :fluidigm_pipeline, class: 'CherrypickPipeline' do - name { generate :pipeline_name } + name { generate(:pipeline_name) } active { true } max_size { 192 } sorter { 11 } @@ -107,10 +107,10 @@ end factory :sequencing_pipeline do - name { generate :pipeline_name } + name { generate(:pipeline_name) } active { true } - workflow { build :lab_workflow_for_pipeline } + workflow { build(:lab_workflow_for_pipeline) } # association(:workflow, factory: :lab_workflow_for_pipeline) after(:build) do |pipeline| @@ -153,12 +153,12 @@ end factory :pac_bio_sequencing_pipeline do - name { FactoryBot.generate :pipeline_name } + name { FactoryBot.generate(:pipeline_name) } active { true } # association(:workflow, factory: :lab_workflow_for_pipeline) control_request_type_id { -1 } - workflow { build :lab_workflow_for_pipeline } + workflow { build(:lab_workflow_for_pipeline) } after(:build) { |pipeline| pipeline.request_types << create(:pac_bio_sequencing_request_type) } end @@ -191,7 +191,7 @@ end factory :workflow, aliases: [:lab_workflow] do - name { FactoryBot.generate :lab_workflow_name } + name { FactoryBot.generate(:lab_workflow_name) } item_limit { 2 } locale { 'Internal' } @@ -200,7 +200,7 @@ end factory :lab_workflow_for_pipeline, class: 'Workflow' do - name { generate :lab_workflow_name } + name { generate(:lab_workflow_name) } item_limit { 2 } locale { 'Internal' } @@ -208,7 +208,7 @@ end factory :fluidigm_pipeline_workflow, class: 'Workflow' do - name { generate :lab_workflow_name } + name { generate(:lab_workflow_name) } after(:build) { |workflow| workflow.pipeline = build(:fluidigm_pipeline, workflow:) unless workflow.pipeline } @@ -216,7 +216,7 @@ end factory :cherrypick_pipeline_workflow, class: 'Workflow' do - name { generate :lab_workflow_name } + name { generate(:lab_workflow_name) } after(:build) { |workflow| workflow.pipeline = build(:cherrypick_pipeline, workflow:) unless workflow.pipeline } diff --git a/spec/factories/plate_factories.rb b/spec/factories/plate_factories.rb index 7dab007c59..a46a5afb24 100644 --- a/spec/factories/plate_factories.rb +++ b/spec/factories/plate_factories.rb @@ -43,7 +43,7 @@ trait :with_submissions do transient do submission_count { 1 } - submissions { create_list :submission, submission_count } + submissions { create_list(:submission, submission_count) } submission_cycle { submissions.cycle } end after(:create) do |plate, evaluator| @@ -76,8 +76,8 @@ factory :target_plate do transient do - parent { build :input_plate } - submission { build :submission } + parent { build(:input_plate) } + submission { build(:submission) } end after(:build) do |plate, evaluator| @@ -92,7 +92,7 @@ outer_request = well_hash[well.map_description].requests.detect { |r| r.submission_id == evaluator.submission.id } - create :transfer_request, asset: well_hash[well.map_description], target_asset: well, outer_request: + create(:transfer_request, asset: well_hash[well.map_description], target_asset: well, outer_request:) end end end @@ -167,7 +167,7 @@ well_factory { :tagged_well } end plate_purpose { create(:fluidigm_192_purpose) } - barcodes { build_list :fluidigm, 1 } + barcodes { build_list(:fluidigm, 1) } size { 192 } end end @@ -183,7 +183,7 @@ # A plate that has exactly the right number of wells! factory :pooling_plate do - plate_purpose { create :pooling_plate_purpose } + plate_purpose { create(:pooling_plate_purpose) } transient do well_count { 6 } well_factory { :tagged_well } @@ -280,7 +280,7 @@ factory :strip_tube do name { 'Strip_tube' } size { 8 } - plate_purpose { create :strip_tube_purpose } + plate_purpose { create(:strip_tube_purpose) } after(:create) { |st| st.wells = st.maps.map { |map| create(:well, map:) } } end end diff --git a/spec/factories/poly_metadata_factories.rb b/spec/factories/poly_metadata_factories.rb index 4b37aa5cf7..f5f2e8c3a2 100644 --- a/spec/factories/poly_metadata_factories.rb +++ b/spec/factories/poly_metadata_factories.rb @@ -5,6 +5,6 @@ sequence(:key) { |n| "some_key_#{n}" } sequence(:value) { |n| "some_value_#{n}" } - metadatable { create :request } + metadatable { create(:request) } end end diff --git a/spec/factories/product_and_catalogue_factories.rb b/spec/factories/product_and_catalogue_factories.rb index 6d3086364e..2a4ea4a484 100644 --- a/spec/factories/product_and_catalogue_factories.rb +++ b/spec/factories/product_and_catalogue_factories.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :product_catalogue do - name { |_x| FactoryBot.generate :product_catalogue_name } + name { |_x| FactoryBot.generate(:product_catalogue_name) } factory :single_product_catalogue do selection_behaviour { 'SingleProduct' } @@ -14,7 +14,7 @@ end factory :product do - name { FactoryBot.generate :product_name } + name { FactoryBot.generate(:product_name) } deprecated_at { nil } end diff --git a/spec/factories/project_metadata.rb b/spec/factories/project_metadata.rb index 2bc0e7a04b..efb74b059c 100644 --- a/spec/factories/project_metadata.rb +++ b/spec/factories/project_metadata.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :budget_division do - name { |_a| generate :budget_division_name } + name { |_a| generate(:budget_division_name) } end factory :project_metadata, class: 'Project::Metadata' do diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 6f2361702c..cf7f42b759 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :project do - name { generate :project_name } + name { generate(:project_name) } enforce_quotas { false } approved { true } state { 'active' } diff --git a/spec/factories/pulldown_factories.rb b/spec/factories/pulldown_factories.rb index 72b70f6c74..7ccadf1ff7 100644 --- a/spec/factories/pulldown_factories.rb +++ b/spec/factories/pulldown_factories.rb @@ -79,7 +79,7 @@ after(:build) do |tube_creation| mock_request_type = create(:library_creation_request_type) - stock_plate = create :full_stock_plate, well_count: 2 + stock_plate = create(:full_stock_plate, well_count: 2) stock_wells = stock_plate.wells AssetLink.create!(ancestor: stock_plate, descendant: tube_creation.parent) @@ -90,7 +90,7 @@ .in_column_major_order .in_groups_of(tube_creation.parent.wells.size / 2) .each_with_index do |pool, i| - submission = create :submission + submission = create(:submission) pool.each do |well| create(:transfer_request, asset: stock_wells[i], target_asset: well, submission:) mock_request_type.create!( @@ -99,7 +99,7 @@ submission:, request_metadata_attributes: create(:request_metadata_for_library_creation).attributes ) - create :stock_well_link, target_well: well, source_well: stock_wells[i] + create(:stock_well_link, target_well: well, source_well: stock_wells[i]) end end end diff --git a/spec/factories/purpose_factories.rb b/spec/factories/purpose_factories.rb index 8589ff57c6..e61cdba57d 100644 --- a/spec/factories/purpose_factories.rb +++ b/spec/factories/purpose_factories.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :purpose do prefix { 'DN' } - name { generate :purpose_name } + name { generate(:purpose_name) } target_type { 'Asset' } factory :stock_purpose do @@ -18,22 +18,22 @@ end factory(:purpose_additional_input, class: 'PlatePurpose::AdditionalInput') do - name { generate :purpose_name } + name { generate(:purpose_name) } target_type { 'Plate' } size { '96' } end factory :strip_tube_purpose, class: 'PlatePurpose' do prefix { 'LS' } - name { generate :purpose_name } + name { generate(:purpose_name) } size { '8' } - asset_shape { create :strip_tube_column_shape } + asset_shape { create(:strip_tube_column_shape) } target_type { 'StripTube' } end factory :plate_purpose do prefix { 'DN' } - name { generate :purpose_name } + name { generate(:purpose_name) } size { 96 } barcode_printer_type factory: %i[plate_barcode_printer_type] target_type { 'Plate' } @@ -83,14 +83,14 @@ end factory :working_dilution_plate_purpose, class: 'DilutionPlatePurpose' do - name { generate :purpose_name } + name { generate(:purpose_name) } target_type { 'WorkingDilutionPlate' } prefix { 'WD' } end factory :tube_purpose, class: 'Tube::Purpose' do prefix { 'NT' } - name { generate :purpose_name } + name { generate(:purpose_name) } target_type { 'MultiplexedLibraryTube' } factory :sample_tube_purpose do @@ -118,7 +118,7 @@ factory :std_mx_tube_purpose, class: 'Tube::StandardMx' do prefix { 'NT' } - name { generate :purpose_name } + name { generate(:purpose_name) } target_type { 'MultiplexedLibraryTube' } end @@ -149,7 +149,7 @@ factory :tube_rack_purpose, class: 'TubeRack::Purpose' do target_type { 'TubeRack' } - name { generate :purpose_name } + name { generate(:purpose_name) } size { 96 } factory :tube_rack_purpose_48 do diff --git a/spec/factories/request_factories.rb b/spec/factories/request_factories.rb index 37bc174df9..05e2aa6e0d 100644 --- a/spec/factories/request_factories.rb +++ b/spec/factories/request_factories.rb @@ -53,7 +53,7 @@ request_type factory: %i[sequencing_request_type] request_purpose { :standard } sti_type { 'SequencingRequest' } - request_metadata_attributes { attributes_for :request_metadata_for_standard_sequencing_with_read_length } + request_metadata_attributes { attributes_for(:request_metadata_for_standard_sequencing_with_read_length) } factory(:sequencing_request_with_assets) do asset factory: %i[library_tube] @@ -85,18 +85,18 @@ asset factory: %i[well] request_type factory: %i[library_request_type] request_purpose { :standard } - request_metadata_attributes { attributes_for :request_metadata_for_library_manufacture } + request_metadata_attributes { attributes_for(:request_metadata_for_library_manufacture) } factory :gbs_request, class: 'IlluminaHtp::Requests::GbsRequest' do - request_metadata_attributes { attributes_for :request_metadata_for_gbs } + request_metadata_attributes { attributes_for(:request_metadata_for_gbs) } end factory :heron_request, class: 'IlluminaHtp::Requests::HeronRequest' do - request_metadata_attributes { attributes_for :request_metadata_for_heron } + request_metadata_attributes { attributes_for(:request_metadata_for_heron) } end factory :heron_tailed_request, class: 'IlluminaHtp::Requests::HeronTailedRequest' do - request_metadata_attributes { attributes_for :request_metadata_for_heron } + request_metadata_attributes { attributes_for(:request_metadata_for_heron) } end end @@ -126,7 +126,7 @@ end factory :cherrypick_for_fluidigm_request do - transient { target_purpose { create :plate_purpose } } + transient { target_purpose { create(:plate_purpose) } } asset factory: %i[well] target_asset factory: %i[well] request_type factory: %i[cherrypick_request_type] diff --git a/spec/factories/request_type_factories.rb b/spec/factories/request_type_factories.rb index dfcf2a8691..aa53fd6df7 100644 --- a/spec/factories/request_type_factories.rb +++ b/spec/factories/request_type_factories.rb @@ -9,7 +9,7 @@ end trait :with_library_types do - transient { library_type { build :library_type } } + transient { library_type { build(:library_type) } } after(:build) do |request_type, evaluator| request_type.library_types_request_types << create( @@ -22,8 +22,8 @@ end factory :request_type do - name { generate :request_type_name } - key { generate :request_type_key } + name { generate(:request_type_name) } + key { generate(:request_type_key) } deprecated { false } asset_type { 'SampleTube' } request_class { Request } diff --git a/spec/factories/robot_factories.rb b/spec/factories/robot_factories.rb index 30b53e1eaa..dca75ce8c1 100644 --- a/spec/factories/robot_factories.rb +++ b/spec/factories/robot_factories.rb @@ -44,12 +44,12 @@ factory :robot_with_verification_behaviour do transient { verification_behaviour_value { 'Tecan' } } - robot_properties { build_list :validation_property, 1, value: verification_behaviour_value } + robot_properties { build_list(:validation_property, 1, value: verification_behaviour_value) } end factory :robot_with_generation_behaviour do transient { generation_behaviour_value { 'Tecan' } } - robot_properties { build_list :generation_property, 1, value: generation_behaviour_value } + robot_properties { build_list(:generation_property, 1, value: generation_behaviour_value) } end factory :full_robot do diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb index ba9ac6f378..681292e83a 100644 --- a/spec/factories/roles.rb +++ b/spec/factories/roles.rb @@ -32,17 +32,17 @@ end trait :with_owner do - transient { owner { build :user } } + transient { owner { build(:user) } } roles { |role| [role.association(:role, name: 'owner', users: [owner])] } end trait :with_manager do - transient { manager { build :user } } + transient { manager { build(:user) } } roles { |role| [role.association(:role, name: 'manager', users: [manager])] } end trait :with_follower do - transient { follower { build :user } } + transient { follower { build(:user) } } roles { |role| [role.association(:role, name: 'follower', users: [follower])] } end end diff --git a/spec/factories/sample_manifest_excel/test_download_plates.rb b/spec/factories/sample_manifest_excel/test_download_plates.rb index a5395e1de1..c2c61923f4 100644 --- a/spec/factories/sample_manifest_excel/test_download_plates.rb +++ b/spec/factories/sample_manifest_excel/test_download_plates.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :test_download_plates, class: 'SampleManifestExcel::TestDownload' do - columns { build :column_list } + columns { build(:column_list) } validation_errors { [] } num_plates { 2 } num_filled_wells_per_plate { 2 } diff --git a/spec/factories/sample_manifest_factories.rb b/spec/factories/sample_manifest_factories.rb index c91ed7bfab..b8d88174e5 100644 --- a/spec/factories/sample_manifest_factories.rb +++ b/spec/factories/sample_manifest_factories.rb @@ -17,7 +17,7 @@ num_plates { 1 } num_wells_per_plate { 1 } num_samples_per_well { 1 } - plates { create_list :plate, num_plates, well_factory: :empty_well, well_count: num_wells_per_plate } + plates { create_list(:plate, num_plates, well_factory: :empty_well, well_count: num_wells_per_plate) } end barcodes { plates.map(&:human_barcode) } @@ -49,7 +49,7 @@ tube_factory { :empty_sample_tube } end - labware { create_list tube_factory, tube_count } + labware { create_list(tube_factory, tube_count) } after(:build) do |sample_manifest| sample_manifest.labware.each do |tube| @@ -80,7 +80,7 @@ num_plates { 2 } num_filled_wells_per_plate { 2 } num_rows_per_well { 1 } - plates { create_list :plate, num_plates, well_factory: :empty_well, well_count: num_filled_wells_per_plate } + plates { create_list(:plate, num_plates, well_factory: :empty_well, well_count: num_filled_wells_per_plate) } end barcodes { plates.map(&:human_barcode) } diff --git a/spec/factories/samples.rb b/spec/factories/samples.rb index e868aae2d3..6306d25142 100644 --- a/spec/factories/samples.rb +++ b/spec/factories/samples.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :sample do - name { generate :sample_name } + name { generate(:sample_name) } factory :sample_with_well do sequence(:sanger_sample_id, &:to_s) diff --git a/spec/factories/study_factories.rb b/spec/factories/study_factories.rb index d0368d6240..8ab0fcae97 100644 --- a/spec/factories/study_factories.rb +++ b/spec/factories/study_factories.rb @@ -7,7 +7,7 @@ # required (as the login step does this) but it's here for clarity should that ever change. FactoryBot.define do factory :study do - name { generate :study_name } + name { generate(:study_name) } user blocked { false } state { 'active' } @@ -63,14 +63,14 @@ end factory :study_type do - name { generate :study_type_name } + name { generate(:study_type_name) } end factory :data_release_study_type do - name { generate :data_release_study_type_name } + name { generate(:data_release_study_type_name) } end - factory(:faculty_sponsor) { name { |_a| generate :faculty_sponsor_name } } + factory(:faculty_sponsor) { name { |_a| generate(:faculty_sponsor_name) } } factory :study_for_study_list, parent: :study do transient do @@ -99,7 +99,7 @@ factory(:study_for_study_list_pending_ethical_approval) do name { 'Study: Pending ethical approval' } ethically_approved { false } - study_metadata_attributes { FactoryBot.attributes_for :study_metadata_for_study_list_pending_ethical_approval } + study_metadata_attributes { FactoryBot.attributes_for(:study_metadata_for_study_list_pending_ethical_approval) } end factory(:study_for_study_list_remove_x_and_autosomes) do diff --git a/spec/factories/study_reports.rb b/spec/factories/study_reports.rb index c743e2ffa9..3119d3c615 100644 --- a/spec/factories/study_reports.rb +++ b/spec/factories/study_reports.rb @@ -13,7 +13,7 @@ factory :completed_study_report do report_filename { 'progress_report.csv' } after(:build) do |study_report_file| - create :db_file, owner: study_report_file, data: Tempfile.open('progress_report.csv').read + create(:db_file, owner: study_report_file, data: Tempfile.open('progress_report.csv').read) end end end diff --git a/spec/factories/submission_factories.rb b/spec/factories/submission_factories.rb index 6ea3dcd98d..7ab6ab42d7 100644 --- a/spec/factories/submission_factories.rb +++ b/spec/factories/submission_factories.rb @@ -23,7 +23,7 @@ factory :cherrypick_submission_template do name { 'Cherrypick' } - request_types { create_list :cherrypick_request_type, 1 } + request_types { create_list(:cherrypick_request_type, 1) } end factory :limber_wgs_submission_template do @@ -69,7 +69,7 @@ request_types { [create(:request_type).id] } factory :library_order do - assets { create_list :untagged_well, 1 } + assets { create_list(:untagged_well, 1) } request_types { [create(:library_request_type).id] } request_options do { @@ -80,7 +80,7 @@ } end template_name { 'test_template_name' } - order_role { create :order_role } + order_role { create(:order_role) } end end diff --git a/spec/factories/tag2_layout_factories.rb b/spec/factories/tag2_layout_factories.rb index da6f3ae88c..f68ec1b60d 100644 --- a/spec/factories/tag2_layout_factories.rb +++ b/spec/factories/tag2_layout_factories.rb @@ -8,7 +8,7 @@ end factory :tag2_layout_template do |_itlt| - transient { oligo { generate :oligo } } + transient { oligo { generate(:oligo) } } sequence(:name) { |n| "Tag 2 layout template #{n}" } tag { |tag| tag.association :tag, oligo: } end diff --git a/spec/factories/tube_factories.rb b/spec/factories/tube_factories.rb index 4de36eb927..034c519889 100644 --- a/spec/factories/tube_factories.rb +++ b/spec/factories/tube_factories.rb @@ -10,7 +10,7 @@ trait :tube_barcode do transient do barcode_number { barcode } - barcode { generate :barcode_number } + barcode { generate(:barcode_number) } prefix { 'NT' } end sanger_barcode { { prefix:, number: barcode_number } } @@ -27,17 +27,17 @@ end factory :tube, traits: [:tube_barcode] do - name { generate :asset_name } + name { generate(:asset_name) } purpose factory: %i[tube_purpose] end factory :unbarcoded_tube, class: 'Tube' do - name { generate :asset_name } + name { generate(:asset_name) } purpose factory: %i[tube_purpose] end factory :empty_sample_tube, class: 'SampleTube', traits: [:tube_barcode] do - name { generate :asset_name } + name { generate(:asset_name) } qc_state { '' } purpose factory: %i[sample_tube_purpose] # { Tube::Purpose.standard_sample_tube } end @@ -78,7 +78,7 @@ study { create(:study) } end - name { generate :asset_name } + name { generate(:asset_name) } purpose factory: %i[mx_tube_purpose] after(:build) do |tube, evaluator| unless evaluator.sample_count.zero? @@ -88,12 +88,12 @@ end factory :pulldown_multiplexed_library_tube, traits: [:tube_barcode] do - name { generate :asset_name } + name { generate(:asset_name) } public_name { 'ABC' } end factory :stock_multiplexed_library_tube, traits: [:tube_barcode] do - name { |_a| generate :asset_name } + name { |_a| generate(:asset_name) } purpose { Tube::Purpose.stock_mx_tube } factory :new_stock_multiplexed_library_tube do |_t| @@ -102,14 +102,14 @@ end factory(:empty_library_tube, traits: [:tube_barcode], class: 'LibraryTube') do - name { generate :asset_name } + name { generate(:asset_name) } purpose factory: %i[library_tube_purpose] # { Tube::Purpose.standard_library_tube } transient do sample_count { 0 } samples { create_list(:sample, sample_count) } aliquot_factory { :untagged_aliquot } - study { build :study } + study { build(:study) } end after(:build) do |library_tube, evaluator| @@ -175,7 +175,7 @@ end factory :stock_library_tube do - name { |_a| generate :asset_name } + name { |_a| generate(:asset_name) } purpose { Tube::Purpose.stock_library_tube } end @@ -185,7 +185,7 @@ aliquot_attributes { { tag_option: } } end - name { generate :asset_name } + name { generate(:asset_name) } concentration { 12.0 } volume { 50 } @@ -194,7 +194,7 @@ end factory :spiked_buffer_with_parent do - transient { parent { create :spiked_buffer, :tube_barcode } } + transient { parent { create(:spiked_buffer, :tube_barcode) } } after(:build) { |tube, evaluator| tube.parents << evaluator.parent } end @@ -203,10 +203,10 @@ factory :phi_x_stock_tube, class: 'LibraryTube', traits: [:tube_barcode] do transient do tag_option { 'Single' } # The PhiX Tag option to use, eg. Single/Dual - study { create :study } + study { create(:study) } end - name { generate :asset_name } + name { generate(:asset_name) } concentration { 12.0 } after(:build) do |tube, evaluator| diff --git a/spec/factories/user_factories.rb b/spec/factories/user_factories.rb index 52974073ad..f81caba325 100644 --- a/spec/factories/user_factories.rb +++ b/spec/factories/user_factories.rb @@ -22,7 +22,7 @@ factory :manager do roles { |role| Array(authorizable).map { |auth| role.association(:manager_role, authorizable: auth) } } - transient { authorizable { create :study } } + transient { authorizable { create(:study) } } end factory :owner do diff --git a/spec/factories/user_query_factories.rb b/spec/factories/user_query_factories.rb index e086d6bb5e..c79b174eef 100644 --- a/spec/factories/user_query_factories.rb +++ b/spec/factories/user_query_factories.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :user_query do - user { create :user, login: 'user_abc', email: 'user_abc@example.com' } + user { create(:user, login: 'user_abc', email: 'user_abc@example.com') } url { 'www.example.com/some_page' } what_was_trying_to_do { 'create' } what_happened { 'it did not work' } diff --git a/spec/factories/well_factories.rb b/spec/factories/well_factories.rb index 739ddfe662..f4d49cef89 100644 --- a/spec/factories/well_factories.rb +++ b/spec/factories/well_factories.rb @@ -3,9 +3,9 @@ FactoryBot.define do factory :well, aliases: [:empty_well] do transient do - study { build :study } - project { build :project } - sample { build :sample } + study { build(:study) } + project { build(:project) } + sample { build(:sample) } aliquot_options { |_e, well| { study:, project:, receptacle: well, sample: } } end association(:well_attribute, strategy: :build) @@ -15,7 +15,7 @@ end factory :picked_well do - well_attribute { build :well_attribute, picked_volume: 12 } + well_attribute { build(:well_attribute, picked_volume: 12) } end end diff --git a/spec/factories/z_tag_qc_factories.rb b/spec/factories/z_tag_qc_factories.rb index 7f93eb31a2..b2b9e98c84 100644 --- a/spec/factories/z_tag_qc_factories.rb +++ b/spec/factories/z_tag_qc_factories.rb @@ -18,12 +18,12 @@ end factory :pending_purpose, parent: :tube_purpose do - name { FactoryBot.generate :purpose_name } + name { FactoryBot.generate(:purpose_name) } default_state { 'pending' } end factory :created_purpose, parent: :tube_purpose do - name { FactoryBot.generate :purpose_name } + name { FactoryBot.generate(:purpose_name) } default_state { 'created' } end @@ -64,12 +64,12 @@ # Incidentally we use attributes_for here as factory_bot instantiates # the object before setting attributes, which messes up the state machine # callbacks. - lot { create :lot } - qcable_creator { create :qcable_creator } + lot { create(:lot) } + qcable_creator { create(:qcable_creator) } factory :qcable_with_asset do state { 'created' } - asset { create :full_plate } + asset { create(:full_plate) } end end diff --git a/spec/features/admin/add_a_primer_panel_spec.rb b/spec/features/admin/add_a_primer_panel_spec.rb index 1cf56fa5c1..aa73044a5a 100644 --- a/spec/features/admin/add_a_primer_panel_spec.rb +++ b/spec/features/admin/add_a_primer_panel_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe 'Primer Panel' do - let(:user) { create :admin, email: 'login@example.com' } - let(:primer_panel) { create :primer_panel, name: 'Primer Panel 1' } + let(:user) { create(:admin, email: 'login@example.com') } + let(:primer_panel) { create(:primer_panel, name: 'Primer Panel 1') } it 'user can add a new primer panel' do login_user user diff --git a/spec/features/admin/add_a_printer_spec.rb b/spec/features/admin/add_a_printer_spec.rb index 8e3e656923..67fc489a4f 100644 --- a/spec/features/admin/add_a_printer_spec.rb +++ b/spec/features/admin/add_a_printer_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Add a printer' do - let(:user) { create :admin, email: 'login@example.com' } + let(:user) { create(:admin, email: 'login@example.com') } it 'user can add a new printer' do login_user user diff --git a/spec/features/admin/changing_user_roles_spec.rb b/spec/features/admin/changing_user_roles_spec.rb index 61396f5b63..7296f78e1a 100644 --- a/spec/features/admin/changing_user_roles_spec.rb +++ b/spec/features/admin/changing_user_roles_spec.rb @@ -3,16 +3,16 @@ require 'rails_helper' describe 'Manage users' do - let(:user) { create :admin, email: 'login@example.com' } - let(:test_user) { create :user, login: 'john', first_name: 'John', last_name: 'Smith' } - let(:primer_panel) { create :primer_panel, name: 'Primer Panel 1' } + let(:user) { create(:admin, email: 'login@example.com') } + let(:test_user) { create(:user, login: 'john', first_name: 'John', last_name: 'Smith') } + let(:primer_panel) { create(:primer_panel, name: 'Primer Panel 1') } before do test_user # is_created - create :study, name: 'Study Name', state: 'active' - create :project, name: 'Project Name', state: 'active' - create :role, name: 'lab_manager' - create :role, name: 'manager' + create(:study, name: 'Study Name', state: 'active') + create(:project, name: 'Project Name', state: 'active') + create(:role, name: 'lab_manager') + create(:role, name: 'manager') login_user user click_link 'Admin' expect(page).to have_content('Administration') diff --git a/spec/features/asset_information_spec.rb b/spec/features/asset_information_spec.rb index 68022bf69f..a5758086bd 100644 --- a/spec/features/asset_information_spec.rb +++ b/spec/features/asset_information_spec.rb @@ -9,7 +9,7 @@ # We'll keep the old controller around for a little while to ensure any # bookmarks continue to work. - let(:user) { create :user } + let(:user) { create(:user) } before do expect(Labware).to receive(:find_by).with(id: '1').and_return(labware) @@ -19,7 +19,7 @@ end context 'when the id is unambiguous' do - let(:labware) { create :sample_tube } + let(:labware) { create(:sample_tube) } let(:receptacle) { nil } it 'redirects to the Labware' do @@ -28,7 +28,7 @@ end context 'when the receptacle maps to the labware' do - let(:labware) { create :sample_tube } + let(:labware) { create(:sample_tube) } let(:receptacle) { labware.receptacle } it 'redirects to the Receptacle' do @@ -37,7 +37,7 @@ end context 'when there is some ambiguity' do - let(:labware) { create :sample_tube } + let(:labware) { create(:sample_tube) } let(:receptacle) { create(:sample_tube).receptacle } it 'redirects to the Labware' do diff --git a/spec/features/assets/asset_submission_spec.rb b/spec/features/assets/asset_submission_spec.rb index d19d31bdd2..bdad5fae7d 100644 --- a/spec/features/assets/asset_submission_spec.rb +++ b/spec/features/assets/asset_submission_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' describe 'Asset submission', :js do - let(:project) { create :project } - let(:study) { create :study } + let(:project) { create(:project) } + let(:study) { create(:study) } let(:request_factory) { :sequencing_request } - let(:asset) { create :library_tube } + let(:asset) { create(:library_tube) } let(:request_types) { create_list(:sequencing_request_type, 2) } let(:original_request_type) { request_types.first } let(:selected_request_type) { original_request_type } @@ -75,7 +75,7 @@ it 'the link is not visible' do login_user user visit labware_path(asset) - expect(page).not_to have_text('Request additional sequencing') + expect(page).to have_no_text('Request additional sequencing') end end @@ -111,7 +111,7 @@ end context 'when an admin' do - let(:user) { create :admin } + let(:user) { create(:admin) } context 'with the original request_type' do it_behaves_like 'it allows additional sequencing' @@ -124,7 +124,7 @@ end context 'when cross study pooled' do - let(:asset) { create :multiplexed_library_tube, aliquots: build_list(:library_aliquot, 2) } + let(:asset) { create(:multiplexed_library_tube, aliquots: build_list(:library_aliquot, 2)) } let(:study) { asset.aliquots.first.study } let(:project) { asset.aliquots.first.project } let!(:original_request) do @@ -137,17 +137,17 @@ end context 'when a regular user' do - let(:user) { create :user } + let(:user) { create(:user) } it_behaves_like 'it forbids additional sequencing' end context 'when study does not have an accession number' do # Create a user that is allowed to request additional sequencing. - let(:user) { create :admin } + let(:user) { create(:admin) } # Create a study that requires accessioning, but does not have an accession number. - let(:study) { create :open_study, enforce_accessioning: true, accession_number: nil } + let(:study) { create(:open_study, enforce_accessioning: true, accession_number: nil) } it_behaves_like 'it shows an error message about study' end diff --git a/spec/features/assets/show_plate_spec.rb b/spec/features/assets/show_plate_spec.rb index 42d59aa867..4ea8073b19 100644 --- a/spec/features/assets/show_plate_spec.rb +++ b/spec/features/assets/show_plate_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe 'Show plate', :js do - let(:plate) { create :plate, well_count: 3 } - let(:user) { create :user } + let(:plate) { create(:plate, well_count: 3) } + let(:user) { create(:user) } before do plate # has been created diff --git a/spec/features/assets/upload_and_retrieve_qc_file_spec.rb b/spec/features/assets/upload_and_retrieve_qc_file_spec.rb index b92884b791..48aef1d9b9 100644 --- a/spec/features/assets/upload_and_retrieve_qc_file_spec.rb +++ b/spec/features/assets/upload_and_retrieve_qc_file_spec.rb @@ -4,8 +4,8 @@ require 'pry' describe 'Asset submission', :js do - let(:plate) { create :plate } - let(:user) { create :user } + let(:plate) { create(:plate) } + let(:user) { create(:user) } it 'upload a qc file' do login_user user diff --git a/spec/features/batches/failing_requests_spec.rb b/spec/features/batches/failing_requests_spec.rb index 24551594ab..088527113d 100644 --- a/spec/features/batches/failing_requests_spec.rb +++ b/spec/features/batches/failing_requests_spec.rb @@ -6,11 +6,11 @@ describe 'Batches controller', :js do let(:request_count) { 3 } let(:batch) do - create :cherrypick_batch, request_count:, state: 'released', request_factory: :passed_cherrypick_request + create(:cherrypick_batch, request_count:, state: 'released', request_factory: :passed_cherrypick_request) end - let(:user) { create :admin } + let(:user) { create(:admin) } - before { create :robot } + before { create(:robot) } it 'failing passed cherrypick requests' do request_ids = batch.batch_requests.map(&:request_id) diff --git a/spec/features/batches/sort_requests_spec.rb b/spec/features/batches/sort_requests_spec.rb index 96e52dcafb..ca4f72c147 100644 --- a/spec/features/batches/sort_requests_spec.rb +++ b/spec/features/batches/sort_requests_spec.rb @@ -5,9 +5,9 @@ describe 'Batches controller', :js, :warren do let(:request_count) { 3 } - let(:batch) { create :sequencing_batch, request_count:, created_at: 1.day.ago, updated_at: 1.day.ago } - let(:user) { create :admin } - let!(:flowcell_message) { create :flowcell_messenger, target: batch } + let(:batch) { create(:sequencing_batch, request_count:, created_at: 1.day.ago, updated_at: 1.day.ago) } + let(:user) { create(:admin) } + let!(:flowcell_message) { create(:flowcell_messenger, target: batch) } it 'reordering requests' do requests_ids = batch.batch_requests.map(&:request_id) diff --git a/spec/features/contact_us_spec.rb b/spec/features/contact_us_spec.rb index 76f0b31339..c2f94bc049 100644 --- a/spec/features/contact_us_spec.rb +++ b/spec/features/contact_us_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Contact us' do - let(:user) { create :user, email: 'login@example.com' } + let(:user) { create(:user, email: 'login@example.com') } it 'user can ask for help' do number_of_mails = ActionMailer::Base.deliveries.count diff --git a/spec/features/creating_a_quad_stamp_spec.rb b/spec/features/creating_a_quad_stamp_spec.rb index d1d05d98ab..3453e191b2 100644 --- a/spec/features/creating_a_quad_stamp_spec.rb +++ b/spec/features/creating_a_quad_stamp_spec.rb @@ -3,13 +3,13 @@ require 'rails_helper' describe 'Creating a quad stamp' do - let(:user) { create :slf_manager, swipecard_code: swipecard } + let(:user) { create(:slf_manager, swipecard_code: swipecard) } let(:swipecard) { '123456' } - let(:quad_1) { create :plate_with_untagged_wells, well_count: 2 } - let(:quad_2) { create :plate_with_untagged_wells, well_count: 2 } - let!(:plate_purpose) { create :plate_purpose, size: 384, stock_plate: true } + let(:quad_1) { create(:plate_with_untagged_wells, well_count: 2) } + let(:quad_2) { create(:plate_with_untagged_wells, well_count: 2) } + let!(:plate_purpose) { create(:plate_purpose, size: 384, stock_plate: true) } let(:new_barcode) { build(:plate_barcode) } - let!(:barcode_printer) { create :barcode_printer } + let!(:barcode_printer) { create(:barcode_printer) } before { allow(PlateBarcode).to receive(:create_barcode).and_return(new_barcode) } diff --git a/spec/features/generate_a_bulk_submission_template_spec.rb b/spec/features/generate_a_bulk_submission_template_spec.rb index 462ceb4b0b..a0b7658a8e 100644 --- a/spec/features/generate_a_bulk_submission_template_spec.rb +++ b/spec/features/generate_a_bulk_submission_template_spec.rb @@ -3,13 +3,13 @@ require 'rails_helper' describe 'Generate a bulk submission spreadsheet', :bulk_submission_excel, :js do - let!(:user) { create :user } + let!(:user) { create(:user) } let!(:plate) { create(:plate_with_untagged_wells, well_count: 30) } # We only use two wells of out partial plate in our submission. However we are generating 13 # to ensure we are only using the specified well. The other two will be ignored. let!(:partial_plate) { create(:plate_with_untagged_wells, well_count: 13) } - let!(:submission_template) { create :libray_and_sequencing_template } + let!(:submission_template) { create(:libray_and_sequencing_template) } let(:iso_date) { Time.current.utc.strftime('%Y%m%d') } let(:filename) { "#{plate.human_barcode}_to_#{partial_plate.human_barcode}_#{iso_date}_#{user.login}.xlsx" } @@ -37,8 +37,8 @@ end context 'with a primer panel submission' do - let!(:submission_template) { create :heron_libray_and_sequencing_template } - let!(:primer_panel) { create :primer_panel } + let!(:submission_template) { create(:heron_libray_and_sequencing_template) } + let!(:primer_panel) { create(:primer_panel) } it 'populates the primer panel column' do # Regression test for https://github.com/sanger/sequencescape/issues/2582 @@ -58,8 +58,8 @@ end context 'with a bait_library submission' do - let!(:submission_template) { create :isc_libray_and_sequencing_template } - let!(:bait_library) { create :bait_library } + let!(:submission_template) { create(:isc_libray_and_sequencing_template) } + let!(:bait_library) { create(:bait_library) } it 'populates the primer panel column' do # Regression test for https://github.com/sanger/sequencescape/issues/2582 diff --git a/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb b/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb index c17967c896..7f7ceb5ca7 100644 --- a/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb +++ b/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb @@ -47,13 +47,13 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # These cherrypick requests will create a transfer request between the wells, all the requests belonging to the same submission id.' do - let(:stock_plate_purpose) { create :stock_plate_purpose } + let(:stock_plate_purpose) { create(:stock_plate_purpose) } let(:stock_plate) do - create :plate, :with_wells, sample_count: 9, plate_purpose: stock_plate_purpose, well_factory: :tagged_well + create(:plate, :with_wells, sample_count: 9, plate_purpose: stock_plate_purpose, well_factory: :tagged_well) end - let(:pcr_xp_purpose) { create :plate_purpose, name: 'LB Lib PCR-XP' } - let(:pcr_xp_plate1) { create :plate, :with_wells, sample_count: 9, plate_purpose: pcr_xp_purpose } - let(:pcr_xp_plate2) { create :plate, :with_wells, sample_count: 9, plate_purpose: pcr_xp_purpose } + let(:pcr_xp_purpose) { create(:plate_purpose, name: 'LB Lib PCR-XP') } + let(:pcr_xp_plate1) { create(:plate, :with_wells, sample_count: 9, plate_purpose: pcr_xp_purpose) } + let(:pcr_xp_plate2) { create(:plate, :with_wells, sample_count: 9, plate_purpose: pcr_xp_purpose) } let(:stamp_transfers) do pcr_xp_plate1.wells.each_with_object({}) { |w, hash| hash[w.map_description] = w.map_description } end @@ -78,10 +78,10 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # context 'when I create a LB Lib Prepool plate and I create 1 Repooling ISC request for each well in the Lib PCR-XP plate' do - let(:prepool_purpose) { create :plate_purpose, name: 'LB Lib Prepool' } - let(:prepool_plate) { create :plate, :with_wells, sample_count: 9, plate_purpose: prepool_purpose } + let(:prepool_purpose) { create(:plate_purpose, name: 'LB Lib Prepool') } + let(:prepool_plate) { create(:plate, :with_wells, sample_count: 9, plate_purpose: prepool_purpose) } - let(:pool_instances1) { create_list :pre_capture_pool, 3 } + let(:pool_instances1) { create_list(:pre_capture_pool, 3) } let(:submission_c) { 4 } let(:submission_d) { 5 } let(:submission_e) { 6 } @@ -113,10 +113,10 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # it 'will create the transfer requests using the submissions ids from the Repooling requests' do # Now we create the transfer requests that represent the pool from before - create :transfer_between_plates, + create(:transfer_between_plates, transfers: pool_transfer1, source: pcr_xp_plate1, - destination: prepool_plate + destination: prepool_plate) # The new transfer requests should have the submission id from the pooling requests (4,5,6), not 1 s_ids = prepool_plate.wells.map(&:transfer_requests_as_target).flatten.map(&:submission_id) @@ -126,7 +126,7 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # context 'when I create another Repooling ISC and the new pooling has a different transfers definition' do let(:submission_f) { 7 } let(:submission_g) { 8 } - let(:pool_instances2) { create_list :pre_capture_pool, 2 } + let(:pool_instances2) { create_list(:pre_capture_pool, 2) } let(:pool_transfer2) do { 'A1' => ['A1'], @@ -148,10 +148,10 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # end it 'creates the transfer with the right submission id' do - create :transfer_between_plates, + create(:transfer_between_plates, transfers: pool_transfer2, source: pcr_xp_plate1, - destination: prepool_plate + destination: prepool_plate) s_ids = prepool_plate.wells.map(&:transfer_requests_as_target).flatten.map(&:submission_id) expect(s_ids.uniq).to eq([submission_f, submission_g]) @@ -162,7 +162,7 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # let(:submission_h) { 9 } let(:submission_i) { 10 } let(:submission_j) { 11 } - let(:pool_instances3) { create_list :pre_capture_pool, 3 } + let(:pool_instances3) { create_list(:pre_capture_pool, 3) } let(:pool_transfer3) do { 'A1' => ['A1'], @@ -194,10 +194,10 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # # There are 2 pools with equal configuration, so it does not know which pooling requests we are # referring to when creating the transfer requests. expect do - create :transfer_between_plates, + create(:transfer_between_plates, transfers: pool_transfer3, source: pcr_xp_plate1, - destination: prepool_plate + destination: prepool_plate) end.to raise_error(ActiveRecord::RecordInvalid) end end diff --git a/spec/features/lab_view_spec.rb b/spec/features/lab_view_spec.rb index b2a2c5fb93..801694d74c 100644 --- a/spec/features/lab_view_spec.rb +++ b/spec/features/lab_view_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe 'Lab view', :js do - let(:user) { create :user, email: 'login@example.com' } - let(:library_tube) { create :library_tube } + let(:user) { create(:user, email: 'login@example.com') } + let(:library_tube) { create(:library_tube) } it 'User can update concentrations' do login_user user diff --git a/spec/features/labware/looking_up_labware_history_spec.rb b/spec/features/labware/looking_up_labware_history_spec.rb index 23457c9667..8a633e4393 100644 --- a/spec/features/labware/looking_up_labware_history_spec.rb +++ b/spec/features/labware/looking_up_labware_history_spec.rb @@ -3,16 +3,16 @@ require 'rails_helper' describe 'See labware history' do - let(:user) { create :admin } - let(:tube) { create :tube } + let(:user) { create(:admin) } + let(:tube) { create(:tube) } let!(:asset_audit) do - create :asset_audit, + create(:asset_audit, asset: tube, created_at: Time.zone.parse('June 16, 2020 15:36'), metadata: { 'metadata key' => 'metadata value' - } + }) end it 'displays asset audits', :js do diff --git a/spec/features/labware/retention_instruction_spec.rb b/spec/features/labware/retention_instruction_spec.rb index adcb308edc..c1d322d6eb 100644 --- a/spec/features/labware/retention_instruction_spec.rb +++ b/spec/features/labware/retention_instruction_spec.rb @@ -20,8 +20,8 @@ end context 'when the user is not an admin' do - let(:user) { create :user } - let(:asset) { create :plate_with_3_wells, retention_instruction: :destroy_after_2_years } + let(:user) { create(:user) } + let(:asset) { create(:plate_with_3_wells, retention_instruction: :destroy_after_2_years) } before { visit labware_path(asset) } @@ -39,8 +39,8 @@ end context 'when retention instruction exists' do - let(:user) { create :admin } - let(:asset) { create :plate_with_3_wells, retention_instruction: :destroy_after_2_years } + let(:user) { create(:admin) } + let(:asset) { create(:plate_with_3_wells, retention_instruction: :destroy_after_2_years) } it 'does not display the warning message' do expect(page).to have_no_content 'This labware does not currently have a retention instruction.' @@ -51,8 +51,8 @@ # NB: This scenario will be obsolete (but still valid) after the script in #4095 is run context 'when retention instruction exists in custom_metadata table' do - let(:user) { create :admin } - let(:asset) { create :plate_with_3_wells, retention_instruction: :destroy_after_2_years } + let(:user) { create(:admin) } + let(:asset) { create(:plate_with_3_wells, retention_instruction: :destroy_after_2_years) } before do asset.custom_metadatum_collection = @@ -72,8 +72,8 @@ end context 'when retention instruction does not exist' do - let(:user) { create :admin } - let(:asset) { create :plate_with_3_wells, retention_instruction: nil } + let(:user) { create(:admin) } + let(:asset) { create(:plate_with_3_wells, retention_instruction: nil) } it 'does not have a retention instruction yet' do expect(page).to have_content 'This labware does not currently have a retention instruction.' @@ -83,8 +83,8 @@ end context 'when retention instruction exists for tube' do - let(:user) { create :admin } - let(:asset) { create :tube, retention_instruction: :destroy_after_2_years } + let(:user) { create(:admin) } + let(:asset) { create(:tube, retention_instruction: :destroy_after_2_years) } it 'does not display the warning message' do expect(page).to have_no_content 'This labware does not currently have a retention instruction.' diff --git a/spec/features/labware_information_spec.rb b/spec/features/labware_information_spec.rb index a63ce31282..4135379822 100644 --- a/spec/features/labware_information_spec.rb +++ b/spec/features/labware_information_spec.rb @@ -6,7 +6,7 @@ RSpec.configure { |c| c.include LabWhereClientHelper } describe 'Viewing labware' do - let(:user) { create :user } + let(:user) { create(:user) } shared_examples 'labware' do it 'can be viewed on its show page' do @@ -17,13 +17,13 @@ end context 'with a sample tube' do - let(:labware) { create :sample_tube } + let(:labware) { create(:sample_tube) } it_behaves_like 'labware' end context 'with a library_tube' do - let(:labware) { create :library_tube } + let(:labware) { create(:library_tube) } it_behaves_like 'labware' end @@ -35,7 +35,7 @@ end context 'with a plate' do - let(:labware) { create :plate, well_count: 2 } + let(:labware) { create(:plate, well_count: 2) } context 'when in labwhere' do before do diff --git a/spec/features/labwhere_reception_spec.rb b/spec/features/labwhere_reception_spec.rb index b3bef5eba5..21bd0072df 100644 --- a/spec/features/labwhere_reception_spec.rb +++ b/spec/features/labwhere_reception_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe 'Labwhere reception', :js do - let(:user) { create :user, email: 'login@example.com', swipecard_code: 12_345 } - let(:plate) { create :plate } + let(:user) { create(:user, email: 'login@example.com', swipecard_code: 12_345) } + let(:plate) { create(:plate) } before { configatron.labwhere_api = 'https://labwhere.example.com/api' } # Reset the configatron value after the test to avoid affecting other tests diff --git a/spec/features/patient_consent_withdrawl_spec.rb b/spec/features/patient_consent_withdrawl_spec.rb index 3296007190..a53065485f 100644 --- a/spec/features/patient_consent_withdrawl_spec.rb +++ b/spec/features/patient_consent_withdrawl_spec.rb @@ -9,9 +9,9 @@ # Essentially: # - If a patient withdraws consent we need to make sure everyone downstream knows # - We need to stop new orders being made. - let(:user) { create :user, email: 'login@example.com' } - let(:sample) { create :sample_with_gender, consent_withdrawn: } - let(:study) { create :study } + let(:user) { create(:user, email: 'login@example.com') } + let(:sample) { create(:sample_with_gender, consent_withdrawn:) } + let(:study) { create(:study) } before { study.samples << sample } @@ -41,8 +41,8 @@ end context 'when batched' do - let(:batch) { create :sequencing_batch, state: 'started' } - let(:lane) { create :lane, samples: [sample] } + let(:batch) { create(:sequencing_batch, state: 'started') } + let(:lane) { create(:lane, samples: [sample]) } before { batch.requests << create(:sequencing_request_with_assets, target_asset: lane) } @@ -55,9 +55,9 @@ context 'an order' do # Lifted straight from the feature test with minimal rspecification # and optimization - let(:submission_template) { create :submission_template, request_type_ids_list: [[create(:request_type).id]] } - let(:sample_tube) { create :sample_tube, sample: } - let(:asset_group) { create :asset_group, assets: [sample_tube.receptacle] } + let(:submission_template) { create(:submission_template, request_type_ids_list: [[create(:request_type).id]]) } + let(:sample_tube) { create(:sample_tube, sample:) } + let(:asset_group) { create(:asset_group, assets: [sample_tube.receptacle]) } context 'defined by asset group' do let(:order) do @@ -128,14 +128,14 @@ login_user user visit study_samples_path(study) expect(page).to have_content sample.name - expect(page).not_to have_content "#{sample.name} - Consent withdrawn" - expect(page).not_to have_css('.withdrawn') + expect(page).to have_no_content "#{sample.name} - Consent withdrawn" + expect(page).to have_no_css('.withdrawn') end it 'and a user visit the sample show page' do login_user user visit sample_path(sample) - expect(page).not_to have_content 'Patient consent has been withdrawn for this sample' + expect(page).to have_no_content 'Patient consent has been withdrawn for this sample' end it_behaves_like 'it reports information elsewhere' diff --git a/spec/features/perform_a_tag_substitution_spec.rb b/spec/features/perform_a_tag_substitution_spec.rb index ebe3d92f8e..ad2b16b32f 100644 --- a/spec/features/perform_a_tag_substitution_spec.rb +++ b/spec/features/perform_a_tag_substitution_spec.rb @@ -3,60 +3,60 @@ require 'rails_helper' describe 'Perform a tag substitution', :js do - let(:sample_a) { create :sample } - let(:sample_b) { create :sample } - let(:library_tube_a) { create :library_tube } - let(:library_tube_b) { create :library_tube } - let(:mx_library_tube) { create :multiplexed_library_tube } - let(:library_type) { create :library_type } - let(:used_tag_group) { create :tag_group } - let(:sample_a_orig_tag) { create :tag, tag_group: used_tag_group, map_id: 1 } - let(:sample_a_orig_tag2) { create :tag, tag_group: used_tag_group, map_id: 2 } + let(:sample_a) { create(:sample) } + let(:sample_b) { create(:sample) } + let(:library_tube_a) { create(:library_tube) } + let(:library_tube_b) { create(:library_tube) } + let(:mx_library_tube) { create(:multiplexed_library_tube) } + let(:library_type) { create(:library_type) } + let(:used_tag_group) { create(:tag_group) } + let(:sample_a_orig_tag) { create(:tag, tag_group: used_tag_group, map_id: 1) } + let(:sample_a_orig_tag2) { create(:tag, tag_group: used_tag_group, map_id: 2) } - let(:sample_b_orig_tag) { create :tag, tag_group: used_tag_group, map_id: 3 } - let(:sample_b_orig_tag2) { create :tag, tag_group: used_tag_group, map_id: 4 } + let(:sample_b_orig_tag) { create(:tag, tag_group: used_tag_group, map_id: 3) } + let(:sample_b_orig_tag2) { create(:tag, tag_group: used_tag_group, map_id: 4) } - let!(:lane) { create :lane } + let!(:lane) { create(:lane) } - let(:user) { create :user } + let(:user) { create(:user) } before do - create :aliquot, + create(:aliquot, sample: sample_a, tag: sample_a_orig_tag, tag2: sample_a_orig_tag2, library: library_tube_a, - receptacle: library_tube_a - create :aliquot, + receptacle: library_tube_a) + create(:aliquot, sample: sample_b, tag: sample_b_orig_tag, tag2: sample_b_orig_tag2, library: library_tube_b, - receptacle: library_tube_b - create :aliquot, + receptacle: library_tube_b) + create(:aliquot, sample: sample_a, tag: sample_a_orig_tag, tag2: sample_a_orig_tag2, library: library_tube_a, - receptacle: mx_library_tube - create :aliquot, + receptacle: mx_library_tube) + create(:aliquot, sample: sample_b, tag: sample_b_orig_tag, tag2: sample_b_orig_tag2, library: library_tube_b, - receptacle: mx_library_tube - create :aliquot, + receptacle: mx_library_tube) + create(:aliquot, sample: sample_a, tag: sample_a_orig_tag, tag2: sample_a_orig_tag2, library: library_tube_a, - receptacle: lane - create :aliquot, + receptacle: lane) + create(:aliquot, sample: sample_b, tag: sample_b_orig_tag, tag2: sample_b_orig_tag2, library: library_tube_b, - receptacle: lane + receptacle: lane) end it 'Performing a tag swap' do diff --git a/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb b/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb index 33a6b79929..a4d3192af4 100644 --- a/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb +++ b/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb @@ -4,35 +4,35 @@ require 'pry' describe 'cherrypick for fluidigm pipeline - micro litre', :js do - let(:user) { create :admin } - let(:project) { create :project, name: 'Test project' } - let(:study) { create :study } + let(:user) { create(:admin) } + let(:project) { create(:project, name: 'Test project') } + let(:study) { create(:study) } let(:pipeline_name) { pipeline.name } - let(:pipeline) { create :fluidigm_pipeline } - let(:submission) { create :submission } - let(:plate1) { create :plate_with_untagged_wells, sample_count: 2, barcode: 'SQPD-1' } - let(:plate2) { create :plate_with_untagged_wells, sample_count: 2, barcode: 'SQPD-10' } - let(:plate3) { create :plate_with_untagged_wells, sample_count: 2, barcode: 'SQPD-5' } + let(:pipeline) { create(:fluidigm_pipeline) } + let(:submission) { create(:submission) } + let(:plate1) { create(:plate_with_untagged_wells, sample_count: 2, barcode: 'SQPD-1') } + let(:plate2) { create(:plate_with_untagged_wells, sample_count: 2, barcode: 'SQPD-10') } + let(:plate3) { create(:plate_with_untagged_wells, sample_count: 2, barcode: 'SQPD-5') } let(:plates) { [plate1, plate2, plate3] } - let(:robot) { create :robot, barcode: '444' } - let!(:plate_template) { create :plate_template } + let(:robot) { create(:robot, barcode: '444') } + let!(:plate_template) { create(:plate_template) } let(:request_types) { pipeline.request_types.map(&:key) } before do - target_purpose = create :plate_purpose, name: 'Fluidigm' + target_purpose = create(:plate_purpose, name: 'Fluidigm') assets = plates.each_with_object([]) do |plate, assets| assets.concat(plate.wells) plate.wells.each_with_index { |well, index| well.well_attribute.update!(measured_volume: 30 + (index % 30)) } end assets.each do |asset| - create :cherrypick_for_fluidigm_request, + create(:cherrypick_for_fluidigm_request, asset:, request_type: pipeline.request_types.first, submission:, study:, project:, - target_purpose: + target_purpose:) end allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode, barcode: 'SQPD-2')) diff --git a/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb b/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb index 2f7db1ddbe..bce0af8c0a 100644 --- a/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb +++ b/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb @@ -7,10 +7,10 @@ include BarcodeHelper let(:swipecard_code) { '123456' } - let(:user) { create :admin, swipecard_code: } - let(:project) { create :project } - let(:study) { create :study } - let(:pipeline) { create :cherrypick_pipeline } + let(:user) { create(:admin, swipecard_code:) } + let(:project) { create(:project) } + let(:study) { create(:study) } + let(:pipeline) { create(:cherrypick_pipeline) } let(:pipeline_name) { pipeline.name } let(:max_plates) { 17 } let(:robot) do @@ -23,16 +23,16 @@ ) end let(:robot_barcode) { SBCF::SangerBarcode.new(prefix: 'RB', number: robot.barcode).machine_barcode } - let(:submission) { create :submission } - let(:plate_template) { create :plate_template } - let(:plate_type) { create :plate_type, name: 'ABgene_0765', maximum_volume: 800 } + let(:submission) { create(:submission) } + let(:plate_template) { create(:plate_template) } + let(:plate_type) { create(:plate_type, name: 'ABgene_0765', maximum_volume: 800) } let(:_destination_plate_barcode) { build(:plate_barcode) } let(:destination_plate_barcode) { _destination_plate_barcode.barcode } let(:_destination_plate_barcode_2) { build(:plate_barcode) } let(:destination_plate_barcode_2) { _destination_plate_barcode_2.barcode } let(:destination_plate_human_barcode_2) { destination_plate_barcode_2 } let(:destination_plate_human_barcode) { destination_plate_barcode } - let(:target_purpose) { create :plate_purpose } + let(:target_purpose) { create(:plate_purpose) } let(:control_plate) { nil } let(:concentrations_required) { false } let(:custom_destination_type) { nil } @@ -96,14 +96,14 @@ def initialize_plates(plates) first(:select, 'action_on_requests').select('Create Batch') first(:button, 'Submit').click click_link 'Back to pipeline' - expect(page).not_to have_content(plates[0].human_barcode) + expect(page).to have_no_content(plates[0].human_barcode) end end describe 'where picking by ng/µl for a tecan robot' do let(:concentrations_required) { true } let(:layout_volume_option) { 'Pick by ng/µl' } - let(:custom_destination_type) { create :plate_type, name: 'Custom Type' } + let(:custom_destination_type) { create(:plate_type, name: 'Custom Type') } let(:expected_plates_by_destination_plate) do { destination_plate_human_barcode => { 1 => { sources: [plates[0], plates[1], plates[2]] } } } end @@ -277,7 +277,7 @@ def initialize_plates(plates) describe 'where picking by ng for a tecan robot' do let(:concentrations_required) { true } let(:layout_volume_option) { 'Pick by ng' } - let(:plate_type) { create :plate_type, name: 'ABgene_0800', maximum_volume: 800 } + let(:plate_type) { create(:plate_type, name: 'ABgene_0800', maximum_volume: 800) } let(:expected_plates_by_destination_plate) do { destination_plate_human_barcode => { 1 => { sources: [plates[0], plates[1], plates[2]] } } } end @@ -368,15 +368,15 @@ def initialize_plates(plates) end describe 'where there is a control plate and a single destination' do - let(:plate1) { create :plate_with_untagged_wells, sample_count: 2 } - let(:plate2) { create :plate_with_untagged_wells, sample_count: 2 } - let(:control_plate) { create :control_plate, sample_count: 2 } + let(:plate1) { create(:plate_with_untagged_wells, sample_count: 2) } + let(:plate2) { create(:plate_with_untagged_wells, sample_count: 2) } + let(:control_plate) { create(:control_plate, sample_count: 2) } let(:plates) { [plate1, plate2] } let(:max_plates) { 25 } - let(:robot) { create :hamilton, barcode: '444', max_plates_value: max_plates } + let(:robot) { create(:hamilton, barcode: '444', max_plates_value: max_plates) } let(:concentrations_required) { true } let(:layout_volume_option) { 'Pick by ng/µl' } - let(:custom_destination_type) { create :plate_type, name: 'Custom Type' } + let(:custom_destination_type) { create(:plate_type, name: 'Custom Type') } let(:expected_plates_by_destination_plate) do { destination_plate_human_barcode => { 1 => { sources: [plates[0], plates[1]], control: control_plate } } } end @@ -385,7 +385,7 @@ def initialize_plates(plates) context 'when the number of plates exceeds number of beds (Several runs)' do let(:max_plates) { 2 } - let(:robot) { create :hamilton, barcode: '444', max_plates_value: max_plates } + let(:robot) { create(:hamilton, barcode: '444', max_plates_value: max_plates) } let(:expected_plates_by_destination_plate) do { destination_plate_human_barcode => { @@ -405,16 +405,16 @@ def initialize_plates(plates) end describe 'where there is a control plate and multiple destinations', :js do - let(:plate1) { create :plate_with_untagged_wells, sample_count: 50 } - let(:plate2) { create :plate_with_untagged_wells, sample_count: 50 } - let(:control_plate) { create :control_plate, sample_count: 2 } + let(:plate1) { create(:plate_with_untagged_wells, sample_count: 50) } + let(:plate2) { create(:plate_with_untagged_wells, sample_count: 50) } + let(:control_plate) { create(:control_plate, sample_count: 2) } let(:plates) { [plate1, plate2] } let(:max_plates) { 25 } - let(:robot) { create :hamilton, barcode: '444', max_plates_value: max_plates } + let(:robot) { create(:hamilton, barcode: '444', max_plates_value: max_plates) } let(:concentrations_required) { true } let(:layout_volume_option) { 'Pick by ng/µl' } - let(:custom_destination_type) { create :plate_type, name: 'Custom Type' } + let(:custom_destination_type) { create(:plate_type, name: 'Custom Type') } let(:expected_plates_by_destination_plate) do { destination_plate_human_barcode => { @@ -436,7 +436,7 @@ def initialize_plates(plates) context 'when the number of plates exceeds number of beds (Several runs)' do let(:max_plates) { 2 } - let(:robot) { create :hamilton, barcode: '444', max_plates_value: max_plates } + let(:robot) { create(:hamilton, barcode: '444', max_plates_value: max_plates) } let(:expected_plates_by_destination_plate) do { destination_plate_human_barcode => { diff --git a/spec/features/pipelines/creating_an_empty_batch_spec.rb b/spec/features/pipelines/creating_an_empty_batch_spec.rb index a92065f252..b17e0a3082 100644 --- a/spec/features/pipelines/creating_an_empty_batch_spec.rb +++ b/spec/features/pipelines/creating_an_empty_batch_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' describe 'Empty batch creation', :js do - let(:user) { create :user } - let(:pipeline) { create :cherrypick_pipeline } + let(:user) { create(:user) } + let(:pipeline) { create(:cherrypick_pipeline) } let(:pipeline_name) { pipeline.name } - let(:submission) { create :submission } + let(:submission) { create(:submission) } let(:plates) { create_list(:plate_with_untagged_wells_and_custom_name, 1, sample_count: 2) } let(:request_type) { pipeline.request_types.first } @@ -14,7 +14,7 @@ plates.each do |plate| plate.wells.each do |well| # create the requests for cherrypicking - create :cherrypick_request, asset: well, request_type:, submission: + create(:cherrypick_request, asset: well, request_type:, submission:) end end end diff --git a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb index eee0c81663..1b74765dd2 100644 --- a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb +++ b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb @@ -4,18 +4,18 @@ require './spec/features/shared_examples/sequencing' RSpec.describe 'Following a Sequencing Pipeline', :js do - let(:user) { create :user } + let(:user) { create(:user) } let(:pipeline) { create(:sequencing_pipeline, :with_workflow) } - let(:spiked_buffer) { create :spiked_buffer, :tube_barcode } + let(:spiked_buffer) { create(:spiked_buffer, :tube_barcode) } let(:requests) do - asset = create :multiplexed_library_tube, :scanned_into_lab, sample_count: 2 - create_list :sequencing_request_with_assets, + asset = create(:multiplexed_library_tube, :scanned_into_lab, sample_count: 2) + create_list(:sequencing_request_with_assets, 2, request_type: pipeline.request_types.first, asset:, target_asset: nil, - submission: create(:submission) + submission: create(:submission)) end before { requests } @@ -25,14 +25,14 @@ end context 'with one lane of pre-added PhiX' do - let(:existing_spiked_buffer) { create :spiked_buffer, :tube_barcode } + let(:existing_spiked_buffer) { create(:spiked_buffer, :tube_barcode) } let(:with_phi_x) do - tube = create :multiplexed_library_tube, :scanned_into_lab, sample_count: 2 + tube = create(:multiplexed_library_tube, :scanned_into_lab, sample_count: 2) tube.parents << existing_spiked_buffer tube end let(:requests) do - no_phi_x = create :multiplexed_library_tube, :scanned_into_lab, sample_count: 2 + no_phi_x = create(:multiplexed_library_tube, :scanned_into_lab, sample_count: 2) [ create( :sequencing_request_with_assets, @@ -113,21 +113,21 @@ end context 'when a batch has been created' do - let(:batch) { create :batch, pipeline:, requests: pipeline.requests, state: 'released', updated_at: 1.day.ago } + let(:batch) { create(:batch, pipeline:, requests: pipeline.requests, state: 'released', updated_at: 1.day.ago) } let!(:flowcell_message) { Messenger.create!(target: batch, template: 'FlowcellIO', root: 'flowcell') } before do batch.requests.each_with_index do |request, i| - create :lab_event, + create(:lab_event, eventful: request, batch:, user:, description: 'Specify Dilution Volume', descriptors: { 'Concentration' => (1.2 + i).to_s - } - create :lab_event, + }) + create(:lab_event, eventful: request, batch:, user:, @@ -136,7 +136,7 @@ 'Workflow (Standard or Xp)' => 'XP', 'Lane loading concentration (pM)' => '23', '+4 field of weirdness' => "Something else #{i}" - } + }) lane = create(:lane) request.update(target_asset: lane) lane.labware.parents << spiked_buffer @@ -246,7 +246,7 @@ login_user(user) visit batch_path(batch) expect(page).to have_content('Fail batch or requests') - expect(page).not_to have_content('Batches can not be failed when pending') + expect(page).to have_no_content('Batches can not be failed when pending') end end end diff --git a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb index 8b141cdd83..55e2026cb7 100644 --- a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb +++ b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb @@ -4,45 +4,45 @@ require './spec/features/shared_examples/sequencing' RSpec.describe 'Following a Sequencing Pipeline', :js do - let(:user) { create :user } - let(:study1) { create :study } - let(:project1) { create :project } + let(:user) { create(:user) } + let(:study1) { create(:study) } + let(:project1) { create(:project) } let(:pipeline) { create(:sequencing_pipeline, :with_workflow) } - let(:spiked_buffer) { create :spiked_buffer, :tube_barcode } - let(:tag) { create :tag, oligo: 'T' } - let(:tag2) { create :tag, oligo: 'C' } + let(:spiked_buffer) { create(:spiked_buffer, :tube_barcode) } + let(:tag) { create(:tag, oligo: 'T') } + let(:tag2) { create(:tag, oligo: 'C') } let(:aliquot1) do - create :aliquot, + create(:aliquot, tag_id: tag.id, tag2_id: tag2.id, tag_depth: 1, study: study1, project: project1, library_type: 'Standard', - library_id: 54 + library_id: 54) end let(:aliquot2) do - create :aliquot, + create(:aliquot, tag_id: tag.id, tag2_id: tag2.id, tag_depth: 2, study: study1, project: project1, library_type: 'Standard', - library_id: 54 + library_id: 54) end let(:requests) do - asset = create :multiplexed_library_tube, :scanned_into_lab, sample_count: 2 + asset = create(:multiplexed_library_tube, :scanned_into_lab, sample_count: 2) asset.aliquots = [aliquot1, aliquot2] asset.reload - create_list :sequencing_request_with_assets, + create_list(:sequencing_request_with_assets, 2, request_type: pipeline.request_types.first, asset:, target_asset: nil, - submission: create(:submission) + submission: create(:submission)) end before { requests } diff --git a/spec/features/pipelines/viewing_request_comments_spec.rb b/spec/features/pipelines/viewing_request_comments_spec.rb index b76f65a804..11f12c1407 100644 --- a/spec/features/pipelines/viewing_request_comments_spec.rb +++ b/spec/features/pipelines/viewing_request_comments_spec.rb @@ -3,17 +3,17 @@ require 'rails_helper' describe 'Viewing request comments', :js do - let(:user) { create :user } - let(:pipeline) { create :sequencing_pipeline } + let(:user) { create(:user) } + let(:pipeline) { create(:sequencing_pipeline) } let(:pipeline_name) { pipeline.name } - let(:submission) { create :submission } - let(:tube) { create :multiplexed_library_tube } - let(:request) { create :sequencing_request, asset: tube, request_type: pipeline.request_types.first, submission: } + let(:submission) { create(:submission) } + let(:tube) { create(:multiplexed_library_tube) } + let(:request) { create(:sequencing_request, asset: tube, request_type: pipeline.request_types.first, submission:) } before do - create :comment, commentable: tube, description: 'An excellent tube' - create :comment, commentable: tube.receptacle, description: 'A good receptacle' - create :comment, commentable: request, description: 'A reasonable request' + create(:comment, commentable: tube, description: 'An excellent tube') + create(:comment, commentable: tube.receptacle, description: 'A good receptacle') + create(:comment, commentable: request, description: 'A reasonable request') end it 'returns an error message' do diff --git a/spec/features/plate_qc_display_spec.rb b/spec/features/plate_qc_display_spec.rb index 7b2c84e2b7..569dececa5 100644 --- a/spec/features/plate_qc_display_spec.rb +++ b/spec/features/plate_qc_display_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Plate QC display' do - let(:user) { create :user, email: 'login@example.com' } + let(:user) { create(:user, email: 'login@example.com') } describe 'with no QC results' do let!(:plate) { create(:plate, sample_count: 3) } @@ -49,7 +49,7 @@ %w[concentration volume quantity_in_nano_grams loci_passed rin].each do |qc_result| within("##{qc_result}") do plate.wells.each_with_index do |well, index| - expect(page).to have_selector("tr[#{1 + index}]/td[2]", text: well.qc_result_for(qc_result)) + expect(page).to have_css("tr[#{1 + index}]/td[2]", text: well.qc_result_for(qc_result)) end end end diff --git a/spec/features/pooling_spec.rb b/spec/features/pooling_spec.rb index ca91ab56f4..0afcf2e5d5 100644 --- a/spec/features/pooling_spec.rb +++ b/spec/features/pooling_spec.rb @@ -3,17 +3,17 @@ require 'rails_helper' describe 'Pooling', :js, :poolings do - let(:user) { create :user, email: 'login@example.com' } + let(:user) { create(:user, email: 'login@example.com') } describe 'from page directly' do - let!(:empty_lb_tube1) { create :empty_library_tube, barcode: 1 } - let!(:empty_lb_tube2) { create :empty_library_tube, barcode: 2 } - let!(:untagged_lb_tube1) { create :library_tube, barcode: 3 } + let!(:empty_lb_tube1) { create(:empty_library_tube, barcode: 1) } + let!(:empty_lb_tube2) { create(:empty_library_tube, barcode: 2) } + let!(:untagged_lb_tube1) { create(:library_tube, barcode: 3) } let(:sample1) { untagged_lb_tube1.samples.first } - let!(:untagged_lb_tube2) { create :library_tube, barcode: 4 } + let!(:untagged_lb_tube2) { create(:library_tube, barcode: 4) } let(:sample2) { untagged_lb_tube2.samples.first } - let!(:tagged_lb_tube1) { create :tagged_library_tube, barcode: 5 } - let!(:tagged_lb_tube2) { create :tagged_library_tube, barcode: 6 } + let!(:tagged_lb_tube1) { create(:tagged_library_tube, barcode: 5) } + let!(:tagged_lb_tube2) { create(:tagged_library_tube, barcode: 6) } it 'user can pool from different tubes to stock and standard mx tubes' do login_user user @@ -63,7 +63,7 @@ end describe 'from sample manifest page' do - let!(:sample_manifest) { create :tube_sample_manifest_with_sample_tubes, asset_type: 'library' } + let!(:sample_manifest) { create(:tube_sample_manifest_with_sample_tubes, asset_type: 'library') } before do aliquot = Tube.last.aliquots.first diff --git a/spec/features/receptacle_information_spec.rb b/spec/features/receptacle_information_spec.rb index ba01b62b08..7f03a027a0 100644 --- a/spec/features/receptacle_information_spec.rb +++ b/spec/features/receptacle_information_spec.rb @@ -6,7 +6,7 @@ RSpec.configure { |c| c.include LabWhereClientHelper } describe 'Viewing a receptacle' do - let(:user) { create :user } + let(:user) { create(:user) } shared_examples 'a receptacle' do it 'can be viewed on its show page' do @@ -35,7 +35,7 @@ end context 'with a well' do - let(:receptacle) { create :well } + let(:receptacle) { create(:well) } it_behaves_like 'a receptacle' end diff --git a/spec/features/retrospective_failure_spec.rb b/spec/features/retrospective_failure_spec.rb index 5bedff6b40..93b93ff639 100644 --- a/spec/features/retrospective_failure_spec.rb +++ b/spec/features/retrospective_failure_spec.rb @@ -26,33 +26,33 @@ # minimal consequence, that the additional code complexity outweighs the minor benefits. # The well we'll be failing - let(:target_well) { create :untagged_well } + let(:target_well) { create(:untagged_well) } # The actual request that gets failed. - let(:target_request) { create :transfer_request, target_asset: target_well } + let(:target_request) { create(:transfer_request, target_asset: target_well) } let(:initial_aliquot) { target_well.aliquots.first } - let(:tag) { create :tag } - let(:tag2) { create :tag } + let(:tag) { create(:tag) } + let(:tag2) { create(:tag) } context 'with two descendants and one clash' do - let(:child_well_1) { create :empty_well } + let(:child_well_1) { create(:empty_well) } let(:child_well_2) do - well = create :empty_well + well = create(:empty_well) well.aliquots << create(:tagged_aliquot, receptacle: well, sample: initial_aliquot.sample) well end before do # NOTE: These transfer requests automatically handle the transfer of our aliquot. - create :transfer_request, asset: target_well, target_asset: child_well_1 + create(:transfer_request, asset: target_well, target_asset: child_well_1) # Apply tags to make sure that gets handled correctly child_well_1.aliquots.first.tap do |aliquot| aliquot.tag = tag aliquot.save! end - create :transfer_request, asset: child_well_1, target_asset: child_well_2 + create(:transfer_request, asset: child_well_1, target_asset: child_well_2) # Just double check that the setup has worked as intended expect(child_well_2.aliquots.count).to eq(2) @@ -75,17 +75,17 @@ end context 'with a QcTube descendant' do - let(:child_well_1) { create :empty_well } + let(:child_well_1) { create(:empty_well) } - let(:qc_tube) { create :qc_tube } + let(:qc_tube) { create(:qc_tube) } - let(:lane) { create :lane } + let(:lane) { create(:lane) } before do # NOTE: These transfer requests automatically handle the transfer of our aliquot. - create :transfer_request, asset: target_well, target_asset: child_well_1 - create :transfer_request, asset: target_well, target_asset: qc_tube - create :transfer_request, asset: qc_tube, target_asset: lane + create(:transfer_request, asset: target_well, target_asset: child_well_1) + create(:transfer_request, asset: target_well, target_asset: qc_tube) + create(:transfer_request, asset: qc_tube, target_asset: lane) end it 'fail removed downstream aliquots' do diff --git a/spec/features/sample_logistics/lab/stock_stamping_spec.rb b/spec/features/sample_logistics/lab/stock_stamping_spec.rb index 7cb038a96c..521bd2dcb1 100644 --- a/spec/features/sample_logistics/lab/stock_stamping_spec.rb +++ b/spec/features/sample_logistics/lab/stock_stamping_spec.rb @@ -3,13 +3,13 @@ require 'rails_helper' describe 'stamping of stock', :js do - let(:user) { create :admin, barcode: 'ID41440E', swipecard_code: '1234567' } - let(:plate) { create :plate_with_3_wells } - let!(:barcode_printer) { create :barcode_printer } + let(:user) { create(:admin, barcode: 'ID41440E', swipecard_code: '1234567') } + let(:plate) { create(:plate_with_3_wells) } + let!(:barcode_printer) { create(:barcode_printer) } before do - create :plate_type, name: 'ABgene_0800', maximum_volume: 180 - create :plate_type, name: 'ABgene_0765', maximum_volume: 800 + create(:plate_type, name: 'ABgene_0800', maximum_volume: 180) + create(:plate_type, name: 'ABgene_0765', maximum_volume: 800) end it 'stamping of stock' do @@ -36,7 +36,7 @@ # rubocop:enable Layout/LineLength expect(page).to have_content 'You can generate the TECAN file and print label now.' - expect(page).not_to have_content('Plates barcodes are not identical') + expect(page).to have_no_content('Plates barcodes are not identical') click_button 'Generate TECAN file' expect(page).to have_content('Stamping of stock') diff --git a/spec/features/sample_manifests/create_manifest_spec.rb b/spec/features/sample_manifests/create_manifest_spec.rb index 26d47963e8..ad98efd0be 100644 --- a/spec/features/sample_manifests/create_manifest_spec.rb +++ b/spec/features/sample_manifests/create_manifest_spec.rb @@ -10,10 +10,10 @@ def load_manifest_spec end end - let(:user) { create :user } - let!(:printer) { create :barcode_printer } - let!(:supplier) { create :supplier } - let!(:study) { create :study } + let(:user) { create(:user) } + let!(:printer) { create(:barcode_printer) } + let!(:supplier) { create(:supplier) } + let!(:study) { create(:study) } let(:plate_barcode) { build(:plate_barcode) } let(:created_plate) { Plate.with_barcode(plate_barcode.barcode).first } @@ -25,7 +25,7 @@ def load_manifest_spec select(supplier.name, from: 'Supplier') within('#sample_manifest_template') do expect(page).to have_css('option', count: 9) - expect(page).not_to have_css('option', text: 'Default Tube') + expect(page).to have_no_css('option', text: 'Default Tube') end select('Default Plate', from: 'Template') select(printer.name, from: 'Barcode printer') @@ -56,13 +56,13 @@ def load_manifest_spec context 'with a selected purpose' do let(:selected_purpose) { created_purpose } - let!(:created_purpose) { create :plate_purpose, stock_plate: true } + let!(:created_purpose) { create(:plate_purpose, stock_plate: true) } it_behaves_like 'a plate manifest' end context 'without a type specified' do - let!(:created_purpose) { create :plate_purpose, stock_plate: true } + let!(:created_purpose) { create(:plate_purpose, stock_plate: true) } it 'indicate the purpose field is used for plates only' do visit(new_sample_manifest_path) @@ -73,8 +73,8 @@ def load_manifest_spec end context 'with a tube rack manifest' do - let!(:selected_purpose) { create :sample_tube_purpose, name: 'Standard sample' } - let!(:selected_tube_rack_purpose) { create :tube_rack_purpose, name: 'TR Stock 96' } + let!(:selected_purpose) { create(:sample_tube_purpose, name: 'Standard sample') } + let!(:selected_tube_rack_purpose) { create(:tube_rack_purpose, name: 'TR Stock 96') } it 'creating manifests' do click_link('Create manifest for tube racks') @@ -85,7 +85,7 @@ def load_manifest_spec expect(page).to have_css('option', text: 'Default Tube Rack') end select('Default Tube Rack', from: 'Template') - expect(page).not_to have_text('Barcodes') + expect(page).to have_no_text('Barcodes') expect(page).to have_text('Tube racks required') select(selected_purpose.name, from: 'Tube purpose') if selected_purpose expect(page).to have_text('Tube rack purpose') diff --git a/spec/features/sample_manifests/track_sample_manifest_updates_spec.rb b/spec/features/sample_manifests/track_sample_manifest_updates_spec.rb index e02458c018..2ffbc66c86 100644 --- a/spec/features/sample_manifests/track_sample_manifest_updates_spec.rb +++ b/spec/features/sample_manifests/track_sample_manifest_updates_spec.rb @@ -14,11 +14,11 @@ def load_manifest_spec end end - let(:user) { create :user, login: 'john' } - let(:new_user) { create :user, login: 'jane' } - let!(:printer) { create :barcode_printer } - let!(:supplier) { create :supplier } - let!(:study) { create :study } + let(:user) { create(:user, login: 'john') } + let(:new_user) { create(:user, login: 'jane') } + let!(:printer) { create(:barcode_printer) } + let!(:supplier) { create(:supplier) } + let!(:study) { create(:study) } before do travel_to(Time.zone.local(2010, 7, 12, 10, 25, 0)) diff --git a/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb b/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb index 5a8c3446e8..7031946edc 100644 --- a/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb +++ b/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb @@ -19,7 +19,7 @@ after(:all) { SampleManifestExcel.reset! } context 'library tube sample manifest with tag sequences' do - let!(:user) { create :admin } + let!(:user) { create(:admin) } let(:columns) { SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup } let(:test_file) { 'test_file.xlsx' } @@ -137,7 +137,7 @@ end context 'multiplexed tube sample manifest with tag sequences' do - let!(:user) { create :admin } + let!(:user) { create(:admin) } let(:columns) { SampleManifestExcel.configuration.columns.tube_multiplexed_library_with_tag_sequences.dup } let(:test_file) { 'test_file.xlsx' } @@ -274,7 +274,7 @@ end context 'multiplexed tube sample manifest with tag groups and indexes' do - let!(:user) { create :admin } + let!(:user) { create(:admin) } let(:columns) { SampleManifestExcel.configuration.columns.tube_multiplexed_library.dup } let(:test_file) { 'test_file.xlsx' } @@ -402,7 +402,7 @@ end context 'plate sample manifest' do - let!(:user) { create :admin } + let!(:user) { create(:admin) } let(:columns) { SampleManifestExcel.configuration.columns.plate_default.dup } let(:test_file) { 'test_file.xlsx' } diff --git a/spec/features/shared_examples/sequencing.rb b/spec/features/shared_examples/sequencing.rb index 3e53228444..e7baf91b2a 100644 --- a/spec/features/shared_examples/sequencing.rb +++ b/spec/features/shared_examples/sequencing.rb @@ -66,7 +66,7 @@ go_back all(:link, 'Lane').last.click - expect(page).not_to have_content('Spiked Buffer') + expect(page).to have_no_content('Spiked Buffer') batch = Batch.last flowcell_message = batch.messengers.last diff --git a/spec/features/starting_transfers_on_repools_starts_repools_spec.rb b/spec/features/starting_transfers_on_repools_starts_repools_spec.rb index 5a2b8108a4..c224f11c95 100644 --- a/spec/features/starting_transfers_on_repools_starts_repools_spec.rb +++ b/spec/features/starting_transfers_on_repools_starts_repools_spec.rb @@ -18,10 +18,10 @@ require 'rails_helper' describe 'Starting transfers on repools starts repools' do - let(:original_input_plate) { create :input_plate_for_pooling } + let(:original_input_plate) { create(:input_plate_for_pooling) } let(:secondary_input_plate) do plate = PlateCreation.create!(user:, parent: original_input_plate, child_purpose: create(:plate_purpose)).child - create :transfer_between_plates, source: original_input_plate, destination: plate + create(:transfer_between_plates, source: original_input_plate, destination: plate) plate end @@ -29,15 +29,15 @@ PlateCreation.create!(user:, parent: original_input_plate, child_purpose: create(:plate_purpose)).child end - let(:user) { create :user } + let(:user) { create(:user) } let(:source_a1) { secondary_input_plate.wells.detect { |w| w.map_description == 'A1' } } let(:source_b1) { secondary_input_plate.wells.detect { |w| w.map_description == 'B1' } } let(:target_a1) { target_plate.wells.detect { |w| w.map_description == 'A1' } } let(:target_b1) { target_plate.wells.detect { |w| w.map_description == 'B1' } } - let(:library_creation_request_a1) { create :library_creation_request, asset: source_a1 } - let(:library_creation_request_b1) { create :library_creation_request, asset: source_b1 } + let(:library_creation_request_a1) { create(:library_creation_request, asset: source_a1) } + let(:library_creation_request_b1) { create(:library_creation_request, asset: source_b1) } before do allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode), build(:plate_barcode)) diff --git a/spec/features/studies/change_study_roles_spec.rb b/spec/features/studies/change_study_roles_spec.rb index 495434151a..2c2823d7bf 100644 --- a/spec/features/studies/change_study_roles_spec.rb +++ b/spec/features/studies/change_study_roles_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe 'Study roles' do - let(:user) { create :admin } - let!(:study) { create :study_with_manager, updated_at: 1.year.ago } + let(:user) { create(:admin) } + let!(:study) { create(:study_with_manager, updated_at: 1.year.ago) } let(:manager) { study.managers.first } it 'can be removed', :js do @@ -16,7 +16,7 @@ click_link 'Contacts' expect(find_by_id('role_list')).to have_content(manager.login) click_button 'Remove' - expect(find_by_id('role_list')).not_to have_content(manager.login) + expect(find_by_id('role_list')).to have_no_content(manager.login) expect(study.reload.updated_at).to be > 1.hour.ago end end diff --git a/spec/features/studies/create_study_spec.rb b/spec/features/studies/create_study_spec.rb index 4500a0bc25..4f63079c5b 100644 --- a/spec/features/studies/create_study_spec.rb +++ b/spec/features/studies/create_study_spec.rb @@ -3,13 +3,13 @@ require 'rails_helper' describe 'Create a study' do - let(:user) { create :admin } + let(:user) { create(:admin) } before do - create :faculty_sponsor, name: 'Jack Sponsor' - create :data_release_study_type, name: 'genomic sequencing' - create :study_type - create :program + create(:faculty_sponsor, name: 'Jack Sponsor') + create(:data_release_study_type, name: 'genomic sequencing') + create(:study_type) + create(:program) end it 'displays the expected fields' do @@ -66,7 +66,7 @@ choose('Managed (EGA)', allow_label_click: true) expect(page).to have_content('HuMFre approval number') click_button 'Create' - expect(page).not_to have_content "Study metadata HuMFre approval number can't be blank" + expect(page).to have_no_content "Study metadata HuMFre approval number can't be blank" end it 'create open study', :js do diff --git a/spec/features/studies/edit_study_spec.rb b/spec/features/studies/edit_study_spec.rb index 89f7649b3a..c8a29b8138 100644 --- a/spec/features/studies/edit_study_spec.rb +++ b/spec/features/studies/edit_study_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe 'Edit a study' do - let(:user) { create :admin } - let!(:study) { create :study } + let(:user) { create(:admin) } + let!(:study) { create(:study) } it 'edit open study', :js do study.study_metadata.bam = false @@ -36,7 +36,7 @@ end context 'when data release strategy is Not Applicable' do - let!(:study) { create :not_app_study } + let!(:study) { create(:not_app_study) } it 'does not error when setting strategy to Open', :js do study.study_metadata.data_release_strategy = 'not applicable' diff --git a/spec/features/studies/manage_study_spec.rb b/spec/features/studies/manage_study_spec.rb index c5f242150a..a6a1a094c3 100644 --- a/spec/features/studies/manage_study_spec.rb +++ b/spec/features/studies/manage_study_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe 'Manage a study' do - let(:user) { create :admin } - let!(:study) { create :study, name: 'Original name' } + let(:user) { create(:admin) } + let!(:study) { create(:study, name: 'Original name') } it 'Rename a study', :js do login_user(user) @@ -14,7 +14,7 @@ fill_in 'Study name', with: 'Updated name' click_on 'Update' expect(page).to have_content('Updated name') - expect(page).not_to have_content('Original name') + expect(page).to have_no_content('Original name') end context 'with data release strategy' do diff --git a/spec/features/studies/qc_reports_spec.rb b/spec/features/studies/qc_reports_spec.rb index 0933c957fa..365fa04d2c 100644 --- a/spec/features/studies/qc_reports_spec.rb +++ b/spec/features/studies/qc_reports_spec.rb @@ -6,7 +6,7 @@ let(:user) { create(:admin) } let!(:study) { create(:study) } let!(:product_criteria) { create(:product_criteria) } - let(:plate_purposes) { create_list :plate_purpose, 3 } + let(:plate_purposes) { create_list(:plate_purpose, 3) } let(:plate_purpose_names) { plate_purposes.map(&:name) } before do diff --git a/spec/features/studies/view_study_properties_spec.rb b/spec/features/studies/view_study_properties_spec.rb index 238c966389..a3359f72ac 100644 --- a/spec/features/studies/view_study_properties_spec.rb +++ b/spec/features/studies/view_study_properties_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'View study properties' do - let(:user) { create :admin } + let(:user) { create(:admin) } let(:prelim_id) { 'A1234' } let(:study) { create(:study, study_metadata: create(:study_metadata, prelim_id:)) } diff --git a/spec/features/studies/view_study_request_links_spec.rb b/spec/features/studies/view_study_request_links_spec.rb index bcfe5f0851..14b5507526 100644 --- a/spec/features/studies/view_study_request_links_spec.rb +++ b/spec/features/studies/view_study_request_links_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' describe 'View study properties' do - let(:user) { create :admin } + let(:user) { create(:admin) } let(:study) { create(:study, name: 'Study 3871492') } let(:sample) { create(:sample, name: 'sample_1-3871492') } - let(:sequencing_request_type) { create :sequencing_request_type } + let(:sequencing_request_type) { create(:sequencing_request_type) } let(:single_request) do create( :sequencing_request, @@ -38,7 +38,7 @@ it 'No links to absent requests', :js do click_link sequencing_request_type.name - expect(page).not_to have_link(title: "#{library_tube.human_barcode} started") + expect(page).to have_no_link(title: "#{library_tube.human_barcode} started") end it 'Single requests link directly to the request', :js do @@ -65,7 +65,7 @@ select('Library tube', from: 'Filter by') expect(page).to have_text 'Currently showing Library tube' within '#summary' do - expect(page).not_to have_text sample_tube.name + expect(page).to have_no_text sample_tube.name expect(page).to have_text library_tube.name end end diff --git a/spec/features/submissions/bulk_submissions_spec.rb b/spec/features/submissions/bulk_submissions_spec.rb index bec0978fe8..cbcfa205ca 100644 --- a/spec/features/submissions/bulk_submissions_spec.rb +++ b/spec/features/submissions/bulk_submissions_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe 'Bulk submission', js: false do - let(:user) { create :admin, login: 'user' } - let(:study) { create :study, name: 'abc123_study' } + let(:user) { create(:admin, login: 'user') } + let(:study) { create(:study, name: 'abc123_study') } def process_submission(filename, encoding = nil) attach_file('bulk_submission_spreadsheet', Rails.root.join('features', 'submission', 'csv', filename)) @@ -14,11 +14,11 @@ def process_submission(filename, encoding = nil) before do login_user user - create :project, name: 'Test project' - create :asset_group, name: 'assetgroup123', study:, asset_count: 2 + create(:project, name: 'Test project') + create(:asset_group, name: 'assetgroup123', study:, asset_count: 2) visit bulk_submissions_path expect(page).to have_content('Bulk Submission New') - create :library_type, name: 'Standard' + create(:library_type, name: 'Standard') end shared_examples 'bulk submission file upload' do @@ -29,8 +29,8 @@ def process_submission(filename, encoding = nil) end end - let(:library_request_type) { create :library_request_type } - let(:sequencing_request_type) { create :sequencing_request_type, read_lengths: [100], default: 100 } + let(:library_request_type) { create(:library_request_type) } + let(:sequencing_request_type) { create(:sequencing_request_type, read_lengths: [100], default: 100) } let(:submission_template_hash) do { diff --git a/spec/features/tag_group_spec.rb b/spec/features/tag_group_spec.rb index a2bb3e6a2a..3065d7cafa 100644 --- a/spec/features/tag_group_spec.rb +++ b/spec/features/tag_group_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' describe 'Create a new tag group' do - let(:user) { create :admin } + let(:user) { create(:admin) } - before { create :adapter_type, name: 'My type' } + before { create(:adapter_type, name: 'My type') } it 'view tag groups and create a new valid one' do login_user user diff --git a/spec/features/tag_layout_template_spec.rb b/spec/features/tag_layout_template_spec.rb index 923ab8c783..2219bfcb9e 100644 --- a/spec/features/tag_layout_template_spec.rb +++ b/spec/features/tag_layout_template_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Create a new tag layout template' do - let(:user) { create :admin } + let(:user) { create(:admin) } let(:tag_group_1) { create(:tag_group_with_tags, name: 'Test tag group 1') } let(:tag_group_2) { create(:tag_group_with_tags, name: 'Test tag group 2') } let(:tag_set_1) { create(:tag_set, name: 'Test tag set 1') } diff --git a/spec/features/tag_set_spec.rb b/spec/features/tag_set_spec.rb index aeb7d903db..4d838f6952 100644 --- a/spec/features/tag_set_spec.rb +++ b/spec/features/tag_set_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' describe 'Create a new tag set' do - let(:user) { create :admin } - let(:adapter_type) { create :adapter_type } - let(:tag_group) { create :tag_group, name: 'test-group-1', adapter_type: } - let(:tag2_group) { create :tag_group, name: 'test-group-2', adapter_type: } + let(:user) { create(:admin) } + let(:adapter_type) { create(:adapter_type) } + let(:tag_group) { create(:tag_group, name: 'test-group-1', adapter_type:) } + let(:tag2_group) { create(:tag_group, name: 'test-group-2', adapter_type:) } before do tag_group diff --git a/spec/helpers/assets_helper_spec.rb b/spec/helpers/assets_helper_spec.rb index bda85472a0..eca5ec8d53 100644 --- a/spec/helpers/assets_helper_spec.rb +++ b/spec/helpers/assets_helper_spec.rb @@ -14,37 +14,37 @@ subject { helper.current_user_can_request_additional_sequencing_on?(asset) } context 'an admin user' do - let(:user) { create :admin } + let(:user) { create(:admin) } context 'with a SampleTube' do - let(:asset) { create :sample_tube } + let(:asset) { create(:sample_tube) } it { is_expected.to be false } end context 'with a LibraryTube' do - let(:asset) { create :library_tube } + let(:asset) { create(:library_tube) } it { is_expected.to be true } end context 'with a MultiplexedTube' do - let(:asset) { create :multiplexed_library_tube } + let(:asset) { create(:multiplexed_library_tube) } it { is_expected.to be true } end end context 'a manager' do - let(:user) { create :manager } - let(:asset) { create :library_tube } + let(:user) { create(:manager) } + let(:asset) { create(:library_tube) } it { is_expected.to be true } end context 'a regular user' do - let(:user) { create :user } - let(:asset) { create :library_tube } + let(:user) { create(:user) } + let(:asset) { create(:library_tube) } it { is_expected.to be false } end @@ -54,30 +54,30 @@ subject { helper.current_user_can_request_additional_library_on?(asset) } context 'an admin user' do - let(:user) { create :admin } + let(:user) { create(:admin) } context 'with a SampleTube' do - let(:asset) { create :sample_tube } + let(:asset) { create(:sample_tube) } it { is_expected.to be true } end context 'with a LibraryTube' do - let(:asset) { create :library_tube } + let(:asset) { create(:library_tube) } it { is_expected.to be false } end context 'with a MultiplexedTube' do - let(:asset) { create :multiplexed_library_tube } + let(:asset) { create(:multiplexed_library_tube) } it { is_expected.to be false } end end context 'with a manager' do - let(:user) { create :manager } - let(:asset) { create :sample_tube } + let(:user) { create(:manager) } + let(:asset) { create(:sample_tube) } # NOTE: This behaviour changes with the permissions update to be consistent # with sequencing. @@ -86,8 +86,8 @@ end context 'with a regular user' do - let(:user) { create :user } - let(:asset) { create :sample_tube } + let(:user) { create(:user) } + let(:asset) { create(:sample_tube) } it { is_expected.to be false } end diff --git a/spec/helpers/batches_helper_spec.rb b/spec/helpers/batches_helper_spec.rb index 83d3fa9772..942b322e5f 100644 --- a/spec/helpers/batches_helper_spec.rb +++ b/spec/helpers/batches_helper_spec.rb @@ -8,7 +8,7 @@ subject { subject { helper.each_action(batch) } } context 'with a pending batch' do - let(:batch) { build :batch, state: 'pending' } + let(:batch) { build(:batch, state: 'pending') } let(:fail_link) do [ 'Fail batch or requests', @@ -24,7 +24,7 @@ end context 'with a release batch' do - let(:batch) { build_stubbed :batch, state: 'released' } + let(:batch) { build_stubbed(:batch, state: 'released') } let(:fail_link) { ['Fail batch or requests', { action: :fail, id: batch.id }, true, nil] } it 'yields an active fail link' do @@ -37,7 +37,7 @@ def stage_link(id) { action: :stage, batch_id: nil, controller: :workflows, id:, workflow_id: pipeline.workflow.id } end let(:pipeline) { create(:sequencing_pipeline, :with_workflow) } - let(:batch) { build :batch, state: 'pending', pipeline: } + let(:batch) { build(:batch, state: 'pending', pipeline:) } let(:task1) { ['Specify Dilution Volume', stage_link(0), true, nil] } let(:task2) { ['Add Spiked in control', stage_link(1), true, nil] } diff --git a/spec/helpers/deprecation_helper_spec.rb b/spec/helpers/deprecation_helper_spec.rb index 126a58b003..66eaab1a45 100644 --- a/spec/helpers/deprecation_helper_spec.rb +++ b/spec/helpers/deprecation_helper_spec.rb @@ -57,7 +57,7 @@ let(:expected_title) { 'Scheduled for removal in 2 days' } let(:expected_style) { 'danger' } - it { is_expected.not_to have_content('Deprecated content') } + it { is_expected.to have_no_content('Deprecated content') } end end end diff --git a/spec/heron/factories/concerns/contents_spec.rb b/spec/heron/factories/concerns/contents_spec.rb index 463ad16883..3eba7fd0fc 100644 --- a/spec/heron/factories/concerns/contents_spec.rb +++ b/spec/heron/factories/concerns/contents_spec.rb @@ -29,7 +29,7 @@ def recipients_key end end let(:factory) { factory_klass.new(params) } - let(:study) { create :study } + let(:study) { create(:study) } include BarcodeHelper diff --git a/spec/heron/factories/concerns/eventful_spec.rb b/spec/heron/factories/concerns/eventful_spec.rb index 2321d53f9b..8c9b4372bb 100644 --- a/spec/heron/factories/concerns/eventful_spec.rb +++ b/spec/heron/factories/concerns/eventful_spec.rb @@ -12,7 +12,7 @@ def initialize(params) end end - let(:plate) { create :plate } + let(:plate) { create(:plate) } let(:subjects) do [ build( diff --git a/spec/heron/factories/event_spec.rb b/spec/heron/factories/event_spec.rb index bae7e00a75..36b9737714 100644 --- a/spec/heron/factories/event_spec.rb +++ b/spec/heron/factories/event_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Heron::Factories::Event, :heron, :heron_events, type: :model do - let(:plate) { create :plate } + let(:plate) { create(:plate) } let(:subjects) do [ build( diff --git a/spec/heron/factories/plate_from_rack_spec.rb b/spec/heron/factories/plate_from_rack_spec.rb index 8205c5ddd1..fc6a0f00b1 100644 --- a/spec/heron/factories/plate_from_rack_spec.rb +++ b/spec/heron/factories/plate_from_rack_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Heron::Factories::PlateFromRack, :heron, type: :model do let(:purpose) { create(:plate_purpose, target_type: 'Plate', name: 'Stock Plate', size: '96') } - let(:rack) { create :tube_rack } + let(:rack) { create(:tube_rack) } let(:plate_factory) { described_class.new(tube_rack: rack, plate_purpose: purpose) } let(:tubes) { create_list(:sample_tube, 2) } diff --git a/spec/heron/factories/sample_spec.rb b/spec/heron/factories/sample_spec.rb index 58f8852afd..bd087c5cb8 100644 --- a/spec/heron/factories/sample_spec.rb +++ b/spec/heron/factories/sample_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Heron::Factories::Sample, :heron, :lighthouse, type: :model do - let(:study) { create :study } + let(:study) { create(:study) } describe '#valid?' do context 'when receiving a study instance' do @@ -80,7 +80,7 @@ describe '#create_aliquot_at' do context 'when the factory is valid' do - let(:well) { create :well } + let(:well) { create(:well) } let(:tag_id) { 1 } let(:factory) { described_class.new(study:, aliquot: { tag_id: }) } @@ -228,7 +228,7 @@ end context 'when the uuid already exist' do - let(:sample) { create :sample } + let(:sample) { create(:sample) } it 'will be invalid if providing any other extra attributes' do factory = described_class.new(study:, uuid: sample.uuid) diff --git a/spec/insdc/import_countries_spec.rb b/spec/insdc/import_countries_spec.rb index 9c2209dd6a..628e5585bb 100644 --- a/spec/insdc/import_countries_spec.rb +++ b/spec/insdc/import_countries_spec.rb @@ -131,8 +131,8 @@ context 'when the file is present' do before do - create :insdc_country, name: 'Historic Coldland' - create :insdc_country, name: 'East Westland' + create(:insdc_country, name: 'Historic Coldland') + create(:insdc_country, name: 'East Westland') allow(File).to receive(:exist?).with(cached_file_path).and_return(true) allow(File).to receive(:open).with(cached_file_path).and_yield(mock_response) importer.import diff --git a/spec/jobs/export_pool_xp_to_traction_job_spec.rb b/spec/jobs/export_pool_xp_to_traction_job_spec.rb index 9eccdbb724..9ad95905d9 100644 --- a/spec/jobs/export_pool_xp_to_traction_job_spec.rb +++ b/spec/jobs/export_pool_xp_to_traction_job_spec.rb @@ -2,7 +2,7 @@ RSpec.describe ExportPoolXpToTractionJob, type: :job do let(:export_job) { described_class.new(tube.human_barcode) } - let(:tube) { create :multiplexed_library_tube, sample_count: 3 } + let(:tube) { create(:multiplexed_library_tube, sample_count: 3) } let(:schema_subject) { configatron.amqp.schemas.subjects[:export_pool_xp_to_traction][:subject] } let(:schema_version) { configatron.amqp.schemas.subjects[:export_pool_xp_to_traction][:version] } @@ -51,10 +51,10 @@ end describe '#get_message_data' do - let(:project) { create :project } + let(:project) { create(:project) } let(:actual_message) { export_job.get_message_data(tube.human_barcode) } - let(:study) { create :study } - let(:compound_sample) { create :sample } + let(:study) { create(:study) } + let(:compound_sample) { create(:sample) } before do allow(tube).to receive_messages(projects: [project], studies: [study]) diff --git a/spec/lib/accession/sample_spec.rb b/spec/lib/accession/sample_spec.rb index 61ebe3bf0e..8db1847c72 100644 --- a/spec/lib/accession/sample_spec.rb +++ b/spec/lib/accession/sample_spec.rb @@ -18,7 +18,7 @@ def find_value_at_tag(xml_received, tag_name) RSpec.describe Accession::Sample, :accession, type: :model do let(:tag_list) { build(:standard_accession_tag_list) } - before { @country = create :insdc_country, name: 'Australia' } + before { @country = create(:insdc_country, name: 'Australia') } it 'is not sent for accessioning if the sample has already been accessioned' do sample = diff --git a/spec/lib/label_printer/asset_labels_spec.rb b/spec/lib/label_printer/asset_labels_spec.rb index 6e62bdec47..b19cea5239 100644 --- a/spec/lib/label_printer/asset_labels_spec.rb +++ b/spec/lib/label_printer/asset_labels_spec.rb @@ -19,9 +19,9 @@ end context 'printing plates' do - let(:asset1) { create :child_plate, name: 'Plate Name' } - let(:asset2) { create :child_plate, name: 'Plate Name' } - let(:asset3) { create :child_plate } + let(:asset1) { create(:child_plate, name: 'Plate Name') } + let(:asset2) { create(:child_plate, name: 'Plate Name') } + let(:asset3) { create(:child_plate) } let(:assets) { [asset1, asset2, asset3] } describe LabelPrinter::Label::AssetPlate do @@ -65,8 +65,8 @@ context 'printing tubes' do describe LabelPrinter::Label::AssetTube do - let(:asset1) { create :empty_sample_tube, barcode: '11111', name: 'Tube Name' } - let(:asset2) { create :empty_sample_tube } + let(:asset1) { create(:empty_sample_tube, barcode: '11111', name: 'Tube Name') } + let(:asset2) { create(:empty_sample_tube) } let(:assets) { [asset1, asset2] } let(:body) do diff --git a/spec/lib/label_printer/asset_redirect_spec.rb b/spec/lib/label_printer/asset_redirect_spec.rb index 32989723a7..26374c5402 100644 --- a/spec/lib/label_printer/asset_redirect_spec.rb +++ b/spec/lib/label_printer/asset_redirect_spec.rb @@ -49,18 +49,18 @@ describe LabelPrinter::Label::AssetRedirect do context 'printing plates' do - let(:asset1) { create :child_plate } - let(:asset2) { create :child_plate } - let(:asset3) { create :child_plate } + let(:asset1) { create(:child_plate) } + let(:asset2) { create(:child_plate) } + let(:asset3) { create(:child_plate) } it_behaves_like 'a correct filter' it_behaves_like 'a correct plate renderer' end context 'printing tubes' do - let(:asset1) { create :empty_sample_tube } - let(:asset2) { create :empty_sample_tube } - let(:asset3) { create :empty_sample_tube } + let(:asset1) { create(:empty_sample_tube) } + let(:asset2) { create(:empty_sample_tube) } + let(:asset3) { create(:empty_sample_tube) } it_behaves_like 'a correct filter' it_behaves_like 'a correct tube renderer' diff --git a/spec/lib/label_printer/batch_plate_spec.rb b/spec/lib/label_printer/batch_plate_spec.rb index 2923e98b33..879e34731e 100644 --- a/spec/lib/label_printer/batch_plate_spec.rb +++ b/spec/lib/label_printer/batch_plate_spec.rb @@ -62,8 +62,8 @@ let(:count) { '1' } let(:date_today) { Time.zone.today.strftime('%e-%^b-%Y') } - let(:batch) { create :batch } - let(:study) { create :study } + let(:batch) { create(:batch) } + let(:study) { create(:study) } let(:request1) do order = create(:order, order_role: OrderRole.new(role: 'test_role'), study:, assets: [create(:empty_sample_tube)]) create( diff --git a/spec/lib/label_printer/sample_manifest_plate_double_spec.rb b/spec/lib/label_printer/sample_manifest_plate_double_spec.rb index 7f7f81f5d3..618e92e1be 100644 --- a/spec/lib/label_printer/sample_manifest_plate_double_spec.rb +++ b/spec/lib/label_printer/sample_manifest_plate_double_spec.rb @@ -5,7 +5,7 @@ describe LabelPrinter::Label::SampleManifestPlateDouble, :sample_manifest do subject { described_class.new(label_options) } - let(:sample_manifest) { create :pending_plate_sample_manifest } + let(:sample_manifest) { create(:pending_plate_sample_manifest) } let(:label_options) { { sample_manifest:, only_first_label: } } let(:sample_manifest_plates) { sample_manifest.printables } diff --git a/spec/lib/record_loader/pipeline_request_information_type_loader_spec.rb b/spec/lib/record_loader/pipeline_request_information_type_loader_spec.rb index a8e851a2b2..c40f32bae5 100644 --- a/spec/lib/record_loader/pipeline_request_information_type_loader_spec.rb +++ b/spec/lib/record_loader/pipeline_request_information_type_loader_spec.rb @@ -11,9 +11,9 @@ let(:test_directory) { Rails.root.join('spec/data/record_loader/pipeline_request_information_types') } before do - create :pipeline, name: 'Pipeline 1' - create :request_information_type, key: 'key' - create :request_information_type, key: 'key2' + create(:pipeline, name: 'Pipeline 1') + create(:request_information_type, key: 'key') + create(:request_information_type, key: 'key2') end context 'with two_entry_example selected' do diff --git a/spec/lib/record_loader/plate_purpose_loader_spec.rb b/spec/lib/record_loader/plate_purpose_loader_spec.rb index 5ae1e72eab..c79a889372 100644 --- a/spec/lib/record_loader/plate_purpose_loader_spec.rb +++ b/spec/lib/record_loader/plate_purpose_loader_spec.rb @@ -32,7 +32,7 @@ def a_new_record_loader context 'with a pre-existing plate' do before do - create :plate_purpose, name: created_purposes.first + create(:plate_purpose, name: created_purposes.first) subject.create! # rubocop:todo RSpec/NamedSubject end diff --git a/spec/lib/record_loader/request_type_loader_spec.rb b/spec/lib/record_loader/request_type_loader_spec.rb index 9b543e84df..87378852cf 100644 --- a/spec/lib/record_loader/request_type_loader_spec.rb +++ b/spec/lib/record_loader/request_type_loader_spec.rb @@ -12,8 +12,8 @@ def a_new_record_loader(files = selected_files) subject(:record_loader) { a_new_record_loader } before do - create :plate_purpose, name: 'Example purpose' - create :library_type, name: 'Standard' + create(:plate_purpose, name: 'Example purpose') + create(:library_type, name: 'Standard') end # Tests use a separate directory to avoid coupling your specs to the data @@ -69,7 +69,7 @@ def a_new_record_loader(files = selected_files) let(:selected_files) { 'request_types_updated' } before do - create :plate_purpose, name: 'Example purpose 2' + create(:plate_purpose, name: 'Example purpose 2') a_new_record_loader('request_types_basic').create! record_loader.create! end diff --git a/spec/lib/record_loader/robot_property_loader_spec.rb b/spec/lib/record_loader/robot_property_loader_spec.rb index 97f87216b8..d3dcbce4a9 100644 --- a/spec/lib/record_loader/robot_property_loader_spec.rb +++ b/spec/lib/record_loader/robot_property_loader_spec.rb @@ -18,8 +18,8 @@ def a_new_record_loader let(:selected_files) { 'robot_properties_example' } before do - create :robot, name: 'Robot 1' - create :robot, name: 'Robot 2' + create(:robot, name: 'Robot 1') + create(:robot, name: 'Robot 2') end it 'creates seven records' do diff --git a/spec/lib/record_loader/tag_group_loader_spec.rb b/spec/lib/record_loader/tag_group_loader_spec.rb index 26428c2b54..93f033ccd1 100644 --- a/spec/lib/record_loader/tag_group_loader_spec.rb +++ b/spec/lib/record_loader/tag_group_loader_spec.rb @@ -11,7 +11,7 @@ def a_new_record_loader subject(:record_loader) { a_new_record_loader } - before { create :adapter_type, name: 'Sanger 168' } + before { create(:adapter_type, name: 'Sanger 168') } # Tests use a separate directory to avoid coupling your specs to the data let(:test_directory) { Rails.root.join('spec/data/record_loader/tag_groups') } diff --git a/spec/lib/record_loader/tag_layout_templates_loader_spec.rb b/spec/lib/record_loader/tag_layout_templates_loader_spec.rb index 0531d49e01..2ed064cfa6 100644 --- a/spec/lib/record_loader/tag_layout_templates_loader_spec.rb +++ b/spec/lib/record_loader/tag_layout_templates_loader_spec.rb @@ -20,8 +20,8 @@ def a_new_record_loader { name: 'Tag Layout 1', tag_group:, tag2_group:, direction: 'column', walking_by: 'wells of plate' } end - let!(:tag_group) { create :tag_group, name: 'group 1' } - let!(:tag2_group) { create :tag_group, name: 'group 2' } + let!(:tag_group) { create(:tag_group, name: 'group 1') } + let!(:tag2_group) { create(:tag_group, name: 'group 2') } it 'creates two records' do expect { record_loader.create! }.to change(TagLayoutTemplate, :count).by(2) diff --git a/spec/mailers/user_query_mailer_spec.rb b/spec/mailers/user_query_mailer_spec.rb index 7723450765..61a4889995 100644 --- a/spec/mailers/user_query_mailer_spec.rb +++ b/spec/mailers/user_query_mailer_spec.rb @@ -12,7 +12,7 @@ after { Timecop.return } describe 'request for help' do - let!(:user_query) { build :user_query } + let!(:user_query) { build(:user_query) } let(:mail) { described_class.request_for_help(user_query) } let(:expected_body) { <<~HEREDOC } diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 6aa59c748b..2f280b723c 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -137,7 +137,7 @@ def merge_permissions(*permissions) end context 'when there is a basic user' do - let(:user) { build :user } + let(:user) { build(:user) } let(:granted_permissions) { basic_permissions } @@ -145,7 +145,7 @@ def merge_permissions(*permissions) end context 'when the user has the role "administrator"' do - let(:user) { build :user, :with_role, role_name: 'administrator' } + let(:user) { build(:user, :with_role, role_name: 'administrator') } let(:granted_permissions) do merge_permissions( @@ -207,7 +207,7 @@ def merge_permissions(*permissions) end context 'when the user has the role "data_access_coordinator"' do - let(:user) { build :user, :with_role, role_name: 'data_access_coordinator' } + let(:user) { build(:user, :with_role, role_name: 'data_access_coordinator') } let(:granted_permissions) { merge_permissions(basic_permissions, { Study => %i[change_ethically_approved] }) } @@ -215,18 +215,18 @@ def merge_permissions(*permissions) end context 'when the user has the role "follower"' do - let(:user) { build :user, :with_role, role_name: 'follower' } + let(:user) { build(:user, :with_role, role_name: 'follower') } let(:granted_permissions) { basic_permissions } it_behaves_like 'it grants only granted_permissions' context 'with specific studies and projects' do - let(:user) { create :user, :with_role, role_name: 'follower' } - let(:authorized_project) { create :project, :with_follower, follower: user } - let(:unauthorized_project) { create :project } - let(:authorized_study) { create :study, :with_follower, follower: user } - let(:unauthorized_study) { create :study } + let(:user) { create(:user, :with_role, role_name: 'follower') } + let(:authorized_project) { create(:project, :with_follower, follower: user) } + let(:unauthorized_project) { create(:project) } + let(:authorized_study) { create(:study, :with_follower, follower: user) } + let(:unauthorized_study) { create(:study) } # Project it { is_expected.not_to be_able_to(:administer, authorized_project) } @@ -267,7 +267,7 @@ def merge_permissions(*permissions) end context 'when the user has the role "lab"' do - let(:user) { build :user, :with_role, role_name: 'lab' } + let(:user) { build(:user, :with_role, role_name: 'lab') } let(:granted_permissions) { basic_permissions } @@ -275,7 +275,7 @@ def merge_permissions(*permissions) end context 'when the user has the role "lab_manager"' do - let(:user) { build :user, :with_role, role_name: 'lab_manager' } + let(:user) { build(:user, :with_role, role_name: 'lab_manager') } let(:granted_permissions) do merge_permissions( @@ -294,7 +294,7 @@ def merge_permissions(*permissions) end context 'when the user has the role "manager"' do - let(:user) { build :user, :with_role, role_name: 'manager' } + let(:user) { build(:user, :with_role, role_name: 'manager') } let(:granted_permissions) do merge_permissions( @@ -318,11 +318,11 @@ def merge_permissions(*permissions) it_behaves_like 'it grants only granted_permissions' context 'with specific studies and projects' do - let(:user) { create :user, :with_role, role_name: 'manager' } - let(:authorized_project) { create :project, :with_manager, manager: user } - let(:unauthorized_project) { create :project } - let(:authorized_study) { create :study, :with_manager, manager: user } - let(:unauthorized_study) { create :study } + let(:user) { create(:user, :with_role, role_name: 'manager') } + let(:authorized_project) { create(:project, :with_manager, manager: user) } + let(:unauthorized_project) { create(:project) } + let(:authorized_study) { create(:study, :with_manager, manager: user) } + let(:unauthorized_study) { create(:study) } # Project it { is_expected.not_to be_able_to(:administer, authorized_project) } @@ -363,20 +363,20 @@ def merge_permissions(*permissions) end context 'when the user has the role "owner"' do - let(:user) { build :user, :with_role, role_name: 'owner' } + let(:user) { build(:user, :with_role, role_name: 'owner') } let(:granted_permissions) { basic_permissions } it_behaves_like 'it grants only granted_permissions' context 'with specific studies and projects' do - let(:user) { create :user, :with_role, role_name: 'owner' } - let(:authorized_project) { create :project, :with_owner, owner: user } - let(:unauthorized_project) { create :project } - let(:authorized_sample) { create :sample, :with_owner, owner: user } - let(:unauthorized_sample) { create :sample } - let(:authorized_study) { create :study, :with_owner, owner: user } - let(:unauthorized_study) { create :study } + let(:user) { create(:user, :with_role, role_name: 'owner') } + let(:authorized_project) { create(:project, :with_owner, owner: user) } + let(:unauthorized_project) { create(:project) } + let(:authorized_sample) { create(:sample, :with_owner, owner: user) } + let(:unauthorized_sample) { create(:sample) } + let(:authorized_study) { create(:study, :with_owner, owner: user) } + let(:unauthorized_study) { create(:study) } # Project it { is_expected.not_to be_able_to(:administer, authorized_project) } @@ -427,7 +427,7 @@ def merge_permissions(*permissions) end context 'when the user has the role "qa_manager"' do - let(:user) { build :user, :with_role, role_name: 'qa_manager' } + let(:user) { build(:user, :with_role, role_name: 'qa_manager') } let(:granted_permissions) { merge_permissions(basic_permissions, { QcDecision => %i[create new] }) } @@ -435,7 +435,7 @@ def merge_permissions(*permissions) end context 'when the user has the role "slf_gel"' do - let(:user) { build :user, :with_role, role_name: 'slf_gel' } + let(:user) { build(:user, :with_role, role_name: 'slf_gel') } let(:granted_permissions) do merge_permissions( @@ -448,7 +448,7 @@ def merge_permissions(*permissions) end context 'when the user has the role "slf_manager"' do - let(:user) { build :user, :with_role, role_name: 'slf_manager' } + let(:user) { build(:user, :with_role, role_name: 'slf_manager') } let(:granted_permissions) do merge_permissions( diff --git a/spec/models/aliquot_spec.rb b/spec/models/aliquot_spec.rb index ce932aea10..903de59b55 100644 --- a/spec/models/aliquot_spec.rb +++ b/spec/models/aliquot_spec.rb @@ -3,64 +3,64 @@ require 'rails_helper' RSpec.describe Aliquot do - let(:tag1) { create :tag } - let(:tag2) { create :tag } - let(:sample1) { create :sample } - let(:sample2) { create :sample } + let(:tag1) { create(:tag) } + let(:tag2) { create(:tag) } + let(:sample1) { create(:sample) } + let(:sample2) { create(:sample) } shared_context 'a tag matcher' do context 'with the same tags' do - let(:aliquot1) { build :aliquot, tag: tag1, tag2: tag1, sample: sample1 } - let(:aliquot2) { build :aliquot, tag: tag1, tag2: tag1, sample: sample1 } + let(:aliquot1) { build(:aliquot, tag: tag1, tag2: tag1, sample: sample1) } + let(:aliquot2) { build(:aliquot, tag: tag1, tag2: tag1, sample: sample1) } it { is_expected.to be true } end context 'with different tags' do - let(:aliquot1) { build :aliquot, tag: tag1, tag2: tag1, sample: sample1 } - let(:aliquot2) { build :aliquot, tag: tag2, tag2: tag1, sample: sample1 } + let(:aliquot1) { build(:aliquot, tag: tag1, tag2: tag1, sample: sample1) } + let(:aliquot2) { build(:aliquot, tag: tag2, tag2: tag1, sample: sample1) } it { is_expected.to be false } end context 'with different tag 2' do - let(:aliquot1) { build :aliquot, tag: tag1, tag2: tag1, sample: sample1 } - let(:aliquot2) { build :aliquot, tag: tag1, tag2:, sample: sample1 } + let(:aliquot1) { build(:aliquot, tag: tag1, tag2: tag1, sample: sample1) } + let(:aliquot2) { build(:aliquot, tag: tag1, tag2:, sample: sample1) } it { is_expected.to be false } end context 'with missing tags' do - let(:aliquot1) { build :aliquot, tag: tag1, tag2_id: -1, sample: sample1 } - let(:aliquot2) { build :aliquot, tag: nil, tag2_id: -1, sample: sample1 } + let(:aliquot1) { build(:aliquot, tag: tag1, tag2_id: -1, sample: sample1) } + let(:aliquot2) { build(:aliquot, tag: nil, tag2_id: -1, sample: sample1) } it { is_expected.to be true } end context 'with missing tag 2' do - let(:aliquot1) { build :aliquot, tag: nil, tag2: tag1, sample: sample1 } - let(:aliquot2) { build :aliquot, tag: nil, tag2_id: -1, sample: sample1 } + let(:aliquot1) { build(:aliquot, tag: nil, tag2: tag1, sample: sample1) } + let(:aliquot2) { build(:aliquot, tag: nil, tag2_id: -1, sample: sample1) } it { is_expected.to be true } end context 'with missing tags but present tag 2s' do - let(:aliquot1) { build :aliquot, tag: tag1, tag2: tag1, sample: sample1 } - let(:aliquot2) { build :aliquot, tag: nil, tag2: tag1, sample: sample1 } + let(:aliquot1) { build(:aliquot, tag: tag1, tag2: tag1, sample: sample1) } + let(:aliquot2) { build(:aliquot, tag: nil, tag2: tag1, sample: sample1) } it { is_expected.to be true } end context 'with missing tag 2s but present tags' do - let(:aliquot1) { build :aliquot, tag: tag1, tag2: tag1, sample: sample1 } - let(:aliquot2) { build :aliquot, tag: tag1, tag2_id: -1, sample: sample1 } + let(:aliquot1) { build(:aliquot, tag: tag1, tag2: tag1, sample: sample1) } + let(:aliquot2) { build(:aliquot, tag: tag1, tag2_id: -1, sample: sample1) } it { is_expected.to be true } end context 'with different samples' do - let(:aliquot1) { build :aliquot, tag: tag1, tag2: tag1, sample: sample1 } - let(:aliquot2) { build :aliquot, tag: tag1, tag2: tag1, sample: sample2 } + let(:aliquot1) { build(:aliquot, tag: tag1, tag2: tag1, sample: sample1) } + let(:aliquot2) { build(:aliquot, tag: tag1, tag2: tag1, sample: sample2) } it { is_expected.to be false } end @@ -74,7 +74,7 @@ end context 'mixing tests' do - let(:asset) { create :empty_well } + let(:asset) { create(:empty_well) } it 'allows mixing different tags with no tag2' do asset.aliquots << build(:aliquot, tag: tag1, sample: sample1) << build(:aliquot, tag: tag2, sample: sample2) @@ -95,9 +95,9 @@ end describe '#set_library' do - subject { build :aliquot, receptacle:, library_id: initial_library_id } + subject { build(:aliquot, receptacle:, library_id: initial_library_id) } - let(:receptacle) { create :empty_well } + let(:receptacle) { create(:empty_well) } before { subject.set_library(force:) } @@ -131,7 +131,7 @@ describe 'for tags substitution' do it 'generates correct substitution hash' do - aliquot = create :aliquot + aliquot = create(:aliquot) tag_id = aliquot.tag_id expect(aliquot.substitution_hash).to be_nil aliquot.update!(tag_id: 42, insert_size_from: 5, insert_size_to: 15) @@ -152,7 +152,7 @@ aliquots.first.update!(project: nil) aliquots.second.project.project_metadata.update!(project_cost_code: 'new_cost_code') default_project_cost_code = aliquots.last.project.project_metadata.project_cost_code - receptacle = create :empty_well + receptacle = create(:empty_well) receptacle.aliquots << aliquots expect(receptacle.aliquots.count_by_project_cost_code).to eq( 'new_cost_code' => 1, diff --git a/spec/models/api/aliquot_io_spec.rb b/spec/models/api/aliquot_io_spec.rb index e66d35aee0..dcfa580544 100644 --- a/spec/models/api/aliquot_io_spec.rb +++ b/spec/models/api/aliquot_io_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Api::AliquotIO do subject do - create :aliquot, + create(:aliquot, receptacle: well, sample:, study:, @@ -13,15 +13,15 @@ tag:, insert_size_from: 100, insert_size_to: 200, - bait_library: + bait_library:) end - let(:well) { create :empty_well } - let(:sample) { create :sample } - let(:study) { create :study } - let(:project) { create :project } - let(:tag) { create :tag } - let(:bait_library) { create :bait_library } + let(:well) { create(:empty_well) } + let(:sample) { create(:sample) } + let(:study) { create(:study) } + let(:project) { create(:project) } + let(:tag) { create(:tag) } + let(:bait_library) { create(:bait_library) } let(:expected_json) do { @@ -55,7 +55,7 @@ it_behaves_like('an IO object') context 'with minimal data' do - subject { create :minimal_aliquot } + subject { create(:minimal_aliquot) } let(:expected_json) do { diff --git a/spec/models/api/asset_link_io_spec.rb b/spec/models/api/asset_link_io_spec.rb index cf051928ed..b93a944ebc 100644 --- a/spec/models/api/asset_link_io_spec.rb +++ b/spec/models/api/asset_link_io_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' RSpec.describe Api::AssetLinkIO do - subject { create :asset_link, ancestor:, descendant: } + subject { create(:asset_link, ancestor:, descendant:) } - let(:ancestor) { create :sample_tube } - let(:descendant) { create :multiplexed_library_tube } + let(:ancestor) { create(:sample_tube) } + let(:descendant) { create(:multiplexed_library_tube) } let(:expected_json) do { diff --git a/spec/models/api/batch_io_spec.rb b/spec/models/api/batch_io_spec.rb index 9ea6ce01dd..21aa02c591 100644 --- a/spec/models/api/batch_io_spec.rb +++ b/spec/models/api/batch_io_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' RSpec.describe Api::BatchIO do - subject { create :batch, user:, assignee: user2, pipeline: } + subject { create(:batch, user:, assignee: user2, pipeline:) } - let(:user) { create :user } - let(:user2) { create :user } - let(:pipeline) { create :pipeline } + let(:user) { create(:user) } + let(:user2) { create(:user) } + let(:pipeline) { create(:pipeline) } let(:expected_json) do { diff --git a/spec/models/api/batch_request_io_spec.rb b/spec/models/api/batch_request_io_spec.rb index 45e960d7f3..ba7cde0c48 100644 --- a/spec/models/api/batch_request_io_spec.rb +++ b/spec/models/api/batch_request_io_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' RSpec.describe Api::BatchRequestIO do - subject { create :batch_request, request: } + subject { create(:batch_request, request:) } - let(:request) { create :request } + let(:request) { create(:request) } let(:expected_json) do { diff --git a/spec/models/api/lane_io_spec.rb b/spec/models/api/lane_io_spec.rb index 775652514c..67770da453 100644 --- a/spec/models/api/lane_io_spec.rb +++ b/spec/models/api/lane_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::LaneIO do - subject { create :lane } + subject { create(:lane) } let(:expected_json) do { diff --git a/spec/models/api/library_tube_io_spec.rb b/spec/models/api/library_tube_io_spec.rb index f1a5da8609..2efe2fd649 100644 --- a/spec/models/api/library_tube_io_spec.rb +++ b/spec/models/api/library_tube_io_spec.rb @@ -3,13 +3,14 @@ require 'rails_helper' RSpec.describe Api::LibraryTubeIO do - subject { create :empty_library_tube, public_name: 'ABC', closed: false, aliquots:, volume: 12.0, concentration: 8.0 } + subject do + create(:empty_library_tube, public_name: 'ABC', closed: false, aliquots:, volume: 12.0, concentration: 8.0) end - let(:sample) { create :sample } - let(:tag) { create :tag } + let(:sample) { create(:sample) } + let(:tag) { create(:tag) } let(:aliquots) { [create(:aliquot, sample:, tag:, library_type: 'Standard')] } - let!(:library_request) { create :library_creation_request, target_asset: subject } + let!(:library_request) { create(:library_creation_request, target_asset: subject) } let(:expected_json) do { diff --git a/spec/models/api/messages/flowcell_io_spec.rb b/spec/models/api/messages/flowcell_io_spec.rb index 3932022cdd..1c6bba3bb7 100644 --- a/spec/models/api/messages/flowcell_io_spec.rb +++ b/spec/models/api/messages/flowcell_io_spec.rb @@ -6,20 +6,20 @@ subject { described_class.to_hash(sequencing_batch.reload) } context 'with a batch' do - let(:sequencing_pipeline) { create :sequencing_pipeline } + let(:sequencing_pipeline) { create(:sequencing_pipeline) } - let(:sequencing_batch) { create :sequencing_batch, pipeline: sequencing_pipeline } + let(:sequencing_batch) { create(:sequencing_batch, pipeline: sequencing_pipeline) } let!(:request_1) do - create :complete_sequencing_request, + create(:complete_sequencing_request, asset: mx_tube1, batch: sequencing_batch, target_asset: lane1, request_type:, - event_descriptors: request_data + event_descriptors: request_data) end - let(:mx_tube1) { create :multiplexed_library_tube, sample_count: 1 } + let(:mx_tube1) { create(:multiplexed_library_tube, sample_count: 1) } let(:request_type) { sequencing_pipeline.request_types.first } @@ -32,7 +32,7 @@ end end - let(:phix) { create :spiked_buffer, :tube_barcode, tag_option: 'Dual' } + let(:phix) { create(:spiked_buffer, :tube_barcode, tag_option: 'Dual') } let(:tags) { lane1.aliquots.map(&:tag) } let(:tag2s) { lane1.aliquots.map(&:tag2) } @@ -50,7 +50,7 @@ context 'with updated events' do before do - create :lab_event, + create(:lab_event, eventful: request_1, batch: request_1.batch, descriptors: { @@ -58,7 +58,7 @@ 'PhiX %' => '1', 'Workflow (Standard or Xp)' => 'xp', 'Lane loading concentration (pM)' => '30' - } + }) end let(:request_data) do @@ -306,7 +306,7 @@ end context 'when there are multiple SpikedBuffer ancestors' do - let(:phix) { create :spiked_buffer_with_parent, :tube_barcode } + let(:phix) { create(:spiked_buffer_with_parent, :tube_barcode) } # To test whether the PhiX barcode and aliquot come from the correct ancestor, # when the lane has multiple SpikedBuffer tube ancestors diff --git a/spec/models/api/messages/pac_bio_run_io_spec.rb b/spec/models/api/messages/pac_bio_run_io_spec.rb index 030bddec3c..14da4473c3 100644 --- a/spec/models/api/messages/pac_bio_run_io_spec.rb +++ b/spec/models/api/messages/pac_bio_run_io_spec.rb @@ -7,14 +7,14 @@ let(:plate) { create(:plate_with_tagged_wells, sample_count: 2) } - let(:aliquot_1) { create :tagged_aliquot } - let(:aliquot_2) { create :untagged_aliquot } + let(:aliquot_1) { create(:tagged_aliquot) } + let(:aliquot_2) { create(:untagged_aliquot) } - let(:library_tube_1) { create :pac_bio_library_tube, aliquot: aliquot_1 } - let(:library_tube_2) { create :pac_bio_library_tube, aliquot: aliquot_2 } + let(:library_tube_1) { create(:pac_bio_library_tube, aliquot: aliquot_1) } + let(:library_tube_2) { create(:pac_bio_library_tube, aliquot: aliquot_2) } let(:pac_bio_batch) do - batch = create :pac_bio_sequencing_batch, assets: [library_tube_1, library_tube_2], target_plate: plate + batch = create(:pac_bio_sequencing_batch, assets: [library_tube_1, library_tube_2], target_plate: plate) # Historically transfer was handled by the pipeline. But now we're keeping # this for update of legacy batches only. diff --git a/spec/models/api/messages/pac_bio_run_with_tag2_io_spec.rb b/spec/models/api/messages/pac_bio_run_with_tag2_io_spec.rb index e7b758ffec..aaf23347cd 100644 --- a/spec/models/api/messages/pac_bio_run_with_tag2_io_spec.rb +++ b/spec/models/api/messages/pac_bio_run_with_tag2_io_spec.rb @@ -7,14 +7,14 @@ let(:plate) { create(:plate_with_tagged_wells, sample_count: 2) } - let(:aliquot_1) { create :tagged_aliquot } - let(:aliquot_2) { create :untagged_aliquot } + let(:aliquot_1) { create(:tagged_aliquot) } + let(:aliquot_2) { create(:untagged_aliquot) } - let(:library_tube_1) { create :pac_bio_library_tube, aliquot: aliquot_1 } - let(:library_tube_2) { create :pac_bio_library_tube, aliquot: aliquot_2 } + let(:library_tube_1) { create(:pac_bio_library_tube, aliquot: aliquot_1) } + let(:library_tube_2) { create(:pac_bio_library_tube, aliquot: aliquot_2) } let(:pac_bio_batch) do - batch = create :pac_bio_sequencing_batch, assets: [library_tube_1, library_tube_2], target_plate: plate + batch = create(:pac_bio_sequencing_batch, assets: [library_tube_1, library_tube_2], target_plate: plate) batch.reload batch end diff --git a/spec/models/api/messages/qc_result_io_spec.rb b/spec/models/api/messages/qc_result_io_spec.rb index 939dec267d..63e19b23f2 100644 --- a/spec/models/api/messages/qc_result_io_spec.rb +++ b/spec/models/api/messages/qc_result_io_spec.rb @@ -5,7 +5,7 @@ describe Api::Messages::QcResultIO do subject { described_class.to_hash(qc_result) } - let(:sample_tube) { create :sample_tube } + let(:sample_tube) { create(:sample_tube) } let(:expected_json) do { 'id_qc_result_lims' => qc_result.id, @@ -22,8 +22,8 @@ context 'the qc_result asset is a well' do let(:aliquots) { create_list(:aliquot, 1, library: sample_tube) } - let(:well) { create :well_with_sample_and_plate, aliquots: } - let(:qc_result) { create :qc_result, asset: well } + let(:well) { create(:well_with_sample_and_plate, aliquots:) } + let(:qc_result) { create(:qc_result, asset: well) } it 'generates a valid json' do actual = subject.as_json @@ -35,7 +35,7 @@ end context 'the qc_result asset is a multiplexed library tube' do - let(:qc_result) { create :qc_result, asset: sample_tube } + let(:qc_result) { create(:qc_result, asset: sample_tube) } it 'generates a valid json' do actual = subject.as_json diff --git a/spec/models/api/messages/well_stock_resource_io_spec.rb b/spec/models/api/messages/well_stock_resource_io_spec.rb index b46c752705..a423d5890c 100644 --- a/spec/models/api/messages/well_stock_resource_io_spec.rb +++ b/spec/models/api/messages/well_stock_resource_io_spec.rb @@ -10,16 +10,16 @@ after { Timecop.return } - let(:sample) { create :sample } + let(:sample) { create(:sample) } let(:plate_barcode) { build(:plate_barcode) } let(:well) do - create :well, + create(:well, map: Map.find_by!(description: 'A1', asset_shape: AssetShape.default, asset_size: 96), plate: create(:plate, barcode: plate_barcode.barcode), - well_attribute: create(:complete_well_attribute) + well_attribute: create(:complete_well_attribute)) end - let(:study) { create :study } - let(:aliquot) { create :aliquot, study:, sample:, receptacle: well } + let(:study) { create(:study) } + let(:aliquot) { create(:aliquot, study:, sample:, receptacle: well) } before { aliquot } # rubocop:todo RSpec/ScatteredSetup diff --git a/spec/models/api/multiplexed_library_tube_io_spec.rb b/spec/models/api/multiplexed_library_tube_io_spec.rb index 13c4737982..d8ac139272 100644 --- a/spec/models/api/multiplexed_library_tube_io_spec.rb +++ b/spec/models/api/multiplexed_library_tube_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::MultiplexedLibraryTubeIO do - subject { create :multiplexed_library_tube, volume: 12.0, concentration: 8.0 } + subject { create(:multiplexed_library_tube, volume: 12.0, concentration: 8.0) } let(:expected_json) do { diff --git a/spec/models/api/order_io_spec.rb b/spec/models/api/order_io_spec.rb index ad19dd1b45..dbf0d6d896 100644 --- a/spec/models/api/order_io_spec.rb +++ b/spec/models/api/order_io_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Api::OrderIO do subject do - create :order, + create(:order, user:, template_name: 'Cool template', study:, @@ -18,12 +18,12 @@ bait_library_name: 'EG', sequencing_type: 'MagBead', insert_size: 12 - } + }) end - let(:user) { create :user } - let(:study) { create :study } - let(:project) { create :project } + let(:user) { create(:user) } + let(:study) { create(:study) } + let(:project) { create(:project) } let(:expected_json) do { diff --git a/spec/models/api/pac_bio_library_tube_io_spec.rb b/spec/models/api/pac_bio_library_tube_io_spec.rb index 16d6a6a0e7..9b9c719c3e 100644 --- a/spec/models/api/pac_bio_library_tube_io_spec.rb +++ b/spec/models/api/pac_bio_library_tube_io_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Api::PacBioLibraryTubeIO do subject do - create :pac_bio_library_tube, + create(:pac_bio_library_tube, :scanned_into_lab, concentration: 8.0, volume: 12.0, @@ -14,7 +14,7 @@ smrt_cells_available: 5, movie_length: 100, protocol: 'xyzzy' - } + }) end let(:expected_json) do diff --git a/spec/models/api/plate_io_spec.rb b/spec/models/api/plate_io_spec.rb index bc7194052b..4c4c23743d 100644 --- a/spec/models/api/plate_io_spec.rb +++ b/spec/models/api/plate_io_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' RSpec.describe Api::PlateIO do - subject { create :plate, plate_purpose: purpose } + subject { create(:plate, plate_purpose: purpose) } - let(:purpose) { create :plate_purpose } + let(:purpose) { create(:plate_purpose) } let(:expected_json) do { @@ -22,7 +22,7 @@ it_behaves_like('an IO object') context 'with an infinium barcode' do - subject { create :plate, plate_purpose: purpose, infinium_barcode: 'WG1234567-DNA' } + subject { create(:plate, plate_purpose: purpose, infinium_barcode: 'WG1234567-DNA') } let(:expected_json) do { 'uuid' => subject.uuid, 'id' => subject.id, 'name' => subject.name, 'infinium_barcode' => 'WG1234567-DNA' } @@ -32,7 +32,7 @@ end context 'with an fluidigm barcode' do - subject { create :plate, plate_purpose: purpose, fluidigm_barcode: '1234567890' } + subject { create(:plate, plate_purpose: purpose, fluidigm_barcode: '1234567890') } let(:expected_json) do { 'uuid' => subject.uuid, 'id' => subject.id, 'name' => subject.name, 'fluidigm_barcode' => '1234567890' } diff --git a/spec/models/api/plate_purpose_io_spec.rb b/spec/models/api/plate_purpose_io_spec.rb index 22a1533546..14cab89d2d 100644 --- a/spec/models/api/plate_purpose_io_spec.rb +++ b/spec/models/api/plate_purpose_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::PlatePurposeIO do - subject { create :plate_purpose } + subject { create(:plate_purpose) } let(:expected_json) { { 'uuid' => subject.uuid, 'internal_id' => subject.id, 'name' => subject.name } } diff --git a/spec/models/api/project_io_spec.rb b/spec/models/api/project_io_spec.rb index 9e38878cd5..bbc333a910 100644 --- a/spec/models/api/project_io_spec.rb +++ b/spec/models/api/project_io_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Api::ProjectIO do context 'with minimal details' do - subject { create :project, approved: true } + subject { create(:project, approved: true) } let(:metadata) { subject.project_metadata } @@ -31,7 +31,7 @@ context 'with roles and collaborators' do subject do - create :project, + create(:project, approved: true, project_metadata_attributes: { collaborators: 'Test', @@ -39,11 +39,11 @@ sequencing_budget_cost_centre: '123', funding_comments: 'It is funded', project_manager: - } + }) end let(:project_manager) { create(:project_manager) } - let!(:manager) { create :manager, authorizable: subject } + let!(:manager) { create(:manager, authorizable: subject) } let(:metadata) { subject.project_metadata } diff --git a/spec/models/api/pulldown_multiplexed_library_tube_io_spec.rb b/spec/models/api/pulldown_multiplexed_library_tube_io_spec.rb index c3e5f3da70..da0514c418 100644 --- a/spec/models/api/pulldown_multiplexed_library_tube_io_spec.rb +++ b/spec/models/api/pulldown_multiplexed_library_tube_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::PulldownMultiplexedLibraryTubeIO do - subject { create :pulldown_multiplexed_library_tube, volume: 12.0, concentration: 8.0 } + subject { create(:pulldown_multiplexed_library_tube, volume: 12.0, concentration: 8.0) } let(:expected_json) do { diff --git a/spec/models/api/reference_genome_io_spec.rb b/spec/models/api/reference_genome_io_spec.rb index 58cb9823a5..90860b2c97 100644 --- a/spec/models/api/reference_genome_io_spec.rb +++ b/spec/models/api/reference_genome_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::ReferenceGenomeIO do - subject { create :reference_genome } + subject { create(:reference_genome) } let(:expected_json) { { 'uuid' => subject.uuid, 'internal_id' => subject.id } } diff --git a/spec/models/api/request_io_spec.rb b/spec/models/api/request_io_spec.rb index ef58dc2d4e..bc4eeabead 100644 --- a/spec/models/api/request_io_spec.rb +++ b/spec/models/api/request_io_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' RSpec.describe Api::RequestIO do - subject { create :request, asset: source_asset, target_asset: } + subject { create(:request, asset: source_asset, target_asset:) } context 'between tubes' do - let(:source_asset) { create :sample_tube } - let(:target_asset) { create :library_tube } + let(:source_asset) { create(:sample_tube) } + let(:target_asset) { create(:library_tube) } let(:expected_json) do { @@ -42,8 +42,8 @@ end context 'between wells' do - let(:source_asset) { create :untagged_well } - let(:target_asset) { create :untagged_well } + let(:source_asset) { create(:untagged_well) } + let(:target_asset) { create(:untagged_well) } let(:expected_json) do { @@ -74,7 +74,7 @@ end context 'with no target asset' do - let(:source_asset) { create :untagged_well } + let(:source_asset) { create(:untagged_well) } let(:target_asset) { nil } let(:expected_json) do @@ -98,7 +98,7 @@ end context 'with metadata' do - subject { create :library_creation_request } + subject { create(:library_creation_request) } let(:expected_json) do { diff --git a/spec/models/api/sample_io_spec.rb b/spec/models/api/sample_io_spec.rb index 1de1a755f1..e84589ae8f 100644 --- a/spec/models/api/sample_io_spec.rb +++ b/spec/models/api/sample_io_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Api::SampleIO do subject do - create :sample, + create(:sample, name: 'sample_testing_messages', component_samples: [comp_sample1, comp_sample2], updated_by_manifest: true, @@ -62,13 +62,13 @@ consent_withdrawn: false, donor_id: 2, developmental_stage: 'thing' - } + }) end - let(:user) { create :user } - let(:reference_genome) { create :reference_genome } - let(:comp_sample1) { create :sample } - let(:comp_sample2) { create :sample } + let(:user) { create(:user) } + let(:reference_genome) { create(:reference_genome) } + let(:comp_sample1) { create(:sample) } + let(:comp_sample2) { create(:sample) } let(:expected_json) do { diff --git a/spec/models/api/sample_tube_io_spec.rb b/spec/models/api/sample_tube_io_spec.rb index de0d443032..93ab11cb8e 100644 --- a/spec/models/api/sample_tube_io_spec.rb +++ b/spec/models/api/sample_tube_io_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' RSpec.describe Api::SampleTubeIO do - subject { create :sample_tube, volume: 12.0, concentration: 8.0, sample: } + subject { create(:sample_tube, volume: 12.0, concentration: 8.0, sample:) } - let(:sample) { create :sample } + let(:sample) { create(:sample) } let(:expected_json) do { diff --git a/spec/models/api/study_io_spec.rb b/spec/models/api/study_io_spec.rb index be797b58dc..8bd5cd05b8 100644 --- a/spec/models/api/study_io_spec.rb +++ b/spec/models/api/study_io_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Api::StudyIO do subject do - create :study, + create(:study, ethically_approved: true, study_metadata_attributes: { faculty_sponsor: create(:faculty_sponsor, name: 'John Smith'), @@ -16,13 +16,13 @@ ega_dac_accession_number: 'DAC333', program: create(:program, name: 'General'), contaminated_human_data_access_group: 'contaminated human data access group test' - } + }) end - let(:reference_genome) { create :reference_genome } + let(:reference_genome) { create(:reference_genome) } - let!(:manager) { create :manager, authorizable: subject } - let!(:manager2) { create :manager, authorizable: subject } + let!(:manager) { create(:manager, authorizable: subject) } + let!(:manager2) { create(:manager, authorizable: subject) } let(:expected_json) do { diff --git a/spec/models/api/study_sample_io_spec.rb b/spec/models/api/study_sample_io_spec.rb index f509289e65..4b0e93039f 100644 --- a/spec/models/api/study_sample_io_spec.rb +++ b/spec/models/api/study_sample_io_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' RSpec.describe Api::StudySampleIO do - subject { create :study_sample, study:, sample: } + subject { create(:study_sample, study:, sample:) } - let(:study) { create :study } - let(:sample) { create :sample } + let(:study) { create(:study) } + let(:sample) { create(:sample) } let(:expected_json) do { diff --git a/spec/models/api/submission_io_spec.rb b/spec/models/api/submission_io_spec.rb index 13fefbebb3..daa7f9604c 100644 --- a/spec/models/api/submission_io_spec.rb +++ b/spec/models/api/submission_io_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' RSpec.describe Api::SubmissionIO do - subject { create :submission, user: } + subject { create(:submission, user:) } - let(:user) { create :user } + let(:user) { create(:user) } let(:expected_json) do { diff --git a/spec/models/api/tag_io_spec.rb b/spec/models/api/tag_io_spec.rb index e4e6672c47..e947c67a2b 100644 --- a/spec/models/api/tag_io_spec.rb +++ b/spec/models/api/tag_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::TagIO do - subject { create :tag } + subject { create(:tag) } let(:expected_json) do { diff --git a/spec/models/api/well_io_spec.rb b/spec/models/api/well_io_spec.rb index 036d472ff7..4a8919fa1f 100644 --- a/spec/models/api/well_io_spec.rb +++ b/spec/models/api/well_io_spec.rb @@ -6,10 +6,10 @@ context 'with one sample' do # As of the current records, the 'description' and 'asset_size' attributes can uniquely identify a map. subject do - create :well_with_sample_and_without_plate, map: Map.find_by(description: 'A1', asset_size: plate.size), plate: + create(:well_with_sample_and_without_plate, map: Map.find_by(description: 'A1', asset_size: plate.size), plate:) end - let(:plate) { create :plate, barcode: 'SQPD-1' } + let(:plate) { create(:plate, barcode: 'SQPD-1') } let(:sample) { subject.samples.first } let(:expected_json) do @@ -41,13 +41,13 @@ context 'with multiple samples' do subject do # As of the current records, the 'description' and 'asset_size' attributes can uniquely identify a map. - create :well_with_sample_and_without_plate, + create(:well_with_sample_and_without_plate, map: Map.find_by(description: 'A1', asset_size: plate.size), plate:, - aliquot_count: 2 + aliquot_count: 2) end - let(:plate) { create :plate, barcode: 'SQPD-1' } + let(:plate) { create(:plate, barcode: 'SQPD-1') } let(:sample) { subject.samples.first } # We only send samples in the event we have just one diff --git a/spec/models/bait_library_type_spec.rb b/spec/models/bait_library_type_spec.rb index ea31b09a8c..2cc063f901 100644 --- a/spec/models/bait_library_type_spec.rb +++ b/spec/models/bait_library_type_spec.rb @@ -4,7 +4,7 @@ describe BaitLibraryType do context 'When a bait library exists' do - let(:bait_library) { create :bait_library } + let(:bait_library) { create(:bait_library) } it 'bait libraries have library types' do expect(bait_library.bait_library_type).to be_truthy @@ -23,8 +23,8 @@ end context 'A request with a bait library' do - let(:request_type) { create :request_type, name: 'Bait Pulldown', target_asset_type: nil } - let(:request) { create :isc_request } + let(:request_type) { create(:request_type, name: 'Bait Pulldown', target_asset_type: nil) } + let(:request) { create(:isc_request) } it 'have a bait library type' do expect(request.request_metadata.bait_library.bait_library_type).to be_truthy diff --git a/spec/models/barcode_spec.rb b/spec/models/barcode_spec.rb index dcebddbe3c..79afce5188 100644 --- a/spec/models/barcode_spec.rb +++ b/spec/models/barcode_spec.rb @@ -98,7 +98,7 @@ context 'Adding labware association' do let(:barcode_value) { 'DN12345U' } let(:barcode_format) { 'sanger_ean13' } - let(:barcode) { build :sanger_ean13, barcode: barcode_value, format: barcode_format } + let(:barcode) { build(:sanger_ean13, barcode: barcode_value, format: barcode_format) } before { barcode.save! } @@ -127,7 +127,7 @@ end context 'sanger_ean13' do - let(:barcode) { build :sanger_ean13, barcode: barcode_value, format: barcode_format } + let(:barcode) { build(:sanger_ean13, barcode: barcode_value, format: barcode_format) } let(:barcode_value) { 'DN12345U' } let(:number) { 12_345 } @@ -160,7 +160,7 @@ end context 'sanger_code39' do - let(:barcode) { build :sanger_code39, barcode: barcode_value, format: barcode_format } + let(:barcode) { build(:sanger_code39, barcode: barcode_value, format: barcode_format) } let(:barcode_value) { 'DN12345U' } let(:number) { 12_345 } @@ -193,7 +193,7 @@ end context 'sequencescape22' do - let(:barcode) { build :sequencescape22, barcode: barcode_value, format: barcode_format } + let(:barcode) { build(:sequencescape22, barcode: barcode_value, format: barcode_format) } let(:barcode_value) { 'SQPD-12345' } let(:barcode_format) { 'sequencescape22' } let(:number) { 12_345 } @@ -233,7 +233,7 @@ end context 'infinium' do - let(:barcode) { build :infinium, barcode: barcode_value, format: barcode_format } + let(:barcode) { build(:infinium, barcode: barcode_value, format: barcode_format) } let(:barcode_value) { 'WG0010602-DNA' } let(:barcode_format) { 'infinium' } @@ -261,7 +261,7 @@ end context 'fluidigm' do - let(:barcode) { build :fluidigm, barcode: barcode_value, format: barcode_format } + let(:barcode) { build(:fluidigm, barcode: barcode_value, format: barcode_format) } let(:barcode_value) { '1662051218' } let(:barcode_format) { 'fluidigm' } @@ -286,7 +286,7 @@ end context 'uk biocentre v3' do - let(:barcode) { build :external, barcode: barcode_value, format: barcode_format } + let(:barcode) { build(:external, barcode: barcode_value, format: barcode_format) } let(:barcode_value) { 'RNA12345' } let(:barcode_format) { 'uk_biocentre_v3' } @@ -315,7 +315,7 @@ end context 'external' do - let(:barcode) { build :external, barcode: barcode_value, format: barcode_format } + let(:barcode) { build(:external, barcode: barcode_value, format: barcode_format) } let(:barcode_value) { 'EXT_135432_D' } let(:barcode_format) { 'external' } @@ -335,7 +335,7 @@ end context 'external - odd format' do - let(:barcode) { build :external, barcode: barcode_value, format: barcode_format } + let(:barcode) { build(:external, barcode: barcode_value, format: barcode_format) } let(:barcode_value) { 'Q123RT12E45' } let(:barcode_format) { 'external' } @@ -356,7 +356,7 @@ end context 'foreign - CGAP format' do - let(:barcode) { build :cgap, barcode: barcode_value, format: barcode_format } + let(:barcode) { build(:cgap, barcode: barcode_value, format: barcode_format) } let(:barcode_value) { 'CGAP-ABC123' } let(:barcode_format) { 'cgap' } diff --git a/spec/models/batch_spec.rb b/spec/models/batch_spec.rb index 7fb8fc0872..2d11359cff 100644 --- a/spec/models/batch_spec.rb +++ b/spec/models/batch_spec.rb @@ -51,10 +51,10 @@ describe '::for_user' do subject(:batch_for_user) { described_class.for_user(query) } - let(:user) { create :user } - let!(:owned_batch) { create :batch, user: } - let!(:assigned_batch) { create :batch, assignee: user } - let!(:other_batch) { create :batch } + let(:user) { create(:user) } + let!(:owned_batch) { create(:batch, user:) } + let!(:assigned_batch) { create(:batch, assignee: user) } + let!(:other_batch) { create(:batch) } context 'with a user' do let(:query) { user } @@ -79,7 +79,7 @@ describe '::add_dynamic_validations' do # Specific validator tests can be found in spec/validators - let(:pipeline) { create :pipeline, validator_class_name: 'TestPipelineValidator' } + let(:pipeline) { create(:pipeline, validator_class_name: 'TestPipelineValidator') } let(:batch) { described_class.new pipeline: } it 'fails validation when dynamic validations fail' do diff --git a/spec/models/broadcast_event/helpers/external_subjects_spec.rb b/spec/models/broadcast_event/helpers/external_subjects_spec.rb index fe0a44598a..f2e1b1a340 100644 --- a/spec/models/broadcast_event/helpers/external_subjects_spec.rb +++ b/spec/models/broadcast_event/helpers/external_subjects_spec.rb @@ -3,7 +3,7 @@ RSpec.describe BroadcastEvent::Helpers::ExternalSubjects, :heron_events do let(:testing_event_class) { Class.new(BroadcastEvent) { include BroadcastEvent::Helpers::ExternalSubjects } } - let(:labware) { create :labware } + let(:labware) { create(:labware) } let(:sub1) do { role_type: 'sender', diff --git a/spec/models/broadcast_event/lab_event_spec.rb b/spec/models/broadcast_event/lab_event_spec.rb index ff7cd24d4c..cf8cab9d0a 100644 --- a/spec/models/broadcast_event/lab_event_spec.rb +++ b/spec/models/broadcast_event/lab_event_spec.rb @@ -9,24 +9,24 @@ let(:json) { JSON.parse(subject.to_json) } let(:eventful) { request } - let(:batch) { create :sequencing_batch } - let(:study) { create :study } + let(:batch) { create(:sequencing_batch) } + let(:study) { create(:study) } let!(:request) do - create :sequencing_request_with_assets, batch:, request_type: batch.pipeline.request_types.first, study: + create(:sequencing_request_with_assets, batch:, request_type: batch.pipeline.request_types.first, study:) end let(:sample) { request.asset.samples.first } let(:stock_asset) { request.asset.labware } let(:lab_event) do - create :lab_event, + create(:lab_event, description: 'Read 1 Lin/block/hyb/load', descriptors: { 'key_a' => 'value a', 'key_b' => 'value b' }, - eventful: + eventful:) end - let(:user) { create :user } + let(:user) { create(:user) } it 'generates json' do expect(json).not_to be_nil @@ -101,7 +101,7 @@ end context 'from a non-sequencing batch' do - let(:eventful) { create :batch } + let(:eventful) { create(:batch) } it 'includes the expected subjects' do expect(json.dig('event', 'subjects')).to match_unordered_json([]) diff --git a/spec/models/broadcast_event/plate_cherrypicked_spec.rb b/spec/models/broadcast_event/plate_cherrypicked_spec.rb index a63290b638..61e8a063a0 100644 --- a/spec/models/broadcast_event/plate_cherrypicked_spec.rb +++ b/spec/models/broadcast_event/plate_cherrypicked_spec.rb @@ -8,7 +8,7 @@ def subject_record(subject_type, role_type, friendly_name, uuid) end let(:uuids) { Array.new(6) { SecureRandom.uuid } } - let(:destination_plate) { create :plate } + let(:destination_plate) { create(:plate) } let(:plate1) do subject_record('plate', BroadcastEvent::PlateCherrypicked::SOURCE_PLATES_ROLE_TYPE, '000001', uuids[0]) end diff --git a/spec/models/broadcast_event/pool_released_spec.rb b/spec/models/broadcast_event/pool_released_spec.rb index ac93053c81..7cb404c035 100644 --- a/spec/models/broadcast_event/pool_released_spec.rb +++ b/spec/models/broadcast_event/pool_released_spec.rb @@ -4,23 +4,23 @@ RSpec.describe BroadcastEvent::PoolReleased, :broadcast_event do let(:source_plate) do - pl = create :full_stock_plate - pl.wells.first.aliquots << (create :aliquot, sample: tube.samples.first) - pl.wells.last.aliquots << (create :aliquot, sample: tube.samples.last) + pl = create(:full_stock_plate) + pl.wells.first.aliquots << (create(:aliquot, sample: tube.samples.first)) + pl.wells.last.aliquots << (create(:aliquot, sample: tube.samples.last)) tube.ancestors << pl pl end - let(:tube) { create :multiplexed_library_tube, sample_count: 2, purpose: (create :illumina_htp_mx_tube_purpose) } + let(:tube) { create(:multiplexed_library_tube, sample_count: 2, purpose: create(:illumina_htp_mx_tube_purpose)) } - let(:submission) { create :library_submission } + let(:submission) { create(:library_submission) } let(:order) { submission.orders.first } let(:request1) do - create :multiplex_request, asset: source_plate.wells.first, target_asset: tube.receptacle, state: 'passed', order: + create(:multiplex_request, asset: source_plate.wells.first, target_asset: tube.receptacle, state: 'passed', order:) end let(:request2) do - create :multiplex_request, asset: source_plate.wells.last, target_asset: tube.receptacle, state: 'passed', order: + create(:multiplex_request, asset: source_plate.wells.last, target_asset: tube.receptacle, state: 'passed', order:) end - let(:library_request) { create :library_request, target_asset: source_plate.wells.first } + let(:library_request) { create(:library_request, target_asset: source_plate.wells.first) } let(:event) { described_class.create!(seed: tube, user: create(:user), properties: { order_id: order.id }) } let(:subject_hash) { event.as_json['event'][:subjects].group_by(&:role_type) } diff --git a/spec/models/broadcast_event/qc_assay_spec.rb b/spec/models/broadcast_event/qc_assay_spec.rb index f7263eb61f..c702034d98 100644 --- a/spec/models/broadcast_event/qc_assay_spec.rb +++ b/spec/models/broadcast_event/qc_assay_spec.rb @@ -17,9 +17,9 @@ let(:json) { JSON.parse(subject.to_json) } let(:lot_number) { '12345' } - let(:plate) { create :plate_with_untagged_wells, sample_count: 2, studies: [study], parents: [stock_plate] } - let(:stock_plate) { create :stock_plate, purpose: PlatePurpose.stock_plate_purpose, well_count: 2 } - let(:study) { create :study } + let(:plate) { create(:plate_with_untagged_wells, sample_count: 2, studies: [study], parents: [stock_plate]) } + let(:stock_plate) { create(:stock_plate, purpose: PlatePurpose.stock_plate_purpose, well_count: 2) } + let(:study) { create(:study) } let(:well1) { plate.wells[0] } let(:sample1) { well1.samples.first } let(:well2) { plate.wells[1] } @@ -27,12 +27,12 @@ context 'A single assay qc_assay' do let(:qc_assay) do - create :qc_assay, + create(:qc_assay, lot_number:, qc_results: [ build(:qc_result_concentration, asset: well1, assay_type: 'Example Assay', assay_version: 'v0.0'), build(:qc_result_concentration, asset: well2, assay_type: 'Example Assay', assay_version: 'v0.0') - ] + ]) end describe '#to_json' do @@ -100,12 +100,12 @@ # The API supports multiple different assays types being conducted at the same time, # but event wise these should be distinguishable. let(:qc_assay) do - create :qc_assay, + create(:qc_assay, lot_number:, qc_results: [ build(:qc_result_concentration, asset: well1, assay_type: 'Example Assay', assay_version: 'v0.0'), build(:qc_result_concentration, asset: well2, assay_type: 'Other Assay', assay_version: 'v0.0') - ] + ]) end describe '#to_json' do diff --git a/spec/models/bulk_submission_spec.rb b/spec/models/bulk_submission_spec.rb index 80a63badfa..e1e254d17b 100644 --- a/spec/models/bulk_submission_spec.rb +++ b/spec/models/bulk_submission_spec.rb @@ -14,17 +14,17 @@ let(:number_submissions_created) { subject.completed_submissions.first.length } let(:generated_submissions) { Submission.find(subject.completed_submissions.first) } let(:generated_submission) { generated_submissions.first } - let(:request_types) { create_list :well_request_type, 2 } + let(:request_types) { create_list(:well_request_type, 2) } after { submission_file.close } - let!(:study) { create :study, name: 'abc123_study' } - let!(:asset_group) { create :asset_group, name: 'assetgroup123', study:, asset_count: 2 } - let!(:library_type) { create :library_type, name: 'Standard' } + let!(:study) { create(:study, name: 'abc123_study') } + let!(:asset_group) { create(:asset_group, name: 'assetgroup123', study:, asset_count: 2) } + let!(:library_type) { create(:library_type, name: 'Standard') } before do - create :user, login: 'user' - create :project, name: 'Test project' + create(:user, login: 'user') + create(:project, name: 'Test project') end context 'a simple submission' do @@ -65,7 +65,7 @@ context 'an asset driven submission' do let(:spreadsheet_filename) { 'template_for_bulk_submission.csv' } - let!(:asset) { create :plate, barcode: 'SQPD-1', well_count: 1, well_factory: :untagged_well } + let!(:asset) { create(:plate, barcode: 'SQPD-1', well_count: 1, well_factory: :untagged_well) } let(:submission_template_hash) do { name: 'Example Template', @@ -100,7 +100,7 @@ let(:spreadsheet_filename) { 'pcr_cycles.csv' } let!(:submission_template) do - create :limber_wgs_submission_template, name: 'pcr_cycle_test', request_types: [request_type] + create(:limber_wgs_submission_template, name: 'pcr_cycle_test', request_types: [request_type]) end let(:request_type) { create(:library_request_type) } @@ -129,10 +129,10 @@ context 'a submission with primer_panels' do let(:spreadsheet_filename) { 'primer_panels.csv' } - let!(:primer_panel) { create :primer_panel, name: 'Test panel' } + let!(:primer_panel) { create(:primer_panel, name: 'Test panel') } let!(:submission_template) do - create :limber_wgs_submission_template, name: 'primer_panel_test', request_types: [request_type] + create(:limber_wgs_submission_template, name: 'primer_panel_test', request_types: [request_type]) end let(:request_type) { create(:gbs_request_type) } @@ -162,11 +162,11 @@ context 'a submission with bait libraries' do let(:spreadsheet_filename) { '2_valid_sc_submissions.csv' } - let!(:bait_library) { create :bait_library, name: 'Bait library 1' } - let!(:bait_library_2) { create :bait_library, name: 'Bait library 2' } + let!(:bait_library) { create(:bait_library, name: 'Bait library 1') } + let!(:bait_library_2) { create(:bait_library, name: 'Bait library 2') } let!(:submission_template) do - create :limber_wgs_submission_template, name: 'Bait submission example', request_types: [request_type] + create(:limber_wgs_submission_template, name: 'Bait submission example', request_types: [request_type]) end let(:request_type) { create(:isc_library_request_type) } @@ -196,7 +196,7 @@ let(:spreadsheet_filename) { 'with_lowercase_library_type.csv' } let!(:submission_template) do - create :limber_wgs_submission_template, name: 'library_type_test', request_types: [request_type] + create(:limber_wgs_submission_template, name: 'library_type_test', request_types: [request_type]) end let(:request_type) { create(:library_request_type) } @@ -227,7 +227,7 @@ let(:spreadsheet_filename) { 'with_unknown_library_type.csv' } let!(:submission_template) do - create :limber_wgs_submission_template, name: 'library_type_test', request_types: [request_type] + create(:limber_wgs_submission_template, name: 'library_type_test', request_types: [request_type]) end let(:request_type) { create(:library_request_type) } diff --git a/spec/models/cherrypick_request_spec.rb b/spec/models/cherrypick_request_spec.rb index e255ed7430..d25158a369 100644 --- a/spec/models/cherrypick_request_spec.rb +++ b/spec/models/cherrypick_request_spec.rb @@ -4,10 +4,10 @@ require 'shared_contexts/limber_shared_context' describe CherrypickRequest do - let(:source_asset) { create :tagged_well } - let(:target_asset) { create :empty_well } + let(:source_asset) { create(:tagged_well) } + let(:target_asset) { create(:empty_well) } - before { create :cherrypick_request, asset: source_asset, target_asset: } + before { create(:cherrypick_request, asset: source_asset, target_asset:) } it 'transfers the contents of the source asset to the target asset' do expect(target_asset.aliquots.length).to eq(source_asset.aliquots.length) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 4c6c8fefb7..d429c8d0d1 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -19,13 +19,13 @@ describe '#counts_for_requests' do context 'when request has asset' do - let(:request) { create :sequencing_request, asset: tube } - let(:tube) { create :multiplexed_library_tube } + let(:request) { create(:sequencing_request, asset: tube) } + let(:tube) { create(:multiplexed_library_tube) } before do - create :comment, commentable: tube, description: 'An excellent tube' - create :comment, commentable: tube.receptacle, description: 'A good receptacle' - create :comment, commentable: request, description: 'A reasonable request' + create(:comment, commentable: tube, description: 'An excellent tube') + create(:comment, commentable: tube.receptacle, description: 'A good receptacle') + create(:comment, commentable: request, description: 'A reasonable request') end it 'counts comments on requests, their assets and receptacles' do @@ -34,9 +34,9 @@ end context 'when request has no asset' do - let(:request) { create :sequencing_request } + let(:request) { create(:sequencing_request) } - before { create :comment, commentable: request, description: 'A reasonable request' } + before { create(:comment, commentable: request, description: 'A reasonable request') } it 'counts comments on requests only' do expect(described_class.counts_for_requests([request])).to eq({ request.id => 1 }) @@ -45,28 +45,28 @@ end context 'while adding comments to requests' do - let(:user) { create :user } - let(:study) { create :study } - let(:project) { create :project } + let(:user) { create(:user) } + let(:study) { create(:study) } + let(:project) { create(:project) } - let(:asset) { create :empty_sample_tube } + let(:asset) { create(:empty_sample_tube) } - let(:asset2) { create :empty_sample_tube } + let(:asset2) { create(:empty_sample_tube) } - let(:order1) { create :order_with_submission, study:, assets: [asset], project: } - let(:order2) { create :order, study:, assets: [asset], project: } - let(:order3) { create :order, study:, assets: [asset2], project: } - let(:order4) { create :order_with_submission, study:, assets: [asset2], project: } + let(:order1) { create(:order_with_submission, study:, assets: [asset], project:) } + let(:order2) { create(:order, study:, assets: [asset], project:) } + let(:order3) { create(:order, study:, assets: [asset2], project:) } + let(:order4) { create(:order_with_submission, study:, assets: [asset2], project:) } let(:submission) { order1.submission } let(:submission2) { order4.submission } - let!(:sequencing_request) { create :request_with_sequencing_request_type, submission: } - let!(:request) { create :request, order: order1, asset:, submission: } - let!(:request2) { create :request, order: order2, submission: } + let!(:sequencing_request) { create(:request_with_sequencing_request_type, submission:) } + let!(:request) { create(:request, order: order1, asset:, submission:) } + let!(:request2) { create(:request, order: order2, submission:) } - let!(:request3) { create :request, order: order4, submission: order4.submission } - let!(:sequencing_request2) { create :request_with_sequencing_request_type, submission: order4.submission } + let!(:request3) { create(:request, order: order4, submission: order4.submission) } + let!(:sequencing_request2) { create(:request_with_sequencing_request_type, submission: order4.submission) } before do asset.aliquots.create!(sample: create(:sample, studies: [study])) @@ -125,17 +125,17 @@ end context 'adding to a plate' do - let(:plate) { create :plate, well_count: 1 } - let(:submission) { create :submission } - let!(:request) { create :request, asset: plate.wells.first, submission: } + let(:plate) { create(:plate, well_count: 1) } + let(:submission) { create(:submission) } + let!(:request) { create(:request, asset: plate.wells.first, submission:) } it 'also adds to the request' do - create :comment, commentable: plate, description: 'Hello' + create(:comment, commentable: plate, description: 'Hello') expect(request.reload.comments.first.description).to eq('Hello') end it 'propagates titles' do - create :comment, commentable: plate, description: 'Hello', title: 'Test' + create(:comment, commentable: plate, description: 'Hello', title: 'Test') expect(request.reload.comments.first.title).to eq('Test') end end diff --git a/spec/models/external_release_event_spec.rb b/spec/models/external_release_event_spec.rb index 27d3306b23..011ad42104 100644 --- a/spec/models/external_release_event_spec.rb +++ b/spec/models/external_release_event_spec.rb @@ -6,22 +6,22 @@ describe '::create_for_asset!' do subject { described_class.create_for_asset!(asset, sendmail) } - let(:asset) { build :lane, aliquots:, external_release: true } - let(:aliquots) { [study_a, study_a, study_b].map { |s| build :aliquot, study: s } } + let(:asset) { build(:lane, aliquots:, external_release: true) } + let(:aliquots) { [study_a, study_a, study_b].map { |s| build(:aliquot, study: s) } } let(:expected_recipients) { [user_on_multiple_studies.email, user_on_single_study.email] } let(:expected_message) { 'Data to be released externally set true' } - let!(:user_without_mail) { create :manager, email: '', roles: [study_a_managers] } + let!(:user_without_mail) { create(:manager, email: '', roles: [study_a_managers]) } let!(:user_on_multiple_studies) do - create :manager, email: 'test@example.com', roles: [study_a_managers, study_b_managers] + create(:manager, email: 'test@example.com', roles: [study_a_managers, study_b_managers]) end - let!(:user_on_single_study) { create :manager, email: 'test2@example.com', roles: [study_b_managers] } + let!(:user_on_single_study) { create(:manager, email: 'test2@example.com', roles: [study_b_managers]) } - let(:study_a) { create :study } - let(:study_b) { create :study } + let(:study_a) { create(:study) } + let(:study_b) { create(:study) } - let(:study_a_managers) { create :manager_role, authorizable: study_a } - let(:study_b_managers) { create :manager_role, authorizable: study_b } + let(:study_a_managers) { create(:manager_role, authorizable: study_a) } + let(:study_b_managers) { create(:manager_role, authorizable: study_b) } context 'when sendmail is true' do let(:sendmail) { true } diff --git a/spec/models/flowcell_type_spec.rb b/spec/models/flowcell_type_spec.rb index 1e8ae8f625..8213cefee8 100644 --- a/spec/models/flowcell_type_spec.rb +++ b/spec/models/flowcell_type_spec.rb @@ -18,7 +18,7 @@ end context 'with a shared name' do - before { create :flowcell_type, name: 'Shared' } + before { create(:flowcell_type, name: 'Shared') } let(:name) { 'Shared' } @@ -26,7 +26,7 @@ end context 'with a shared name (case-insensitive)' do - before { create :flowcell_type, name: 'Shared' } + before { create(:flowcell_type, name: 'Shared') } let(:name) { 'shared' } diff --git a/spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb b/spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb index 29dd463851..ce3b1a37a8 100644 --- a/spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb +++ b/spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb @@ -3,28 +3,28 @@ require 'rails_helper' describe IlluminaHtp::InitialStockTubePurpose do - let(:tube_purpose) { create :illumina_htp_initial_stock_tube_purpose } - let(:tube) { create :stock_multiplexed_library_tube, purpose: tube_purpose, name: 'Current Asset' } + let(:tube_purpose) { create(:illumina_htp_initial_stock_tube_purpose) } + let(:tube) { create(:stock_multiplexed_library_tube, purpose: tube_purpose, name: 'Current Asset') } describe '#sibling_tubes' do subject { tube_purpose.sibling_tubes(tube) } - let(:current_submission) { create :submission } + let(:current_submission) { create(:submission) } let(:parent_well) do - well = create :well + well = create(:well) well.stock_wells << well well end - let(:target_tube) { create :multiplexed_library_tube } + let(:target_tube) { create(:multiplexed_library_tube) } let(:sibling_state) { 'pending' } let(:library_request) do - create :multiplex_request, asset: parent_well, target_asset: target_tube, submission: current_submission + create(:multiplex_request, asset: parent_well, target_asset: target_tube, submission: current_submission) end before do - create :transfer_request, asset: parent_well, target_asset: tube, submission: current_submission + create(:transfer_request, asset: parent_well, target_asset: tube, submission: current_submission) library_request if sibling_tube create :transfer_request, @@ -33,15 +33,15 @@ submission: sibling_submission, state: sibling_state end - create :multiplex_request, + create(:multiplex_request, asset: parents_sibling_well, target_asset: target_tube, submission: sibling_submission, - request_type: sibling_request_type + request_type: sibling_request_type) end context 'which has been created' do - let(:sibling_tube) { create :stock_multiplexed_library_tube, purpose: tube_purpose, name: 'Sibling tube' } + let(:sibling_tube) { create(:stock_multiplexed_library_tube, purpose: tube_purpose, name: 'Sibling tube') } let(:sibling_tube_hash) do { name: sibling_tube.name, @@ -54,7 +54,7 @@ context 'with siblings' do let(:sibling_request_type) { library_request.request_type } let(:sibling_submission) { current_submission } - let(:parents_sibling_well) { create :well } + let(:parents_sibling_well) { create(:well) } it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording expect(subject).to be_a Array @@ -65,9 +65,9 @@ # Not only is the request_type different, but so is the purpose, we also throw # an additional spanner in the works by adding another tube in upstream of the # sibling, which we don't want to show up. - let(:sibling_tube) { create :stock_multiplexed_library_tube, name: 'Sibling tube' } + let(:sibling_tube) { create(:stock_multiplexed_library_tube, name: 'Sibling tube') } let(:sibling_submission) { current_submission } - let(:sibling_request_type) { create :multiplex_request_type } + let(:sibling_request_type) { create(:multiplex_request_type) } let(:sibling_state) { 'started' } it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording @@ -83,10 +83,10 @@ # >-> MX # P -> P -> T context 'which have a lineage of siblings' do - let(:sibling_tube) { create :stock_multiplexed_library_tube, name: 'Sibling tube' } - let(:sibling_descendant) { create :stock_multiplexed_library_tube, name: 'Sibling tube descendant' } + let(:sibling_tube) { create(:stock_multiplexed_library_tube, name: 'Sibling tube') } + let(:sibling_descendant) { create(:stock_multiplexed_library_tube, name: 'Sibling tube descendant') } let(:sibling_submission) { current_submission } - let(:sibling_request_type) { create :multiplex_request_type } + let(:sibling_request_type) { create(:multiplex_request_type) } let(:sibling_state) { 'passed' } let(:sibling_descendant_hash) do { @@ -98,11 +98,11 @@ end before do - create :transfer_request, + create(:transfer_request, asset: sibling_tube, target_asset: sibling_descendant, submission: sibling_submission, - state: 'passed' + state: 'passed') end it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording @@ -117,7 +117,7 @@ let(:sibling_request_type) { library_request.request_type } let(:sibling_submission) { current_submission } let(:sibling_tube) { create(:well) } - let(:parents_sibling_well) { create :well } + let(:parents_sibling_well) { create(:well) } it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording expect(subject).to be_a Array @@ -127,7 +127,7 @@ context 'with unrelated requests out the same well' do let(:sibling_request_type) { library_request.request_type } - let(:sibling_submission) { create :submission } + let(:sibling_submission) { create(:submission) } let(:parents_sibling_well) { parent_well } it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording @@ -164,7 +164,7 @@ context 'with siblings' do let(:sibling_request_type) { library_request.request_type } let(:sibling_submission) { current_submission } - let(:parents_sibling_well) { create :well } + let(:parents_sibling_well) { create(:well) } it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording expect(subject).to be_a Array diff --git a/spec/models/illumina_htp/requests/gbs_request_spec.rb b/spec/models/illumina_htp/requests/gbs_request_spec.rb index e50774cf6a..c82a11984d 100644 --- a/spec/models/illumina_htp/requests/gbs_request_spec.rb +++ b/spec/models/illumina_htp/requests/gbs_request_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe IlluminaHtp::Requests::GbsRequest do - subject(:request) { create :gbs_request } + subject(:request) { create(:gbs_request) } describe '#request_metadata' do describe '#primer_panel' do diff --git a/spec/models/illumina_htp/requests/heron_request_spec.rb b/spec/models/illumina_htp/requests/heron_request_spec.rb index 8f38925810..75613c22b9 100644 --- a/spec/models/illumina_htp/requests/heron_request_spec.rb +++ b/spec/models/illumina_htp/requests/heron_request_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe IlluminaHtp::Requests::HeronRequest, :heron do - subject(:request) { create :heron_request } + subject(:request) { create(:heron_request) } describe '#request_metadata' do describe '#primer_panel' do diff --git a/spec/models/illumina_htp/requests/heron_tailed_request_spec.rb b/spec/models/illumina_htp/requests/heron_tailed_request_spec.rb index 8cc8468612..8d72a51e64 100644 --- a/spec/models/illumina_htp/requests/heron_tailed_request_spec.rb +++ b/spec/models/illumina_htp/requests/heron_tailed_request_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe IlluminaHtp::Requests::HeronTailedRequest, :heron do - subject(:request) { build :heron_tailed_request } + subject(:request) { build(:heron_tailed_request) } describe '#request_metadata' do describe '#primer_panel' do diff --git a/spec/models/insdc/country_spec.rb b/spec/models/insdc/country_spec.rb index 33551a5f72..cbc979ab37 100644 --- a/spec/models/insdc/country_spec.rb +++ b/spec/models/insdc/country_spec.rb @@ -4,25 +4,25 @@ RSpec.describe Insdc::Country do context 'without a name' do - subject { build :insdc_country, name: nil } + subject { build(:insdc_country, name: nil) } it { is_expected.not_to be_valid } end context 'without a sort_priority' do - subject { build :insdc_country, sort_priority: nil } + subject { build(:insdc_country, sort_priority: nil) } it { is_expected.not_to be_valid } end context 'without a validation_state' do - subject { build :insdc_country, validation_state: nil } + subject { build(:insdc_country, validation_state: nil) } it { is_expected.not_to be_valid } end describe '#invalid!' do - let(:country) { build :insdc_country, validation_state: 'valid' } + let(:country) { build(:insdc_country, validation_state: 'valid') } it 'marks a country as invalid' do country.invalid! @@ -34,11 +34,11 @@ subject(:options) { described_class.options } before do - create :insdc_country, name: 'Excellent land' - create :insdc_country, name: 'Amazing land' - create :insdc_country, name: 'Best land' - create :insdc_country, :high_priority, name: 'Cool land' - create :insdc_country, :invalid, name: 'Dead land' + create(:insdc_country, name: 'Excellent land') + create(:insdc_country, name: 'Amazing land') + create(:insdc_country, name: 'Best land') + create(:insdc_country, :high_priority, name: 'Cool land') + create(:insdc_country, :invalid, name: 'Dead land') end it { is_expected.to be_an Array } diff --git a/spec/models/lab_event_spec.rb b/spec/models/lab_event_spec.rb index 9afb74540b..25d482b7bb 100644 --- a/spec/models/lab_event_spec.rb +++ b/spec/models/lab_event_spec.rb @@ -4,7 +4,7 @@ require 'broadcast_event/lab_event' RSpec.describe LabEvent do - subject { build :lab_event, user: build(:user) } + subject { build(:lab_event, user: build(:user)) } it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording expect(subject).to respond_to :eventful diff --git a/spec/models/labware_spec.rb b/spec/models/labware_spec.rb index 5db0d34af9..e5c4037999 100644 --- a/spec/models/labware_spec.rb +++ b/spec/models/labware_spec.rb @@ -73,7 +73,7 @@ describe '#labwhere_location' do subject { plate.labwhere_location } - let(:plate) { create :plate } + let(:plate) { create(:plate) } let(:parentage) { 'Sanger / Ogilvie / AA316' } let(:location) { 'Shelf 1' } @@ -96,8 +96,8 @@ describe '#labwhere_locations' do subject { described_class.labwhere_locations(barcodes) } - let(:plate_1) { create :plate } - let(:plate_2) { create :plate } + let(:plate_1) { create(:plate) } + let(:plate_2) { create(:plate) } let(:barcodes) { [plate_1.human_barcode, plate_2.human_barcode] } let(:parentage_1) { 'Sanger / Ogilvie / AA316' } let(:parentage_2) { 'Sanger / Ogilvie / AA317' } diff --git a/spec/models/lane_spec.rb b/spec/models/lane_spec.rb index 10cd5470d5..6e1eb633ce 100644 --- a/spec/models/lane_spec.rb +++ b/spec/models/lane_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' RSpec.describe Lane do - let(:lane) { create :lane_with_stock_plate } - let!(:request) { create :sequencing_request_with_assets, target_asset: lane } + let(:lane) { create(:lane_with_stock_plate) } + let!(:request) { create(:sequencing_request_with_assets, target_asset: lane) } it 'finds lanes that have requested aliquots' do aliquots = create_list(:aliquot, 5) @@ -15,8 +15,8 @@ lane.aliquots << aliquots # lanes containing requested aliquots - lane1 = create :lane - lane2 = create :lane + lane1 = create(:lane) + lane2 = create(:lane) lane1.aliquots << requested_aliquots.first lane2.aliquots << requested_aliquots.last lanes_to_be_found = [lane1, lane2] @@ -26,7 +26,7 @@ it 'can be rebroadcasted' do # request = create :sequencing_request, target_asset: lane - batch = create :sequencing_batch + batch = create(:sequencing_batch) batch.requests << request # as requests_as_targets is a scope, not the above instance of batch receive the message diff --git a/spec/models/library_type_spec.rb b/spec/models/library_type_spec.rb index 40e85afa8b..b04608ef9a 100644 --- a/spec/models/library_type_spec.rb +++ b/spec/models/library_type_spec.rb @@ -18,7 +18,7 @@ end context 'with a shared name' do - before { create :library_type, name: 'Shared' } + before { create(:library_type, name: 'Shared') } let(:name) { 'Shared' } @@ -26,7 +26,7 @@ end context 'with a shared name (case-insensitive)' do - before { create :library_type, name: 'Shared' } + before { create(:library_type, name: 'Shared') } let(:name) { 'shared' } @@ -35,9 +35,9 @@ describe '::alphabetical' do before do - create :library_type, name: 'Brilliant' - create :library_type, name: 'Amazing' - create :library_type, name: 'Cool' + create(:library_type, name: 'Brilliant') + create(:library_type, name: 'Amazing') + create(:library_type, name: 'Cool') end it 'returns library types in alphabetical order' do @@ -60,7 +60,7 @@ end before do - create :library_type, name: 'Not long read' + create(:library_type, name: 'Not long read') record_loader.create! end diff --git a/spec/models/linear_submission_spec.rb b/spec/models/linear_submission_spec.rb index 2b6a3c6001..1435c29efe 100644 --- a/spec/models/linear_submission_spec.rb +++ b/spec/models/linear_submission_spec.rb @@ -6,13 +6,13 @@ let(:mx_asset_count) { 5 } let(:sx_asset_count) { 5 } - let(:study) { create :study } - let(:project) { create :project } - let(:user) { create :user } + let(:study) { create(:study) } + let(:project) { create(:project) } + let(:user) { create(:user) } describe 'build (Submission factory)' do - let(:sequencing_request_type) { create :sequencing_request_type } - let(:purpose) { create :std_mx_tube_purpose } + let(:sequencing_request_type) { create(:sequencing_request_type) } + let(:purpose) { create(:std_mx_tube_purpose) } let(:request_options) do { 'read_length' => '108', 'fragment_size_required_from' => '150', 'fragment_size_required_to' => '200' } end @@ -20,19 +20,20 @@ context 'when a multiplexed submission' do describe 'Customer decision propagation' do let(:library_creation_request_type) do - create :well_request_type, :with_library_types, target_purpose: purpose, for_multiplexing: true + create(:well_request_type, :with_library_types, target_purpose: purpose, for_multiplexing: true) end - let(:product_criteria) { create :product_criteria } - let(:current_report) { create :qc_report, product_criteria: } - let(:stock_well) { create :well } + let(:product_criteria) { create(:product_criteria) } + let(:current_report) { create(:qc_report, product_criteria:) } + let(:stock_well) { create(:well) } let(:request_well) do - well = create :well + well = create(:well) well.stock_wells.attach!([stock_well]) well.reload well end let(:expected_metric) do - create :qc_metric, asset: stock_well, qc_report: current_report, qc_decision: 'manually_failed', proceed: true + create(:qc_metric, asset: stock_well, qc_report: current_report, qc_decision: 'manually_failed', +proceed: true) end let(:mpx_submission) do create( @@ -68,7 +69,7 @@ context 'with basic behaviour' do let(:mpx_assets) { create_list(:sample_tube, mx_asset_count) } let(:library_creation_request_type) do - create :multiplexed_library_creation_request_type, target_purpose: purpose + create(:multiplexed_library_creation_request_type, target_purpose: purpose) end let(:mpx_submission) do create( @@ -107,7 +108,7 @@ end context 'when multiple requests after plexing' do - let(:sequencing_request_type_2) { create :sequencing_request_type } + let(:sequencing_request_type_2) { create(:sequencing_request_type) } let(:request_type_option) do [library_creation_request_type.id, sequencing_request_type_2.id, sequencing_request_type.id] end @@ -126,9 +127,9 @@ end context 'with two stages of library creation' do - let(:library_creation_stage1) { create :library_request_type, :with_library_types } - let(:library_creation_stage2) { create :library_request_type, :with_library_types } - let(:mx_request_type) { create :multiplex_request_type } + let(:library_creation_stage1) { create(:library_request_type, :with_library_types) } + let(:library_creation_stage2) { create(:library_request_type, :with_library_types) } + let(:mx_request_type) { create(:multiplex_request_type) } let(:request_type_option) do [library_creation_stage1.id, library_creation_stage2.id, mx_request_type.id, sequencing_request_type.id] end @@ -146,7 +147,7 @@ context 'when a single-plex submission' do let(:assets) { (1..sx_asset_count).map { |i| create(:sample_tube, name: "Asset#{i}") } } - let(:library_creation_request_type) { create :library_creation_request_type, :with_library_types } + let(:library_creation_request_type) { create(:library_creation_request_type, :with_library_types) } let(:request_type_option) { [library_creation_request_type.id, sequencing_request_type.id] } let(:submission) do create( @@ -216,33 +217,33 @@ end context 'when we have a multiplier for request type' do - let(:assets) { create_list :sample_tube, 2 } + let(:assets) { create_list(:sample_tube, 2) } let(:mx_request_type) do - create :multiplexed_library_creation_request_type, + create(:multiplexed_library_creation_request_type, asset_type: 'SampleTube', target_asset_type: 'LibraryTube', initial_state: 'pending', name: 'Multiplexed Library Creation', order: 1, - key: 'multiplexed_library_creation' + key: 'multiplexed_library_creation') end let(:lib_request_type) do - create :library_creation_request_type, + create(:library_creation_request_type, :with_library_types, asset_type: 'SampleTube', target_asset_type: 'LibraryTube', initial_state: 'pending', name: 'Library Creation', order: 1, - key: 'library_creation' + key: 'library_creation') end let(:sequencing_request_type) do - create :request_type, + create(:request_type, asset_type: 'LibraryTube', initial_state: 'pending', name: 'PE sequencing', order: 2, - key: 'pe_sequencing' + key: 'pe_sequencing') end context 'when a multiplication factor of 5 is provided' do diff --git a/spec/models/location_report_spec.rb b/spec/models/location_report_spec.rb index 53d6853f49..0050c4ecbe 100644 --- a/spec/models/location_report_spec.rb +++ b/spec/models/location_report_spec.rb @@ -13,7 +13,7 @@ let(:study_2) { studies[1] } let(:study_1_sponsor) { study_1.study_metadata.faculty_sponsor } let(:study_2_sponsor) { study_2.study_metadata.faculty_sponsor } - let(:user) { create :user, login: 'test' } + let(:user) { create(:user, login: 'test') } # setup plates let(:plate_1) do @@ -25,16 +25,16 @@ ) end let!(:plt_1_asset_audit) do - create :asset_audit, + create(:asset_audit, asset: plate_1, created_at: Time.zone.parse('June 15, 2020 15:41'), key: 'slf_receive_plates', - message: "Process '...' performed on instrument Reception fridge" - create :asset_audit, + message: "Process '...' performed on instrument Reception fridge") + create(:asset_audit, asset: plate_1, created_at: Time.zone.parse('June 16, 2020 15:42'), key: 'slf_receive_plates', - message: "Process '...' performed on instrument Reception fridge" + message: "Process '...' performed on instrument Reception fridge") # return the last audit only end let(:plt_1_purpose) { plate_1.plate_purpose.name } @@ -44,12 +44,12 @@ # add retention instruction metadata to plate 1 custom metadatum collection let(:retention_key) { 'retention_instruction' } let(:retention_value) { 'Long term storage' } - let(:plate_1_custom_metadatum_collection) { create :custom_metadatum_collection, asset: plate_1, user: } + let(:plate_1_custom_metadatum_collection) { create(:custom_metadatum_collection, asset: plate_1, user:) } let(:plate_1_custom_metadatum) do - create :custom_metadatum, + create(:custom_metadatum, custom_metadatum_collection: plate_1_custom_metadatum_collection, key: retention_key, - value: retention_value + value: retention_value) end let(:plate_2) do @@ -78,12 +78,12 @@ let(:plt_3_received_date) { 'Unknown' } # add retention instruction metadata to plate 3 custom metadatum collection - let(:plate_3_custom_metadatum_collection) { create :custom_metadatum_collection, asset: plate_3, user: } + let(:plate_3_custom_metadatum_collection) { create(:custom_metadatum_collection, asset: plate_3, user:) } let(:plate_3_custom_metadatum) do - create :custom_metadatum, + create(:custom_metadatum, custom_metadatum_collection: plate_3_custom_metadatum_collection, key: retention_key, - value: retention_value + value: retention_value) end let(:headers_line) do diff --git a/spec/models/lot_type_spec.rb b/spec/models/lot_type_spec.rb index 205c63e4bd..f0ce865f51 100644 --- a/spec/models/lot_type_spec.rb +++ b/spec/models/lot_type_spec.rb @@ -5,7 +5,7 @@ RSpec.describe LotType do context 'validating' do - before { create :lot } + before { create(:lot) } it { is_expected.to validate_uniqueness_of(:name).case_insensitive } end @@ -18,8 +18,8 @@ end describe '#lot' do - let(:lot_type) { create :lot_type } - let(:user) { create :user } + let(:lot_type) { create(:lot_type) } + let(:user) { create(:user) } let(:template) { PlateTemplate.new } let(:lot) { lot_type.create!(template:, user:, lot_number: '123456789', received_at: '2014-02-01') } diff --git a/spec/models/orders/automated_order_spec.rb b/spec/models/orders/automated_order_spec.rb index fa5d1c01f6..478dd62b83 100644 --- a/spec/models/orders/automated_order_spec.rb +++ b/spec/models/orders/automated_order_spec.rb @@ -4,17 +4,17 @@ require_relative 'shared_order_specs' RSpec.describe AutomatedOrder do - subject { build :automated_order, assets: } + subject { build(:automated_order, assets:) } let(:assets) { [tube] } - let(:tube) { create :multiplexed_library_tube, aliquots: } - let(:study) { create :study } - let(:project) { create :project } + let(:tube) { create(:multiplexed_library_tube, aliquots:) } + let(:study) { create(:study) } + let(:project) { create(:project) } it_behaves_like 'an automated order' context 'with a cross study/project tube' do - let(:aliquots) { create_list :tagged_aliquot, 2 } + let(:aliquots) { create_list(:tagged_aliquot, 2) } it { is_expected.to be_valid } end diff --git a/spec/models/orders/order_spec.rb b/spec/models/orders/order_spec.rb index 1ba21ada23..96d257f110 100644 --- a/spec/models/orders/order_spec.rb +++ b/spec/models/orders/order_spec.rb @@ -4,10 +4,10 @@ require_relative 'shared_order_specs' RSpec.describe Order do - let(:study) { create :study, state: study_state } + let(:study) { create(:study, state: study_state) } let(:study_state) { 'pending' } - let(:project) { create :project } - let(:asset) { create :empty_sample_tube } + let(:project) { create(:project) } + let(:asset) { create(:empty_sample_tube) } describe 'study and project autodetection' do # When automating submission creation, it is really useful if we can @@ -15,10 +15,10 @@ # don't want to trigger this behaviour accidentally if someone forgets to # specify a study. - subject(:order) { build :order, assets:, autodetect_studies:, autodetect_projects:, study: nil, project: nil } + subject(:order) { build(:order, assets:, autodetect_studies:, autodetect_projects:, study: nil, project: nil) } let(:assets) { [tube] } - let(:tube) { create :sample_tube, aliquots: } + let(:tube) { create(:sample_tube, aliquots:) } let(:study_state) { 'active' } context 'with autodetection turned on' do @@ -28,7 +28,7 @@ it_behaves_like 'an automated order' context 'with a cross study/project tube' do - let(:aliquots) { create_list :tagged_aliquot, 2 } + let(:aliquots) { create_list(:tagged_aliquot, 2) } # We may wish to relax this in future. I'm keeping the restriction in # place for the time being solely because we don't need the @@ -41,7 +41,7 @@ context 'with autodetection turned off' do let(:autodetect_studies) { false } let(:autodetect_projects) { false } - let(:aliquots) { create_list :tagged_aliquot, 2, study:, project: } + let(:aliquots) { create_list(:tagged_aliquot, 2, study:, project:) } it { is_expected.not_to be_valid } end @@ -49,15 +49,15 @@ context 'An order' do let(:shared_template) { 'shared_template' } - let(:asset_a) { create :sample_tube } - let(:order) { create :order, assets: [asset_a], template_name: shared_template } + let(:asset_a) { create(:sample_tube) } + let(:order) { create(:order, assets: [asset_a], template_name: shared_template) } it 'not detect duplicates when there are none' do expect(order.duplicates_within(1.month)).not_to be_truthy end context 'with the same asset in a different order' do - before { create :order, assets: [asset_a], template_name: 'other_template' } + before { create(:order, assets: [asset_a], template_name: 'other_template') } it 'not detect duplicates' do expect(order.duplicates_within(1.month)).not_to be_truthy @@ -66,10 +66,10 @@ context 'with the same sample in a similar order' do before do - @asset_b = create :sample_tube, sample: asset_a.samples.first - @secondary_submission = create :submission + @asset_b = create(:sample_tube, sample: asset_a.samples.first) + @secondary_submission = create(:submission) @secondary_order = - create :order, assets: [@asset_b], template_name: shared_template, submission: @secondary_submission + create(:order, assets: [@asset_b], template_name: shared_template, submission: @secondary_submission) end it 'detect duplicates' do @@ -97,7 +97,7 @@ %w[SequencingRequest].each do |request_class| context "with #{request_class}" do before do - @sequencing_request_type = create :request_type, request_class_name: request_class + @sequencing_request_type = create(:request_type, request_class_name: request_class) order.request_types << @sequencing_request_type.id end @@ -118,21 +118,21 @@ order = create(:order, study:, assets: [asset.receptacle], project:) assert order.valid? study.deactivate! - new_asset = create :empty_sample_tube + new_asset = create(:empty_sample_tube) order.assets << new_asset assert order.valid? end it 'knows if it has samples that can not be included in submission' do - sample_manifest = create :tube_sample_manifest_with_samples - order = create :order, assets: sample_manifest.labware + sample_manifest = create(:tube_sample_manifest_with_samples) + order = create(:order, assets: sample_manifest.labware) expect(order.not_ready_samples.count).to eq 5 sample = sample_manifest.samples.first sample.sample_metadata.update(supplier_name: 'new_name') expect(order.reload.not_ready_samples.count).to eq 4 - sample_tube_without_manifest = create_list :sample_tube, 1 - order = create :order, assets: sample_tube_without_manifest + sample_tube_without_manifest = create_list(:sample_tube, 1) + order = create(:order, assets: sample_tube_without_manifest) expect(order.all_samples).not_to be_empty expect(order.not_ready_samples).to be_empty end diff --git a/spec/models/orders/shared_order_specs.rb b/spec/models/orders/shared_order_specs.rb index a83dbba565..4a7efd96e9 100644 --- a/spec/models/orders/shared_order_specs.rb +++ b/spec/models/orders/shared_order_specs.rb @@ -2,7 +2,7 @@ shared_examples 'an automated order' do context 'with a cross study/project tube' do - let(:aliquots) { create_list :tagged_aliquot, 2 } + let(:aliquots) { create_list(:tagged_aliquot, 2) } it 'does not set study' do subject.valid? @@ -16,7 +16,7 @@ end context 'with a single study/project tube' do - let(:aliquots) { create_list :tagged_aliquot, 2, study:, project: } + let(:aliquots) { create_list(:tagged_aliquot, 2, study:, project:) } it { is_expected.to be_valid } @@ -32,8 +32,8 @@ context 'with two single study/project assets in different studies' do let(:assets) { [tube, other_tube] } - let(:other_tube) { create :multiplexed_library_tube, aliquots: other_aliquots } - let(:other_aliquots) { create_list :tagged_aliquot, 1 } + let(:other_tube) { create(:multiplexed_library_tube, aliquots: other_aliquots) } + let(:other_aliquots) { create_list(:tagged_aliquot, 1) } it { is_expected.not_to be_valid } end diff --git a/spec/models/phi_x/spiked_buffer_spec.rb b/spec/models/phi_x/spiked_buffer_spec.rb index 71181f96aa..f4a25b83da 100644 --- a/spec/models/phi_x/spiked_buffer_spec.rb +++ b/spec/models/phi_x/spiked_buffer_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe PhiX::SpikedBuffer, :phi_x do - subject { build :phi_x_spiked_buffer, custom_options } + subject { build(:phi_x_spiked_buffer, custom_options) } context 'with suitable options' do let(:custom_options) { {} } # Fallback to factory defaults @@ -46,7 +46,7 @@ end context 'with a non-PhiX containing parent' do - let(:parent) { create :library_tube } + let(:parent) { create(:library_tube) } let(:custom_options) { { parent_barcode: parent.machine_barcode, parent: nil } } it { is_expected.not_to be_valid } @@ -56,20 +56,20 @@ context 'with valid data' do subject(:save) { phi_x_spiked_buffer.save } - let(:stock_study) { create :study } + let(:stock_study) { create(:study) } - let(:parent) { create :phi_x_stock_tube, study: stock_study } + let(:parent) { create(:phi_x_stock_tube, study: stock_study) } let(:study_id) { nil } let(:phi_x_spiked_buffer) do - build :phi_x_spiked_buffer, + build(:phi_x_spiked_buffer, name: 'Example', parent_barcode: parent.human_barcode, parent: nil, concentration: '0.8', volume: '10', number: 2, - study_id: + study_id:) end before { save } @@ -135,7 +135,7 @@ end context 'with invalid data' do - let(:phi_x_spiked_buffer) { build :phi_x_spiked_buffer, number: -2 } + let(:phi_x_spiked_buffer) { build(:phi_x_spiked_buffer, number: -2) } it 'returns false' do expect(phi_x_spiked_buffer.save).to be false @@ -145,17 +145,17 @@ describe '#tags' do let(:phi_x_spiked_buffer) do - build :phi_x_spiked_buffer, + build(:phi_x_spiked_buffer, name: 'Example', parent_barcode: parent.human_barcode, parent: nil, concentration: '0.8', volume: '10', - number: 2 + number: 2) end context 'when single' do - let(:parent) { create :phi_x_stock_tube, tag_option: 'Single' } + let(:parent) { create(:phi_x_stock_tube, tag_option: 'Single') } it 'returns Single' do expect(phi_x_spiked_buffer.tags).to eq('Single') @@ -163,7 +163,7 @@ end context 'when dual' do - let(:parent) { create :phi_x_stock_tube, tag_option: 'Dual' } + let(:parent) { create(:phi_x_stock_tube, tag_option: 'Dual') } it 'returns Dual' do expect(phi_x_spiked_buffer.tags).to eq('Dual') diff --git a/spec/models/phi_x/stock_spec.rb b/spec/models/phi_x/stock_spec.rb index 8fe4476867..4c9973a7c4 100644 --- a/spec/models/phi_x/stock_spec.rb +++ b/spec/models/phi_x/stock_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe PhiX::Stock, :phi_x do - subject { build :phi_x_stock, custom_options } + subject { build(:phi_x_stock, custom_options) } context 'with suitable options' do let(:custom_options) { {} } # Fallback to factory defaults @@ -49,7 +49,7 @@ context 'with valid data' do subject(:save) { phi_x_stock.save } - let(:phi_x_stock) { build :phi_x_stock, number: 2, name: 'Example', concentration: '0.8', tags:, study_id: } + let(:phi_x_stock) { build(:phi_x_stock, number: 2, name: 'Example', concentration: '0.8', tags:, study_id:) } let(:tags) { 'Single' } let(:study_id) { build_stubbed(:study).id } @@ -116,7 +116,7 @@ end context 'with invalid data' do - let(:phi_x_stock) { build :phi_x_stock, number: -2 } + let(:phi_x_stock) { build(:phi_x_stock, number: -2) } it 'returns false' do expect(phi_x_stock.save).to be false diff --git a/spec/models/pick_list_spec.rb b/spec/models/pick_list_spec.rb index 64e228e430..026edb5948 100644 --- a/spec/models/pick_list_spec.rb +++ b/spec/models/pick_list_spec.rb @@ -4,14 +4,14 @@ RSpec.describe PickList, :pick_list do subject(:pick_list) { described_class.new(pick_attributes: picks, asynchronous:) } - let(:wells) { create_list :untagged_well, 2 } + let(:wells) { create_list(:untagged_well, 2) } let(:asynchronous) { false } let(:picks) { wells.map { |well| { source_receptacle: well } } } - let(:project) { create :project } + let(:project) { create(:project) } before do - rt = create :cherrypick_request_type, key: 'cherrypick' - create :cherrypick_pipeline, request_type: rt + rt = create(:cherrypick_request_type, key: 'cherrypick') + create(:cherrypick_pipeline, request_type: rt) end describe '#valid?' do @@ -22,13 +22,13 @@ end context 'when wells lack project information' do - let(:wells) { create_list :untagged_well, 2, project: nil } + let(:wells) { create_list(:untagged_well, 2, project: nil) } it { is_expected.not_to be_valid } end context 'when wells lack project information but the pick provides it' do - let(:wells) { create_list :untagged_well, 2, project: nil } + let(:wells) { create_list(:untagged_well, 2, project: nil) } let(:picks) { wells.map { |well| { source_receptacle: well, project: } } } it { is_expected.to be_valid } diff --git a/spec/models/plate/quad_creator_spec.rb b/spec/models/plate/quad_creator_spec.rb index b8bf4bd7cd..c983cbf66f 100644 --- a/spec/models/plate/quad_creator_spec.rb +++ b/spec/models/plate/quad_creator_spec.rb @@ -7,8 +7,8 @@ RSpec.describe Plate::QuadCreator do subject(:quad_creator) { described_class.new(creation_options) } - let(:target_purpose) { create :plate_purpose, size: 384 } - let(:user) { create :user } + let(:target_purpose) { create(:plate_purpose, size: 384) } + let(:user) { create(:user) } let(:creation_options) { { parent_barcodes: parent_barcodes_hash, target_purpose:, user: } } before { allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode)) } @@ -45,7 +45,7 @@ end context 'when a parent is not a plate or rack' do - let(:tube) { create :tube } + let(:tube) { create(:tube) } # this should pass in the tube, not the barcode let(:parent_barcodes_hash) { { 'quad_1' => tube.machine_barcode } } @@ -61,7 +61,7 @@ end context 'when a parent is the wrong size' do - let(:plate) { create :plate, size: 384 } + let(:plate) { create(:plate, size: 384) } # this should pass in the plate, not the barcode let(:parent_barcodes_hash) { { 'quad_1' => plate.machine_barcode } } @@ -83,7 +83,7 @@ let(:number_of_parents) { 4 } # 2 wells in each, A1 & H12 - let(:parents) { create_list :plate_with_untagged_wells, number_of_parents, occupied_well_index: occupied_wells } + let(:parents) { create_list(:plate_with_untagged_wells, number_of_parents, occupied_well_index: occupied_wells) } let(:parent_barcodes_hash) do { 'quad_1' => parents[0].machine_barcode, @@ -144,7 +144,7 @@ end context 'with 1 parent' do - let(:parents) { create_list :plate_with_untagged_wells, 1, occupied_well_index: [0, 95] } # 2 wells, A1 & H12 + let(:parents) { create_list(:plate_with_untagged_wells, 1, occupied_well_index: [0, 95]) } # 2 wells, A1 & H12 let(:parent_barcodes_hash) { { 'quad_3' => parents[0].machine_barcode } } let(:quad_3_wells) { parents[0].wells.index_by(&:map_description) } @@ -171,7 +171,7 @@ context 'with parent tube racks' do context 'with 4 parents' do - let(:parents) { create_list :tube_rack_with_tubes, 4 } + let(:parents) { create_list(:tube_rack_with_tubes, 4) } let(:parent_barcodes_hash) do { 'quad_1' => parents[0].machine_barcode, @@ -213,8 +213,8 @@ context 'with a mixture of parent plates and racks' do # 2 wells in each, A1 & H12 - let(:parents_plates) { create_list :plate_with_untagged_wells, 2, occupied_well_index: [0, 95] } - let(:parents_racks) { create_list :tube_rack_with_tubes, 2 } + let(:parents_plates) { create_list(:plate_with_untagged_wells, 2, occupied_well_index: [0, 95]) } + let(:parents_racks) { create_list(:tube_rack_with_tubes, 2) } let(:parent_barcodes_hash) do { diff --git a/spec/models/plate/sample_tube_factory_spec.rb b/spec/models/plate/sample_tube_factory_spec.rb index f3a0be109e..03de26c907 100644 --- a/spec/models/plate/sample_tube_factory_spec.rb +++ b/spec/models/plate/sample_tube_factory_spec.rb @@ -4,8 +4,8 @@ RSpec.describe Plate::SampleTubeFactory do it 'sends print request' do - plate = create :plate, :with_wells, well_count: 2 - barcode_printer = create :barcode_printer + plate = create(:plate, :with_wells, well_count: 2) + barcode_printer = create(:barcode_printer) expect(RestClient).to receive(:post) diff --git a/spec/models/plate_purpose/additional_input_spec.rb b/spec/models/plate_purpose/additional_input_spec.rb index 5893196688..e5a25c6554 100644 --- a/spec/models/plate_purpose/additional_input_spec.rb +++ b/spec/models/plate_purpose/additional_input_spec.rb @@ -14,7 +14,7 @@ describe '#state_of' do subject(:state_of) { plate_purpose_input.state_of(plate) } - let(:plate) { create :plate, :with_wells, well_count: 2, purpose: plate_purpose_input } + let(:plate) { create(:plate, :with_wells, well_count: 2, purpose: plate_purpose_input) } context 'with no requests' do it 'is pending' do @@ -23,7 +23,7 @@ end context 'with ancestors' do - let(:parent_plate) { create :plate } + let(:parent_plate) { create(:plate) } let(:plate) { create(:target_plate, parent: parent_plate, purpose: plate_purpose_input) } context 'with no library requests' do @@ -45,7 +45,7 @@ end context 'with no ancestors' do - let(:plate) { create :plate_with_untagged_wells, well_count: 2, purpose: plate_purpose_input } + let(:plate) { create(:plate_with_untagged_wells, well_count: 2, purpose: plate_purpose_input) } context 'with no library requests' do it 'is pending' do diff --git a/spec/models/plate_purpose/input_spec.rb b/spec/models/plate_purpose/input_spec.rb index c595a9d709..d227d04f7a 100644 --- a/spec/models/plate_purpose/input_spec.rb +++ b/spec/models/plate_purpose/input_spec.rb @@ -5,8 +5,8 @@ # This behaviour is necessary because of limitations in generic lims # We can switch to the PlatePurpose::Input class once we're in limber describe PlatePurpose::Input do - let(:plate_purpose_input) { create :input_plate_purpose } - let(:plate) { create :plate, purpose: plate_purpose_input, well_count: 2, well_factory: :untagged_well } + let(:plate_purpose_input) { create(:input_plate_purpose) } + let(:plate) { create(:plate, purpose: plate_purpose_input, well_count: 2, well_factory: :untagged_well) } describe '#state_of' do subject(:state_of) { plate_purpose_input.state_of(plate) } @@ -18,7 +18,7 @@ end context 'with two pending requests' do - before { plate.wells.each { |well| create :request_library_creation, asset: well } } + before { plate.wells.each { |well| create(:request_library_creation, asset: well) } } it 'is passed' do expect(state_of).to eq('passed') @@ -26,7 +26,7 @@ end context 'with two failed requests' do - before { plate.wells.each { |well| create :request_library_creation, asset: well, state: 'failed' } } + before { plate.wells.each { |well| create(:request_library_creation, asset: well, state: 'failed') } } it 'is failed' do expect(state_of).to eq('failed') @@ -34,7 +34,7 @@ end context 'with two cancelled requests' do - before { plate.wells.each { |well| create :request_library_creation, asset: well, state: 'cancelled' } } + before { plate.wells.each { |well| create(:request_library_creation, asset: well, state: 'cancelled') } } it 'is cancelled' do expect(state_of).to eq('cancelled') @@ -43,8 +43,8 @@ context 'with a mix of cancelled and failed requests' do before do - create :request_library_creation, asset: plate.wells.first, state: 'cancelled' - create :request_library_creation, asset: plate.wells.last, state: 'failed' + create(:request_library_creation, asset: plate.wells.first, state: 'cancelled') + create(:request_library_creation, asset: plate.wells.last, state: 'failed') end it 'is failed' do @@ -53,7 +53,7 @@ end context 'with two active requests' do - before { plate.wells.each { |well| create_list :request_library_creation, 2, asset: well } } + before { plate.wells.each { |well| create_list(:request_library_creation, 2, asset: well) } } it 'is passed' do expect(state_of).to eq('passed') @@ -63,8 +63,8 @@ context 'with one active and one cancelled requests' do before do plate.wells.each do |well| - create :request_library_creation, asset: well - create :request_library_creation, asset: well, state: 'cancelled' + create(:request_library_creation, asset: well) + create(:request_library_creation, asset: well, state: 'cancelled') end end diff --git a/spec/models/plate_purpose_spec.rb b/spec/models/plate_purpose_spec.rb index f9a8aa24aa..67d8aa808e 100644 --- a/spec/models/plate_purpose_spec.rb +++ b/spec/models/plate_purpose_spec.rb @@ -4,7 +4,7 @@ require 'shared_contexts/limber_shared_context' describe PlatePurpose do - let(:plate_purpose) { create :plate_purpose, target_type:, size: } + let(:plate_purpose) { create(:plate_purpose, target_type:, size:) } shared_examples 'a plate factory' do before { expect(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode)) } diff --git a/spec/models/plate_spec.rb b/spec/models/plate_spec.rb index 133f3a302b..16d5ff2b7b 100644 --- a/spec/models/plate_spec.rb +++ b/spec/models/plate_spec.rb @@ -5,9 +5,9 @@ describe Plate do describe '#comments' do - let(:plate) { create :plate, well_count: 2 } + let(:plate) { create(:plate, well_count: 2) } - before { create :comment, commentable: plate, description: 'Comment on plate' } + before { create(:comment, commentable: plate, description: 'Comment on plate') } it 'allows comment addition' do plate.comments.create!(description: 'Works') @@ -24,9 +24,9 @@ context 'with requests out of the wells' do before do - submission = create :submission + submission = create(:submission) request = create(:well_request, asset: plate.wells.first, submission:) - create :comment, commentable: request, description: 'Comment on request' + create(:comment, commentable: request, description: 'Comment on request') plate.reload end @@ -45,11 +45,11 @@ context 'with requests in progress the wells' do before do - submission = create :submission + submission = create(:submission) request = create(:well_request, submission:) plate.wells.first.aliquots << create(:aliquot, request:) create(:transfer_request, target_asset: plate.wells.first, submission:) - create :comment, commentable: request, description: 'Comment on request' + create(:comment, commentable: request, description: 'Comment on request') plate.reload end @@ -62,12 +62,12 @@ context 'with multiple identical comments' do before do - submission = create :submission + submission = create(:submission) request = create(:well_request, asset: plate.wells.first, submission:) request2 = create(:well_request, asset: plate.wells.last, submission:) - create :comment, commentable: request, description: 'Duplicate comment' - create :comment, commentable: request2, description: 'Duplicate comment' - create :comment, commentable: plate, description: 'Duplicate comment' + create(:comment, commentable: request, description: 'Duplicate comment') + create(:comment, commentable: request2, description: 'Duplicate comment') + create(:comment, commentable: plate, description: 'Duplicate comment') plate.reload end @@ -82,7 +82,7 @@ context 'barcodes' do # Maintaining existing barcode behaviour context 'sanger barcodes' do - let(:plate) { create :plate } + let(:plate) { create(:plate) } describe '#human_barcode' do subject { plate.human_barcode } diff --git a/spec/models/plate_type_spec.rb b/spec/models/plate_type_spec.rb index 1b41ee4be3..e1c8079641 100644 --- a/spec/models/plate_type_spec.rb +++ b/spec/models/plate_type_spec.rb @@ -3,14 +3,14 @@ require 'rails_helper' describe PlateType do - let(:plate_type) { create :plate_type } + let(:plate_type) { create(:plate_type) } let(:invalid_plate_type) { described_class.new } before do - create :plate_type, name: 'ABgene_0765', maximum_volume: 800 - create :plate_type, name: 'ABgene_0800', maximum_volume: 180 - create :plate_type, name: 'FluidX075', maximum_volume: 500 - create :plate_type, name: 'FluidX03', maximum_volume: 280 + create(:plate_type, name: 'ABgene_0765', maximum_volume: 800) + create(:plate_type, name: 'ABgene_0800', maximum_volume: 180) + create(:plate_type, name: 'FluidX075', maximum_volume: 500) + create(:plate_type, name: 'FluidX03', maximum_volume: 280) end it 'has name and maximum volume' do diff --git a/spec/models/plate_volume_spec.rb b/spec/models/plate_volume_spec.rb index 13c5733808..5dc7a33e17 100644 --- a/spec/models/plate_volume_spec.rb +++ b/spec/models/plate_volume_spec.rb @@ -5,11 +5,11 @@ describe PlateVolume do let(:plate_with_barcodes_in_csv) do # This plate has a CSV file in which the barcode is listed in the column - create :plate, barcode: 'SQPD-1234567', well_count: 24, well_factory: :untagged_well, well_order: :row_order + create(:plate, barcode: 'SQPD-1234567', well_count: 24, well_factory: :untagged_well, well_order: :row_order) end let(:plate_without_barcodes_in_csv) do # This plate barcode is only used to name the volume check file - create :plate, barcode: 'SQPD-111', well_count: 24, well_factory: :untagged_well, well_order: :row_order + create(:plate, barcode: 'SQPD-111', well_count: 24, well_factory: :untagged_well, well_order: :row_order) end describe '::process_all_volume_check_files' do diff --git a/spec/models/pooling_spec.rb b/spec/models/pooling_spec.rb index a40a679db3..68b0f2ac40 100644 --- a/spec/models/pooling_spec.rb +++ b/spec/models/pooling_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' describe Pooling, :poolings do - let(:empty_lb_tube) { create :empty_library_tube, barcode: 1 } - let(:untagged_lb_tube1) { create :library_tube, barcode: 2 } - let(:untagged_lb_tube2) { create :library_tube, barcode: 3 } - let(:tagged_lb_tube1) { create :tagged_library_tube, barcode: 4 } - let(:tagged_lb_tube2) { create :tagged_library_tube, barcode: 5 } - let(:mx_tube) { create :multiplexed_library_tube, barcode: 6 } + let(:empty_lb_tube) { create(:empty_library_tube, barcode: 1) } + let(:untagged_lb_tube1) { create(:library_tube, barcode: 2) } + let(:untagged_lb_tube2) { create(:library_tube, barcode: 3) } + let(:tagged_lb_tube1) { create(:tagged_library_tube, barcode: 4) } + let(:tagged_lb_tube2) { create(:tagged_library_tube, barcode: 5) } + let(:mx_tube) { create(:multiplexed_library_tube, barcode: 6) } let(:stock_mx_tube_required) { false } let(:barcode_printer_option) { nil } let(:pooling) do @@ -104,7 +104,7 @@ # failing to disambiguate between them. context 'when the source tubes are from an mx library manifest' do before do - create :create_asset_request, asset: tagged_lb_tube1.receptacle + create(:create_asset_request, asset: tagged_lb_tube1.receptacle) create(:external_multiplexed_library_tube_creation_request, asset: tagged_lb_tube1.receptacle) end @@ -116,7 +116,7 @@ end context 'when a barcode printer is provided' do - let(:barcode_printer) { create :barcode_printer } + let(:barcode_printer) { create(:barcode_printer) } let(:barcode_printer_option) { barcode_printer.name } it 'executes print_job' do diff --git a/spec/models/primer_panel_spec.rb b/spec/models/primer_panel_spec.rb index 1caa304eb7..5423b23d0d 100644 --- a/spec/models/primer_panel_spec.rb +++ b/spec/models/primer_panel_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe PrimerPanel do - let(:primer_panel) { create :primer_panel } + let(:primer_panel) { create(:primer_panel) } it 'validates a valid primer panel' do expect(primer_panel).to be_valid diff --git a/spec/models/pulldown/requests/isc_library_request_spec.rb b/spec/models/pulldown/requests/isc_library_request_spec.rb index 55287ce817..0472df90b9 100644 --- a/spec/models/pulldown/requests/isc_library_request_spec.rb +++ b/spec/models/pulldown/requests/isc_library_request_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Pulldown::Requests::IscLibraryRequest do - subject { build :isc_request, bait_library: } + subject { build(:isc_request, bait_library:) } context 'with a active bait library' do let(:bait_library) { create(:bait_library) } diff --git a/spec/models/qc_report_spec.rb b/spec/models/qc_report_spec.rb index 106e027a8d..394bdc5707 100644 --- a/spec/models/qc_report_spec.rb +++ b/spec/models/qc_report_spec.rb @@ -15,26 +15,26 @@ attr_reader :study, :other_study, :stock_plate, :qc_report, :qc_metric_count before do - @study = create :study - @other_study = create :study - @stock_plate = create :plate, purpose: PlatePurpose.find_or_create_by(name: 'Stock plate') + @study = create(:study) + @other_study = create(:study) + @stock_plate = create(:plate, purpose: PlatePurpose.find_or_create_by(name: 'Stock plate')) [@study, @other_study].each do |study| 2.times do |i| - attribute = create :well_attribute, current_volume: 500, concentration: 200 + attribute = create(:well_attribute, current_volume: 500, concentration: 200) sample = create(:study_sample, study:).sample sample.update!(sanger_sample_id: 'TEST1') well = - create :well, + create(:well, samples: [sample], plate: stock_plate, map: create(:map, location_id: i), - well_attribute: attribute + well_attribute: attribute) well.aliquots.each { |a| a.update!(study:) } end end - @qc_report = create :qc_report, study: @study + @qc_report = create(:qc_report, study: @study) @qc_metric_count = QcMetric.count Delayed::Worker.new.work_off end @@ -73,65 +73,65 @@ :other_reported_sample before do - @study = create :study - @stock_plate = create :plate, purpose: PlatePurpose.find_or_create_by(name: 'Stock plate') + @study = create(:study) + @stock_plate = create(:plate, purpose: PlatePurpose.find_or_create_by(name: 'Stock plate')) - @current_criteria = create :product_criteria - @other_criteria = create :product_criteria + @current_criteria = create(:product_criteria) + @other_criteria = create(:product_criteria) @matching_report = - create :qc_report, + create(:qc_report, study:, exclude_existing: true, product_criteria: current_criteria, - report_identifier: 'Override' - @other_report = create :qc_report, study:, exclude_existing: true, product_criteria: other_criteria + report_identifier: 'Override') + @other_report = create(:qc_report, study:, exclude_existing: true, product_criteria: other_criteria) - @attribute = create :well_attribute, current_volume: 500, concentration: 200 + @attribute = create(:well_attribute, current_volume: 500, concentration: 200) sample = create(:study_sample, study:).sample @unreported_sample = well = - create :well, + create(:well, samples: [sample], plate: stock_plate, map: create(:map, location_id: 1), - well_attribute: attribute + well_attribute: attribute) well.aliquots.each { |a| a.update!(study:) } sample = create(:study_sample, study:).sample well = - create :well, + create(:well, samples: [sample], plate: stock_plate, map: create(:map, location_id: 2), - well_attribute: attribute + well_attribute: attribute) well.aliquots.each { |a| a.update!(study:) } - create :qc_metric, asset: well, qc_report: matching_report + create(:qc_metric, asset: well, qc_report: matching_report) sample = create(:study_sample, study:).sample @other_reported_sample = well = - create :well, + create(:well, samples: [sample], plate: stock_plate, map: create(:map, location_id: 3), - well_attribute: attribute + well_attribute: attribute) well.aliquots.each { |a| a.update!(study:) } - create :qc_metric, asset: well, qc_report: other_report + create(:qc_metric, asset: well, qc_report: other_report) sample = create(:study_sample, study:).sample well = - create :well, + create(:well, samples: [sample], plate: stock_plate, map: create(:map, location_id: 4), - well_attribute: attribute + well_attribute: attribute) well.aliquots.each { |a| a.update!(study:) } - create :qc_metric, asset: well, qc_report: matching_report - create :qc_metric, asset: well, qc_report: other_report + create(:qc_metric, asset: well, qc_report: matching_report) + create(:qc_metric, asset: well, qc_report: other_report) - @qc_report = create :qc_report, study:, exclude_existing: true, product_criteria: current_criteria + @qc_report = create(:qc_report, study:, exclude_existing: true, product_criteria: current_criteria) @qc_metric_count = QcMetric.count qc_report.generate! end @@ -164,7 +164,7 @@ attr_reader :qc_report let!(:study) { create(:study) } - let(:plate_purposes) { create_list :plate_purpose, 3 } + let(:plate_purposes) { create_list(:plate_purpose, 3) } let(:plate_purpose_names) { plate_purposes.map(&:name) } before do @@ -173,11 +173,11 @@ create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[2])) @qc_report = - create :qc_report, + create(:qc_report, study:, exclude_existing: false, product_criteria: create(:product_criteria), - plate_purposes: plate_purpose_names + plate_purposes: plate_purpose_names) qc_report.generate! end diff --git a/spec/models/qc_result/qc_result_spec.rb b/spec/models/qc_result/qc_result_spec.rb index 2724eaacff..eeed0789b5 100644 --- a/spec/models/qc_result/qc_result_spec.rb +++ b/spec/models/qc_result/qc_result_spec.rb @@ -51,11 +51,11 @@ end context 'with an asset' do - let(:asset) { build :receptacle } + let(:asset) { build(:receptacle) } it 'can update its asset' do expect(asset).to receive(:update_from_qc).with(an_instance_of(described_class)) - create :qc_result, asset: + create(:qc_result, asset:) end end end @@ -65,7 +65,7 @@ before { warren.clear_messages } - let(:resource) { build :qc_result } + let(:resource) { build(:qc_result) } let(:routing_key) { 'message.qc_result.' } it 'broadcasts the resource' do diff --git a/spec/models/racked_tube_spec.rb b/spec/models/racked_tube_spec.rb index 64c26ff7ed..2bfa4147a5 100644 --- a/spec/models/racked_tube_spec.rb +++ b/spec/models/racked_tube_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' RSpec.describe RackedTube do describe '#create' do - let!(:tube_rack) { create :tube_rack } - let!(:tube) { create :tube } + let!(:tube_rack) { create(:tube_rack) } + let!(:tube) { create(:tube) } it 'allows a tube rack to be accessed from a tube' do racked_tube = described_class.create(tube_rack_id: tube_rack.id, tube_id: tube.id) @@ -24,8 +24,8 @@ end describe '#update' do - let!(:tube_rack) { create :tube_rack } - let!(:tube) { create :tube } + let!(:tube_rack) { create(:tube_rack) } + let!(:tube) { create(:tube) } let!(:racked_tube) { described_class.create(tube_rack_id: tube_rack.id, tube_id: tube.id) } it 'can be updated' do @@ -36,8 +36,8 @@ end describe '#destroy' do - let!(:tube_rack) { create :tube_rack } - let!(:tube) { create :tube } + let!(:tube_rack) { create(:tube_rack) } + let!(:tube) { create(:tube) } let!(:racked_tube) { described_class.create(tube_rack_id: tube_rack.id, tube_id: tube.id) } it 'can be destroyed without affecting the tube or tube rack' do @@ -49,10 +49,10 @@ end describe 'scope:: in_column_major_order' do - let(:tube_rack) { create :tube_rack } + let(:tube_rack) { create(:tube_rack) } let(:num_tubes) { locations.length } let(:locations) { %w[A01 H12 D04] } - let(:barcodes) { Array.new(num_tubes) { create :fluidx } } + let(:barcodes) { Array.new(num_tubes) { create(:fluidx) } } before do Array.new(num_tubes) do |i| diff --git a/spec/models/receptacle_spec.rb b/spec/models/receptacle_spec.rb index 51a566f407..719ca56fa8 100644 --- a/spec/models/receptacle_spec.rb +++ b/spec/models/receptacle_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Receptacle do - let(:receptacle) { create :receptacle } + let(:receptacle) { create(:receptacle) } # Uhh, looks like all our asset tests were labware tests! @@ -12,10 +12,10 @@ end describe '#most_recent_requests_as_target_group_by_same_source' do - let(:source) { create :receptacle } - let(:source2) { create :receptacle } - let(:requests_source1) { create_list :request, 3, { asset: source } } - let(:requests_source2) { create_list :request, 2, { asset: source2 } } + let(:source) { create(:receptacle) } + let(:source2) { create(:receptacle) } + let(:requests_source1) { create_list(:request, 3, { asset: source }) } + let(:requests_source2) { create_list(:request, 2, { asset: source2 }) } let(:requests) { [requests_source1, requests_source2].flatten } let(:expected) { [requests_source1.last, requests_source2.last].flatten } @@ -27,7 +27,7 @@ end describe '#update_from_qc' do - let(:qc_result) { build :qc_result, key:, value:, units:, assay_type: 'assay', assay_version: 1 } + let(:qc_result) { build(:qc_result, key:, value:, units:, assay_type: 'assay', assay_version: 1) } before { receptacle.update_from_qc(qc_result) } @@ -62,39 +62,39 @@ end describe '#pcr_cycles' do - let(:receptacle) { create :receptacle, pcr_cycles: 10 } + let(:receptacle) { create(:receptacle, pcr_cycles: 10) } it { expect(receptacle.pcr_cycles).to eq 10 } end describe '#submit_for_sequencing' do - let(:receptacle) { create :receptacle, submit_for_sequencing: true } + let(:receptacle) { create(:receptacle, submit_for_sequencing: true) } it { expect(receptacle.submit_for_sequencing).to be true } end describe '#sub_pool' do - let(:receptacle) { create :receptacle, sub_pool: 5 } + let(:receptacle) { create(:receptacle, sub_pool: 5) } it { expect(receptacle.sub_pool).to eq 5 } end describe '#coverage' do - let(:receptacle) { create :receptacle, coverage: 100 } + let(:receptacle) { create(:receptacle, coverage: 100) } it { expect(receptacle.coverage).to eq 100 } end describe '#diluent_volume' do - let(:receptacle) { create :receptacle, diluent_volume: 40 } + let(:receptacle) { create(:receptacle, diluent_volume: 40) } it { expect(receptacle.diluent_volume).to eq 40 } end describe '#attach_tag' do - let(:tag1) { create :tag } - let(:tag2) { create :tag } - let(:receptacle) { create :receptacle } + let(:tag1) { create(:tag) } + let(:tag2) { create(:tag) } + let(:receptacle) { create(:receptacle) } before { receptacle.update(aliquots:) } @@ -108,7 +108,7 @@ context 'when the receptacle has one aliquot' do let(:aliquots) { [al1] } - let(:al1) { create :aliquot } + let(:al1) { create(:aliquot) } it 'can attach a tag to an aliquot' do receptacle.attach_tag(tag1, tag2) @@ -119,8 +119,8 @@ let(:aliquots) { [al1, al2] } context 'when every aliquot has a different tag_depth' do - let(:al1) { create :aliquot, tag_depth: 1 } - let(:al2) { create :aliquot, tag_depth: 2 } + let(:al1) { create(:aliquot, tag_depth: 1) } + let(:al2) { create(:aliquot, tag_depth: 2) } it 'can attach a tag to every aliquot' do receptacle.attach_tag(tag1, tag2) @@ -128,8 +128,8 @@ end context 'when there is duplication in tag_depths' do - let(:al1) { create :aliquot, tag_depth: 1 } - let(:al2) { create :aliquot, tag_depth: 1 } + let(:al1) { create(:aliquot, tag_depth: 1) } + let(:al2) { create(:aliquot, tag_depth: 1) } it 'raises an error' do expect { receptacle.attach_tag(tag1, tag2) }.to raise_error(StandardError) @@ -137,8 +137,8 @@ end context 'when there is no tag_depth' do - let(:al1) { create :aliquot } - let(:al2) { create :aliquot } + let(:al1) { create(:aliquot) } + let(:al2) { create(:aliquot) } it 'raises an error' do expect { receptacle.attach_tag(tag1, tag2) }.to raise_error(StandardError) diff --git a/spec/models/request/sample_compound_aliquot_transfer_spec.rb b/spec/models/request/sample_compound_aliquot_transfer_spec.rb index 0a7dfffa75..608dac72ef 100644 --- a/spec/models/request/sample_compound_aliquot_transfer_spec.rb +++ b/spec/models/request/sample_compound_aliquot_transfer_spec.rb @@ -5,23 +5,23 @@ # Test for module to provide support to create a compound sample during the # sequencing request start from all the samples at source of the request RSpec.describe 'Request::SampleCompoundAliquotTransfer' do - let(:samples) { create_list :sample, 3 } - let(:study1) { create :study } - let(:study2) { create :study } - let(:project1) { create :project } - let(:project2) { create :project } - let(:destination) { create :receptacle } - let(:source) { create :receptacle, aliquots: [aliquot1, aliquot2] } - let(:library_tube) { create :library_tube, receptacles: [source] } + let(:samples) { create_list(:sample, 3) } + let(:study1) { create(:study) } + let(:study2) { create(:study) } + let(:project1) { create(:project) } + let(:project2) { create(:project) } + let(:destination) { create(:receptacle) } + let(:source) { create(:receptacle, aliquots: [aliquot1, aliquot2]) } + let(:library_tube) { create(:library_tube, receptacles: [source]) } let(:sequencing_request) do create(:sequencing_request, asset: source, target_asset: destination, initial_study_id: study1.id) end - let(:tags) { create_list :tag, 3 } + let(:tags) { create_list(:tag, 3) } describe '#compound_samples_needed?' do context 'when number of aliquots is 1' do - let(:aliquot1) { create :aliquot, sample: samples[0], tag_id: 1, tag_depth: 1, project: project1 } - let(:source) { create :receptacle, aliquots: [aliquot1] } + let(:aliquot1) { create(:aliquot, sample: samples[0], tag_id: 1, tag_depth: 1, project: project1) } + let(:source) { create(:receptacle, aliquots: [aliquot1]) } it 'returns false' do expect(sequencing_request).not_to be_compound_samples_needed @@ -29,8 +29,10 @@ end context 'when there is no tag clash, using tags 1 and 2' do - let(:aliquot1) { create :aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, project: project1 } - let(:aliquot2) { create :aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[2].id, project: project1 } + let(:aliquot1) do + create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, project: project1) end + let(:aliquot2) do + create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[2].id, project: project1) end it 'returns false' do expect(sequencing_request).not_to be_compound_samples_needed @@ -39,10 +41,10 @@ context 'when there is a tag clash, using tags 1 and 2' do let(:aliquot1) do - create :aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, project: project1 + create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, project: project1) end let(:aliquot2) do - create :aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, project: project1 + create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, project: project1) end it 'returns true' do @@ -53,7 +55,7 @@ describe '#transfer_aliquots_into_compound_sample_aliquots' do let(:aliquot1) do - create :aliquot, + create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, @@ -61,10 +63,10 @@ study: study1, project: project1, library_type: 'Standard', - library_id: 54 + library_id: 54) end let(:aliquot2) do - create :aliquot, + create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, @@ -72,7 +74,7 @@ study: study1, project: project1, library_type: 'Standard', - library_id: 54 + library_id: 54) end context 'when no compound sample exists with the component samples' do @@ -219,9 +221,9 @@ end context 'when there are two compound samples' do - let(:samples_extra) { create_list :sample, 2 } + let(:samples_extra) { create_list(:sample, 2) } let(:aliquot3) do - create :aliquot, + create(:aliquot, sample: samples_extra[0], tag_id: tags_extra[0].id, tag2_id: tags_extra[1].id, @@ -229,10 +231,10 @@ study: study2, project: project2, library_type: 'Standard', - library_id: 55 + library_id: 55) end let(:aliquot4) do - create :aliquot, + create(:aliquot, sample: samples_extra[1], tag_id: tags_extra[0].id, tag2_id: tags_extra[1].id, @@ -240,10 +242,10 @@ study: study2, project: project2, library_type: 'Standard', - library_id: 55 + library_id: 55) end - let(:tags_extra) { create_list :tag, 2 } - let(:source) { create :receptacle, aliquots: [aliquot1, aliquot2, aliquot3, aliquot4] } + let(:tags_extra) { create_list(:tag, 2) } + let(:source) { create(:receptacle, aliquots: [aliquot1, aliquot2, aliquot3, aliquot4]) } before { sequencing_request.update!(initial_study_id: nil) } diff --git a/spec/models/request/traction/grid_ion_spec.rb b/spec/models/request/traction/grid_ion_spec.rb index fd40ea4615..725ec2b013 100644 --- a/spec/models/request/traction/grid_ion_spec.rb +++ b/spec/models/request/traction/grid_ion_spec.rb @@ -5,19 +5,19 @@ describe Request::Traction::GridIon do subject do - build :request_traction_grid_ion, + build(:request_traction_grid_ion, asset: well, request_metadata_attributes: metadata, order:, submission:, request_type:, - state: + state:) end let(:order) { build(:order, submission:, assets: [well], request_types: [request_type.id]) } - let(:request_type) { create :well_request_type } + let(:request_type) { create(:well_request_type) } let(:submission) { build(:submission) } - let(:well) { create :well } + let(:well) { create(:well) } let(:state) { 'pending' } context 'with valid metadata' do diff --git a/spec/models/request_event_spec.rb b/spec/models/request_event_spec.rb index 3f4428063f..48d2af1230 100644 --- a/spec/models/request_event_spec.rb +++ b/spec/models/request_event_spec.rb @@ -4,7 +4,7 @@ describe RequestEvent do context 'Customer Requests' do - let!(:request) { create :customer_request, asset: create(:well), target_asset: create(:well) } + let!(:request) { create(:customer_request, asset: create(:well), target_asset: create(:well)) } context 'creating requests' do it 'records a RequestEvent' do diff --git a/spec/models/request_information_type_spec.rb b/spec/models/request_information_type_spec.rb index 119006403b..5383355688 100644 --- a/spec/models/request_information_type_spec.rb +++ b/spec/models/request_information_type_spec.rb @@ -8,14 +8,14 @@ describe '#value_for' do subject { request_information_type.value_for(request, batch) } - let(:batch) { create :batch } + let(:batch) { create(:batch) } let(:request) do - create :sequencing_request, + create(:sequencing_request, request_metadata_attributes: { read_length: 76, created_at: Date.parse('2021-03-01') }, - batch: + batch:) end context 'when key is a request metadata' do @@ -37,7 +37,7 @@ context 'when key is an event' do before do create(:lab_event, descriptors: { 'My event' => 'old value' }, eventful: request, batch:) - create :lab_event, descriptors: { 'My event' => 'new value' }, eventful: request, batch: + create(:lab_event, descriptors: { 'My event' => 'new value' }, eventful: request, batch:) end let(:name) { 'My event' } diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 9edef5b542..e1f7cc7232 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -3,22 +3,22 @@ require 'rails_helper' RSpec.describe Request do - let(:study) { create :study } - let(:project) { create :project } - let(:submission) { create :submission } - let(:order1) { create :order, study:, project:, submission: } - let(:order2) { create :order, study:, project:, submission: } - let(:order3) { create :order, study:, project:, submission: } - let(:order4) { create :order_with_submission, study:, project: } + let(:study) { create(:study) } + let(:project) { create(:project) } + let(:submission) { create(:submission) } + let(:order1) { create(:order, study:, project:, submission:) } + let(:order2) { create(:order, study:, project:, submission:) } + let(:order3) { create(:order, study:, project:, submission:) } + let(:order4) { create(:order_with_submission, study:, project:) } describe '#for_order_including_submission_based_requests' do before do @sequencing_request = create(:request_with_sequencing_request_type, submission:) - @request = create :request, order: order1, submission:, asset: @asset + @request = create(:request, order: order1, submission:, asset: @asset) @request2 = create(:request, order: order2, submission:) - @request3 = create :request, order: order4, submission: order4.submission - @sequencing_request2 = create :request_with_sequencing_request_type, submission: order4.submission + @request3 = create(:request, order: order4, submission: order4.submission) + @sequencing_request2 = create(:request_with_sequencing_request_type, submission: order4.submission) end it 'the sequencing requests are included' do @@ -59,16 +59,16 @@ describe '#next_request' do before do - @genotyping_request_type = create :request_type, name: 'genotyping' - @cherrypick_request_type = create :request_type, name: 'cherrypick', target_asset_type: nil + @genotyping_request_type = create(:request_type, name: 'genotyping') + @cherrypick_request_type = create(:request_type, name: 'cherrypick', target_asset_type: nil) @submission = FactoryHelp.submission( request_types: [@cherrypick_request_type, @genotyping_request_type].map(&:id), asset_group_name: 'to avoid asset errors' ) - @genotype_pipeline = create :pipeline, name: 'genotyping pipeline', request_types: [@genotyping_request_type] - @cherrypick_pipeline = create :pipeline, name: 'cherrypick pipeline', request_types: [@cherrypick_request_type] + @genotype_pipeline = create(:pipeline, name: 'genotyping pipeline', request_types: [@genotyping_request_type]) + @cherrypick_pipeline = create(:pipeline, name: 'cherrypick pipeline', request_types: [@cherrypick_request_type]) @request1 = create( @@ -83,7 +83,7 @@ end context 'with valid input' do - before { @request2 = create :request, submission: @submission, request_type: @genotyping_request_type } + before { @request2 = create(:request, submission: @submission, request_type: @genotyping_request_type) } it 'return the correct next request' do expect(@request1.next_requests).to eq([@request2]) @@ -92,7 +92,7 @@ context 'where asset hasnt been created for second request' do before do - @request2 = create :request, asset: nil, submission: @submission, request_type: @genotyping_request_type + @request2 = create(:request, asset: nil, submission: @submission, request_type: @genotyping_request_type) end it 'return the correct next request' do @@ -106,7 +106,7 @@ # so these tests use the submission builder. Please don't switch to building the requests # themselves via FactoryBot until the two behaviours are uncoupled describe '#next_requests' do - let(:submission) { create :submission, orders: [order1, order2], state: 'pending' } + let(:submission) { create(:submission, orders: [order1, order2], state: 'pending') } let(:order1) { create(:linear_submission, request_types: order1_request_types, request_options:) } let(:order2) { create(:linear_submission, request_types: order2_request_types, request_options:) } let(:order1_request1) do @@ -232,8 +232,8 @@ describe '#copy' do before do - @request_type = create :request_type - @request = create :request, request_type: @request_type, study:, state: 'failed' + @request_type = create(:request_type) + @request = create(:request, request_type: @request_type, study:, state: 'failed') @new_request = @request.copy end @@ -258,8 +258,8 @@ describe '#after_create' do context 'successful' do - let(:study) { create :study } - let(:request) { create :request, study: } + let(:study) { create(:study) } + let(:request) { create(:request, study:) } it 'not have ActiveRecord errors' do expect(request.errors).to be_empty @@ -274,7 +274,7 @@ describe '#state' do before do @request = create(:request_suitable_for_starting, study:) - @user = create :admin + @user = create(:admin) @user.grant_owner study end @@ -388,8 +388,8 @@ end describe '#eventful_studies' do - let(:asset) { create :untagged_well } - let(:request) { create :request, asset:, initial_study: study } + let(:asset) { create(:untagged_well) } + let(:request) { create(:request, asset:, initial_study: study) } context 'with no study itself' do let(:study) { nil } @@ -398,7 +398,7 @@ end context 'with a study itself' do - let(:study) { create :study } + let(:study) { create(:study) } it { expect(request.eventful_studies).to eq([study]) } end @@ -411,7 +411,7 @@ @all_states = @open_states + @closed_states - @all_states.each { |state| create :request, state: } + @all_states.each { |state| create(:request, state:) } expect(described_class.count).to eq(@all_states.size) end @@ -439,7 +439,7 @@ describe '#customer_responsible' do before do - @request = create :library_creation_request + @request = create(:library_creation_request) @request.state = 'started' end @@ -459,18 +459,18 @@ describe '::progress_statistics' do subject { described_class.progress_statistics } - let(:request_type1) { create :request_type } - let(:request_type2) { create :request_type } + let(:request_type1) { create(:request_type) } + let(:request_type2) { create(:request_type) } before do - create_list :request, 2, state: 'pending', request_type: request_type1 - create_list :request, 1, state: 'started', request_type: request_type1 - create_list :request, 3, state: 'passed', request_type: request_type1 - create_list :request, 1, state: 'failed', request_type: request_type1 - create_list :request, 2, state: 'pending', request_type: request_type2 - create_list :request, 1, state: 'started', request_type: request_type2 - create_list :request, 3, state: 'cancelled', request_type: request_type2 - create_list :request, 1, state: 'failed', request_type: request_type2 + create_list(:request, 2, state: 'pending', request_type: request_type1) + create_list(:request, 1, state: 'started', request_type: request_type1) + create_list(:request, 3, state: 'passed', request_type: request_type1) + create_list(:request, 1, state: 'failed', request_type: request_type1) + create_list(:request, 2, state: 'pending', request_type: request_type2) + create_list(:request, 1, state: 'started', request_type: request_type2) + create_list(:request, 3, state: 'cancelled', request_type: request_type2) + create_list(:request, 1, state: 'failed', request_type: request_type2) end it 'returns a summary' do @@ -496,15 +496,15 @@ end describe '.get_all_comments' do - let(:labware) { create :labware } - let(:receptacle) { create :receptacle, labware: } - let(:request) { create :request, asset: receptacle } + let(:labware) { create(:labware) } + let(:receptacle) { create(:receptacle, labware:) } + let(:request) { create(:request, asset: receptacle) } before do - create :comment, commentable: labware, description: 'comment on labware' - create :comment, commentable: receptacle, description: 'comment on receptacle' - create :comment, commentable: request, description: 'first comment on request' - create :comment, commentable: request, description: 'second comment on request' + create(:comment, commentable: labware, description: 'comment on labware') + create(:comment, commentable: receptacle, description: 'comment on receptacle') + create(:comment, commentable: request, description: 'first comment on request') + create(:comment, commentable: request, description: 'second comment on request') end it 'returns all of the comments including associated labware, receptacle and request itself' do diff --git a/spec/models/request_type/validator/library_type_validator_spec.rb b/spec/models/request_type/validator/library_type_validator_spec.rb index 8e3c8e791a..a44214f92f 100644 --- a/spec/models/request_type/validator/library_type_validator_spec.rb +++ b/spec/models/request_type/validator/library_type_validator_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe RequestType::Validator::LibraryTypeValidator do - let(:library_type) { create :library_type, name: 'MyLibraryType' } - let(:request_type) { create :library_creation_request_type, :with_library_types, library_type: } + let(:library_type) { create(:library_type, name: 'MyLibraryType') } + let(:request_type) { create(:library_creation_request_type, :with_library_types, library_type:) } let(:validator) { described_class.new(request_type.id) } context 'when initialising' do @@ -34,8 +34,8 @@ end context 'when using default' do - let(:request_type) { create :request_type } - let(:library_type2) { create :library_type, name: 'MyDefaultLibraryType' } + let(:request_type) { create(:request_type) } + let(:library_type2) { create(:library_type, name: 'MyDefaultLibraryType') } context 'when a default library type is set' do before do diff --git a/spec/models/request_type_spec.rb b/spec/models/request_type_spec.rb index fa008faaee..0662c365be 100644 --- a/spec/models/request_type_spec.rb +++ b/spec/models/request_type_spec.rb @@ -6,7 +6,7 @@ context described_class do describe '#for_multiplexing?' do context 'when it is for multiplexing' do - let(:request_type) { create :multiplexed_library_creation_request_type } + let(:request_type) { create(:multiplexed_library_creation_request_type) } it 'return true' do expect(request_type).to be_for_multiplexing @@ -14,7 +14,7 @@ end context 'when it is not for multiplexing' do - let(:request_type) { create :library_creation_request_type } + let(:request_type) { create(:library_creation_request_type) } it 'return false' do expect(request_type).not_to be_for_multiplexing diff --git a/spec/models/robot/pick_data_spec.rb b/spec/models/robot/pick_data_spec.rb index c84c586c54..a64b3f7993 100644 --- a/spec/models/robot/pick_data_spec.rb +++ b/spec/models/robot/pick_data_spec.rb @@ -10,11 +10,11 @@ describe '#picking_data_hash' do let(:time) { Time.zone.local(2010, 7, 12, 10, 25, 0) } - let(:source_plate_1) { create :plate, well_count: 2 } - let(:source_plate_2) { create :plate, well_count: 2 } - let(:source_plate_3) { create :plate, well_count: 2 } - let(:destination_plate) { create :plate, well_count: 9 } - let(:pipeline) { create :cherrypick_pipeline } + let(:source_plate_1) { create(:plate, well_count: 2) } + let(:source_plate_2) { create(:plate, well_count: 2) } + let(:source_plate_3) { create(:plate, well_count: 2) } + let(:destination_plate) { create(:plate, well_count: 9) } + let(:pipeline) { create(:cherrypick_pipeline) } let(:transfers) do # We generate the plates before the transfer map, as otherwise @@ -44,17 +44,17 @@ let(:requests) do transfers.map do |source, target| - create :cherrypick_request, + create(:cherrypick_request, asset: source, target_asset: target, request_type: pipeline.request_types.first, - state: 'passed' + state: 'passed') end end - let(:user) { create :user } + let(:user) { create(:user) } - let(:batch) { create :batch, requests:, pipeline:, user: } + let(:batch) { create(:batch, requests:, pipeline:, user:) } shared_examples_for 'a picking process' do # This is how the output of the process should be displayed: @@ -145,8 +145,8 @@ end context 'when we have several plates and needs to use several picks' do - let(:destination_plate) { create :plate, well_count: 10 } - let(:plates) { create_list :plate, 5, well_count: 2 } + let(:destination_plate) { create(:plate, well_count: 10) } + let(:plates) { create_list(:plate, 5, well_count: 2) } let(:picks) do { 'A1' => [plates[0], 'A1'], @@ -168,18 +168,18 @@ context 'when we create the requests in different order' do let(:requests) do transfers.to_a.reverse.map do |source, target| - create :cherrypick_request, + create(:cherrypick_request, asset: source, target_asset: target, request_type: pipeline.request_types.first, - state: 'passed' + state: 'passed') end end it_behaves_like 'a picking process' context 'when we have a control' do - let(:control_plate) { create :control_plate, sample_count: 2 } + let(:control_plate) { create(:control_plate, sample_count: 2) } let(:expected_pick) { { 1 => %w[A2 B2 A1 B1], 2 => %w[C1 D1 E1 F1], 3 => %w[G1 H1] } } before { plates[4] = control_plate } diff --git a/spec/models/robot/verification/source_dest_beds_spec.rb b/spec/models/robot/verification/source_dest_beds_spec.rb index d8eaa11c01..1a6aa4aa08 100644 --- a/spec/models/robot/verification/source_dest_beds_spec.rb +++ b/spec/models/robot/verification/source_dest_beds_spec.rb @@ -34,10 +34,10 @@ end end - let(:source_plate_1) { create :plate, well_count: 2 } - let(:source_plate_3) { create :plate, well_count: 2 } - let(:destination_plate) { create :plate, well_count: 9 } - let(:pipeline) { create :cherrypick_pipeline } + let(:source_plate_1) { create(:plate, well_count: 2) } + let(:source_plate_3) { create(:plate, well_count: 2) } + let(:destination_plate) { create(:plate, well_count: 9) } + let(:pipeline) { create(:cherrypick_pipeline) } let(:max_beds) { 17 } let(:transfers) do @@ -62,18 +62,18 @@ let(:requests) do transfers.map do |source, target| - create :cherrypick_request, + create(:cherrypick_request, asset: source, target_asset: target, request_type: pipeline.request_types.first, - state: 'passed' + state: 'passed') end end - let(:batch) { create :batch, requests:, pipeline: } + let(:batch) { create(:batch, requests:, pipeline:) } context 'without control plates' do - let(:source_plate_2) { create :plate, well_count: 2 } + let(:source_plate_2) { create(:plate, well_count: 2) } let(:expected_layout) do { 1 => [ @@ -93,7 +93,7 @@ end context 'with control plates' do - let(:source_plate_2) { create :control_plate, well_count: 2 } + let(:source_plate_2) { create(:control_plate, well_count: 2) } let(:expected_layout) do { 1 => [ diff --git a/spec/models/robot/verification/source_dest_control_beds_spec.rb b/spec/models/robot/verification/source_dest_control_beds_spec.rb index 0846766b6a..9db26bf8e7 100644 --- a/spec/models/robot/verification/source_dest_control_beds_spec.rb +++ b/spec/models/robot/verification/source_dest_control_beds_spec.rb @@ -29,10 +29,10 @@ end end - let(:source_plate_1) { create :plate, well_count: 2 } - let(:source_plate_3) { create :plate, well_count: 2 } - let(:destination_plate) { create :plate, well_count: 9 } - let(:pipeline) { create :cherrypick_pipeline } + let(:source_plate_1) { create(:plate, well_count: 2) } + let(:source_plate_3) { create(:plate, well_count: 2) } + let(:destination_plate) { create(:plate, well_count: 9) } + let(:pipeline) { create(:cherrypick_pipeline) } let(:max_beds) { 17 } let(:transfers) do @@ -57,20 +57,20 @@ let(:requests) do transfers.map do |source, target| - create :cherrypick_request, + create(:cherrypick_request, asset: source, target_asset: target, request_type: pipeline.request_types.first, - state: 'passed' + state: 'passed') end end - let(:batch) { create :batch, requests:, pipeline: } - let(:user) { create :user } - let(:robot) { create :hamilton, barcode: '444' } + let(:batch) { create(:batch, requests:, pipeline:) } + let(:user) { create(:user) } + let(:robot) { create(:hamilton, barcode: '444') } context 'without control plates' do - let(:source_plate_2) { create :plate, well_count: 2 } + let(:source_plate_2) { create(:plate, well_count: 2) } let(:expected_layout) do { 1 => [ @@ -131,7 +131,7 @@ context 'without control plates and multiple picks' do let(:max_beds) { 2 } - let(:source_plate_2) { create :plate, well_count: 2 } + let(:source_plate_2) { create(:plate, well_count: 2) } let(:expected_layout) do { 1 => [ @@ -153,7 +153,7 @@ end context 'with control plates' do - let(:source_plate_2) { create :control_plate, well_count: 2 } + let(:source_plate_2) { create(:control_plate, well_count: 2) } let(:expected_layout) do { 1 => [ @@ -215,7 +215,7 @@ context 'with control plates and multiple picks' do let(:max_beds) { 1 } - let(:source_plate_2) { create :control_plate, well_count: 2 } + let(:source_plate_2) { create(:control_plate, well_count: 2) } let(:expected_layout) do # NOTE: This generates three picks. # In theory this should be possible to do in two, as the control bed diff --git a/spec/models/sample/metadata_spec.rb b/spec/models/sample/metadata_spec.rb index dfe4f78e43..8803116f0f 100644 --- a/spec/models/sample/metadata_spec.rb +++ b/spec/models/sample/metadata_spec.rb @@ -4,10 +4,10 @@ RSpec.describe Sample::Metadata do describe '#user_of_consent_withdrawn' do - let(:user) { create :user } - let(:sample) { create :sample } - let(:sample_metadata) { create :sample_metadata_for_api } - let(:sample_with_metadata) { create :sample, sample_metadata: } + let(:user) { create(:user) } + let(:sample) { create(:sample) } + let(:sample_metadata) { create(:sample_metadata_for_api) } + let(:sample_with_metadata) { create(:sample, sample_metadata:) } before { sample.sample_metadata.update(user_id_of_consent_withdrawn: user.id) } diff --git a/spec/models/sample_manifest/uploader_spec.rb b/spec/models/sample_manifest/uploader_spec.rb index 83a30e20c5..2faa736466 100644 --- a/spec/models/sample_manifest/uploader_spec.rb +++ b/spec/models/sample_manifest/uploader_spec.rb @@ -14,7 +14,7 @@ let(:test_file_name) { 'test_file.xlsx' } let(:test_file) { Rack::Test::UploadedFile.new(Rails.root.join(test_file_name), '') } - let(:user) { create :user } + let(:user) { create(:user) } after(:all) { SampleManifestExcel.reset! } diff --git a/spec/models/sample_manifest_spec.rb b/spec/models/sample_manifest_spec.rb index 45d2363e9c..0338c603e4 100644 --- a/spec/models/sample_manifest_spec.rb +++ b/spec/models/sample_manifest_spec.rb @@ -6,12 +6,12 @@ # result in repeatedly indenting them to the level of the last call in the previous chain RSpec.describe SampleManifest, :sample_manifest do - let(:user) { create :user } - let(:study) { create :study } + let(:user) { create(:user) } + let(:study) { create(:study) } describe '#default_filename' do let(:date) { Date.parse('25/10/2018') } - let(:manifest) { create :sample_manifest, study:, created_at: date } + let(:manifest) { create(:sample_manifest, study:, created_at: date) } it 'includes the information requested' do expect(manifest.default_filename).to eq("#{study.id}stdy_manifest_#{manifest.id}_251018") @@ -19,7 +19,7 @@ end describe '#generate' do - let(:manifest) { create :sample_manifest, study:, count:, asset_type:, purpose: } + let(:manifest) { create(:sample_manifest, study:, count:, asset_type:, purpose:) } let(:purpose) { nil } let(:first_plate_barcode) { build(:plate_barcode) } let(:second_plate_barcode) { build(:plate_barcode) } @@ -81,7 +81,7 @@ end context 'with a custom purpose' do - let(:purpose) { create :plate_purpose, size: 2 } + let(:purpose) { create(:plate_purpose, size: 2) } let(:count) { 1 } before { manifest.generate } @@ -140,7 +140,7 @@ end context 'with a custom purpose' do - let(:purpose) { create :plate_purpose, size: 2 } + let(:purpose) { create(:plate_purpose, size: 2) } let(:count) { 1 } before { manifest.generate } @@ -152,7 +152,7 @@ end context 'with no rapid generation' do - let(:manifest) { create :sample_manifest, study: } + let(:manifest) { create(:sample_manifest, study:) } it 'adds created broadcast event when sample manifest is created' do expect { manifest.generate }.to change(BroadcastEvent::SampleManifestCreated, :count).by(1) @@ -329,7 +329,7 @@ describe '#updated_by!' do let(:plate_behaviour_core) { SampleManifest::PlateBehaviour::Core.new(described_class.new) } - let(:well_with_plate) { create :well_with_sample_and_plate } + let(:well_with_plate) { create(:well_with_sample_and_plate) } it 'adds an event to the plate' do plate_behaviour_core.updated_by!(user, [well_with_plate.samples.first]) @@ -358,7 +358,7 @@ describe '#pools' do let(:manifest) do - create :plate_sample_manifest_with_manifest_assets, study:, asset_type: 'plate', num_samples_per_well: + create(:plate_sample_manifest_with_manifest_assets, study:, asset_type: 'plate', num_samples_per_well:) end context 'when there is only one sample per well' do diff --git a/spec/models/sample_spec.rb b/spec/models/sample_spec.rb index cc92050c0a..daa588a53d 100644 --- a/spec/models/sample_spec.rb +++ b/spec/models/sample_spec.rb @@ -51,15 +51,15 @@ context 'can be included in submission' do it 'knows if it was registered through manifest' do - stand_alone_sample = create :sample + stand_alone_sample = create(:sample) expect(stand_alone_sample).not_to be_registered_through_manifest - sample_manifest = create :tube_sample_manifest_with_samples + sample_manifest = create(:tube_sample_manifest_with_samples) sample_manifest.samples.each { |sample| expect(sample).to be_registered_through_manifest } end it 'knows when it can be included in submission if it was registered through manifest' do - sample_manifest = create :tube_sample_manifest_with_samples + sample_manifest = create(:tube_sample_manifest_with_samples) sample_manifest.samples.each { |sample| expect(sample).not_to be_can_be_included_in_submission } sample = sample_manifest.samples.first sample.sample_metadata.supplier_name = 'new sample' @@ -67,15 +67,15 @@ end it 'knows when it can be included in submission if it was not registered through manifest' do - sample = create :sample + sample = create(:sample) expect(sample).to be_can_be_included_in_submission end end context 'consent withdraw' do - let(:user) { create :user } + let(:user) { create(:user) } let(:time) { DateTime.now } - let(:sample) { create :sample } + let(:sample) { create(:sample) } before do sample.update(consent_withdrawn: true, date_of_consent_withdrawn: time, user_id_of_consent_withdrawn: user.id) @@ -141,7 +141,7 @@ end context 'updating supplier name' do - let(:sample) { create :sample } + let(:sample) { create(:sample) } it 'validates that supplier name allows only ASCII characters' do expect(sample.sample_metadata.supplier_name).to be_nil @@ -260,7 +260,7 @@ end context '(DPL-148) on updating sample metadata' do - let(:sample) { create :sample } + let(:sample) { create(:sample) } it 'triggers warehouse update', :warren do expect do diff --git a/spec/models/sequencing_request_spec.rb b/spec/models/sequencing_request_spec.rb index 4329e06b95..6bdb27086e 100644 --- a/spec/models/sequencing_request_spec.rb +++ b/spec/models/sequencing_request_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe SequencingRequest do - let(:library_tube) { create :library_tube } + let(:library_tube) { create(:library_tube) } let(:sequencing_request) { create(:sequencing_request, asset: library_tube) } describe '#ready?' do @@ -17,7 +17,7 @@ end context 'with empty assets' do - let(:library_tube) { create :empty_library_tube } + let(:library_tube) { create(:empty_library_tube) } it { is_expected.to be false } end @@ -38,12 +38,12 @@ context 'with upstream requests' do before do library_tube.create_scanned_into_lab_event!(content: '2018-01-01') - create :library_creation_request_for_testing_sequencing_requests, + create(:library_creation_request_for_testing_sequencing_requests, target_asset: library_tube, - state: library_request_1_state - create :library_creation_request_for_testing_sequencing_requests, + state: library_request_1_state) + create(:library_creation_request_for_testing_sequencing_requests, target_asset: library_tube, - state: library_request_2_state + state: library_request_2_state) end # Nothing has happened yet! @@ -94,7 +94,7 @@ subject { request.loading_concentration } let(:request) do - create :complete_sequencing_request, event_descriptors: { 'Lane loading concentration (pM)' => user_input } + create(:complete_sequencing_request, event_descriptors: { 'Lane loading concentration (pM)' => user_input }) end context 'with the expected input' do @@ -136,13 +136,13 @@ end context 'on start' do - let(:samples) { create_list :sample, 2 } - let(:study) { create :study, samples: } - let(:project) { create :project } - let(:destination) { create :receptacle } + let(:samples) { create_list(:sample, 2) } + let(:study) { create(:study, samples:) } + let(:project) { create(:project) } + let(:destination) { create(:receptacle) } let(:aliquots) { [aliquot1, aliquot2] } - let(:source) { create :receptacle, aliquots: } - let(:library_tube) { create :library_tube, receptacles: [source] } + let(:source) { create(:receptacle, aliquots:) } + let(:library_tube) { create(:library_tube, receptacles: [source]) } let(:sequencing_request) do create( :sequencing_request, @@ -152,11 +152,11 @@ initial_project: project ) end - let(:tags) { create_list :tag, 4 } + let(:tags) { create_list(:tag, 4) } context 'when compound samples are not necessary because each aliquot has a unique tag combination' do - let(:aliquot1) { create :aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, study: } - let(:aliquot2) { create :aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[2].id, study: } + let(:aliquot1) { create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, study:) } + let(:aliquot2) { create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[2].id, study:) } it 'performs a normal transfer of aliquots' do expect(sequencing_request.target_asset.aliquots.count).to eq(0) @@ -169,10 +169,10 @@ context 'when compound samples are necessary because each aliquot does not have a unique tag combination' do context 'when there is one tag combination' do let(:aliquot1) do - create :aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, study:, project: + create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, study:, project:) end let(:aliquot2) do - create :aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, study:, project: + create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, study:, project:) end it 'creates a compound sample and transfers an aliquot of it' do @@ -184,18 +184,18 @@ end context 'when there are two tag combinations' do - let(:samples) { create_list :sample, 4 } + let(:samples) { create_list(:sample, 4) } let(:aliquot1) do - create :aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, study: + create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, study:) end let(:aliquot2) do - create :aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, study: + create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, study:) end let(:aliquot3) do - create :aliquot, sample: samples[2], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 1, study: + create(:aliquot, sample: samples[2], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 1, study:) end let(:aliquot4) do - create :aliquot, sample: samples[3], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 2, study: + create(:aliquot, sample: samples[3], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 2, study:) end let(:aliquots) { [aliquot1, aliquot2, aliquot3, aliquot4] } diff --git a/spec/models/specific_tube_creations_spec.rb b/spec/models/specific_tube_creations_spec.rb index c68af8e778..3eb2cd3f63 100644 --- a/spec/models/specific_tube_creations_spec.rb +++ b/spec/models/specific_tube_creations_spec.rb @@ -7,8 +7,8 @@ subject(:specific_tube_creation) { described_class.new(creation_parameters) } let(:child_purpose) { create(:tube_purpose) } - let(:user) { create :user } - let(:parent) { create :plate } + let(:user) { create(:user) } + let(:parent) { create(:plate) } end shared_context 'with common test setup' do diff --git a/spec/models/state_changer/initial_stock_tube_spec.rb b/spec/models/state_changer/initial_stock_tube_spec.rb index 2f670fd3c8..9b09079fdd 100644 --- a/spec/models/state_changer/initial_stock_tube_spec.rb +++ b/spec/models/state_changer/initial_stock_tube_spec.rb @@ -6,19 +6,19 @@ RSpec.describe StateChanger::InitialStockTube do let(:state_changer) { described_class.new(labware:, target_state:, user:, customer_accepts_responsibility:) } - let(:user) { build_stubbed :user } + let(:user) { build_stubbed(:user) } let(:customer_accepts_responsibility) { false } - let(:labware) { create :tube } - let(:submission) { build_stubbed :submission } - let(:well) { create :well } + let(:labware) { create(:tube) } + let(:submission) { build_stubbed(:submission) } + let(:well) { create(:well) } let!(:transfer_request) do - create :transfer_request, + create(:transfer_request, asset: well, target_asset: labware.receptacle, state: transfer_request_state, - outer_request: request + outer_request: request) end - let!(:request) { create :customer_request, asset: well, state: request_state, submission: } + let!(:request) { create(:customer_request, asset: well, state: request_state, submission:) } before do well.stock_wells << well diff --git a/spec/models/state_changer/input_plate_spec.rb b/spec/models/state_changer/input_plate_spec.rb index 65b89d38d5..1571d6353c 100644 --- a/spec/models/state_changer/input_plate_spec.rb +++ b/spec/models/state_changer/input_plate_spec.rb @@ -8,7 +8,7 @@ let(:state_changer) do described_class.new(labware: input_plate, target_state:, user:, contents:, customer_accepts_responsibility:) end - let(:user) { build_stubbed :user } + let(:user) { build_stubbed(:user) } let(:contents) { [] } let(:customer_accepts_responsibility) { false } diff --git a/spec/models/state_changer/mx_tube_spec.rb b/spec/models/state_changer/mx_tube_spec.rb index f8eb6cc017..2dcbedb85c 100644 --- a/spec/models/state_changer/mx_tube_spec.rb +++ b/spec/models/state_changer/mx_tube_spec.rb @@ -6,13 +6,13 @@ RSpec.describe StateChanger::MxTube do let(:state_changer) { described_class.new(labware:, target_state:, user:, customer_accepts_responsibility:) } - let(:user) { build_stubbed :user } + let(:user) { build_stubbed(:user) } let(:customer_accepts_responsibility) { false } - let(:labware) { create :multiplexed_library_tube } - let(:transfer_request) { create :transfer_request, target_asset: labware.receptacle, state: transfer_request_state } - let(:request) { create :request, target_asset: labware.receptacle, state: request_state, order: } + let(:labware) { create(:multiplexed_library_tube) } + let(:transfer_request) { create(:transfer_request, target_asset: labware.receptacle, state: transfer_request_state) } + let(:request) { create(:request, target_asset: labware.receptacle, state: request_state, order:) } let(:requests) { [request] } - let(:order) { create :order } + let(:order) { create(:order) } def create_requests_and_transfers transfer_request @@ -391,9 +391,9 @@ def create_requests_and_transfers end context 'when there are multiple orders' do - let(:request2) { create :request, target_asset: labware.receptacle, state: request_state, order: order2 } + let(:request2) { create(:request, target_asset: labware.receptacle, state: request_state, order: order2) } let(:requests) { [request, request2] } - let(:order2) { create :order } + let(:order2) { create(:order) } it 'fires an event per order' do expect(BroadcastEvent::PoolReleased.count).to eq(2) diff --git a/spec/models/state_changer/qcable_labware_spec.rb b/spec/models/state_changer/qcable_labware_spec.rb index 10a19408b2..faf8ce086e 100644 --- a/spec/models/state_changer/qcable_labware_spec.rb +++ b/spec/models/state_changer/qcable_labware_spec.rb @@ -5,9 +5,9 @@ RSpec.describe StateChanger::QcableLabware do let(:state_changer) { described_class.new(labware:, target_state: 'exhausted', user:) } - let!(:qcable) { create :qcable, asset: labware, state: 'available' } - let(:labware) { create :plate } - let(:user) { build_stubbed :user } + let!(:qcable) { create(:qcable, asset: labware, state: 'available') } + let(:labware) { create(:plate) } + let(:user) { build_stubbed(:user) } it 'sets library type on aliquots' do state_changer.update_labware_state diff --git a/spec/models/state_changer/qcable_library_plate_spec.rb b/spec/models/state_changer/qcable_library_plate_spec.rb index 7fa9f8ea9f..93001600f9 100644 --- a/spec/models/state_changer/qcable_library_plate_spec.rb +++ b/spec/models/state_changer/qcable_library_plate_spec.rb @@ -9,7 +9,7 @@ end let(:labware) { instance_double('Plate', wells: [well]) } # rubocop:todo RSpec/VerifiedDoubleReference let(:well) { instance_double('Well', aliquots: [aliquot]) } # rubocop:todo RSpec/VerifiedDoubleReference - let(:user) { build_stubbed :user } + let(:user) { build_stubbed(:user) } let(:contents) { [] } let(:customer_accepts_responsibility) { false } let(:aliquot) do diff --git a/spec/models/state_changer/standard_plate_spec.rb b/spec/models/state_changer/standard_plate_spec.rb index 94c1a49363..56b20e3d5f 100644 --- a/spec/models/state_changer/standard_plate_spec.rb +++ b/spec/models/state_changer/standard_plate_spec.rb @@ -7,7 +7,7 @@ let(:state_changer) do described_class.new(labware: target_plate, target_state:, user:, contents:, customer_accepts_responsibility:) end - let(:user) { build_stubbed :user } + let(:user) { build_stubbed(:user) } let(:contents) { [] } let(:customer_accepts_responsibility) { false } @@ -35,7 +35,7 @@ end context 'when the plate is cancelled at the end of the pipeline' do - let(:target_plate) { create :final_plate } + let(:target_plate) { create(:final_plate) } let(:library_requests) { target_plate.wells.flat_map(&:requests_as_target) } let(:target_state) { 'cancelled' } @@ -46,7 +46,7 @@ end context 'when the plate is failed at the end of the pipeline' do - let(:target_plate) { create :final_plate } + let(:target_plate) { create(:final_plate) } let(:library_requests) { target_plate.wells.flat_map(&:requests_as_target) } let(:target_state) { 'failed' } @@ -103,7 +103,7 @@ let(:target_state) { 'failed' } # override default target plate creation - let(:target_plate) { create :plate, well_count: 4 } + let(:target_plate) { create(:plate, well_count: 4) } let(:target_wells) { target_plate.wells.index_by(&:map_description) } before do @@ -119,30 +119,30 @@ target_well: target_wells['A1'], source_well: parent_wells['A1'] ) - create :transfer_request, + create(:transfer_request, asset: parent_wells['A1'], target_asset: target_wells['A1'], - outer_request: source_well_a1_request + outer_request: source_well_a1_request) target_wells['B1'].stock_well_links << build( :stock_well_link, target_well: target_wells['B1'], source_well: parent_wells['A1'] ) - create :transfer_request, + create(:transfer_request, asset: parent_wells['A1'], target_asset: target_wells['B1'], - outer_request: source_well_a1_request + outer_request: source_well_a1_request) target_wells['C1'].stock_well_links << build( :stock_well_link, target_well: target_wells['C1'], source_well: parent_wells['A1'] ) - create :transfer_request, + create(:transfer_request, asset: parent_wells['A1'], target_asset: target_wells['C1'], - outer_request: source_well_a1_request + outer_request: source_well_a1_request) # D1 created by transferring from parent B1 (2nd library request) target_wells['D1'].stock_well_links << build( @@ -150,10 +150,10 @@ target_well: target_wells['D1'], source_well: parent_wells['B1'] ) - create :transfer_request, + create(:transfer_request, asset: parent_wells['B1'], target_asset: target_wells['D1'], - outer_request: source_well_b1_request + outer_request: source_well_b1_request) end context 'when the other wells are not failed' do diff --git a/spec/models/state_changer/stock_tube_spec.rb b/spec/models/state_changer/stock_tube_spec.rb index 9bea2f435e..55803cc4e9 100644 --- a/spec/models/state_changer/stock_tube_spec.rb +++ b/spec/models/state_changer/stock_tube_spec.rb @@ -6,11 +6,11 @@ RSpec.describe StateChanger::StockTube do let(:state_changer) { described_class.new(labware:, target_state:, user:, customer_accepts_responsibility:) } - let(:user) { build_stubbed :user } + let(:user) { build_stubbed(:user) } let(:customer_accepts_responsibility) { false } - let(:labware) { create :tube } - let!(:transfer_request) { create :transfer_request, target_asset: labware.receptacle, state: transfer_request_state } - let!(:request) { create :request, target_asset: labware.receptacle, state: request_state } + let(:labware) { create(:tube) } + let!(:transfer_request) { create(:transfer_request, target_asset: labware.receptacle, state: transfer_request_state) } + let!(:request) { create(:request, target_asset: labware.receptacle, state: request_state) } before do labware.receptacle.aliquots << build(:aliquot, request:) diff --git a/spec/models/std_library_request_spec.rb b/spec/models/std_library_request_spec.rb index ceedb0a024..8bfc9ab8db 100644 --- a/spec/models/std_library_request_spec.rb +++ b/spec/models/std_library_request_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' RSpec.describe IlluminaHtp::Requests::StdLibraryRequest do - let(:tagged_well) { create :tagged_well } + let(:tagged_well) { create(:tagged_well) } describe '#pass' do - subject { create :library_request, target_asset: tagged_well, state: } + subject { create(:library_request, target_asset: tagged_well, state:) } let(:state) { 'started' } @@ -17,7 +17,7 @@ end describe '#request_metadata' do - subject { build :library_request, request_metadata_attributes:, request_type: } + subject { build(:library_request, request_metadata_attributes:, request_type:) } let(:fragment_size_required_from) { 1 } let(:fragment_size_required_to) { 20 } @@ -28,7 +28,7 @@ { fragment_size_required_from:, fragment_size_required_to:, library_type:, pcr_cycles: } end - let(:request_type) { create :library_creation_request_type } + let(:request_type) { create(:library_creation_request_type) } let(:expected_pool_info) do { diff --git a/spec/models/stock_stamper_spec.rb b/spec/models/stock_stamper_spec.rb index 13d3b72159..cf68a232f3 100644 --- a/spec/models/stock_stamper_spec.rb +++ b/spec/models/stock_stamper_spec.rb @@ -5,16 +5,16 @@ require 'timecop' describe StockStamper do - let(:plate) { create :plate_with_3_wells } - let!(:user) { create :user, login: 'abc', barcode: 'ID41440E' } + let(:plate) { create(:plate_with_3_wells) } + let!(:user) { create(:user, login: 'abc', barcode: 'ID41440E') } before do # Set the plate barcode to be a DN barcode plate.barcodes = [Barcode.build_sanger_code39({ prefix: 'DN', number: '1' })] - create :plate_type, name: 'ABgene_0765', maximum_volume: 800 - create :plate_type, name: 'ABgene_0800', maximum_volume: 180 - create :plate_type, name: 'FluidX075', maximum_volume: 500 - create :plate_type, name: 'FluidX03', maximum_volume: 280 + create(:plate_type, name: 'ABgene_0765', maximum_volume: 800) + create(:plate_type, name: 'ABgene_0800', maximum_volume: 180) + create(:plate_type, name: 'FluidX075', maximum_volume: 500) + create(:plate_type, name: 'FluidX03', maximum_volume: 280) @attributes = { user_barcode: '2470041440697', diff --git a/spec/models/study_spec.rb b/spec/models/study_spec.rb index a20c613e6c..db255ad928 100644 --- a/spec/models/study_spec.rb +++ b/spec/models/study_spec.rb @@ -12,21 +12,21 @@ requests = [].tap do |r| # Cancelled - 3.times { r << (create :cancelled_request, study:, request_type:) } + 3.times { r << (create(:cancelled_request, study:, request_type:)) } # Failed - r << (create :failed_request, study:, request_type:) + r << (create(:failed_request, study:, request_type:)) # Passed - 3.times { r << (create :passed_request, study:, request_type:) } + 3.times { r << (create(:passed_request, study:, request_type:)) } - r << (create :passed_request, study:, request_type: request_type_2) - r << (create :passed_request, study:, request_type: request_type_3) - r << (create :passed_request, study:, request_type: request_type_3) + r << (create(:passed_request, study:, request_type: request_type_2)) + r << (create(:passed_request, study:, request_type: request_type_3)) + r << (create(:passed_request, study:, request_type: request_type_3)) # Pending - r << (create :pending_request, study:, request_type:) - r << (create :pending_request, study:, request_type: request_type_3) + r << (create(:pending_request, study:, request_type:)) + r << (create(:pending_request, study:, request_type: request_type_3)) end # we have to hack t @@ -38,9 +38,9 @@ end it 'validates uniqueness of name (case sensitive)' do - study_1 = create :study, name: 'Study_name' - study_2 = build :study, name: 'Study_name' - study_3 = build :study, name: 'Study_NAME' + study_1 = create(:study, name: 'Study_name') + study_2 = build(:study, name: 'Study_name') + study_3 = build(:study, name: 'Study_NAME') expect(study_2.valid?).to be false expect(study_2.errors.messages.length).to eq 1 expect(study_2.errors.full_messages).to include 'Name has already been taken' @@ -377,9 +377,9 @@ describe '#each_well_for_qc_report_in_batches' do let!(:study) { create(:study) } let(:purpose_1) { PlatePurpose.stock_plate_purpose } - let(:purpose_2) { create :plate_purpose } - let(:purpose_3) { create :plate_purpose } - let(:purpose_4) { create :plate_purpose } + let(:purpose_2) { create(:plate_purpose) } + let(:purpose_3) { create(:plate_purpose) } + let(:purpose_4) { create(:plate_purpose) } let!(:well_1) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_1)) } let!(:well_2) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_2)) } let!(:well_3) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_3)) } @@ -412,16 +412,16 @@ describe '#mailing_list_of_managers' do subject { study.mailing_list_of_managers } - let(:study) { create :study } + let(:study) { create(:study) } context 'with a manger' do - before { create :manager, authorizable: study, email: 'manager@example.com' } + before { create(:manager, authorizable: study, email: 'manager@example.com') } it { is_expected.to eq ['manager@example.com'] } end context 'without a manger' do - before { create :admin } + before { create(:admin) } it { is_expected.to eq ['ssr@example.com'] } end @@ -858,8 +858,8 @@ end context '(DPL-148) on updating user roles' do - let(:study) { create :study } - let(:user) { create :user } + let(:study) { create(:study) } + let(:user) { create(:user) } it 'triggers warehouse update', :warren do expect { user.grant_follower(study) }.to change(Warren.handler.messages, :count).from(0) diff --git a/spec/models/submission/submission_creator_spec.rb b/spec/models/submission/submission_creator_spec.rb index c70afbdf55..e6c1581a83 100644 --- a/spec/models/submission/submission_creator_spec.rb +++ b/spec/models/submission/submission_creator_spec.rb @@ -4,14 +4,14 @@ describe Submission::SubmissionCreator do describe '#order_fields' do - let(:user) { create :user } + let(:user) { create(:user) } let(:creator) { described_class.new(user, template_id: template.id) } context 'a full template' do - let(:library_type) { create :library_type } + let(:library_type) { create(:library_type) } let(:library_creation_request_type) { create(:library_request_type, :with_library_types, library_type:) } let(:template) do - create :submission_template, request_types: [library_creation_request_type, create(:sequencing_request_type)] + create(:submission_template, request_types: [library_creation_request_type, create(:sequencing_request_type)]) end it 'finds the appropriate order fields' do diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index 9342628fb6..bc9d0e147a 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -94,13 +94,13 @@ end it 'knows all samples that can not be included in submission' do - sample_manifest = create :tube_sample_manifest_with_samples + sample_manifest = create(:tube_sample_manifest_with_samples) sample_manifest.samples.first.sample_metadata.update(supplier_name: 'new_name') samples = sample_manifest.samples[1..] - order1 = create :order, assets: sample_manifest.labware + order1 = create(:order, assets: sample_manifest.labware) - asset = create :sample_tube - order2 = create :order, assets: [asset.receptacle] + asset = create(:sample_tube) + order2 = create(:order, assets: [asset.receptacle]) submission = described_class.new(user: create(:user), orders: [order1, order2]) @@ -108,24 +108,24 @@ end describe '#used_tags' do - let(:submission) { create :submission } - let(:request_1) { create :request, submission: } - let(:request_2) { create :request, submission: } - let(:tag_a) { create :tag } - let(:tag2_a) { create :tag } - let(:tag_b) { create :tag } - let(:tag2_b) { create :tag } + let(:submission) { create(:submission) } + let(:request_1) { create(:request, submission:) } + let(:request_2) { create(:request, submission:) } + let(:tag_a) { create(:tag) } + let(:tag2_a) { create(:tag) } + let(:tag_b) { create(:tag) } + let(:tag2_b) { create(:tag) } before do # Some untagged aliquots upstream of tagging - create :untagged_aliquot, request: request_1 - create :untagged_aliquot, request: request_2 + create(:untagged_aliquot, request: request_1) + create(:untagged_aliquot, request: request_2) # Once tagged, we may have multiple tagged aliquots - create :aliquot, request: request_1, tag: tag_a, tag2: tag2_a - create :aliquot, request: request_2, tag: tag_b, tag2: tag2_b - create :aliquot, request: request_1, tag: tag_a, tag2: tag2_a - create :aliquot, request: request_2, tag: tag_b, tag2: tag2_b + create(:aliquot, request: request_1, tag: tag_a, tag2: tag2_a) + create(:aliquot, request: request_2, tag: tag_b, tag2: tag2_b) + create(:aliquot, request: request_1, tag: tag_a, tag2: tag2_a) + create(:aliquot, request: request_2, tag: tag_b, tag2: tag2_b) end it 'returns an array of used tag pairs' do diff --git a/spec/models/tag2_layout_spec.rb b/spec/models/tag2_layout_spec.rb index 52eb27d9fd..52d01fdc00 100644 --- a/spec/models/tag2_layout_spec.rb +++ b/spec/models/tag2_layout_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' RSpec.describe Tag2Layout do - subject { create :tag2_layout, plate:, tag: } + subject { create(:tag2_layout, plate:, tag:) } - let(:plate) { create :plate_with_untagged_wells, :with_submissions, sample_count: 2 } - let(:tag) { create :tag } - let!(:tag2_layout_template) { create :tag2_layout_template, tag: } + let(:plate) { create(:plate_with_untagged_wells, :with_submissions, sample_count: 2) } + let(:tag) { create(:tag) } + let!(:tag2_layout_template) { create(:tag2_layout_template, tag:) } it 'applies its tag to every well of the plate' do expect(subject.plate.wells).to be_present diff --git a/spec/models/tag2_layout_template_spec.rb b/spec/models/tag2_layout_template_spec.rb index e6e7335e65..c9cf955545 100644 --- a/spec/models/tag2_layout_template_spec.rb +++ b/spec/models/tag2_layout_template_spec.rb @@ -5,10 +5,10 @@ RSpec.describe Tag2LayoutTemplate do subject { tag2_layout_template.create! plate:, tag:, user: } - let(:plate) { create :plate_with_untagged_wells, :with_submissions, sample_count: 2 } - let(:tag) { create :tag } - let(:user) { create :user } - let(:tag2_layout_template) { create :tag2_layout_template, tag: } + let(:plate) { create(:plate_with_untagged_wells, :with_submissions, sample_count: 2) } + let(:tag) { create(:tag) } + let(:user) { create(:user) } + let(:tag2_layout_template) { create(:tag2_layout_template, tag:) } it 'applies its tag to every well of the plate' do expect(subject.plate.wells).to be_present diff --git a/spec/models/tag_group/adapter_type_spec.rb b/spec/models/tag_group/adapter_type_spec.rb index 5c83667610..bbe1d0bbdb 100644 --- a/spec/models/tag_group/adapter_type_spec.rb +++ b/spec/models/tag_group/adapter_type_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe TagGroup::AdapterType do - subject(:adapter_type) { build :adapter_type, name: } + subject(:adapter_type) { build(:adapter_type, name:) } context 'when it has a unique name' do let(:name) { 'name' } @@ -18,7 +18,7 @@ end context 'when it is in use' do - before { create :tag_group, adapter_type: } + before { create(:tag_group, adapter_type:) } it { is_expected.to be false } end @@ -45,7 +45,7 @@ end context 'when its name is already in use' do - before { create :adapter_type, name: 'name' } + before { create(:adapter_type, name: 'name') } let(:name) { 'name' } diff --git a/spec/models/tag_group_spec.rb b/spec/models/tag_group_spec.rb index eb8279a17d..e983d0dcf4 100644 --- a/spec/models/tag_group_spec.rb +++ b/spec/models/tag_group_spec.rb @@ -52,10 +52,10 @@ describe '#adapter_type_name' do subject { tag_group.adapter_type_name } - let(:tag_group) { build_stubbed :tag_group, adapter_type: } + let(:tag_group) { build_stubbed(:tag_group, adapter_type:) } context 'when an adapter type is specified' do - let(:adapter_type) { build_stubbed :adapter_type, name: 'name' } + let(:adapter_type) { build_stubbed(:adapter_type, name: 'name') } it { is_expected.to eq 'name' } end diff --git a/spec/models/tag_layout_spec.rb b/spec/models/tag_layout_spec.rb index 39c37c75a9..795ae63d2b 100644 --- a/spec/models/tag_layout_spec.rb +++ b/spec/models/tag_layout_spec.rb @@ -10,11 +10,11 @@ def generate_tag_layout(plate, tag_type = :tag) plate.wells.with_aliquots.each_with_object({}) { |w, h| h[w.map_description] = w.aliquots.map(&tag_type) } end - let(:plate) { create :plate_with_untagged_wells, well_count: 8 } - let(:tag_group) { create :tag_group, tag_count: } + let(:plate) { create(:plate_with_untagged_wells, well_count: 8) } + let(:tag_group) { create(:tag_group, tag_count:) } let(:tag2_group) { nil } let(:tag_count) { 16 } - let(:user) { create :user } + let(:user) { create(:user) } let(:initial_tag) { 0 } shared_examples 'a tag layout' do @@ -33,7 +33,7 @@ def generate_tag_layout(plate, tag_type = :tag) end context 'substitutions' do - let(:tag_layout) { build_stubbed :tag_layout } + let(:tag_layout) { build_stubbed(:tag_layout) } it 'defaults to an empty hash' do expect(tag_layout.substitutions).to eq({}) @@ -97,9 +97,9 @@ def generate_tag_layout(plate, tag_type = :tag) let(:direction) { 'combinatorial by row' } context 'with a 384 well plate' do - let(:plate) { create :plate_with_untagged_wells, sample_count: 4 * 16, size: 384 } + let(:plate) { create(:plate_with_untagged_wells, sample_count: 4 * 16, size: 384) } let(:tag_count) { 384 } - let(:tag2_group) { create :tag_group, tag_count: } + let(:tag2_group) { create(:tag_group, tag_count:) } let(:expected_tag_layout) do { 'A1' => [1], @@ -258,9 +258,9 @@ def generate_tag_layout(plate, tag_type = :tag) let(:direction) { 'column then row' } context 'with a 384 well plate' do - let(:plate) { create :plate_with_untagged_wells, sample_count: 4 * 16, size: 384 } + let(:plate) { create(:plate_with_untagged_wells, sample_count: 4 * 16, size: 384) } let(:tag_count) { 384 } - let(:tag2_group) { create :tag_group, tag_count: } + let(:tag2_group) { create(:tag_group, tag_count:) } let(:expected_tag_layout) do { 'A1' => [1], @@ -415,9 +415,9 @@ def generate_tag_layout(plate, tag_type = :tag) let(:direction) { 'column' } context 'with a 384 well plate' do - let(:plate) { create :plate_with_untagged_wells, sample_count: 4 * 16, size: 384 } + let(:plate) { create(:plate_with_untagged_wells, sample_count: 4 * 16, size: 384) } let(:tag_count) { 384 } - let(:tag2_group) { create :tag_group, tag_count: } + let(:tag2_group) { create(:tag_group, tag_count:) } let(:expected_tag_layout) do { 'A1' => [1], @@ -572,9 +572,9 @@ def generate_tag_layout(plate, tag_type = :tag) let(:direction) { 'inverse column' } context 'with a 384 well plate' do - let(:plate) { create :plate_with_untagged_wells, sample_count: 4 * 16, size: 384 } + let(:plate) { create(:plate_with_untagged_wells, sample_count: 4 * 16, size: 384) } let(:tag_count) { 384 } - let(:tag2_group) { create :tag_group, tag_count: } + let(:tag2_group) { create(:tag_group, tag_count:) } let(:expected_tag_layout) do { 'A1' => [96], @@ -729,9 +729,9 @@ def generate_tag_layout(plate, tag_type = :tag) let(:direction) { 'row' } context 'with a 384 well plate' do - let(:plate) { create :plate_with_untagged_wells, sample_count: 4 * 16, size: 384 } + let(:plate) { create(:plate_with_untagged_wells, sample_count: 4 * 16, size: 384) } let(:tag_count) { 384 } - let(:tag2_group) { create :tag_group, tag_count: } + let(:tag2_group) { create(:tag_group, tag_count:) } let(:expected_tag_layout) do { 'A1' => [1], @@ -1014,7 +1014,7 @@ def generate_tag_layout(plate, tag_type = :tag) end context 'with a tag2 group' do - let(:tag2_group) { create :tag_group, tag_count: } + let(:tag2_group) { create(:tag_group, tag_count:) } let(:walking_by) { 'wells of plate' } let(:direction) { 'column' } let(:expected_tag_layout) do diff --git a/spec/models/tag_layout_template_spec.rb b/spec/models/tag_layout_template_spec.rb index df287dc940..b7f48db02d 100644 --- a/spec/models/tag_layout_template_spec.rb +++ b/spec/models/tag_layout_template_spec.rb @@ -7,21 +7,21 @@ # templates. The actual layout of tags is carried out by the tag layouts themselves, # and is tested there. describe TagLayoutTemplate do - let(:template) { build :tag_layout_template, direction_algorithm:, walking_algorithm:, tag2_group:, tags: ['AAA'] } + let(:template) { build(:tag_layout_template, direction_algorithm:, walking_algorithm:, tag2_group:, tags: ['AAA']) } describe '#create!' do subject { template.create!(plate:, user:) } - let(:user) { build :user } + let(:user) { build(:user) } - let(:plate) { create :plate } + let(:plate) { create(:plate) } let(:tag2_group) { nil } let(:enforce_uniqueness) { nil } context 'by plate in columns' do let(:direction_algorithm) { 'TagLayout::InColumns' } let(:walking_algorithm) { 'TagLayout::WalkWellsOfPlate' } - let(:plate) { create :plate, :with_submissions, well_count: 1 } + let(:plate) { create(:plate, :with_submissions, well_count: 1) } it { is_expected.to be_a TagLayout } @@ -48,7 +48,7 @@ context 'with a tag2 group' do let(:enforce_uniqueness) { true } - let(:tag2_group) { create :tag_group_with_tags } + let(:tag2_group) { create(:tag_group_with_tags) } it { is_expected.to be_a TagLayout } @@ -76,7 +76,7 @@ subject { template.create!(plate:, user:, enforce_uniqueness:) } let(:enforce_uniqueness) { nil } - let(:tag2_group) { create :tag_group_with_tags } + let(:tag2_group) { create(:tag_group_with_tags) } it { is_expected.to be_a TagLayout } diff --git a/spec/models/tag_substitutions_spec.rb b/spec/models/tag_substitutions_spec.rb index af24e4729f..8f8175877e 100644 --- a/spec/models/tag_substitutions_spec.rb +++ b/spec/models/tag_substitutions_spec.rb @@ -15,12 +15,12 @@ subject { described_class.new({ substitutions: instructions }.merge(additional_parameters)) } - let(:sample_a) { create :sample } - let(:sample_b) { create :sample } - let(:library_tube_a) { create :library_tube } - let(:library_tube_b) { create :library_tube } - let(:mx_library_tube) { create :multiplexed_library_tube } - let(:library_type) { create :library_type } + let(:sample_a) { create(:sample) } + let(:sample_b) { create(:sample) } + let(:library_tube_a) { create(:library_tube) } + let(:library_tube_b) { create(:library_tube) } + let(:mx_library_tube) { create(:multiplexed_library_tube) } + let(:library_type) { create(:library_type) } let(:additional_parameters) { {} } shared_examples 'tag substitution' do @@ -57,61 +57,61 @@ end context 'with a simple tag swap' do - let(:sample_a_orig_tag) { create :tag } - let(:sample_a_orig_tag2) { create :tag } + let(:sample_a_orig_tag) { create(:tag) } + let(:sample_a_orig_tag2) { create(:tag) } let(:sample_a_new_tag) { sample_b_orig_tag } - let(:sample_b_orig_tag) { create :tag } - let(:sample_b_orig_tag2) { create :tag } + let(:sample_b_orig_tag) { create(:tag) } + let(:sample_b_orig_tag2) { create(:tag) } let(:sample_b_new_tag) { sample_a_orig_tag } let!(:library_aliquot_a) do - create :aliquot, + create(:aliquot, sample: sample_a, tag: sample_a_orig_tag, tag2: sample_a_orig_tag2, library: library_tube_a, - receptacle: library_tube_a + receptacle: library_tube_a) end let!(:library_aliquot_b) do - create :aliquot, + create(:aliquot, sample: sample_b, tag: sample_b_orig_tag, tag2: sample_b_orig_tag2, library: library_tube_b, - receptacle: library_tube_b + receptacle: library_tube_b) end let!(:mx_aliquot_a) do - create :aliquot, + create(:aliquot, sample: sample_a, tag: sample_a_orig_tag, tag2: sample_a_orig_tag2, library: library_tube_a, - receptacle: mx_library_tube + receptacle: mx_library_tube) end let!(:mx_aliquot_b) do - create :aliquot, + create(:aliquot, sample: sample_b, tag: sample_b_orig_tag, tag2: sample_b_orig_tag2, library: library_tube_b, - receptacle: mx_library_tube + receptacle: mx_library_tube) end - let!(:mx_aliquot_c) { create :tagged_aliquot, library: library_tube_b, receptacle: mx_library_tube } + let!(:mx_aliquot_c) { create(:tagged_aliquot, library: library_tube_b, receptacle: mx_library_tube) } - let!(:lane) { create :lane } + let!(:lane) { create(:lane) } let!(:lane_aliquot_a) do - create :aliquot, + create(:aliquot, sample: sample_a, tag: sample_a_orig_tag, tag2: sample_a_orig_tag2, library: library_tube_a, - receptacle: lane + receptacle: lane) end let!(:flowcell_message) do batch = create(:sequencing_batch, request_attributes: [{ target_asset: lane }]) - create :flowcell_messenger, target: batch + create(:flowcell_messenger, target: batch) end context 'with only tag 1' do @@ -342,36 +342,36 @@ end context 'with a multi-tag sample tag swap' do - let(:sample_a_orig_tag_a) { create :tag } - let(:sample_b_orig_tag_a) { create :tag } - let(:sample_a_orig_tag_b) { create :tag } - let(:sample_b_orig_tag_b) { create :tag } - let(:other_tag) { create :tag } + let(:sample_a_orig_tag_a) { create(:tag) } + let(:sample_b_orig_tag_a) { create(:tag) } + let(:sample_a_orig_tag_b) { create(:tag) } + let(:sample_b_orig_tag_b) { create(:tag) } + let(:other_tag) { create(:tag) } # Build aliquots let!(:library_aliquot_a_a) do - create :aliquot, sample: sample_a, tag: sample_a_orig_tag_a, library: library_tube_a, receptacle: library_tube_a + create(:aliquot, sample: sample_a, tag: sample_a_orig_tag_a, library: library_tube_a, receptacle: library_tube_a) end let!(:library_aliquot_a_b) do - create :aliquot, sample: sample_a, tag: sample_a_orig_tag_b, library: library_tube_a, receptacle: library_tube_a + create(:aliquot, sample: sample_a, tag: sample_a_orig_tag_b, library: library_tube_a, receptacle: library_tube_a) end let!(:library_aliquot_b_a) do - create :aliquot, sample: sample_b, tag: sample_b_orig_tag_a, library: library_tube_b, receptacle: library_tube_b + create(:aliquot, sample: sample_b, tag: sample_b_orig_tag_a, library: library_tube_b, receptacle: library_tube_b) end let!(:library_aliquot_b_b) do - create :aliquot, sample: sample_b, tag: sample_b_orig_tag_b, library: library_tube_b, receptacle: library_tube_b + create(:aliquot, sample: sample_b, tag: sample_b_orig_tag_b, library: library_tube_b, receptacle: library_tube_b) end let!(:mx_aliquot_a_a) do - create :aliquot, sample: sample_a, tag: sample_a_orig_tag_a, library: library_tube_a, receptacle: mx_library_tube + create(:aliquot, sample: sample_a, tag: sample_a_orig_tag_a, library: library_tube_a, receptacle: mx_library_tube) end let!(:mx_aliquot_a_b) do - create :aliquot, sample: sample_a, tag: sample_a_orig_tag_b, library: library_tube_a, receptacle: mx_library_tube + create(:aliquot, sample: sample_a, tag: sample_a_orig_tag_b, library: library_tube_a, receptacle: mx_library_tube) end let!(:mx_aliquot_b_a) do - create :aliquot, sample: sample_b, tag: sample_b_orig_tag_a, library: library_tube_b, receptacle: mx_library_tube + create(:aliquot, sample: sample_b, tag: sample_b_orig_tag_a, library: library_tube_b, receptacle: mx_library_tube) end let!(:mx_aliquot_b_b) do - create :aliquot, sample: sample_b, tag: sample_b_orig_tag_b, library: library_tube_b, receptacle: mx_library_tube + create(:aliquot, sample: sample_b, tag: sample_b_orig_tag_b, library: library_tube_b, receptacle: mx_library_tube) end let(:instructions) do diff --git a/spec/models/tasks/cherrypick_task_spec.rb b/spec/models/tasks/cherrypick_task_spec.rb index 91974f4d1b..b076f84ddf 100644 --- a/spec/models/tasks/cherrypick_task_spec.rb +++ b/spec/models/tasks/cherrypick_task_spec.rb @@ -5,14 +5,14 @@ RSpec.configure { |c| c.include LabWhereClientHelper } RSpec.describe CherrypickTask do - let!(:plate) { create :plate_with_untagged_wells, sample_count: 4 } - let(:control_plate) { create :control_plate, sample_count: 2 } + let!(:plate) { create(:plate_with_untagged_wells, sample_count: 4) } + let(:control_plate) { create(:control_plate, sample_count: 2) } let(:requests) { plate.wells.in_column_major_order.map { |w| create(:cherrypick_request, asset: w, submission:) } } let(:template) { create(:plate_template, size: 6) } let(:robot) { instance_double('Robot', max_beds: 2) } # rubocop:todo RSpec/VerifiedDoubleReference - let(:purpose) { create :purpose } + let(:purpose) { create(:purpose) } let(:batch) { instance_double('Batch', id: 1235, requests:) } # rubocop:todo RSpec/VerifiedDoubleReference - let(:submission) { create :submission } + let(:submission) { create(:submission) } let(:wells_to_leave_free) { Rails.application.config.plate_default_control_wells_to_leave_free } def pick_without_request_id(plates) @@ -98,7 +98,7 @@ def requests_for_plate(plate) end describe '#pick_onto_partial_plate' do - let!(:partial_plate) { create :plate, size: 6 } + let!(:partial_plate) { create(:plate, size: 6) } before do partial_plate.wells.create! @@ -118,7 +118,7 @@ def requests_for_plate(plate) end let(:instance) { described_class.new } - let!(:plate) { create :plate_with_untagged_wells, sample_count: 2 } + let!(:plate) { create(:plate_with_untagged_wells, sample_count: 2) } let(:destinations) do [ [ @@ -146,7 +146,7 @@ def requests_for_plate(plate) end let(:instance) { described_class.new } - let!(:plate) { create :plate_with_untagged_wells, sample_count: 4 } + let!(:plate) { create(:plate_with_untagged_wells, sample_count: 4) } let(:destinations) do [ [ @@ -177,9 +177,9 @@ def requests_for_plate(plate) end describe '#build_plate_wells_from_requests' do - let!(:plate1) { create :plate_with_untagged_wells, sample_count: 4, name: 'plate1' } - let!(:plate2) { create :plate_with_untagged_wells, sample_count: 4, name: 'plate2' } - let!(:plate3) { create :plate_with_untagged_wells, sample_count: 4, name: 'plate3' } + let!(:plate1) { create(:plate_with_untagged_wells, sample_count: 4, name: 'plate1') } + let!(:plate2) { create(:plate_with_untagged_wells, sample_count: 4, name: 'plate2') } + let!(:plate3) { create(:plate_with_untagged_wells, sample_count: 4, name: 'plate3') } let(:plates) { [plate1, plate2, plate3] } let(:requests1) { requests_for_plate(plate1) } let(:requests2) { requests_for_plate(plate2) } diff --git a/spec/models/tasks/plate_template_task_spec.rb b/spec/models/tasks/plate_template_task_spec.rb index d961cf2772..cf15bc55cf 100644 --- a/spec/models/tasks/plate_template_task_spec.rb +++ b/spec/models/tasks/plate_template_task_spec.rb @@ -5,7 +5,7 @@ # This is a very tangled test, as I'm hoping to unhook the current dependencies # so need to wrap it at its current level of messiness RSpec.describe PlateTemplateTask do - subject(:task) { create :plate_template_task } + subject(:task) { create(:plate_template_task) } let(:pipeline) { task.workflow.pipeline } let(:requests) do @@ -21,13 +21,13 @@ let(:plate_a_barcode_number) { '1' } let(:plate_b_barcode_number) { '2' } let(:plate_a) do - create :plate, barcode: "SQPD-#{plate_a_barcode_number}", well_count: 4, well_factory: :untagged_well + create(:plate, barcode: "SQPD-#{plate_a_barcode_number}", well_count: 4, well_factory: :untagged_well) end let(:plate_b) do - create :plate, barcode: "SQPD-#{plate_b_barcode_number}", well_count: 4, well_factory: :untagged_well + create(:plate, barcode: "SQPD-#{plate_b_barcode_number}", well_count: 4, well_factory: :untagged_well) end - let(:batch) { create :batch, requests:, pipeline: } + let(:batch) { create(:batch, requests:, pipeline:) } let(:request) { instance_double(ActionDispatch::Request, parameters: params) } let(:workflow) { pipeline.workflow } @@ -58,7 +58,7 @@ let(:file) { instance_double(ActionDispatch::Http::UploadedFile, 'blank?' => false, :read => payload) } let(:workflow_controller) { instance_double(WorkflowsController, batch:) } - let(:user) { build :user } + let(:user) { build(:user) } describe '#render_task' do let(:workflow_controller) do diff --git a/spec/models/tasks/set_descriptors_handler/handler_spec.rb b/spec/models/tasks/set_descriptors_handler/handler_spec.rb index edd1567dde..b3410c6714 100644 --- a/spec/models/tasks/set_descriptors_handler/handler_spec.rb +++ b/spec/models/tasks/set_descriptors_handler/handler_spec.rb @@ -7,10 +7,10 @@ RSpec.describe Tasks::SetDescriptorsHandler::Handler do subject(:handler) { described_class.new(controller:, params:, task:, user:) } - let(:batch) { create :batch, request_count: 1 } + let(:batch) { create(:batch, request_count: 1) } let(:request) { batch.requests.first } let(:controller) { instance_double(WorkflowsController) } - let(:user) { create :user } + let(:user) { create(:user) } let(:task) { instance_double(SetDescriptorsTask, name: 'Step 1', id: 1) } describe '#perform' do diff --git a/spec/models/transfer/between_plates_spec.rb b/spec/models/transfer/between_plates_spec.rb index b3583e96da..fac5959b16 100644 --- a/spec/models/transfer/between_plates_spec.rb +++ b/spec/models/transfer/between_plates_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' describe Transfer::BetweenPlates do - let(:user) { create :user } - let(:source) { create :stock_plate, sample_count: 5, well_factory: :untagged_well } - let(:destination) { create :plate, well_count: 5, well_factory: :empty_well } + let(:user) { create(:user) } + let(:source) { create(:stock_plate, sample_count: 5, well_factory: :untagged_well) } + let(:destination) { create(:plate, well_count: 5, well_factory: :empty_well) } before do described_class.create!( diff --git a/spec/models/transfer/from_plate_to_tube_spec.rb b/spec/models/transfer/from_plate_to_tube_spec.rb index 1bfdd4e42a..983872a7f9 100644 --- a/spec/models/transfer/from_plate_to_tube_spec.rb +++ b/spec/models/transfer/from_plate_to_tube_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe Transfer::FromPlateToTube do - let(:transfer_without_transfers) { create :transfer_from_plate_to_tube } - let(:transfer_with_transfers) { create :transfer_from_plate_to_tube_with_transfers } + let(:transfer_without_transfers) { create(:transfer_from_plate_to_tube) } + let(:transfer_with_transfers) { create(:transfer_from_plate_to_tube_with_transfers) } it 'transfers all wells by default' do expect(transfer_without_transfers.transfers).to eq(%w[A1 B1 C1]) diff --git a/spec/models/transfer_request_collection_spec.rb b/spec/models/transfer_request_collection_spec.rb index 349f8b8025..ed8de275f0 100644 --- a/spec/models/transfer_request_collection_spec.rb +++ b/spec/models/transfer_request_collection_spec.rb @@ -5,9 +5,9 @@ RSpec.describe TransferRequestCollection, :transfer_request_collection do subject { described_class.new(creation_attributes) } - let(:user) { create :user } - let(:asset) { create :tagged_well } - let(:target_asset) { create :empty_library_tube } + let(:user) { create(:user) } + let(:asset) { create(:tagged_well) } + let(:target_asset) { create(:empty_library_tube) } context 'with a single transfer' do let(:creation_attributes) { { user:, transfer_requests_attributes: [{ asset:, target_asset: }] } } @@ -33,8 +33,8 @@ end context 'and one outer request' do - let(:submission) { create :submission } - let!(:outer_request) { create :request, asset:, submission: } + let(:submission) { create(:submission) } + let!(:outer_request) { create(:request, asset:, submission:) } describe '#save' do let(:transfer_request) { subject.transfer_requests.first } @@ -56,10 +56,10 @@ end context 'and two outer requests' do - let(:submission_a) { create :submission } - let(:submission_b) { create :submission } - let!(:outer_request) { create :request, asset:, submission: submission_a } - let!(:other_outer_request) { create :request, asset:, submission: submission_b } + let(:submission_a) { create(:submission) } + let(:submission_b) { create(:submission) } + let!(:outer_request) { create(:request, asset:, submission: submission_a) } + let!(:other_outer_request) { create(:request, asset:, submission: submission_b) } describe '#save' do let(:transfer_request) { subject.transfer_requests.first } @@ -95,9 +95,9 @@ end context 'and two outer requests in the same submission' do - let(:submission) { create :submission } - let!(:outer_request) { create :request, asset:, submission: } - let!(:other_outer_request) { create :request, asset:, submission: } + let(:submission) { create(:submission) } + let!(:outer_request) { create(:request, asset:, submission:) } + let!(:other_outer_request) { create(:request, asset:, submission:) } describe '#save' do let(:transfer_request) { subject.transfer_requests.first } diff --git a/spec/models/transfer_request_spec.rb b/spec/models/transfer_request_spec.rb index 77199bfc9b..e9d9de3a7d 100644 --- a/spec/models/transfer_request_spec.rb +++ b/spec/models/transfer_request_spec.rb @@ -4,32 +4,32 @@ require 'shared_contexts/limber_shared_context' RSpec.describe TransferRequest do - let(:source) { create :well_with_sample_and_without_plate } + let(:source) { create(:well_with_sample_and_without_plate) } let(:tag) { create(:tag).tag!(source) } - let(:destination) { create :well } - let(:example_study) { create :study } - let(:example_project) { create :project } + let(:destination) { create(:well) } + let(:example_study) { create(:study) } + let(:example_project) { create(:project) } context 'with a library request' do subject do - create :transfer_request, asset: source, target_asset: destination, submission: library_request.submission + create(:transfer_request, asset: source, target_asset: destination, submission: library_request.submission) end let(:library_request) do - create :library_request, + create(:library_request, asset: source, initial_study: example_study, initial_project: example_project, - state: library_state + state: library_state) end context 'with volume' do subject do - create :transfer_request, + create(:transfer_request, asset: source, target_asset: destination, submission: library_request.submission, - volume: 4.5 + volume: 4.5) end let(:library_state) { 'pending' } @@ -68,11 +68,11 @@ context 'with a primer panel' do let(:library_request) do - create :gbs_request, + create(:gbs_request, state: 'pending', asset: source, initial_study: example_study, - initial_project: example_project + initial_project: example_project) end it 'sets appropriate metadata on the aliquots' do @@ -94,7 +94,7 @@ end context 'with multiple library requests' do - subject { create :transfer_request, asset: source, target_asset: destination, outer_request: library_request } + subject { create(:transfer_request, asset: source, target_asset: destination, outer_request: library_request) } before do library_request @@ -102,20 +102,20 @@ end let(:library_request) do - create :library_request, + create(:library_request, asset: source, initial_study: example_study, initial_project: example_project, - state: library_state + state: library_state) end let(:dummy_library_request) do - create :library_request, + create(:library_request, asset: source, initial_study: example_study, initial_project: example_project, state: library_state, - submission: library_request.submission + submission: library_request.submission) end context 'with a pending library request' do @@ -168,7 +168,7 @@ end context 'when the source has stock wells' do - let(:source) { create :well_with_sample_and_without_plate, stock_wells: create_list(:well, 2) } + let(:source) { create(:well_with_sample_and_without_plate, stock_wells: create_list(:well, 2)) } it 'sets the stock wells' do expect(destination.stock_wells).to eq(source.stock_wells) @@ -176,7 +176,7 @@ end context 'when the source is a stock well' do - let(:source) { create :well_with_sample_and_without_plate, plate: create(:stock_plate) } + let(:source) { create(:well_with_sample_and_without_plate, plate: create(:stock_plate)) } it 'sets the stock wells' do expect(destination.stock_wells).to eq([source]) @@ -214,7 +214,7 @@ context 'when the destination has equivalent aliquots' do let(:equivalent_aliquot) { source.aliquots.first.dup } - let(:destination) { create :well, aliquots: [equivalent_aliquot] } + let(:destination) { create(:well, aliquots: [equivalent_aliquot]) } let(:transfer_request) do described_class.new(asset: source, target_asset: destination, merge_equivalent_aliquots: merge) end @@ -245,11 +245,11 @@ end context 'with a tag clash' do - let!(:tag) { create :tag } - let!(:tag2) { create :tag } - let!(:aliquot_1) { create :aliquot, tag:, tag2: } - let!(:aliquot_2) { create :aliquot, tag:, tag2:, receptacle: create(:well) } - let!(:target_asset) { create :well, aliquots: [aliquot_1] } + let!(:tag) { create(:tag) } + let!(:tag2) { create(:tag) } + let!(:aliquot_1) { create(:aliquot, tag:, tag2:) } + let!(:aliquot_2) { create(:aliquot, tag:, tag2:, receptacle: create(:well)) } + let!(:target_asset) { create(:well, aliquots: [aliquot_1]) } it 'raises an exception' do expect do @@ -260,7 +260,7 @@ end describe 'state_machine' do - subject { create :transfer_request } + subject { create(:transfer_request) } { start: { @@ -324,20 +324,20 @@ end context 'outer request' do - let(:last_well) { create :well_with_sample_and_without_plate } - let(:example_study) { create :study } - let(:example_project) { create :project } + let(:last_well) { create(:well_with_sample_and_without_plate) } + let(:example_study) { create(:study) } + let(:example_project) { create(:project) } - let(:library_request) { create :library_request, asset: stock_asset, submission: create(:submission) } + let(:library_request) { create(:library_request, asset: stock_asset, submission: create(:submission)) } before do # A decoy library request, this is part of a different submission and # should be ignored - create :library_request, asset: stock_asset, submission: create(:submission) + create(:library_request, asset: stock_asset, submission: create(:submission)) last_well.stock_wells << stock_asset end - let(:transfer_request) { create :transfer_request, asset: source_asset, submission: library_request.submission } + let(:transfer_request) { create(:transfer_request, asset: source_asset, submission: library_request.submission) } describe '#outer_request' do subject { transfer_request.outer_request } @@ -351,17 +351,18 @@ context 'from a well downstream of a stock asset' do let(:source_asset) { last_well } - let(:stock_asset) { create :well_with_sample_and_without_plate } + let(:stock_asset) { create(:well_with_sample_and_without_plate) } it { is_expected.to eq library_request } end context 'from a tube made from the last well' do - let(:stock_asset) { create :well_with_sample_and_without_plate } - let(:source_asset) { create :tube } + let(:stock_asset) { create(:well_with_sample_and_without_plate) } + let(:source_asset) { create(:tube) } before do - create :transfer_request, asset: last_well, target_asset: source_asset, submission: library_request.submission + create(:transfer_request, asset: last_well, target_asset: source_asset, +submission: library_request.submission) end it { is_expected.to eq library_request } @@ -433,56 +434,56 @@ end context 'transfer downstream of pooling (such as in ISC)' do - let(:library_request_type) { create :library_request_type } - let(:multiplex_request_type) { create :multiplex_request_type } + let(:library_request_type) { create(:library_request_type) } + let(:multiplex_request_type) { create(:multiplex_request_type) } # In some cases (such as chromium) we have multiple aliquots pre library request - let(:source_well_a) { create :tagged_well, aliquot_count: 2 } - let(:source_well_b) { create :tagged_well } - let(:target_well) { create :empty_well } - let(:submission) { create :submission } + let(:source_well_a) { create(:tagged_well, aliquot_count: 2) } + let(:source_well_b) { create(:tagged_well) } + let(:target_well) { create(:empty_well) } + let(:submission) { create(:submission) } let(:order) do - create :library_order, + create(:library_order, submission:, request_types: [library_request_type.id, multiplex_request_type.id], - assets: [source_well_a, source_well_b] + assets: [source_well_a, source_well_b]) end - let(:multiplexed_library_tube) { create :multiplexed_library_tube, aliquots: [] } + let(:multiplexed_library_tube) { create(:multiplexed_library_tube, aliquots: []) } let(:library_request_a) do - create :library_request, + create(:library_request, asset: source_well_a, target_asset: target_well, submission:, order:, state: 'passed', - request_type: library_request_type + request_type: library_request_type) end let(:library_request_b) do - create :library_request, + create(:library_request, asset: source_well_b, target_asset: target_well, submission:, order:, state: 'passed', - request_type: library_request_type + request_type: library_request_type) end # While source and target assets are the same, we actually have two requests let(:multiplex_request_a) do - create :multiplex_request, + create(:multiplex_request, asset: target_well, target_asset: multiplexed_library_tube, submission:, order:, - request_type: multiplex_request_type + request_type: multiplex_request_type) end let(:multiplex_request_b) do - create :multiplex_request, + create(:multiplex_request, asset: target_well, target_asset: multiplexed_library_tube, submission:, order:, - request_type: multiplex_request_type + request_type: multiplex_request_type) end # Order here matters @@ -493,7 +494,7 @@ multiplex_request_a multiplex_request_b create(:transfer_request, asset: source_well_a, target_asset: target_well, submission:) - create :transfer_request, asset: source_well_b, target_asset: target_well, submission: + create(:transfer_request, asset: source_well_b, target_asset: target_well, submission:) end it 'associated each aliquot with a different library request' do diff --git a/spec/models/tube_purpose_spec.rb b/spec/models/tube_purpose_spec.rb index 8581ce7a97..b5acfb940a 100644 --- a/spec/models/tube_purpose_spec.rb +++ b/spec/models/tube_purpose_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Tube::Purpose do - let(:tube_purpose) { create :tube_purpose, prefix: barcode_prefix, target_type: } + let(:tube_purpose) { create(:tube_purpose, prefix: barcode_prefix, target_type:) } shared_examples 'a tube factory' do describe '#create!' do diff --git a/spec/models/tube_rack_spec.rb b/spec/models/tube_rack_spec.rb index 8a3678bb99..1bf07e9ce7 100644 --- a/spec/models/tube_rack_spec.rb +++ b/spec/models/tube_rack_spec.rb @@ -4,21 +4,21 @@ RSpec.describe TubeRack do describe '#create' do it 'can be created' do - tube_rack = create :tube_rack + tube_rack = create(:tube_rack) expect(described_class.exists?(tube_rack.id)).to be(true) end it 'can contain racked_tubes' do - tube_rack = create :tube_rack - racked_tube = create :racked_tube + tube_rack = create(:tube_rack) + racked_tube = create(:racked_tube) expect { tube_rack.racked_tubes << racked_tube }.to(change { tube_rack.racked_tubes.count }.by(1)) end it 'can contain a barcode' do - tube_rack = create :tube_rack - barcode = create :barcode, barcode: 'SA00057843' + tube_rack = create(:tube_rack) + barcode = create(:barcode, barcode: 'SA00057843') tube_rack.barcodes << barcode @@ -28,7 +28,7 @@ describe '#update' do it 'can be updated' do - tube_rack = create :tube_rack + tube_rack = create(:tube_rack) tube_rack.update(size: 96) expect(described_class.find(tube_rack.id).size).to eq(96) @@ -36,7 +36,7 @@ end describe '#destroy' do - let!(:tube_rack) { create :tube_rack } + let!(:tube_rack) { create(:tube_rack) } it 'can be destroyed' do tube_rack.destroy @@ -57,9 +57,9 @@ describe 'scope #contained_samples' do let(:num_tubes) { locations.length } - let(:tube_rack) { create :tube_rack } + let(:tube_rack) { create(:tube_rack) } let(:locations) { %w[A01 B01 C01] } - let(:barcodes) { Array.new(num_tubes) { create :fluidx } } + let(:barcodes) { Array.new(num_tubes) { create(:fluidx) } } let!(:tubes) do Array.new(num_tubes) do |i| create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) @@ -72,20 +72,20 @@ end context 'with a rack with tubes and requests' do - let(:tube_rack) { create :tube_rack } - let(:tube_a) { create :tube, :in_a_rack, tube_rack:, coordinate: 'A1' } - let(:tube_b) { create :tube, :in_a_rack, tube_rack:, coordinate: 'H12' } - let(:aliquot) { create :aliquot, receptacle: tube_a.receptacle, request: create(:request, submission:) } - let(:outer_request) { create :request, asset: tube_b.receptacle, submission: } - let(:submission) { create :submission } + let(:tube_rack) { create(:tube_rack) } + let(:tube_a) { create(:tube, :in_a_rack, tube_rack:, coordinate: 'A1') } + let(:tube_b) { create(:tube, :in_a_rack, tube_rack:, coordinate: 'H12') } + let(:aliquot) { create(:aliquot, receptacle: tube_a.receptacle, request: create(:request, submission:)) } + let(:outer_request) { create(:request, asset: tube_b.receptacle, submission:) } + let(:submission) { create(:submission) } # The comments scope should also retrieve comments associated with tubes, and # their requests describe '#comments' do - let!(:rack_comment) { create :comment, commentable: tube_rack, title: 'Rack' } - let!(:tube_comment) { create :comment, commentable: tube_a, title: 'Tube' } - let!(:request_comment_a) { create :comment, commentable: aliquot.request, title: 'Request(Aliquot)' } - let!(:request_comment_b) { create :comment, commentable: outer_request, title: 'Request(Receptacle)' } + let!(:rack_comment) { create(:comment, commentable: tube_rack, title: 'Rack') } + let!(:tube_comment) { create(:comment, commentable: tube_a, title: 'Tube') } + let!(:request_comment_a) { create(:comment, commentable: aliquot.request, title: 'Request(Aliquot)') } + let!(:request_comment_b) { create(:comment, commentable: outer_request, title: 'Request(Receptacle)') } it 'includes all relevant comments' do comments = tube_rack.reload.comments @@ -105,7 +105,7 @@ before { outer_request } it 'ensures comments are visible on the tubes' do - create :comment, commentable: tube_rack + create(:comment, commentable: tube_rack) expect(tube_b.reload.comments.count).to eq 1 end end @@ -114,7 +114,7 @@ before { tube_b } it 'ensures comments are visible on the tubes' do - create :comment, commentable: tube_rack + create(:comment, commentable: tube_rack) expect(tube_b.reload.comments.count).to eq 1 end end diff --git a/spec/models/tube_spec.rb b/spec/models/tube_spec.rb index 71f53282c3..5a14236d10 100644 --- a/spec/models/tube_spec.rb +++ b/spec/models/tube_spec.rb @@ -5,10 +5,10 @@ describe Tube do describe 'scope:: in_column_major_order' do - let(:tube_rack) { create :tube_rack } + let(:tube_rack) { create(:tube_rack) } let(:num_tubes) { locations.length } let(:locations) { %w[A01 H12 D04] } - let(:barcodes) { Array.new(num_tubes) { create :fluidx } } + let(:barcodes) { Array.new(num_tubes) { create(:fluidx) } } before do Array.new(num_tubes) do |i| @@ -22,7 +22,7 @@ end context 'when a tube is not in a rack' do - let!(:tube) { create :tube } + let!(:tube) { create(:tube) } it 'returns nil for the tube_rack relation' do expect(tube.tube_rack).to be_nil @@ -30,8 +30,8 @@ end context 'when a tube is in a rack' do - let!(:tube_rack) { create :tube_rack } - let!(:tube) { create :tube } + let!(:tube_rack) { create(:tube_rack) } + let!(:tube) { create(:tube) } let!(:racked_tube) { RackedTube.create(tube_rack_id: tube_rack.id, tube_id: tube.id) } it 'destroying the Tube destroys the RackedTube too, but not the TubeRack' do @@ -68,9 +68,9 @@ end describe '#comments' do - let(:tube) { create :tube } + let(:tube) { create(:tube) } - before { create :comment, commentable: tube, description: 'Comment on tube' } + before { create(:comment, commentable: tube, description: 'Comment on tube') } it 'allows comment addition' do tube.comments.create!(description: 'Works') @@ -86,11 +86,11 @@ end context 'with requests' do - let(:submission) { create :submission } - let!(:request) { create :well_request, asset: tube, submission: } + let(:submission) { create(:submission) } + let!(:request) { create(:well_request, asset: tube, submission:) } before do - create :comment, commentable: request, description: 'Comment on request' + create(:comment, commentable: request, description: 'Comment on request') tube.reload end @@ -110,11 +110,11 @@ context 'with requests in progress the wells' do before do - submission = create :submission + submission = create(:submission) request = create(:well_request, submission:) tube.receptacle.aliquots << create(:aliquot, request:) create(:transfer_request, target_asset: tube, submission:) - create :comment, commentable: request, description: 'Comment on request' + create(:comment, commentable: request, description: 'Comment on request') tube.reload end @@ -127,12 +127,12 @@ context 'with multiple identical comments' do before do - submission = create :submission + submission = create(:submission) request = create(:well_request, asset: tube, submission:) request2 = create(:well_request, asset: tube, submission:) - create :comment, commentable: request, description: 'Duplicate comment' - create :comment, commentable: request2, description: 'Duplicate comment' - create :comment, commentable: tube, description: 'Duplicate comment' + create(:comment, commentable: request, description: 'Duplicate comment') + create(:comment, commentable: request2, description: 'Duplicate comment') + create(:comment, commentable: tube, description: 'Duplicate comment') tube.reload end diff --git a/spec/models/user_query_spec.rb b/spec/models/user_query_spec.rb index a987f9e09b..b785a71729 100644 --- a/spec/models/user_query_spec.rb +++ b/spec/models/user_query_spec.rb @@ -4,7 +4,7 @@ require 'timecop' describe UserQuery do - let!(:user) { create :user, login: 'login', email: 'login@example.com' } + let!(:user) { create(:user, login: 'login', email: 'login@example.com') } let!(:user_query_attributes) do { user_email: 'another_email@example.com', diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c7c3b1632e..9772a60032 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' RSpec.describe User do - let(:user) { create :user } + let(:user) { create(:user) } describe '#consent_withdrawn_sample_metadata' do - let(:samples) { create_list :sample, 4 } + let(:samples) { create_list(:sample, 4) } before { samples.each { |sample| sample.sample_metadata.update(user_id_of_consent_withdrawn: user.id) } } @@ -17,7 +17,7 @@ shared_examples 'a role predicate' do context 'when checking an administrator is an administrator' do - let(:user) { create :admin } + let(:user) { create(:admin) } let(:role_name) { 'administrator' } let(:authorizable) { nil } @@ -25,7 +25,7 @@ end context 'when checking an administrator is an manager' do - let(:user) { create :admin } + let(:user) { create(:admin) } let(:role_name) { 'manager' } let(:authorizable) { nil } @@ -33,7 +33,7 @@ end context 'when checking an non-administrator is an administrator' do - let(:user) { create :user } + let(:user) { create(:user) } let(:role_name) { 'administrator' } let(:authorizable) { nil } @@ -41,7 +41,7 @@ end context 'when checking an manager is an manager (generic)' do - let(:study) { create :study_with_manager } + let(:study) { create(:study_with_manager) } let(:user) { study.managers.first } let(:role_name) { 'manager' } let(:authorizable) { nil } @@ -50,7 +50,7 @@ end context 'when checking an manager of their study' do - let(:study) { create :study_with_manager } + let(:study) { create(:study_with_manager) } let(:user) { study.managers.first } let(:role_name) { 'manager' } let(:authorizable) { study } @@ -59,10 +59,10 @@ end context 'when checking an manager of a different study' do - let(:study) { create :study_with_manager } + let(:study) { create(:study_with_manager) } let(:user) { study.managers.first } let(:role_name) { 'manager' } - let(:authorizable) { create :study } + let(:authorizable) { create(:study) } it { is_expected.to be false } end @@ -98,8 +98,8 @@ end describe '#grant_role' do - let(:user) { create :user } - let(:study) { create :study } + let(:user) { create(:user) } + let(:study) { create(:study) } it 'adds a role to a user' do user.grant_role('administrator') @@ -127,7 +127,7 @@ end describe '#remove_role' do - let(:study) { create :study_with_manager, updated_at: 2.years.ago } + let(:study) { create(:study_with_manager, updated_at: 2.years.ago) } it 'updates the study updated_at timestamp' do # We make sure that defining a study with a manager triggers study update diff --git a/spec/models/well_attribute_spec.rb b/spec/models/well_attribute_spec.rb index 3c58df2683..9fbc043992 100644 --- a/spec/models/well_attribute_spec.rb +++ b/spec/models/well_attribute_spec.rb @@ -3,8 +3,8 @@ require 'rails_helper' describe WellAttribute do - let(:well_attribute) { create :well_attribute } - let(:well) { create :well, well_attribute: } + let(:well_attribute) { create(:well_attribute) } + let(:well) { create(:well, well_attribute:) } let!(:warehouse_message) { Messenger.create!(target: well, template: 'WellStockResourceIO', root: 'stock_resource') } it 'does not let current_volume to get negative' do diff --git a/spec/models/well_spec.rb b/spec/models/well_spec.rb index f1d7ec5382..88b0a3dc7f 100644 --- a/spec/models/well_spec.rb +++ b/spec/models/well_spec.rb @@ -3,7 +3,7 @@ require 'timecop' describe Well do - subject(:well) { create :well, well_attribute_attributes: well_attributes } + subject(:well) { create(:well, well_attribute_attributes: well_attributes) } let(:well_attributes) { {} } @@ -73,7 +73,7 @@ describe '#update_from_qc' do let(:well_attributes) { { concentration: nil } } - let(:qc_result) { build :qc_result, key:, value:, units:, assay_type: 'assay', assay_version: 1 } + let(:qc_result) { build(:qc_result, key:, value:, units:, assay_type: 'assay', assay_version: 1) } before { well.update_from_qc(qc_result) } @@ -159,10 +159,10 @@ end it 'return a correct hash of target wells' do - purposes = create_list :plate_purpose, 4 - stock_plate = create :plate_with_untagged_wells, sample_count: 3 + purposes = create_list(:plate_purpose, 4) + stock_plate = create(:plate_with_untagged_wells, sample_count: 3) - norm_plates = purposes.map { |purpose| create :plate_with_untagged_wells, purpose:, sample_count: 3 } + norm_plates = purposes.map { |purpose| create(:plate_with_untagged_wells, purpose:, sample_count: 3) } well_plate_concentrations = [ # Plate 1, Plate 2, Plate 3 @@ -242,7 +242,7 @@ context 'with a plate' do before do - @plate = create :plate + @plate = create(:plate) well.plate = @plate end @@ -277,8 +277,8 @@ # rubocop:enable Metrics/ParameterLists context 'cherrypick by nano grams' do before do - @source_well = create :well - @target_well = create :well + @source_well = create(:well) + @target_well = create(:well) minimum_volume = 10 maximum_volume = 50 robot_minimum_picking_volume = 1.0 @@ -310,8 +310,8 @@ context 'when while cherrypicking by nanograms' do context 'and we want to get less volume than the minimum' do before do - @source_well = create :well - @target_well = create :well + @source_well = create(:well) + @target_well = create(:well) @measured_concentration = 100 @measured_volume = 50 @@ -466,35 +466,35 @@ context 'proceed test' do before do - @our_product_criteria = create :product_criteria - @other_criteria = create :product_criteria + @our_product_criteria = create(:product_criteria) + @other_criteria = create(:product_criteria) @old_report = - create :qc_report, + create(:qc_report, product_criteria: @our_product_criteria, created_at: 1.day.ago, - report_identifier: "A#{Time.zone.now}" + report_identifier: "A#{Time.zone.now}") @current_report = - create :qc_report, + create(:qc_report, product_criteria: @our_product_criteria, created_at: 1.hour.ago, - report_identifier: "B#{Time.zone.now}" + report_identifier: "B#{Time.zone.now}") @unrelated_report = - create :qc_report, + create(:qc_report, product_criteria: @other_criteria, created_at: Time.zone.now, - report_identifier: "C#{Time.zone.now}" + report_identifier: "C#{Time.zone.now}") - @stock_well = create :well + @stock_well = create(:well) well.stock_wells.attach!([@stock_well]) well.reload - create :qc_metric, asset: @stock_well, qc_report: @old_report, qc_decision: 'passed', proceed: true - create :qc_metric, asset: @stock_well, qc_report: @unrelated_report, qc_decision: 'passed', proceed: true + create(:qc_metric, asset: @stock_well, qc_report: @old_report, qc_decision: 'passed', proceed: true) + create(:qc_metric, asset: @stock_well, qc_report: @unrelated_report, qc_decision: 'passed', proceed: true) @expected_metric = - create :qc_metric, asset: @stock_well, qc_report: @current_report, qc_decision: 'failed', proceed: true + create(:qc_metric, asset: @stock_well, qc_report: @current_report, qc_decision: 'failed', proceed: true) end it 'report appropriate metrics' do @@ -562,7 +562,7 @@ end context '(DPL-148) on updating well attribute' do - let(:well) { create :well } + let(:well) { create(:well) } it 'triggers warehouse update', :warren do expect do diff --git a/spec/models/work_completion_spec.rb b/spec/models/work_completion_spec.rb index dd84c0fefb..ef71d58b27 100644 --- a/spec/models/work_completion_spec.rb +++ b/spec/models/work_completion_spec.rb @@ -15,16 +15,16 @@ let(:submission_request_types) { [library_request_type] } let(:target_tube) do - tt = create :multiplexed_library_tube + tt = create(:multiplexed_library_tube) tt.parents << upstream_tube - create :transfer_request, asset: upstream_tube, target_asset: tt + create(:transfer_request, asset: upstream_tube, target_asset: tt) tt end let(:upstream_tube) do - ut = create :new_stock_multiplexed_library_tube + ut = create(:new_stock_multiplexed_library_tube) [target_plate, target_plate2].each do |plate| - plate.wells.each { |well| create :transfer_request, asset: well, target_asset: ut } + plate.wells.each { |well| create(:transfer_request, asset: well, target_asset: ut) } end ut.parents = [target_plate, target_plate2] ut @@ -32,22 +32,22 @@ let(:target_plate2) do build_library_requests2 - create :target_plate, parent: input_plate2, well_count: tested_wells, submission: target_submission2 + create(:target_plate, parent: input_plate2, well_count: tested_wells, submission: target_submission2) end - let(:input_plate2) { create :input_plate, well_count: tested_wells, well_factory: :tagged_well } + let(:input_plate2) { create(:input_plate, well_count: tested_wells, well_factory: :tagged_well) } let(:build_library_requests2) do input_plate2.wells.each do |well| - create_list :library_request, + create_list(:library_request, requests_per_well, request_type: library_request_type, asset: well, submission: target_submission2, state: 'started', - order: order2 + order: order2) end end let(:target_submission2) do - create :library_submission, assets: input_plate2.wells, request_types: submission_request_types + create(:library_submission, assets: input_plate2.wells, request_types: submission_request_types) end let(:order2) { target_submission2.orders.first } diff --git a/spec/models/work_order_spec.rb b/spec/models/work_order_spec.rb index 903537e2b5..e387e67124 100644 --- a/spec/models/work_order_spec.rb +++ b/spec/models/work_order_spec.rb @@ -3,10 +3,10 @@ require 'rails_helper' describe WorkOrder do - subject { build :work_order, work_order_type: } + subject { build(:work_order, work_order_type:) } context 'with a work_order_type' do - let(:work_order_type) { create :work_order_type } + let(:work_order_type) { create(:work_order_type) } it { is_expected.to be_valid } end @@ -19,7 +19,7 @@ context 'with requests' do let(:requests) { build_list(:request, 2) } - let(:work_order) { build :work_order, requests: } + let(:work_order) { build(:work_order, requests:) } describe '#state=' do before { work_order.state = 'passed' } @@ -33,8 +33,8 @@ describe WorkOrder::Factory do subject(:factory) { described_class.new(submission) } - let(:submission) { create :submission, requests: } - let(:request_type) { create :request_type } + let(:submission) { create(:submission, requests:) } + let(:request_type) { create(:request_type) } let(:requests_set_a) { create_list(:request, 3, asset: create(:well), request_type:) } let(:requests) { requests_set_a + requests_set_b } diff --git a/spec/models/work_order_type_spec.rb b/spec/models/work_order_type_spec.rb index 17b6bd85a7..fe8fe8c869 100644 --- a/spec/models/work_order_type_spec.rb +++ b/spec/models/work_order_type_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe WorkOrderType do - subject { build :work_order_type, name: } + subject { build(:work_order_type, name:) } context 'with a name' do let(:name) { 'test_order' } @@ -13,7 +13,7 @@ end context 'which already exists' do - before { create :work_order_type, name: } + before { create(:work_order_type, name:) } it { is_expected.not_to be_valid } end diff --git a/spec/models/working_dilution_plate_spec.rb b/spec/models/working_dilution_plate_spec.rb index 01b53bab83..45bf75e8a6 100644 --- a/spec/models/working_dilution_plate_spec.rb +++ b/spec/models/working_dilution_plate_spec.rb @@ -22,9 +22,9 @@ } end let(:plate) do - create :working_dilution_plate, well_count: 3, well_factory: :empty_well, parents: [parent], dilution_factor: 10 + create(:working_dilution_plate, well_count: 3, well_factory: :empty_well, parents: [parent], dilution_factor: 10) end - let(:parent) { create :plate, well_count: 3 } + let(:parent) { create(:plate, well_count: 3) } let(:parser) { MockParser.new(readings) } before { plate.update_qc_values_with_parser(parser) } diff --git a/spec/requests/api/v2/aliquots_spec.rb b/spec/requests/api/v2/aliquots_spec.rb index 614ae9290c..9708bb64bd 100644 --- a/spec/requests/api/v2/aliquots_spec.rb +++ b/spec/requests/api/v2/aliquots_spec.rb @@ -25,7 +25,7 @@ end context 'with a aliquot' do - let(:resource_model) { create :aliquot } + let(:resource_model) { create(:aliquot) } it 'sends an individual aliquot' do api_get "#{base_endpoint}/#{resource_model.id}" diff --git a/spec/requests/api/v2/asset_audits_spec.rb b/spec/requests/api/v2/asset_audits_spec.rb index b00e71e203..82a81b0add 100644 --- a/spec/requests/api/v2/asset_audits_spec.rb +++ b/spec/requests/api/v2/asset_audits_spec.rb @@ -51,7 +51,7 @@ end describe '#post' do - let(:labware) { create :labware } + let(:labware) { create(:labware) } let(:payload) do { diff --git a/spec/requests/api/v2/comments_spec.rb b/spec/requests/api/v2/comments_spec.rb index 0689fc6fb6..26599cfa5f 100644 --- a/spec/requests/api/v2/comments_spec.rb +++ b/spec/requests/api/v2/comments_spec.rb @@ -25,7 +25,7 @@ end context 'with a Comment' do - let(:resource_model) { create :comment } + let(:resource_model) { create(:comment) } let(:payload) do { @@ -56,8 +56,8 @@ end describe '#post' do - let(:plate) { create :plate } - let!(:request) { create :well_request, asset: plate.wells.first } + let(:plate) { create(:plate) } + let!(:request) { create(:well_request, asset: plate.wells.first) } let(:payload) do { diff --git a/spec/requests/api/v2/custom_metadatum_collections_spec.rb b/spec/requests/api/v2/custom_metadatum_collections_spec.rb index 0c5f1c5571..47e254d67f 100644 --- a/spec/requests/api/v2/custom_metadatum_collections_spec.rb +++ b/spec/requests/api/v2/custom_metadatum_collections_spec.rb @@ -20,9 +20,9 @@ end context 'with a collection' do - let(:resource_model) { create :custom_metadatum_collection_with_metadata } - let(:user) { create :user } - let(:asset) { create :asset } + let(:resource_model) { create(:custom_metadatum_collection_with_metadata) } + let(:user) { create(:user) } + let(:asset) { create(:asset) } describe '#get' do it 'responds with success' do diff --git a/spec/requests/api/v2/labware_spec.rb b/spec/requests/api/v2/labware_spec.rb index fc45d9c744..f648eebba7 100644 --- a/spec/requests/api/v2/labware_spec.rb +++ b/spec/requests/api/v2/labware_spec.rb @@ -34,7 +34,7 @@ end context 'with a request' do - let(:resource_model) { create :sample_tube } + let(:resource_model) { create(:sample_tube) } it 'sends an individual labware' do api_get "#{base_endpoint}/#{resource_model.id}" @@ -44,7 +44,7 @@ end context 'with include' do - let(:custom_metadatum_collection) { create :custom_metadatum_collection_with_metadata } + let(:custom_metadatum_collection) { create(:custom_metadatum_collection_with_metadata) } let(:labware) { custom_metadatum_collection.asset } it 'sends an individual labware' do diff --git a/spec/requests/api/v2/lanes_spec.rb b/spec/requests/api/v2/lanes_spec.rb index d95271a712..b245adebf7 100644 --- a/spec/requests/api/v2/lanes_spec.rb +++ b/spec/requests/api/v2/lanes_spec.rb @@ -25,7 +25,7 @@ end context 'with a lane' do - let(:resource_model) { create :lane } + let(:resource_model) { create(:lane) } it 'sends an individual lane' do api_get "#{base_endpoint}/#{resource_model.id}" diff --git a/spec/requests/api/v2/lot_types_spec.rb b/spec/requests/api/v2/lot_types_spec.rb index dbec287485..b9443d4623 100644 --- a/spec/requests/api/v2/lot_types_spec.rb +++ b/spec/requests/api/v2/lot_types_spec.rb @@ -25,7 +25,7 @@ end context 'with a LotType' do - let(:resource_model) { create :lot_type } + let(:resource_model) { create(:lot_type) } let(:payload) do { diff --git a/spec/requests/api/v2/lots_spec.rb b/spec/requests/api/v2/lots_spec.rb index 28e8ab91bf..333d386dcb 100644 --- a/spec/requests/api/v2/lots_spec.rb +++ b/spec/requests/api/v2/lots_spec.rb @@ -25,7 +25,7 @@ end context 'with a Lot' do - let(:resource_model) { create :lot } + let(:resource_model) { create(:lot) } let(:payload) do { diff --git a/spec/requests/api/v2/orders_spec.rb b/spec/requests/api/v2/orders_spec.rb index cee4ec8334..0faeec1378 100644 --- a/spec/requests/api/v2/orders_spec.rb +++ b/spec/requests/api/v2/orders_spec.rb @@ -25,7 +25,7 @@ end context 'with a order' do - let(:resource_model) { create :order } + let(:resource_model) { create(:order) } let(:payload) do { diff --git a/spec/requests/api/v2/pick_lists_spec.rb b/spec/requests/api/v2/pick_lists_spec.rb index d4558a4a29..70683ef952 100644 --- a/spec/requests/api/v2/pick_lists_spec.rb +++ b/spec/requests/api/v2/pick_lists_spec.rb @@ -25,7 +25,7 @@ end context 'with a PickList' do - let(:resource_model) { create :pick_list } + let(:resource_model) { create(:pick_list) } let(:payload) do { 'data' => { @@ -56,12 +56,12 @@ describe 'POST' do before do - rt = create :cherrypick_request_type, key: 'cherrypick' - create :cherrypick_pipeline, request_type: rt + rt = create(:cherrypick_request_type, key: 'cherrypick') + create(:cherrypick_pipeline, request_type: rt) end context 'with pick_attributes' do - let(:wells) { create_list :untagged_well, 2 } + let(:wells) { create_list(:untagged_well, 2) } let(:payload) do { @@ -85,8 +85,8 @@ end context 'with labware_pick_attributes' do - let(:plate_1) { create :plate_with_untagged_wells, well_count: 1 } - let(:plate_2) { create :plate_with_untagged_wells, well_count: 2 } + let(:plate_1) { create(:plate_with_untagged_wells, well_count: 1) } + let(:plate_2) { create(:plate_with_untagged_wells, well_count: 2) } let(:payload) do { diff --git a/spec/requests/api/v2/plate_purposes_spec.rb b/spec/requests/api/v2/plate_purposes_spec.rb index 48764c0ae0..2522656370 100644 --- a/spec/requests/api/v2/plate_purposes_spec.rb +++ b/spec/requests/api/v2/plate_purposes_spec.rb @@ -51,7 +51,7 @@ end describe '#post' do - let(:asset_shape) { create :asset_shape } + let(:asset_shape) { create(:asset_shape) } context 'with valid payload' do def payload(bools) diff --git a/spec/requests/api/v2/plate_templates_spec.rb b/spec/requests/api/v2/plate_templates_spec.rb index 88149841a9..9b259151de 100644 --- a/spec/requests/api/v2/plate_templates_spec.rb +++ b/spec/requests/api/v2/plate_templates_spec.rb @@ -25,7 +25,7 @@ end context 'with a PlateTemplate' do - let(:resource_model) { create :plate_template } + let(:resource_model) { create(:plate_template) } let(:payload) do { diff --git a/spec/requests/api/v2/plates_spec.rb b/spec/requests/api/v2/plates_spec.rb index 033b06ea04..d73a9414d8 100644 --- a/spec/requests/api/v2/plates_spec.rb +++ b/spec/requests/api/v2/plates_spec.rb @@ -33,9 +33,9 @@ end context 'when providing a payload using default JSON API' do - let(:purpose) { create :plate_purpose } - let(:well) { create :well } - let(:well2) { create :well } + let(:purpose) { create(:plate_purpose) } + let(:well) { create(:well) } + let(:well2) { create(:well) } let(:payload) do { 'data' => { @@ -82,8 +82,8 @@ end context 'with a plate' do - let(:resource_model) { create :plate } - let!(:resource_model_2) { create :plate } + let(:resource_model) { create(:plate) } + let!(:resource_model_2) { create(:plate) } it 'sends an individual plate' do api_get "#{base_endpoint}/#{resource_model.id}" @@ -99,7 +99,7 @@ context 'when the ancestor is a tube rack' do let(:purpose) { create(:plate_purpose, target_type: 'Plate', name: 'Stock Plate', size: '96') } - let(:rack) { create :tube_rack } + let(:rack) { create(:tube_rack) } let(:plate_factory) { Heron::Factories::PlateFromRack.new(tube_rack: rack, plate_purpose: purpose) } let(:tubes) { create_list(:sample_tube, 2) } diff --git a/spec/requests/api/v2/poly_metadata_spec.rb b/spec/requests/api/v2/poly_metadata_spec.rb index 606cb55c22..b3029adce5 100644 --- a/spec/requests/api/v2/poly_metadata_spec.rb +++ b/spec/requests/api/v2/poly_metadata_spec.rb @@ -25,7 +25,7 @@ end context 'with a PolyMetadatum' do - let(:resource_model) { create :poly_metadatum } + let(:resource_model) { create(:poly_metadatum) } let(:payload) do { @@ -61,8 +61,8 @@ end describe '#post' do - let(:plate) { create :plate } - let!(:request) { create :well_request, asset: plate.wells.first } + let(:plate) { create(:plate) } + let!(:request) { create(:well_request, asset: plate.wells.first) } let(:payload) do { diff --git a/spec/requests/api/v2/pre_capture_pools_spec.rb b/spec/requests/api/v2/pre_capture_pools_spec.rb index c6a0bb2d04..82b8f9b2c2 100644 --- a/spec/requests/api/v2/pre_capture_pools_spec.rb +++ b/spec/requests/api/v2/pre_capture_pools_spec.rb @@ -25,7 +25,7 @@ end context 'with a pre_capture_pool' do - let(:resource_model) { create :pre_capture_pool } + let(:resource_model) { create(:pre_capture_pool) } let(:payload) do { diff --git a/spec/requests/api/v2/primer_panels_spec.rb b/spec/requests/api/v2/primer_panels_spec.rb index db580178d9..1fee512fd0 100644 --- a/spec/requests/api/v2/primer_panels_spec.rb +++ b/spec/requests/api/v2/primer_panels_spec.rb @@ -25,7 +25,7 @@ end context 'with a primer_panel' do - let(:resource_model) { create :primer_panel } + let(:resource_model) { create(:primer_panel) } let(:payload) do { diff --git a/spec/requests/api/v2/purposes_spec.rb b/spec/requests/api/v2/purposes_spec.rb index 05bb1a2a1b..09f43df832 100644 --- a/spec/requests/api/v2/purposes_spec.rb +++ b/spec/requests/api/v2/purposes_spec.rb @@ -36,7 +36,7 @@ end context 'with a purpose' do - let(:resource_model) { create :purpose } + let(:resource_model) { create(:purpose) } it 'sends an individual purpose' do api_get "#{base_endpoint}/#{resource_model.id}" diff --git a/spec/requests/api/v2/qcables_spec.rb b/spec/requests/api/v2/qcables_spec.rb index f146723760..03f2aff4c1 100644 --- a/spec/requests/api/v2/qcables_spec.rb +++ b/spec/requests/api/v2/qcables_spec.rb @@ -25,7 +25,7 @@ end context 'with a Qcable' do - let(:resource_model) { create :qcable } + let(:resource_model) { create(:qcable) } let(:payload) do { diff --git a/spec/requests/api/v2/receptacles_spec.rb b/spec/requests/api/v2/receptacles_spec.rb index 8d1ff75143..c13bb8432f 100644 --- a/spec/requests/api/v2/receptacles_spec.rb +++ b/spec/requests/api/v2/receptacles_spec.rb @@ -40,7 +40,7 @@ let(:coverage) { 100 } let(:diluent_volume) { 50.0 } - let(:receptacle) { create :receptacle, pcr_cycles:, submit_for_sequencing:, sub_pool:, coverage:, diluent_volume: } + let(:receptacle) { create(:receptacle, pcr_cycles:, submit_for_sequencing:, sub_pool:, coverage:, diluent_volume:) } before { api_get "#{base_endpoint}/#{receptacle.id}" } diff --git a/spec/requests/api/v2/request_types_spec.rb b/spec/requests/api/v2/request_types_spec.rb index 72f1f8acfc..dde7b95cb8 100644 --- a/spec/requests/api/v2/request_types_spec.rb +++ b/spec/requests/api/v2/request_types_spec.rb @@ -25,7 +25,7 @@ end context 'with a request_type' do - let(:resource_model) { create :request_type } + let(:resource_model) { create(:request_type) } it 'sends an individual request_type' do api_get "#{base_endpoint}/#{resource_model.id}" diff --git a/spec/requests/api/v2/requests_spec.rb b/spec/requests/api/v2/requests_spec.rb index e55c11fdea..a733fa3de2 100644 --- a/spec/requests/api/v2/requests_spec.rb +++ b/spec/requests/api/v2/requests_spec.rb @@ -25,7 +25,7 @@ end context 'with a request' do - let(:resource_model) { create :request } + let(:resource_model) { create(:request) } it 'sends an individual request' do api_get "#{base_endpoint}/#{resource_model.id}?include=primer_panel" diff --git a/spec/requests/api/v2/sample_metadata_spec.rb b/spec/requests/api/v2/sample_metadata_spec.rb index 55251c6b5b..e511e72565 100644 --- a/spec/requests/api/v2/sample_metadata_spec.rb +++ b/spec/requests/api/v2/sample_metadata_spec.rb @@ -20,7 +20,7 @@ end context 'with a single metadata resource' do - let(:resource_model) { create :sample_metadata_for_api } + let(:resource_model) { create(:sample_metadata_for_api) } describe '#get' do it 'generates a success response' do diff --git a/spec/requests/api/v2/studies_spec.rb b/spec/requests/api/v2/studies_spec.rb index 57918382e6..b4badc72d6 100644 --- a/spec/requests/api/v2/studies_spec.rb +++ b/spec/requests/api/v2/studies_spec.rb @@ -36,7 +36,7 @@ end context 'with a study' do - let(:resource_model) { create :study } + let(:resource_model) { create(:study) } it 'sends an individual study' do api_get "#{base_endpoint}/#{resource_model.id}" diff --git a/spec/requests/api/v2/submissions_spec.rb b/spec/requests/api/v2/submissions_spec.rb index 3b3f0db2aa..3483f2004a 100644 --- a/spec/requests/api/v2/submissions_spec.rb +++ b/spec/requests/api/v2/submissions_spec.rb @@ -25,7 +25,7 @@ end context 'with a submission' do - let(:resource_model) { create :submission } + let(:resource_model) { create(:submission) } it 'sends an individual submission without tags' do api_get "#{base_endpoint}/#{resource_model.id}?fields[submissions]" diff --git a/spec/requests/api/v2/tag_groups_spec.rb b/spec/requests/api/v2/tag_groups_spec.rb index 25e1255d0c..a965576834 100644 --- a/spec/requests/api/v2/tag_groups_spec.rb +++ b/spec/requests/api/v2/tag_groups_spec.rb @@ -39,7 +39,7 @@ end context 'with a TagGroup' do - let(:resource_model) { create :tag_group } + let(:resource_model) { create(:tag_group) } let(:payload) do { diff --git a/spec/requests/api/v2/tag_layout_templates_spec.rb b/spec/requests/api/v2/tag_layout_templates_spec.rb index 90a47bb214..5adb31e515 100644 --- a/spec/requests/api/v2/tag_layout_templates_spec.rb +++ b/spec/requests/api/v2/tag_layout_templates_spec.rb @@ -46,7 +46,7 @@ end context 'with a TagLayoutTemplate' do - let(:resource_model) { create :tag_layout_template } + let(:resource_model) { create(:tag_layout_template) } describe '#get' do it 'responds with a success HTTP status code' do diff --git a/spec/requests/api/v2/transfer_requests_spec.rb b/spec/requests/api/v2/transfer_requests_spec.rb index 2459d2173b..9c87eed187 100644 --- a/spec/requests/api/v2/transfer_requests_spec.rb +++ b/spec/requests/api/v2/transfer_requests_spec.rb @@ -25,7 +25,7 @@ end context 'with a TransferRequest' do - let(:resource_model) { create :transfer_request_with_submission } + let(:resource_model) { create(:transfer_request_with_submission) } let(:payload) do { diff --git a/spec/requests/api/v2/transfers/transfers_spec.rb b/spec/requests/api/v2/transfers/transfers_spec.rb index 417a2206de..012975fa0c 100644 --- a/spec/requests/api/v2/transfers/transfers_spec.rb +++ b/spec/requests/api/v2/transfers/transfers_spec.rb @@ -27,7 +27,7 @@ describe '#get Transfer by ID' do context 'with all relationships' do - let(:transfer) { create :transfer_between_plates } + let(:transfer) { create(:transfer_between_plates) } before { api_get "#{base_endpoint}/#{transfer.id}" } @@ -51,7 +51,7 @@ # Some old data may not have a User relationship even though it's required for new records. context 'without a User relationship' do - let(:transfer) { create :transfer_between_plates } + let(:transfer) { create(:transfer_between_plates) } before do # We need to remove the user relationship without invoking validations. diff --git a/spec/requests/api/v2/tube_racks_spec.rb b/spec/requests/api/v2/tube_racks_spec.rb index e32735f2b4..2616a28a7e 100644 --- a/spec/requests/api/v2/tube_racks_spec.rb +++ b/spec/requests/api/v2/tube_racks_spec.rb @@ -25,7 +25,7 @@ end context 'with a TubeRack' do - let(:resource_model) { create :tube_rack } + let(:resource_model) { create(:tube_rack) } let(:payload) do { diff --git a/spec/requests/api/v2/tubes_spec.rb b/spec/requests/api/v2/tubes_spec.rb index 49082d317d..d5e8fd2c9e 100644 --- a/spec/requests/api/v2/tubes_spec.rb +++ b/spec/requests/api/v2/tubes_spec.rb @@ -30,7 +30,7 @@ end context 'with a tube' do - let(:resource_model) { create :tube } + let(:resource_model) { create(:tube) } it 'sends an individual tube' do api_get "#{base_endpoint}/#{resource_model.id}" diff --git a/spec/requests/api/v2/users_spec.rb b/spec/requests/api/v2/users_spec.rb index fe56865dbe..5f44db92f4 100644 --- a/spec/requests/api/v2/users_spec.rb +++ b/spec/requests/api/v2/users_spec.rb @@ -76,7 +76,7 @@ end context 'with a User' do - let(:resource_model) { create :user } + let(:resource_model) { create(:user) } describe '#get' do before { api_get "#{base_endpoint}/#{resource_model.id}" } @@ -97,7 +97,7 @@ end describe '#patch' do - let(:resource_model) { create :user } + let(:resource_model) { create(:user) } let(:payload) { { 'data' => { 'id' => resource_model.id, 'type' => 'users', 'attributes' => {} } } } it 'cannot find a route to the endpoint' do diff --git a/spec/requests/api/v2/volume_update_spec.rb b/spec/requests/api/v2/volume_update_spec.rb index 82c1f31569..8767586e27 100644 --- a/spec/requests/api/v2/volume_update_spec.rb +++ b/spec/requests/api/v2/volume_update_spec.rb @@ -50,7 +50,7 @@ end describe '#post' do - let(:plate) { create :plate } # Only works for plates as update_volume is not set for all labware + let(:plate) { create(:plate) } # Only works for plates as update_volume is not set for all labware let(:payload) do { diff --git a/spec/requests/api/v2/wells_spec.rb b/spec/requests/api/v2/wells_spec.rb index 32911cc516..b2a717647e 100644 --- a/spec/requests/api/v2/wells_spec.rb +++ b/spec/requests/api/v2/wells_spec.rb @@ -31,7 +31,7 @@ let(:coverage) { 100 } let(:diluent_volume) { 50.0 } - let(:well) { create :well, pcr_cycles:, submit_for_sequencing:, sub_pool:, coverage:, diluent_volume: } + let(:well) { create(:well, pcr_cycles:, submit_for_sequencing:, sub_pool:, coverage:, diluent_volume:) } describe '#get' do before { api_get "#{base_endpoint}/#{well.id}" } diff --git a/spec/requests/api/v2/work_orders_spec.rb b/spec/requests/api/v2/work_orders_spec.rb index 2ed8fc439e..b6a25d625e 100644 --- a/spec/requests/api/v2/work_orders_spec.rb +++ b/spec/requests/api/v2/work_orders_spec.rb @@ -9,10 +9,10 @@ it_behaves_like 'ApiKeyAuthenticatable' context 'with multiple requests' do - let(:our_request_type) { create :request_type } - let(:other_request_type) { create :request_type } - let(:our_work_order_type) { create :work_order_type, name: our_request_type.key } - let(:other_work_order_type) { create :work_order_type, name: other_request_type.key } + let(:our_request_type) { create(:request_type) } + let(:other_request_type) { create(:request_type) } + let(:our_work_order_type) { create(:work_order_type, name: our_request_type.key) } + let(:other_work_order_type) { create(:work_order_type, name: other_request_type.key) } before do [ @@ -69,13 +69,13 @@ end context 'with relationships' do - let(:study) { create :study } - let(:well) { create :untagged_well } + let(:study) { create(:study) } + let(:well) { create(:untagged_well) } let(:sample) { well.samples.first } before do - request = create :library_request, initial_study: study, asset: well, project: nil - create :work_order, requests: [request] + request = create(:library_request, initial_study: study, asset: well, project: nil) + create(:work_order, requests: [request]) end let(:expected_includes) do @@ -99,8 +99,8 @@ end context 'with a request' do - let(:requests) { create_list :library_request, 2 } - let(:work_order) { create :work_order, requests: } + let(:requests) { create_list(:library_request, 2) } + let(:work_order) { create(:work_order, requests:) } let(:payload) do { diff --git a/spec/requests/pick_lists_request_spec.rb b/spec/requests/pick_lists_request_spec.rb index 5ce01e03fa..5a82c1e3aa 100644 --- a/spec/requests/pick_lists_request_spec.rb +++ b/spec/requests/pick_lists_request_spec.rb @@ -2,12 +2,12 @@ require 'rails_helper' RSpec.describe 'PickLists' do - let(:user) { create :user, password: 'password' } + let(:user) { create(:user, password: 'password') } before { post '/login', params: { login: user.login, password: 'password' } } describe 'GET index' do - before { create_list :pick_list, 2 } + before { create_list(:pick_list, 2) } it 'returns a list of pick-lists', :aggregate_failures do get '/pick_lists' @@ -17,7 +17,7 @@ end describe 'GET show' do - let(:pick_list) { create :pick_list } + let(:pick_list) { create(:pick_list) } it 'returns a pick-list', :aggregate_failures do get "/pick_lists/#{pick_list.id}" diff --git a/spec/requests/plate_picks_request_spec.rb b/spec/requests/plate_picks_request_spec.rb index 1c34437436..ef57ad8bfd 100644 --- a/spec/requests/plate_picks_request_spec.rb +++ b/spec/requests/plate_picks_request_spec.rb @@ -2,18 +2,18 @@ require 'rails_helper' RSpec.describe 'PlatePicks' do - let(:user) { create :user, password: 'password' } + let(:user) { create(:user, password: 'password') } let(:headers) { { 'ACCEPT' => 'application/json' } } - let(:plate) { create :plate, well_count: 1 } - let(:destination_plate) { create :plate, well_count: 1 } + let(:plate) { create(:plate, well_count: 1) } + let(:destination_plate) { create(:plate, well_count: 1) } let(:released_cherrypick_batch) do - build :cherrypick_batch, + build(:cherrypick_batch, state: 'released', - request_attributes: [{ asset: plate.wells[0], target_asset: destination_plate.wells.first, state: 'passed' }] + request_attributes: [{ asset: plate.wells[0], target_asset: destination_plate.wells.first, state: 'passed' }]) end - let(:released_other_batch) { build :batch, state: 'released', request_attributes: [{ asset: plate.wells[0] }] } + let(:released_other_batch) { build(:batch, state: 'released', request_attributes: [{ asset: plate.wells[0] }]) } let(:pending_cherrypick_batch) do - build :cherrypick_batch, state: 'pending', request_attributes: [{ asset: plate.wells[0] }] + build(:cherrypick_batch, state: 'pending', request_attributes: [{ asset: plate.wells[0] }]) end # We exclude the pending batches here, as they don't have pick information. @@ -71,7 +71,7 @@ describe 'GET batches/:id' do before do - create :robot_with_verification_behaviour + create(:robot_with_verification_behaviour) released_cherrypick_batch.save! pending_cherrypick_batch.save! released_other_batch.save! diff --git a/spec/requests/qc_files_spec.rb b/spec/requests/qc_files_spec.rb index 0a67e06808..e4336b6331 100644 --- a/spec/requests/qc_files_spec.rb +++ b/spec/requests/qc_files_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' RSpec.describe 'QcFiles' do - let(:authorised_app) { create :api_application } + let(:authorised_app) { create(:api_application) } describe 'create qc file' do let(:filename) { Rails.root.join('spec/data/parsers/cardinal_pbmc_count.csv').expand_path } diff --git a/spec/requests/users_request_spec.rb b/spec/requests/users_request_spec.rb index ab6d66e631..e0bc0b53de 100644 --- a/spec/requests/users_request_spec.rb +++ b/spec/requests/users_request_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' RSpec.describe 'Users' do - let(:user) { create :user, password: 'password' } + let(:user) { create(:user, password: 'password') } before { post '/login', params: { login: user.login, password: 'password' } } diff --git a/spec/resources/api/v2/aliquot_resource_spec.rb b/spec/resources/api/v2/aliquot_resource_spec.rb index c8fee4c81a..f9fd7794b8 100644 --- a/spec/resources/api/v2/aliquot_resource_spec.rb +++ b/spec/resources/api/v2/aliquot_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::AliquotResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :aliquot } + let(:resource_model) { build_stubbed(:aliquot) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/barcode_printer_resource_spec.rb b/spec/resources/api/v2/barcode_printer_resource_spec.rb index 8c445b38fc..f7dfeca10c 100644 --- a/spec/resources/api/v2/barcode_printer_resource_spec.rb +++ b/spec/resources/api/v2/barcode_printer_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::BarcodePrinterResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :barcode_printer } + let(:resource_model) { build_stubbed(:barcode_printer) } # Test attributes it 'has the expected attributes', :aggregate_failures do diff --git a/spec/resources/api/v2/comment_resource_spec.rb b/spec/resources/api/v2/comment_resource_spec.rb index 45ad0e4baa..d6dbc109ff 100644 --- a/spec/resources/api/v2/comment_resource_spec.rb +++ b/spec/resources/api/v2/comment_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::CommentResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :comment } + let(:resource_model) { build_stubbed(:comment) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/custom_metadatum_collection_resource_spec.rb b/spec/resources/api/v2/custom_metadatum_collection_resource_spec.rb index 63aec31f3f..ae16ce9d4a 100644 --- a/spec/resources/api/v2/custom_metadatum_collection_resource_spec.rb +++ b/spec/resources/api/v2/custom_metadatum_collection_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::CustomMetadatumCollectionResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :custom_metadatum_collection } + let(:resource_model) { build_stubbed(:custom_metadatum_collection) } # Test attributes it 'has the expected attributes', :aggregate_failures do diff --git a/spec/resources/api/v2/labware_resource_spec.rb b/spec/resources/api/v2/labware_resource_spec.rb index 67186e12b6..1e82bbc23f 100644 --- a/spec/resources/api/v2/labware_resource_spec.rb +++ b/spec/resources/api/v2/labware_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::LabwareResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :labware } + let(:resource_model) { build_stubbed(:labware) } shared_examples 'a labware resource' do # Test attributes diff --git a/spec/resources/api/v2/lane_resource_spec.rb b/spec/resources/api/v2/lane_resource_spec.rb index b64f22f802..212bbfede9 100644 --- a/spec/resources/api/v2/lane_resource_spec.rb +++ b/spec/resources/api/v2/lane_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::LaneResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :lane } + let(:resource_model) { build_stubbed(:lane) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/lot_resource_spec.rb b/spec/resources/api/v2/lot_resource_spec.rb index cfd5d78344..f303fda98a 100644 --- a/spec/resources/api/v2/lot_resource_spec.rb +++ b/spec/resources/api/v2/lot_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::LotResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :lot } + let(:resource_model) { build_stubbed(:lot) } # Test attributes it 'has attributes', :aggregate_failures do diff --git a/spec/resources/api/v2/lot_type_resource_spec.rb b/spec/resources/api/v2/lot_type_resource_spec.rb index d120176c53..74a907b06e 100644 --- a/spec/resources/api/v2/lot_type_resource_spec.rb +++ b/spec/resources/api/v2/lot_type_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::LotTypeResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :lot_type, template_class: } + let(:resource_model) { build_stubbed(:lot_type, template_class:) } let(:template_class) { 'TagLayoutTemplate' } # Test attributes diff --git a/spec/resources/api/v2/order_resource_spec.rb b/spec/resources/api/v2/order_resource_spec.rb index f0c56255ba..d6ee5b6719 100644 --- a/spec/resources/api/v2/order_resource_spec.rb +++ b/spec/resources/api/v2/order_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::OrderResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :order } + let(:resource_model) { build_stubbed(:order) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/pick_list_resource_spec.rb b/spec/resources/api/v2/pick_list_resource_spec.rb index b3e2cfd4d6..e6ee944fc4 100644 --- a/spec/resources/api/v2/pick_list_resource_spec.rb +++ b/spec/resources/api/v2/pick_list_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::PickListResource, :pick_list, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :pick_list } + let(:resource_model) { build_stubbed(:pick_list) } # Read only attributes (almost certainly id) # Once again RSpec/ExampleLength cops war with RSpec/AggregateExamples diff --git a/spec/resources/api/v2/plate_resource_spec.rb b/spec/resources/api/v2/plate_resource_spec.rb index 4659c676a4..3b44e2dc34 100644 --- a/spec/resources/api/v2/plate_resource_spec.rb +++ b/spec/resources/api/v2/plate_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::PlateResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :plate, barcode: 'SQPD-1', well_count: 3 } + let(:resource_model) { build_stubbed(:plate, barcode: 'SQPD-1', well_count: 3) } shared_examples 'a plate resource' do # Test attributes diff --git a/spec/resources/api/v2/plate_template_resource_spec.rb b/spec/resources/api/v2/plate_template_resource_spec.rb index 89c0955f88..83dcdbf7d5 100644 --- a/spec/resources/api/v2/plate_template_resource_spec.rb +++ b/spec/resources/api/v2/plate_template_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::PlateTemplateResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :plate_template } + let(:resource_model) { build_stubbed(:plate_template) } # Test attributes it 'has the expected attributes', :aggregate_failures do diff --git a/spec/resources/api/v2/poly_metadatum_resource_spec.rb b/spec/resources/api/v2/poly_metadatum_resource_spec.rb index f06608189a..da1efc7a41 100644 --- a/spec/resources/api/v2/poly_metadatum_resource_spec.rb +++ b/spec/resources/api/v2/poly_metadatum_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::PolyMetadatumResource, type: :resource do subject(:metadatum_resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :poly_metadatum } + let(:resource_model) { build_stubbed(:poly_metadatum) } # Test attributes it 'works as expected', :aggregate_failures do diff --git a/spec/resources/api/v2/pre_capture_pool_resource_spec.rb b/spec/resources/api/v2/pre_capture_pool_resource_spec.rb index 36f9f77451..b1ae416f5e 100644 --- a/spec/resources/api/v2/pre_capture_pool_resource_spec.rb +++ b/spec/resources/api/v2/pre_capture_pool_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::PreCapturePoolResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :pre_capture_pool } + let(:resource_model) { build_stubbed(:pre_capture_pool) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/primer_panel_resource_spec.rb b/spec/resources/api/v2/primer_panel_resource_spec.rb index 6f5637419f..5a9afa1aa9 100644 --- a/spec/resources/api/v2/primer_panel_resource_spec.rb +++ b/spec/resources/api/v2/primer_panel_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::PrimerPanelResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :primer_panel } + let(:resource_model) { build_stubbed(:primer_panel) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/project_resource_spec.rb b/spec/resources/api/v2/project_resource_spec.rb index 1cd8d53014..a1c3d08d31 100644 --- a/spec/resources/api/v2/project_resource_spec.rb +++ b/spec/resources/api/v2/project_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::SampleResource, type: :resource do subject { described_class.new(sample, {}) } - let(:sample) { create :sample } + let(:sample) { create(:sample) } it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording expect(subject).to have_attribute :sanger_sample_id diff --git a/spec/resources/api/v2/purpose_resource_spec.rb b/spec/resources/api/v2/purpose_resource_spec.rb index 9cca0287c2..9a4e47408d 100644 --- a/spec/resources/api/v2/purpose_resource_spec.rb +++ b/spec/resources/api/v2/purpose_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::PurposeResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :purpose } + let(:resource_model) { build_stubbed(:purpose) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/qcable_resource_spec.rb b/spec/resources/api/v2/qcable_resource_spec.rb index 71d4fd91aa..52e46c8eab 100644 --- a/spec/resources/api/v2/qcable_resource_spec.rb +++ b/spec/resources/api/v2/qcable_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::QcableResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :qcable } + let(:resource_model) { build_stubbed(:qcable) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/receptacle_resource_spec.rb b/spec/resources/api/v2/receptacle_resource_spec.rb index 310a4cc4e5..c992e6e011 100644 --- a/spec/resources/api/v2/receptacle_resource_spec.rb +++ b/spec/resources/api/v2/receptacle_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::ReceptacleResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :receptacle } + let(:resource_model) { build_stubbed(:receptacle) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/request_resource_spec.rb b/spec/resources/api/v2/request_resource_spec.rb index 7cb7a0ff1e..d9e81d28c3 100644 --- a/spec/resources/api/v2/request_resource_spec.rb +++ b/spec/resources/api/v2/request_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::RequestResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :request } + let(:resource_model) { build_stubbed(:request) } # Test attributes let(:expected_metadata) { { 'customer_accepts_responsibility' => false } } @@ -34,8 +34,8 @@ end context 'isc request' do - let(:resource_model) { build_stubbed :isc_request, bait_library: } - let(:bait_library) { create :bait_library } + let(:resource_model) { build_stubbed(:isc_request, bait_library:) } + let(:bait_library) { create(:bait_library) } let(:expected_metadata) do { 'library_type' => 'Agilent Pulldown', diff --git a/spec/resources/api/v2/request_type_resource_spec.rb b/spec/resources/api/v2/request_type_resource_spec.rb index 0f7329d8a7..5d87343d34 100644 --- a/spec/resources/api/v2/request_type_resource_spec.rb +++ b/spec/resources/api/v2/request_type_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::RequestTypeResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :request_type } + let(:resource_model) { build_stubbed(:request_type) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/sample_resource_spec.rb b/spec/resources/api/v2/sample_resource_spec.rb index 5badaae453..248e392d85 100644 --- a/spec/resources/api/v2/sample_resource_spec.rb +++ b/spec/resources/api/v2/sample_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::SampleResource, type: :resource do subject { described_class.new(sample, {}) } - let(:sample) { create :sample } + let(:sample) { create(:sample) } it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording expect(subject).to have_attribute :sanger_sample_id diff --git a/spec/resources/api/v2/state_change_resource_spec.rb b/spec/resources/api/v2/state_change_resource_spec.rb index d985610dc6..94b4309d4f 100644 --- a/spec/resources/api/v2/state_change_resource_spec.rb +++ b/spec/resources/api/v2/state_change_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::StateChangeResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :state_change } + let(:resource_model) { build_stubbed(:state_change) } # Attributes it 'has the expected read-only attributes', :aggregate_failures do diff --git a/spec/resources/api/v2/study_resource_spec.rb b/spec/resources/api/v2/study_resource_spec.rb index 78570bd11f..8876bd0dd8 100644 --- a/spec/resources/api/v2/study_resource_spec.rb +++ b/spec/resources/api/v2/study_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::StudyResource, type: :resource do subject { described_class.new(study, {}) } - let(:study) { create :study } + let(:study) { create(:study) } it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording expect(subject).to have_attribute :name diff --git a/spec/resources/api/v2/submission_resource_spec.rb b/spec/resources/api/v2/submission_resource_spec.rb index c94a48d613..355dadd6f9 100644 --- a/spec/resources/api/v2/submission_resource_spec.rb +++ b/spec/resources/api/v2/submission_resource_spec.rb @@ -7,7 +7,7 @@ subject(:resource) { described_class.new(resource_model, {}) } let(:sequencing_requests) { build_stubbed_list(:sequencing_request, 3) } - let(:resource_model) { build_stubbed :submission, sequencing_requests: } + let(:resource_model) { build_stubbed(:submission, sequencing_requests:) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/submission_template_resource_spec.rb b/spec/resources/api/v2/submission_template_resource_spec.rb index 7f1a8f39db..f9f9546280 100644 --- a/spec/resources/api/v2/submission_template_resource_spec.rb +++ b/spec/resources/api/v2/submission_template_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::SubmissionTemplateResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :submission_template } + let(:resource_model) { build_stubbed(:submission_template) } # Test attributes it 'has the expected attributes', :aggregate_failures do diff --git a/spec/resources/api/v2/tag_group_resource_spec.rb b/spec/resources/api/v2/tag_group_resource_spec.rb index 54fb257d58..ff4f4e21bb 100644 --- a/spec/resources/api/v2/tag_group_resource_spec.rb +++ b/spec/resources/api/v2/tag_group_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::TagGroupResource, type: :resource do subject { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :tag_group, tags: } + let(:resource_model) { build_stubbed(:tag_group, tags:) } let(:tags) do [ build(:tag, oligo: 'AAA', map_id: 1), diff --git a/spec/resources/api/v2/tag_layout_template_resource_spec.rb b/spec/resources/api/v2/tag_layout_template_resource_spec.rb index c01091e1f3..416b946154 100644 --- a/spec/resources/api/v2/tag_layout_template_resource_spec.rb +++ b/spec/resources/api/v2/tag_layout_template_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::TagLayoutTemplateResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :tag_layout_template } + let(:resource_model) { build_stubbed(:tag_layout_template) } # Expected attributes it { is_expected.not_to have_attribute :id } diff --git a/spec/resources/api/v2/tag_resource_spec.rb b/spec/resources/api/v2/tag_resource_spec.rb index 6f60b4d1db..3a1b003fd3 100644 --- a/spec/resources/api/v2/tag_resource_spec.rb +++ b/spec/resources/api/v2/tag_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::TagResource, type: :resource do subject(:tag_resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :tag } + let(:resource_model) { build_stubbed(:tag) } # Test attributes it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/resources/api/v2/transfer_request_resource_spec.rb b/spec/resources/api/v2/transfer_request_resource_spec.rb index 51b552bed4..7cd1a205cb 100644 --- a/spec/resources/api/v2/transfer_request_resource_spec.rb +++ b/spec/resources/api/v2/transfer_request_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::TransferRequestResource, type: :resource do subject(:transfer_request) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :transfer_request } + let(:resource_model) { build_stubbed(:transfer_request) } it 'exposes attributes', :aggregate_failures do # Test attributes diff --git a/spec/resources/api/v2/transfer_template_resource_spec.rb b/spec/resources/api/v2/transfer_template_resource_spec.rb index adb61a50c7..24d70c69d3 100644 --- a/spec/resources/api/v2/transfer_template_resource_spec.rb +++ b/spec/resources/api/v2/transfer_template_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::TransferTemplateResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :transfer_template } + let(:resource_model) { build_stubbed(:transfer_template) } # Test attributes it 'has the expected attributes', :aggregate_failures do diff --git a/spec/resources/api/v2/transfers/transfer_resource_spec.rb b/spec/resources/api/v2/transfers/transfer_resource_spec.rb index 54fc4a02a1..e63cd10711 100644 --- a/spec/resources/api/v2/transfers/transfer_resource_spec.rb +++ b/spec/resources/api/v2/transfers/transfer_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::Transfers::TransferResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :transfer_between_plates } + let(:resource_model) { build_stubbed(:transfer_between_plates) } # Test attributes it 'allows fetching the expected attributes', :aggregate_failures do diff --git a/spec/resources/api/v2/tube_purpose_resource_spec.rb b/spec/resources/api/v2/tube_purpose_resource_spec.rb index 8dff614633..6b274c9004 100644 --- a/spec/resources/api/v2/tube_purpose_resource_spec.rb +++ b/spec/resources/api/v2/tube_purpose_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::TubePurposeResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :tube_purpose } + let(:resource_model) { build_stubbed(:tube_purpose) } # Test attributes it 'has the expected attributes', :aggregate_failures do diff --git a/spec/resources/api/v2/tube_rack_resource_spec.rb b/spec/resources/api/v2/tube_rack_resource_spec.rb index 3877257c99..89e9f4f6c5 100644 --- a/spec/resources/api/v2/tube_rack_resource_spec.rb +++ b/spec/resources/api/v2/tube_rack_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::TubeRackResource, type: :resource do subject(:tube_rack) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :tube_rack } + let(:resource_model) { build_stubbed(:tube_rack) } # Test attributes it 'has attributes', :aggregate_failures do @@ -40,8 +40,8 @@ # Add tests for any custom methods you've added. describe 'tube_locations=' do - let(:a1_tube) { create :tube } - let(:b1_tube) { create :tube } + let(:a1_tube) { create(:tube) } + let(:b1_tube) { create(:tube) } let(:new_locations) { { A1: { uuid: a1_tube.uuid }, B1: { uuid: b1_tube.uuid } } } it 'adds associations for the two tubes' do diff --git a/spec/resources/api/v2/tube_resource_spec.rb b/spec/resources/api/v2/tube_resource_spec.rb index ab049b52c1..e6bb581770 100644 --- a/spec/resources/api/v2/tube_resource_spec.rb +++ b/spec/resources/api/v2/tube_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::TubeResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :tube, barcode_number: 1 } + let(:resource_model) { build_stubbed(:tube, barcode_number: 1) } # Test attributes it 'exposes the expected data', :aggregate_failures do diff --git a/spec/resources/api/v2/user_resource_spec.rb b/spec/resources/api/v2/user_resource_spec.rb index 233ea86fd1..0983c96a04 100644 --- a/spec/resources/api/v2/user_resource_spec.rb +++ b/spec/resources/api/v2/user_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::UserResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :user } + let(:resource_model) { build_stubbed(:user) } # Expected attributes it { is_expected.not_to have_attribute :id } diff --git a/spec/resources/api/v2/well_resource_spec.rb b/spec/resources/api/v2/well_resource_spec.rb index a6e88e7731..44175ee6cd 100644 --- a/spec/resources/api/v2/well_resource_spec.rb +++ b/spec/resources/api/v2/well_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::WellResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :well, plate:, map: position } + let(:resource_model) { build_stubbed(:well, plate:, map: position) } shared_examples 'a well resource' do # Test attributes @@ -54,8 +54,8 @@ end context 'on a plate' do - let(:plate) { create :plate, barcode: 'SQPD-1' } - let(:position) { create :map, description: 'A1' } + let(:plate) { create(:plate, barcode: 'SQPD-1') } + let(:position) { create(:map, description: 'A1') } let(:expected_barcode_hash) { { 'ean13_barcode' => nil, 'human_barcode' => 'SQPD-1' } } let(:expected_position) { { 'name' => 'A1' } } diff --git a/spec/sample_manifest_excel/upload/processor_spec.rb b/spec/sample_manifest_excel/upload/processor_spec.rb index 8b8b445aa5..de2b8bcfe4 100644 --- a/spec/sample_manifest_excel/upload/processor_spec.rb +++ b/spec/sample_manifest_excel/upload/processor_spec.rb @@ -127,7 +127,7 @@ def cell(row, column) # This test may seem a little paranoid, but I actually observed this behaviour # when testing. Somewhat lucky, as I only triggered it by accident! it 'will update the aliquots downstream if both tags and library types have changed' do - new_lt = create :library_type + new_lt = create(:library_type) chromium_tag1 = cell(rows.first, columns[:chromium_tag_well]).value chromium_tag2 = cell(rows.last, columns[:chromium_tag_well]).value cell(rows.first, columns[:chromium_tag_well]).value = chromium_tag2 @@ -1097,7 +1097,7 @@ def cell(row, column) context 'when the tube barcode exists already' do let(:no_of_racks) { 1 } let(:no_of_rows) { 2 } - let(:tube) { create :tube } + let(:tube) { create(:tube) } before { Barcode.create!(asset_id: tube.id, barcode: 'TB11111110', format: 'fluidx_barcode') } diff --git a/spec/sample_manifest_excel/upload/row_spec.rb b/spec/sample_manifest_excel/upload/row_spec.rb index 797fff391a..1b01424401 100644 --- a/spec/sample_manifest_excel/upload/row_spec.rb +++ b/spec/sample_manifest_excel/upload/row_spec.rb @@ -364,7 +364,7 @@ let(:library_tubes) { create_list(:empty_library_tube, 5) } let(:mx_library_tube) { create(:multiplexed_library_tube) } let(:tags) { SampleManifestExcel::Tags::ExampleData.new.take(0, 4) } - let(:manifest) { create :sample_manifest, asset_type: 'multiplexed_library' } + let(:manifest) { create(:sample_manifest, asset_type: 'multiplexed_library') } before do @rows = [] @@ -406,7 +406,7 @@ let(:library_tubes) { create_list(:tagged_library_tube, 5) } let(:mx_library_tube) { create(:multiplexed_library_tube) } let(:tags) { SampleManifestExcel::Tags::ExampleData.new.take(0, 4) } - let(:manifest) { create :sample_manifest, asset_type: 'library' } + let(:manifest) { create(:sample_manifest, asset_type: 'library') } before do @rows = [] diff --git a/spec/sample_manifest_excel/upload/upload_spec.rb b/spec/sample_manifest_excel/upload/upload_spec.rb index 4e737e7c5b..3d6d2d7a52 100644 --- a/spec/sample_manifest_excel/upload/upload_spec.rb +++ b/spec/sample_manifest_excel/upload/upload_spec.rb @@ -10,7 +10,7 @@ end end - let(:user) { create :user, login: 'test_user' } + let(:user) { create(:user, login: 'test_user') } let(:test_file_name) { 'test_file.xlsx' } let(:test_file) { Rack::Test::UploadedFile.new(Rails.root.join(test_file_name), '') } let!(:tag_group) { create(:tag_group) } diff --git a/spec/sample_manifest_excel/worksheet_spec.rb b/spec/sample_manifest_excel/worksheet_spec.rb index 8187f13e01..6b9c3c219b 100644 --- a/spec/sample_manifest_excel/worksheet_spec.rb +++ b/spec/sample_manifest_excel/worksheet_spec.rb @@ -24,7 +24,7 @@ def save_file before do allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode)) - @sample_manifest = create :sample_manifest + @sample_manifest = create(:sample_manifest) sample_manifest.generate end diff --git a/spec/sequencescape_excel/range_spec.rb b/spec/sequencescape_excel/range_spec.rb index 579476a3fd..2117a663d7 100644 --- a/spec/sequencescape_excel/range_spec.rb +++ b/spec/sequencescape_excel/range_spec.rb @@ -72,7 +72,7 @@ context 'with dynamic options' do # Ensure we have at least one option. - before { create :library_type } + before { create(:library_type) } let!(:original_option_size) { LibraryType.count } let(:attributes) { { name: 'library_type', identifier: :name, scope: :alphabetical, first_row: 4 } } @@ -135,7 +135,7 @@ it 'adjusts to changes in option number' do previous_last_cell = range.last_cell.column - create :library_type, name: 'Other' + create(:library_type, name: 'Other') expect(range.last_column).to eq(original_option_size + 1) expect(range.last_cell.column).to eq(previous_last_cell.next) end diff --git a/spec/sequencescape_excel/specialised_field_spec.rb b/spec/sequencescape_excel/specialised_field_spec.rb index a708324385..a9b011a427 100644 --- a/spec/sequencescape_excel/specialised_field_spec.rb +++ b/spec/sequencescape_excel/specialised_field_spec.rb @@ -6,18 +6,18 @@ let(:map) { create(:map) } let(:asset) { create(:untagged_well, map:) } let(:asset2) { create(:untagged_well, map:) } - let(:sample_manifest) { create :sample_manifest } + let(:sample_manifest) { create(:sample_manifest) } let(:sample_manifest_asset) do - create :sample_manifest_asset, asset:, sanger_sample_id: sample.sanger_sample_id, sample_manifest: + create(:sample_manifest_asset, asset:, sanger_sample_id: sample.sanger_sample_id, sample_manifest:) end let(:sample_manifest_asset2) do - create :sample_manifest_asset, asset: asset2, sanger_sample_id: sample2.sanger_sample_id, sample_manifest: + create(:sample_manifest_asset, asset: asset2, sanger_sample_id: sample2.sanger_sample_id, sample_manifest:) end let!(:library_type) { create(:library_type) } let!(:reference_genome) { create(:reference_genome, name: 'new one') } let(:aliquot) { sample_manifest_asset.asset.aliquots.first } - let(:sample) { create :sample_with_sanger_sample_id } - let(:sample2) { create :sample_with_sanger_sample_id } + let(:sample) { create(:sample_with_sanger_sample_id) } + let(:sample2) { create(:sample_with_sanger_sample_id) } describe SequencescapeExcel::SpecialisedField::Base do # We use an anonymous class as classes created in specs have global scope. @@ -195,7 +195,7 @@ def self.name describe SequencescapeExcel::SpecialisedField::SangerPlateId do let!(:sample1) { create(:sample_with_well) } let!(:sample1_plate) { sample1.wells.first.plate } - let(:sample_manifest_asset1) { create :sample_manifest_asset, asset: sample1.primary_receptacle } + let(:sample_manifest_asset1) { create(:sample_manifest_asset, asset: sample1.primary_receptacle) } it 'will be valid if the value matches the sanger human barcode' do expect( @@ -206,7 +206,7 @@ def self.name describe 'with foreign barcodes' do let!(:sample2) { create(:sample_with_well) } - let(:sample_manifest_asset2) { create :sample_manifest_asset, asset: sample2.primary_receptacle } + let(:sample_manifest_asset2) { create(:sample_manifest_asset, asset: sample2.primary_receptacle) } it 'will be valid if the value matches an unused cgap foreign barcode' do expect(described_class.new(value: 'CGAP-ABC001', sample_manifest_asset: sample_manifest_asset1)).to be_valid @@ -241,7 +241,7 @@ def self.name let!(:sample1) { create(:sample) } let!(:sample1_tube) { create(:sample_tube_with_sanger_sample_id, sample: sample1) } - let(:manifest_asset) { create :sample_manifest_asset, asset: sample1_tube } + let(:manifest_asset) { create(:sample_manifest_asset, asset: sample1_tube) } it 'will be valid if the value matches the sanger human barcode' do expect(described_class.new(value: sample1_tube.human_barcode, sample_manifest_asset: manifest_asset)).to be_valid @@ -251,7 +251,7 @@ def self.name describe 'with foreign barcodes' do let!(:sample2) { create(:sample) } let!(:sample2_tube) { create(:sample_tube_with_sanger_sample_id, sample: sample2) } - let(:manifest_asset2) { create :sample_manifest_asset, asset: sample2_tube } + let(:manifest_asset2) { create(:sample_manifest_asset, asset: sample2_tube) } it 'will be valid if the value matches an unused cgap foreign barcode' do expect(described_class.new(value: 'CGAP-ABC001', sample_manifest_asset: manifest_asset)).to be_valid @@ -536,7 +536,7 @@ def self.name end describe SequencescapeExcel::SpecialisedField::ChromiumTagGroup do - let(:adapter_type) { create :adapter_type, name: 'Chromium' } + let(:adapter_type) { create(:adapter_type, name: 'Chromium') } let(:tag_group) { create(:tag_group_with_tags, adapter_type:) } let(:tag_group_name) { tag_group.name } let(:tag_well) { 'A1' } @@ -552,7 +552,7 @@ def self.name end context 'when the tag group is not Chromium' do - let(:adapter_type) { create :adapter_type, name: 'Other' } + let(:adapter_type) { create(:adapter_type, name: 'Other') } it 'will not be valid' do expect(described_class.new(value: tag_group_name, sample_manifest_asset:)).not_to be_valid @@ -615,9 +615,9 @@ def self.name end describe SequencescapeExcel::SpecialisedField::DualIndexTagSet do - let(:tag_group1) { create :tag_group_with_tags } - let(:tag_group2) { create :tag_group_with_tags } - let(:dual_index_tag_set) { create :tag_set, tag_group: tag_group1, tag2_group: tag_group2 } + let(:tag_group1) { create(:tag_group_with_tags) } + let(:tag_group2) { create(:tag_group_with_tags) } + let(:dual_index_tag_set) { create(:tag_set, tag_group: tag_group1, tag2_group: tag_group2) } let(:dual_index_tag_well) { 'A1' } describe 'dual index tag set' do @@ -652,7 +652,7 @@ def self.name end context 'when the tag set name is has only one visible tag group' do - let(:tag_group2) { create :tag_group_with_tags, visible: false } + let(:tag_group2) { create(:tag_group_with_tags, visible: false) } it 'will be not be valid' do expect(sf_dual_index_tag_set).not_to be_valid @@ -740,7 +740,7 @@ def self.name end describe SequencescapeExcel::SpecialisedField::PrimerPanel do - let(:primer_panel) { create :primer_panel } + let(:primer_panel) { create(:primer_panel) } it 'will not be valid without a persisted primer panel' do expect(described_class.new(value: primer_panel.name, sample_manifest_asset:)).to be_valid @@ -957,7 +957,7 @@ def self.name # This section is for the Retention instruction field added as part of the Labware Destruction work describe SequencescapeExcel::SpecialisedField::RetentionInstruction do - let(:user) { create :user } + let(:user) { create(:user) } shared_examples 'a retention instruction labware' do it 'will be invalid if the value is not set' do @@ -1003,23 +1003,23 @@ def self.name end context 'when processing plate wells' do - let(:asset_plate) { create :plate_with_untagged_wells, sample_count: 1 } + let(:asset_plate) { create(:plate_with_untagged_wells, sample_count: 1) } let(:asset) { asset_plate.wells.first } it_behaves_like 'a retention instruction labware' end context 'when processing tubes' do - let(:asset) { create :sample_tube } + let(:asset) { create(:sample_tube) } it_behaves_like 'a retention instruction labware' end context 'when retention instruction is updated (through manifests) for a labware that doesn\'t have retention instructions' do - let(:asset_plate) { create :plate_with_untagged_wells, sample_count: 1 } + let(:asset_plate) { create(:plate_with_untagged_wells, sample_count: 1) } let(:asset) { asset_plate.wells.first } - let(:user) { create :user } + let(:user) { create(:user) } before do custom_metadatum = CustomMetadatum.new diff --git a/spec/sequencescape_excel/worksheet_spec.rb b/spec/sequencescape_excel/worksheet_spec.rb index dd96272d45..7a4a3c90e2 100644 --- a/spec/sequencescape_excel/worksheet_spec.rb +++ b/spec/sequencescape_excel/worksheet_spec.rb @@ -24,11 +24,11 @@ def save_file end before do - create :tag_group, adapter_type: (create :adapter_type, name: 'chromium') - create :primer_panel + create(:tag_group, adapter_type: create(:adapter_type, name: 'chromium')) + create(:primer_panel) allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode)) - @sample_manifest = create :sample_manifest + @sample_manifest = create(:sample_manifest) sample_manifest.generate end diff --git a/spec/shared_contexts/it_requires_login.rb b/spec/shared_contexts/it_requires_login.rb index 1d5cd05827..16e03881d6 100644 --- a/spec/shared_contexts/it_requires_login.rb +++ b/spec/shared_contexts/it_requires_login.rb @@ -11,11 +11,11 @@ session[:user] = create(:user) if params[:resource].present? resource = params.delete(:resource) - params['id'] = (create resource).id + params['id'] = create(resource).id end if params[:parent].present? parent_resource = params.delete(:parent) - params["#{parent_resource}_id"] = (create parent_resource).id + params["#{parent_resource}_id"] = create(parent_resource).id end begin get(action, params:) @@ -38,11 +38,11 @@ session[:user] = nil if params[:resource].present? resource = params.delete(:resource) - params['id'] = (create resource).id + params['id'] = create(resource).id end if params[:parent].present? parent_resource = params.delete(:parent) - params["#{parent_resource}_id"] = (create parent_resource).id + params["#{parent_resource}_id"] = create(parent_resource).id end begin get(action, params:) diff --git a/spec/shared_contexts/limber_shared_context.rb b/spec/shared_contexts/limber_shared_context.rb index 444939fa31..45d204da45 100644 --- a/spec/shared_contexts/limber_shared_context.rb +++ b/spec/shared_contexts/limber_shared_context.rb @@ -10,25 +10,25 @@ # The input plate represents the plate going into the pipeline # from which the requests will be made. - let(:input_plate) { create :input_plate, well_count: tested_wells, well_factory: :tagged_well } - let(:library_request_type) { create :library_request_type } - let(:multiplex_request_type) { create :multiplex_request_type } + let(:input_plate) { create(:input_plate, well_count: tested_wells, well_factory: :tagged_well) } + let(:library_request_type) { create(:library_request_type) } + let(:multiplex_request_type) { create(:multiplex_request_type) } let(:submission_request_types) { [library_request_type, multiplex_request_type] } # The target submission represents the submission we're about to pass requests for let(:target_submission) do - create :library_submission, assets: input_plate.wells, request_types: submission_request_types + create(:library_submission, assets: input_plate.wells, request_types: submission_request_types) end let(:order) { target_submission.orders.first } # The decoy submission represents a submission which we don't care about let(:decoy_submission) do - create :library_submission, assets: input_plate.wells, request_types: submission_request_types + create(:library_submission, assets: input_plate.wells, request_types: submission_request_types) end # The target plate is the downstream plate we are going to be passing. let(:target_plate) do - create :target_plate, parent: input_plate, well_count: tested_wells, submission: target_submission + create(:target_plate, parent: input_plate, well_count: tested_wells, submission: target_submission) end # And now we have a few helpers to make the tests more readable @@ -47,11 +47,11 @@ state: library_state, order: ) - create :library_request, + create(:library_request, request_type: library_request_type, asset: well, submission: decoy_submission, - state: library_state + state: library_state) end end @@ -61,8 +61,8 @@ build_library_requests submission_request_types[1..].each do |downstream_type| input_plate.wells.count.times do - create_list :multiplex_request, requests_per_well, request_type: downstream_type, submission: target_submission - create :multiplex_request, request_type: downstream_type, submission: decoy_submission + create_list(:multiplex_request, requests_per_well, request_type: downstream_type, submission: target_submission) + create(:multiplex_request, request_type: downstream_type, submission: decoy_submission) end end end diff --git a/spec/uat_actions/generate_plate_concentrations_spec.rb b/spec/uat_actions/generate_plate_concentrations_spec.rb index f090c21fef..0c15ece3cb 100644 --- a/spec/uat_actions/generate_plate_concentrations_spec.rb +++ b/spec/uat_actions/generate_plate_concentrations_spec.rb @@ -4,7 +4,7 @@ describe UatActions::GeneratePlateConcentrations do context 'with valid options' do - let(:plate) { create :plate_with_untagged_wells, sample_count: 3 } + let(:plate) { create(:plate_with_untagged_wells, sample_count: 3) } let(:uat_action) { described_class.new(parameters) } let(:report) do # A report is a hash of key value pairs which get returned to the user. diff --git a/spec/uat_actions/generate_qc_results_spec.rb b/spec/uat_actions/generate_qc_results_spec.rb index ce90f2dd33..f2780011b7 100644 --- a/spec/uat_actions/generate_qc_results_spec.rb +++ b/spec/uat_actions/generate_qc_results_spec.rb @@ -4,8 +4,8 @@ describe UatActions::GenerateQcResults do context 'with valid options' do - let(:plate) { create :plate_with_untagged_wells, sample_count: 3 } - let(:tube) { create :sample_tube, barcode: '1' } + let(:plate) { create(:plate_with_untagged_wells, sample_count: 3) } + let(:tube) { create(:sample_tube, barcode: '1') } let(:uat_action) { described_class.new(parameters) } let(:report) do diff --git a/spec/uat_actions/generate_sample_manifest_spec.rb b/spec/uat_actions/generate_sample_manifest_spec.rb index afe0ee14f4..322d4a86cb 100644 --- a/spec/uat_actions/generate_sample_manifest_spec.rb +++ b/spec/uat_actions/generate_sample_manifest_spec.rb @@ -68,7 +68,7 @@ end describe '#create_sample_manifest' do - let(:manifest) { create :sample_manifest, study:, supplier:, count:, asset_type:, purpose: } + let(:manifest) { create(:sample_manifest, study:, supplier:, count:, asset_type:, purpose:) } it 'sets the created sample manifest' do allow(SampleManifest).to receive(:create!).and_return(manifest) @@ -78,7 +78,7 @@ end describe '#generate_manifest' do - let(:manifest) { create :sample_manifest, study:, supplier:, count:, asset_type:, purpose: } + let(:manifest) { create(:sample_manifest, study:, supplier:, count:, asset_type:, purpose:) } it 'create tubes(s)' do expect { uat_action.generate_manifest(manifest) }.to change(SampleTube, :count).by(count).and change { diff --git a/spec/uat_actions/generate_spiked_buffer_tube_spec.rb b/spec/uat_actions/generate_spiked_buffer_tube_spec.rb index 72ac2c9a85..829cb2a8c9 100644 --- a/spec/uat_actions/generate_spiked_buffer_tube_spec.rb +++ b/spec/uat_actions/generate_spiked_buffer_tube_spec.rb @@ -4,7 +4,7 @@ describe UatActions::GenerateSpikedBufferTube do context 'with valid options' do - before { create :study, name: PhiX.configuration[:default_study_option] } + before { create(:study, name: PhiX.configuration[:default_study_option]) } let(:uat_action) { described_class.new(parameters) } diff --git a/spec/uat_actions/generate_tag_layout_template_spec.rb b/spec/uat_actions/generate_tag_layout_template_spec.rb index eb7637fbe3..bb5ac24462 100644 --- a/spec/uat_actions/generate_tag_layout_template_spec.rb +++ b/spec/uat_actions/generate_tag_layout_template_spec.rb @@ -5,8 +5,8 @@ describe UatActions::GenerateTagLayoutTemplate do context 'with valid options' do let(:tag_count) { 96 } - let(:tag_group) { create :tag_group, tag_count: } - let(:tag2_group) { create :tag_group, tag_count: } + let(:tag_group) { create(:tag_group, tag_count:) } + let(:tag2_group) { create(:tag_group, tag_count:) } let(:parameters) do { diff --git a/spec/uat_actions/plate_information_spec.rb b/spec/uat_actions/plate_information_spec.rb index 175e041fe4..6f806275e1 100644 --- a/spec/uat_actions/plate_information_spec.rb +++ b/spec/uat_actions/plate_information_spec.rb @@ -13,7 +13,7 @@ { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } end - before { create :plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode } + before { create(:plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode) } it 'can be performed' do expect(uat_action.perform).to be true @@ -31,7 +31,7 @@ { plate_barcode:, wells_with_aliquots: '', wells_with_active_requests_as_source: '' } end - before { create :plate_with_empty_wells, well_count: 3, barcode: plate_barcode } + before { create(:plate_with_empty_wells, well_count: 3, barcode: plate_barcode) } it 'can be performed' do expect(uat_action.perform).to be true @@ -60,21 +60,21 @@ let(:plate_barcode) { 'SQPD-3' } let(:parameters) { { plate_barcode: } } let(:uat_action) { described_class.new(parameters) } - let(:submission) { create :submission } - let(:request_type) { create :library_creation_request_type } + let(:submission) { create(:submission) } + let(:request_type) { create(:library_creation_request_type) } let(:report) do { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: 'A1, C1' } end before do - plate = create :plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode + plate = create(:plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode) plate_wells = plate.wells.with_contents - req1 = create :library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'started' + req1 = create(:library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'started') plate_wells.first.requests_as_source << req1 - req2 = create :library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'started' + req2 = create(:library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'started') plate_wells.last.requests_as_source << req2 end @@ -90,19 +90,19 @@ let(:plate_barcode) { 'SQPD-4' } let(:parameters) { { plate_barcode: } } let(:uat_action) { described_class.new(parameters) } - let(:submission) { create :submission } - let(:request_type) { create :library_creation_request_type } + let(:submission) { create(:submission) } + let(:request_type) { create(:library_creation_request_type) } let(:report) { { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } } before do - plate = create :plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode + plate = create(:plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode) plate_wells = plate.wells.with_contents - req1 = create :library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'passed' + req1 = create(:library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'passed') plate_wells.first.requests_as_source << req1 - req2 = create :library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'passed' + req2 = create(:library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'passed') plate_wells.last.requests_as_source << req2 end @@ -118,41 +118,41 @@ let(:plate_barcode) { 'SQPD-4' } let(:parameters) { { plate_barcode: } } let(:uat_action) { described_class.new(parameters) } - let(:submission) { create :submission } - let(:submission2) { create :submission } - let(:request_type) { create :library_creation_request_type } + let(:submission) { create(:submission) } + let(:submission2) { create(:submission) } + let(:request_type) { create(:library_creation_request_type) } let(:report) do { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: 'A1, C1' } end before do - plate = create :plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode + plate = create(:plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode) plate_wells = plate.wells.with_contents - req1 = create :library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'passed' + req1 = create(:library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'passed') plate_wells.first.requests_as_source << req1 - req2 = create :library_creation_request, asset: plate_wells.second, submission:, request_type:, state: 'passed' + req2 = create(:library_creation_request, asset: plate_wells.second, submission:, request_type:, state: 'passed') plate_wells.second.requests_as_source << req2 - req3 = create :library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'passed' + req3 = create(:library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'passed') plate_wells.last.requests_as_source << req3 req4 = - create :library_creation_request, + create(:library_creation_request, asset: plate_wells.first, submission: submission2, request_type:, - state: 'started' + state: 'started') plate_wells.first.requests_as_source << req4 req5 = - create :library_creation_request, + create(:library_creation_request, asset: plate_wells.last, submission: submission2, request_type:, - state: 'started' + state: 'started') plate_wells.last.requests_as_source << req5 end diff --git a/spec/uat_actions/test_submission_spec.rb b/spec/uat_actions/test_submission_spec.rb index 43311460fe..5230308d32 100644 --- a/spec/uat_actions/test_submission_spec.rb +++ b/spec/uat_actions/test_submission_spec.rb @@ -6,8 +6,8 @@ context 'valid options' do before { expect(PlateBarcode).to receive(:create_barcode).and_return(first_plate_barcode) } - let(:submission_template) { create :limber_wgs_submission_template } - let(:primer_panel) { create :primer_panel } + let(:submission_template) { create(:limber_wgs_submission_template) } + let(:primer_panel) { create(:primer_panel) } let(:parameters) { { submission_template_name: submission_template.name } } let(:uat_action) { described_class.new(parameters) } let(:first_plate_barcode) { build(:plate_barcode) } diff --git a/spec/validators/novaseqx_pe_validator_spec.rb b/spec/validators/novaseqx_pe_validator_spec.rb index e0c52c5c17..6178f22494 100644 --- a/spec/validators/novaseqx_pe_validator_spec.rb +++ b/spec/validators/novaseqx_pe_validator_spec.rb @@ -5,7 +5,7 @@ describe NovaseqxPeValidator do describe '#validate' do context 'with batch_size_for_flowcell_type validations' do - let(:record) { create :batch, request_count: 2 } + let(:record) { create(:batch, request_count: 2) } it 'returns true if no requests are selected' do record.requests = [] @@ -35,7 +35,7 @@ ].each do |batch_data| it "returns #{batch_data[:result].nil? ? 'nil' : batch_data[:result]} if the flowcell_type is #{batch_data[:flowcell_type]} and the request count is #{batch_data[:request_count]}" do - record = create :batch, request_count: batch_data[:request_count] + record = create(:batch, request_count: batch_data[:request_count]) record.requests.each do |request| request.request_metadata.requested_flowcell_type = batch_data[:flowcell_type] end diff --git a/spec/views/labware/retention_instruction_spec.rb b/spec/views/labware/retention_instruction_spec.rb index 5f1d57cf39..ba58f0f151 100644 --- a/spec/views/labware/retention_instruction_spec.rb +++ b/spec/views/labware/retention_instruction_spec.rb @@ -5,7 +5,7 @@ RSpec.describe 'labware/retention_instruction.html.erb' do include AuthenticatedSystem include RetentionInstructionHelper - let(:user) { create :user } + let(:user) { create(:user) } shared_examples 'displaying retention instruction' do it 'displays the retention instruction' do @@ -37,14 +37,14 @@ context 'when rendering an existing retention instruction - plate' do let(:current_user) { user } - let(:asset) { create :plate_with_3_wells, retention_instruction: :destroy_after_2_years } + let(:asset) { create(:plate_with_3_wells, retention_instruction: :destroy_after_2_years) } it_behaves_like 'displaying retention instruction' end context 'when rendering an existing retention instruction - tube' do let(:current_user) { user } - let(:asset) { create :tube, retention_instruction: :destroy_after_2_years } + let(:asset) { create(:tube, retention_instruction: :destroy_after_2_years) } it_behaves_like 'displaying retention instruction' end diff --git a/spec/views/labware/show_chromium_chip_spec.rb b/spec/views/labware/show_chromium_chip_spec.rb index 71acab24f5..70fe68f26d 100644 --- a/spec/views/labware/show_chromium_chip_spec.rb +++ b/spec/views/labware/show_chromium_chip_spec.rb @@ -4,7 +4,7 @@ RSpec.describe 'labware/show.html.erb' do include AuthenticatedSystem - let(:user) { create :user } + let(:user) { create(:user) } context 'when rendering a Chromium Chip 16-well plate' do # We have a plate with a purpose that has an asset_shape of Shape4x1 @@ -13,8 +13,8 @@ let(:current_user) { user } let(:purpose_name) { 'chromium-chip-purpose' } - let(:purpose) { create :shape4x1_purpose, name: purpose_name } # AssetShape Shape4x1, size 16 - let(:plate) { create :child_plate, well_factory: :passed_well, purpose:, size: 16, sample_count: 16 } + let(:purpose) { create(:shape4x1_purpose, name: purpose_name) } # AssetShape Shape4x1, size 16 + let(:plate) { create(:child_plate, well_factory: :passed_well, purpose:, size: 16, sample_count: 16) } let(:doc) { Nokogiri.HTML(rendered) } before do diff --git a/spec/views/labware/show_html_erb_spec.rb b/spec/views/labware/show_html_erb_spec.rb index 0b57c6da76..cf451915f4 100644 --- a/spec/views/labware/show_html_erb_spec.rb +++ b/spec/views/labware/show_html_erb_spec.rb @@ -4,7 +4,7 @@ RSpec.describe 'labware/show.html.erb' do # rubocop:todo RSpec/DescribeClass include AuthenticatedSystem - let(:user) { create :user } + let(:user) { create(:user) } shared_examples 'retention instruction' do it 'displays retention key instruction in asset summary' do @@ -20,7 +20,7 @@ context 'when rendering a plate' do let(:current_user) { user } - let(:plate) { create :plate_with_3_wells } + let(:plate) { create(:plate_with_3_wells) } before do assign(:asset, plate) # sets @widget = Widget.new in the view template @@ -64,11 +64,11 @@ context 'when rendering a tube rack' do let(:current_user) { user } - let(:rack_barcode) { create :barcode } - let(:tube_rack) { create :tube_rack, barcode: rack_barcode } + let(:rack_barcode) { create(:barcode) } + let(:tube_rack) { create(:tube_rack, barcode: rack_barcode) } let(:locations) { %w[A01 B01 C01] } - let(:barcodes) { Array.new(num_tubes) { create :fluidx } } + let(:barcodes) { Array.new(num_tubes) { create(:fluidx) } } let!(:tubes) do Array.new(num_tubes) do |i| create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) @@ -102,8 +102,8 @@ context 'when rendering a tube' do let(:current_user) { user } - let(:tube_barcode) { create :fluidx } - let(:tube) { create :tube, barcodes: [tube_barcode] } + let(:tube_barcode) { create(:fluidx) } + let(:tube) { create(:tube, barcodes: [tube_barcode]) } before do assign(:asset, tube) # sets @widget = Widget.new in the view template @@ -114,10 +114,10 @@ before { tube.update(racked_tube:) } let(:coordinate) { 'A1' } - let(:racked_tube) { build :racked_tube, tube_rack:, coordinate: } + let(:racked_tube) { build(:racked_tube, tube_rack:, coordinate:) } - let(:rack_barcode) { create :barcode } - let(:tube_rack) { create :tube_rack, barcodes: [rack_barcode] } + let(:rack_barcode) { create(:barcode) } + let(:tube_rack) { create(:tube_rack, barcodes: [rack_barcode]) } it 'renders a tube description label' do render diff --git a/spec/views/report_fails/index_html_erb_spec.rb b/spec/views/report_fails/index_html_erb_spec.rb index 916c913c7f..b9b82c16b4 100644 --- a/spec/views/report_fails/index_html_erb_spec.rb +++ b/spec/views/report_fails/index_html_erb_spec.rb @@ -4,7 +4,7 @@ RSpec.describe 'report_fails/index.html.erb' do include AuthenticatedSystem - let(:user) { create :user } + let(:user) { create(:user) } context 'when rendering the index' do let(:current_user) { user } diff --git a/spec/views/samples/edit_html_erb_spec.rb b/spec/views/samples/edit_html_erb_spec.rb index addee9c510..cf5d3aba71 100644 --- a/spec/views/samples/edit_html_erb_spec.rb +++ b/spec/views/samples/edit_html_erb_spec.rb @@ -5,11 +5,11 @@ RSpec.describe 'samples/edit.html.erb' do include AuthenticatedSystem include RSpecHtmlMatchers - let(:user) { create :user } + let(:user) { create(:user) } context 'when rendering the edit view' do let(:current_user) { user } - let(:sample) { create :sample } + let(:sample) { create(:sample) } let(:time) { DateTime.now } context 'when the sample has consent withdrawn' do diff --git a/spec/views/samples/index_html_erb_spec.rb b/spec/views/samples/index_html_erb_spec.rb index 3f3bdef2aa..ccee843d85 100644 --- a/spec/views/samples/index_html_erb_spec.rb +++ b/spec/views/samples/index_html_erb_spec.rb @@ -4,11 +4,11 @@ RSpec.describe 'samples/index.html.erb' do include AuthenticatedSystem - let(:user) { create :user } + let(:user) { create(:user) } context 'when rendering the index view' do let(:current_user) { user } - let(:samples) { create_list :sample, 4 } + let(:samples) { create_list(:sample, 4) } let(:time) { DateTime.now.utc } let(:time2) { DateTime.now.utc + 5 } diff --git a/spec/views/samples/show_html_erb_spec.rb b/spec/views/samples/show_html_erb_spec.rb index dba8c7e3d1..e89071b61f 100644 --- a/spec/views/samples/show_html_erb_spec.rb +++ b/spec/views/samples/show_html_erb_spec.rb @@ -4,11 +4,11 @@ RSpec.describe 'samples/show.html.erb' do include AuthenticatedSystem - let(:user) { create :user } + let(:user) { create(:user) } context 'when rendering a sample' do let(:current_user) { user } - let(:sample) { create :sample } + let(:sample) { create(:sample) } let(:time) { DateTime.now.utc } context 'when the user has withdrawn consent' do diff --git a/spec/views/tube_rack_summaries/show_html_erb_spec.rb b/spec/views/tube_rack_summaries/show_html_erb_spec.rb index c9ed0a1279..329cdf1de2 100644 --- a/spec/views/tube_rack_summaries/show_html_erb_spec.rb +++ b/spec/views/tube_rack_summaries/show_html_erb_spec.rb @@ -4,15 +4,15 @@ RSpec.describe 'tube_rack_summaries/show.html.erb' do include AuthenticatedSystem - let(:user) { create :user } + let(:user) { create(:user) } context 'when rendering a tube rack summary' do let(:current_user) { user } - let(:rack_barcode) { create :barcode } - let(:tube_rack) { create :tube_rack, barcode: rack_barcode } + let(:rack_barcode) { create(:barcode) } + let(:tube_rack) { create(:tube_rack, barcode: rack_barcode) } let(:locations) { %w[A01 B01 C01] } - let(:barcodes) { Array.new(num_tubes) { create :fluidx } } + let(:barcodes) { Array.new(num_tubes) { create(:fluidx) } } before do Array.new(num_tubes) do |i| diff --git a/test/controllers/admin_controller_test.rb b/test/controllers/admin_controller_test.rb index c7029694b5..4735d1f243 100644 --- a/test/controllers/admin_controller_test.rb +++ b/test/controllers/admin_controller_test.rb @@ -12,7 +12,7 @@ class AdminControllerTest < ActionController::TestCase should_require_login context 'admin frontpage' do - setup { session[:user] = @user = create :admin } + setup { session[:user] = @user = create(:admin) } context '#index' do setup { get :index } diff --git a/test/controllers/admin_programs_controller_test.rb b/test/controllers/admin_programs_controller_test.rb index 49f1014260..fcae80af66 100644 --- a/test/controllers/admin_programs_controller_test.rb +++ b/test/controllers/admin_programs_controller_test.rb @@ -8,13 +8,13 @@ class ProgramsControllerTest < ActionController::TestCase setup do @controller = Admin::ProgramsController.new @request = ActionController::TestRequest.create(@controller) - session[:user] = @user = create :admin + session[:user] = @user = create(:admin) end should_require_login context '#create' do - setup { FactoryBot.create :program, name: 'My unique name of program' } + setup { FactoryBot.create(:program, name: 'My unique name of program') } should 'create a new program' do num = Program.count @@ -32,7 +32,7 @@ class ProgramsControllerTest < ActionController::TestCase end context '#edit' do - setup { @program = FactoryBot.create :program, name: 'My program name' } + setup { @program = FactoryBot.create(:program, name: 'My program name') } should 'edit the name of the new program' do post :update, params: { id: @program.id, program: { name: 'A new name for the program' } } @@ -44,7 +44,7 @@ class ProgramsControllerTest < ActionController::TestCase end context '#show' do - setup { @program = create :program } + setup { @program = create(:program) } should 'display existing programs' do get :show, params: { id: @program.id } diff --git a/test/controllers/admin_projects_controller_test.rb b/test/controllers/admin_projects_controller_test.rb index 0c69f3bb32..5281098d9b 100644 --- a/test/controllers/admin_projects_controller_test.rb +++ b/test/controllers/admin_projects_controller_test.rb @@ -17,12 +17,12 @@ class ProjectsControllerTest < ActionController::TestCase context 'management UI' do setup do - @user = create :admin, email: 'project.owner@example.com' - @project = create :project, approved: false - role = FactoryBot.create :owner_role, authorizable: @project + @user = create(:admin, email: 'project.owner@example.com') + @project = create(:project, approved: false) + role = FactoryBot.create(:owner_role, authorizable: @project) role.users << @user - @request_type = FactoryBot.create :request_type - @other_request_type = FactoryBot.create :request_type + @request_type = FactoryBot.create(:request_type) + @other_request_type = FactoryBot.create(:request_type) session[:user] = @user.id @emails = ActionMailer::Base.deliveries @emails.clear diff --git a/test/controllers/admin_roles_controller_test.rb b/test/controllers/admin_roles_controller_test.rb index adcd7bda24..6e413d7406 100644 --- a/test/controllers/admin_roles_controller_test.rb +++ b/test/controllers/admin_roles_controller_test.rb @@ -13,7 +13,7 @@ class RolesControllerTest < ActionController::TestCase should_require_login context 'with user' do - setup { session[:user] = @user = create :admin } + setup { session[:user] = @user = create(:admin) } resource_test( 'role', diff --git a/test/controllers/admin_studies_controller_test.rb b/test/controllers/admin_studies_controller_test.rb index 7996d83f5f..db80564090 100644 --- a/test/controllers/admin_studies_controller_test.rb +++ b/test/controllers/admin_studies_controller_test.rb @@ -14,9 +14,9 @@ class StudiesControllerTest < ActionController::TestCase context 'management UI' do setup do - @user = FactoryBot.create :admin - @study = FactoryBot.create :study - @request_type = FactoryBot.create :request_type + @user = FactoryBot.create(:admin) + @study = FactoryBot.create(:study) + @request_type = FactoryBot.create(:request_type) session[:user] = @user.id @emails = ActionMailer::Base.deliveries @emails.clear @@ -51,7 +51,7 @@ class StudiesControllerTest < ActionController::TestCase end context 'with a data_access_coordinator role' do - setup { @user.roles << (create :data_access_coordinator_role) } + setup { @user.roles << (create(:data_access_coordinator_role)) } should "change 'ethically_approved'" do Rails.logger.info '******** First Request' diff --git a/test/controllers/admin_users_controller_test.rb b/test/controllers/admin_users_controller_test.rb index 49e279fb6f..19e3835461 100644 --- a/test/controllers/admin_users_controller_test.rb +++ b/test/controllers/admin_users_controller_test.rb @@ -32,13 +32,13 @@ class UsersControllerTest < ActionController::TestCase context '#filter' do setup do - @user = FactoryBot.create :user - @admin = FactoryBot.create :admin + @user = FactoryBot.create(:user) + @admin = FactoryBot.create(:admin) session[:user] = @admin - @user_to_find = FactoryBot.create :user, first_name: 'Some', last_name: 'Body', login: 'sb1' - @another_user = FactoryBot.create :user, first_name: 'No', last_name: 'One', login: 'no1' + @user_to_find = FactoryBot.create(:user, first_name: 'Some', last_name: 'Body', login: 'sb1') + @another_user = FactoryBot.create(:user, first_name: 'No', last_name: 'One', login: 'no1') end should 'find a user based on name' do diff --git a/test/controllers/api/submissions_controller.rb b/test/controllers/api/submissions_controller.rb index bed1cef749..68715f175d 100644 --- a/test/controllers/api/submissions_controller.rb +++ b/test/controllers/api/submissions_controller.rb @@ -8,7 +8,7 @@ class SubmissionsControllerTest < ActionController::TestCase setup do @controller = Api::SubmissionsController.new @request = ActionController::TestRequest.create(@controller) - @user = FactoryBot.create :user + @user = FactoryBot.create(:user) @controller.stubs(:logged_in?).returns(@user) session[:user] = @user.id end @@ -16,11 +16,11 @@ class SubmissionsControllerTest < ActionController::TestCase context '#create' do setup do @submission_count = Submission.count - template = FactoryBot.create :submission_template - study = FactoryBot.create :study - project = FactoryBot.create :project - sample_tube = FactoryBot.create :sample_tube - rt = FactoryBot.create :request_type + template = FactoryBot.create(:submission_template) + study = FactoryBot.create(:study) + project = FactoryBot.create(:project) + sample_tube = FactoryBot.create(:sample_tube) + rt = FactoryBot.create(:request_type) template.request_types << rt post :create, diff --git a/test/controllers/authentication_controller_test.rb b/test/controllers/authentication_controller_test.rb index 32ef3f863e..505e68c3d8 100644 --- a/test/controllers/authentication_controller_test.rb +++ b/test/controllers/authentication_controller_test.rb @@ -114,7 +114,7 @@ class AuthenticationControllerTest < ActionController::TestCase end context 'with valid api_key will not require login to restricted content' do setup do - @user = FactoryBot.create :user + @user = FactoryBot.create(:user) get :restricted, params: { api_key: @user.api_key } end should respond_with :success @@ -143,7 +143,7 @@ class AuthenticationControllerTest < ActionController::TestCase end context 'with valid api_key will not require login to restricted content' do setup do - @user = FactoryBot.create :user + @user = FactoryBot.create(:user) get :restricted, params: { api_key: @user.api_key } end should respond_with :success @@ -177,7 +177,7 @@ class AuthenticationControllerTest < ActionController::TestCase end context 'with valid api_key will not require login to restricted content' do setup do - @user = FactoryBot.create :user + @user = FactoryBot.create(:user) get :restricted, params: { api_key: @user.api_key } end should respond_with :success diff --git a/test/controllers/batches_controller_test.rb b/test/controllers/batches_controller_test.rb index 3738950a45..2c3c84c1c0 100644 --- a/test/controllers/batches_controller_test.rb +++ b/test/controllers/batches_controller_test.rb @@ -16,12 +16,12 @@ class BatchesControllerTest < ActionController::TestCase context 'NPG xml view' do setup do - pipeline = create :sequencing_pipeline + pipeline = create(:sequencing_pipeline) @study = create(:study) @project = create(:project) - @sample = create :sample - @submission = create :submission_without_order, priority: 3 + @sample = create(:sample) + @submission = create(:submission_without_order, priority: 3) @library = create(:empty_library_tube).tap do |library_tube| @@ -34,7 +34,7 @@ class BatchesControllerTest < ActionController::TestCase ) end - @phix = create :spiked_buffer, :tube_barcode + @phix = create(:spiked_buffer, :tube_barcode) @lane = create(:empty_lane, qc_state: 'failed') @lane.labware.parents << @library @@ -120,7 +120,7 @@ class BatchesControllerTest < ActionController::TestCase context 'when the lane has multiple SpikedBuffer ancestors' do setup do - @phix_with_parent = create :spiked_buffer_with_parent, :tube_barcode + @phix_with_parent = create(:spiked_buffer_with_parent, :tube_barcode) @library.parents << @phix_with_parent get :show, params: { id: @batch.id, format: :xml } @@ -141,14 +141,14 @@ class BatchesControllerTest < ActionController::TestCase context 'with a user logged in' do setup do - @user = create :user + @user = create(:user) session[:user] = @user.id end context 'with a few batches' do setup do - @batch_one = create :batch - @batch_two = create :batch + @batch_one = create(:batch) + @batch_two = create(:batch) end should '#index' do @@ -172,9 +172,9 @@ class BatchesControllerTest < ActionController::TestCase context '#verify_tube_layout' do setup do - @pipeline = create :pipeline - @asset1 = create :sample_tube, barcode: '123456' - @asset2 = create :sample_tube, barcode: '654321' + @pipeline = create(:pipeline) + @asset1 = create(:sample_tube, barcode: '123456') + @asset2 = create(:sample_tube, barcode: '654321') @request1 = @pipeline.request_types.last.create!(asset: @asset1) @request2 = @pipeline.request_types.last.create!(asset: @asset2) @@ -216,7 +216,7 @@ class BatchesControllerTest < ActionController::TestCase context 'with a cherrypick pipeline' do setup do - @pipeline = create :cherrypick_pipeline + @pipeline = create(:cherrypick_pipeline) @requests = create_list(:cherrypick_request_for_pipeline, 2, request_type: @pipeline.request_types.first) @selected_request = @requests.first @submission = @selected_request.submission || raise('No Sub') @@ -240,10 +240,10 @@ class BatchesControllerTest < ActionController::TestCase context 'actions' do setup do - @pipeline_next = create :pipeline, name: 'Next pipeline' - @pipeline = create :pipeline, name: 'New Pipeline' - @pipeline_qc_manual = create :pipeline, name: 'Manual quality control' - @pipeline_qc = create :pipeline, name: 'quality control' + @pipeline_next = create(:pipeline, name: 'Next pipeline') + @pipeline = create(:pipeline, name: 'New Pipeline') + @pipeline_qc_manual = create(:pipeline, name: 'Manual quality control') + @pipeline_qc = create(:pipeline, name: 'quality control') @ws = @pipeline.workflow # :name => 'A New workflow', :item_limit => 2 @ws_two = @pipeline_qc.workflow # :name => 'Another workflow', :item_limit => 2 @@ -252,10 +252,10 @@ class BatchesControllerTest < ActionController::TestCase @batch_one = create(:batch, pipeline: @pipeline) @batch_two = create(:batch, pipeline: @pipeline_qc) - @sample = create :sample_tube - @library1 = create :empty_library_tube + @sample = create(:sample_tube) + @library1 = create(:empty_library_tube) @library1.parents << @sample - @library2 = create :empty_library_tube + @library2 = create(:empty_library_tube) @library2.parents << @sample @target_one = create(:sample_tube) @@ -280,7 +280,7 @@ class BatchesControllerTest < ActionController::TestCase end should '#update' do - @pipeline_user = create :pipeline_admin, login: 'ur1', first_name: 'Ursula', last_name: 'Robinson' + @pipeline_user = create(:pipeline_admin, login: 'ur1', first_name: 'Ursula', last_name: 'Robinson') put :update, params: { id: @batch_one.id, batch: { assignee_id: @pipeline_user.id } } assert_redirected_to batch_path(assigns(:batch)) assert_equal assigns(:batch).assignee, @pipeline_user @@ -507,8 +507,8 @@ class BatchesControllerTest < ActionController::TestCase context 'Find by barcode (found)' do setup do @controller.stubs(:current_user).returns(@admin) - @batch = FactoryBot.create :batch - request = FactoryBot.create :request + @batch = FactoryBot.create(:batch) + request = FactoryBot.create(:request) @batch.requests << request r = @batch.requests.first @e = r.lab_events.create(description: 'Cluster generation') @@ -541,26 +541,26 @@ class BatchesControllerTest < ActionController::TestCase attr_reader :barcode_printer setup do - @user = create :user + @user = create(:user) @controller.stubs(:current_user).returns(@user) - @barcode_printer = create :barcode_printer + @barcode_printer = create(:barcode_printer) end should '#print_plate_barcodes should send print request' do - study = create :study - project = create :project - asset = create :empty_sample_tube + study = create(:study) + project = create(:project) + asset = create(:empty_sample_tube) order_role = OrderRole.new role: 'test' order = create(:order, order_role:, study:, assets: [asset], project:) request = create( :well_request, - asset: (create :well_with_sample_and_plate), - target_asset: (create :well_with_sample_and_plate), + asset: create(:well_with_sample_and_plate), + target_asset: create(:well_with_sample_and_plate), order: ) - @batch = create :batch + @batch = create(:batch) @batch.requests << request RestClient.expects(:post) @@ -577,8 +577,8 @@ class BatchesControllerTest < ActionController::TestCase end should '#print_barcodes should send print request' do - request = create :library_creation_request, target_asset: (create :library_tube, barcode: '111') - @batch = create :batch + request = create(:library_creation_request, target_asset: create(:library_tube, barcode: '111')) + @batch = create(:batch) @batch.requests << request printable = { request.id => 'on' } diff --git a/test/controllers/labware_controller_test.rb b/test/controllers/labware_controller_test.rb index 6ad91b0cc7..7d256cc32b 100644 --- a/test/controllers/labware_controller_test.rb +++ b/test/controllers/labware_controller_test.rb @@ -6,7 +6,7 @@ class LabwareControllerTest < ActionController::TestCase setup do @controller = LabwareController.new @request = ActionController::TestRequest.create(@controller) - @user = create :admin, api_key: 'abc' + @user = create(:admin, api_key: 'abc') session[:user] = @user.id end @@ -16,18 +16,18 @@ class LabwareControllerTest < ActionController::TestCase attr_reader :barcode_printer setup do - @user = create :user + @user = create(:user) @controller.stubs(:current_user).returns(@user) - @barcode_printer = create :barcode_printer + @barcode_printer = create(:barcode_printer) end should '#print_assets should send print request' do - asset = create :child_plate + asset = create(:child_plate) RestClient.expects(:post) post :print_assets, params: { printables: asset, printer: barcode_printer.name, id: asset.id.to_s } end should '#print_labels should send print request' do - asset = create :sample_tube + asset = create(:sample_tube) RestClient.expects(:post) post :print_labels, params: { @@ -44,7 +44,7 @@ class LabwareControllerTest < ActionController::TestCase attr_reader :asset setup do - @asset = create :sample_tube + @asset = create(:sample_tube) @controller.stubs(:current_user).returns(@user) end diff --git a/test/controllers/pipelines_controller_test.rb b/test/controllers/pipelines_controller_test.rb index ce4a72ba88..12c43a451c 100644 --- a/test/controllers/pipelines_controller_test.rb +++ b/test/controllers/pipelines_controller_test.rb @@ -8,7 +8,7 @@ class PipelinesControllerTest < ActionController::TestCase setup do @controller = PipelinesController.new @request = ActionController::TestRequest.create(@controller) - @user = FactoryBot.create :user + @user = FactoryBot.create(:user) session[:user] = @user.id end should_require_login @@ -20,7 +20,7 @@ class PipelinesControllerTest < ActionController::TestCase end context '#batches' do - setup { @pipeline = FactoryBot.create :pipeline } + setup { @pipeline = FactoryBot.create(:pipeline) } context 'without any pipeline batches' do setup { get :batches, params: { id: @pipeline.id.to_s } } @@ -29,7 +29,7 @@ class PipelinesControllerTest < ActionController::TestCase context 'with 1 batch' do setup do - FactoryBot.create :batch, pipeline: @pipeline + FactoryBot.create(:batch, pipeline: @pipeline) get :batches, params: { id: @pipeline.id.to_s } end @@ -39,14 +39,14 @@ class PipelinesControllerTest < ActionController::TestCase context '#show' do setup do - @pipeline = FactoryBot.create :pipeline + @pipeline = FactoryBot.create(:pipeline) get :show, params: { id: @pipeline } end should respond_with :success context 'and no batches' do setup do - @pipeline = FactoryBot.create :pipeline + @pipeline = FactoryBot.create(:pipeline) get :show, params: { id: @pipeline } end @@ -56,7 +56,7 @@ class PipelinesControllerTest < ActionController::TestCase context '#activate' do setup do - @pipeline = FactoryBot.create :pipeline + @pipeline = FactoryBot.create(:pipeline) get :activate, params: { id: @pipeline.id.to_s } end @@ -65,7 +65,7 @@ class PipelinesControllerTest < ActionController::TestCase context '#deactivate' do setup do - @pipeline = FactoryBot.create :pipeline + @pipeline = FactoryBot.create(:pipeline) get :deactivate, params: { id: @pipeline.id.to_s } end diff --git a/test/controllers/plate_summaries_controller_test.rb b/test/controllers/plate_summaries_controller_test.rb index b7154d6487..97602d9f71 100644 --- a/test/controllers/plate_summaries_controller_test.rb +++ b/test/controllers/plate_summaries_controller_test.rb @@ -8,17 +8,17 @@ class PlateSummariesControllerTest < ActionController::TestCase setup do @controller = PlateSummariesController.new @request = ActionController::TestRequest.create(@controller) - @user = create :user + @user = create(:user) session[:user] = @user.id end context 'with some plates' do setup do - purpose = create :source_plate_purpose + purpose = create(:source_plate_purpose) @source_plate_a = create(:source_plate, purpose:) @source_plate_b = create(:source_plate, purpose:) - @child_plate_a = create :child_plate, parent: @source_plate_a - @child_plate_b = create :child_plate, parent: @source_plate_b + @child_plate_a = create(:child_plate, parent: @source_plate_a) + @child_plate_b = create(:child_plate, parent: @source_plate_b) end should 'test factory is created' do @@ -26,7 +26,7 @@ class PlateSummariesControllerTest < ActionController::TestCase end context '#index' do - setup { create :plate_owner, user: @user, plate: @child_plate_a } + setup { create(:plate_owner, user: @user, plate: @child_plate_a) } should 'include owned plates' do get :index diff --git a/test/controllers/plates_controller_test.rb b/test/controllers/plates_controller_test.rb index 23008e4187..414bc52579 100644 --- a/test/controllers/plates_controller_test.rb +++ b/test/controllers/plates_controller_test.rb @@ -8,13 +8,13 @@ class PlatesControllerTest < ActionController::TestCase @controller = PlatesController.new @request = ActionController::TestRequest.create(@controller) - @pico_purposes = create_list :pico_assay_purpose, 2 - @working_dilution = create_list :working_dilution_plate_purpose, 1 + @pico_purposes = create_list(:pico_assay_purpose, 2) + @working_dilution = create_list(:working_dilution_plate_purpose, 1) - @pico_assay_plate_creator = FactoryBot.create :plate_creator, plate_purposes: @pico_purposes - @dilution_plates_creator = FactoryBot.create :plate_creator, plate_purposes: @working_dilution + @pico_assay_plate_creator = FactoryBot.create(:plate_creator, plate_purposes: @pico_purposes) + @dilution_plates_creator = FactoryBot.create(:plate_creator, plate_purposes: @working_dilution) - @barcode_printer = create :barcode_printer + @barcode_printer = create(:barcode_printer) PlateBarcode.stubs(:create_barcode).returns( build(:plate_barcode, barcode: 'SQPD-1234567'), @@ -31,13 +31,13 @@ class PlatesControllerTest < ActionController::TestCase context 'with a logged in user' do setup do - @user = FactoryBot.create :user, barcode: 'ID100I', swipecard_code: '1234567' + @user = FactoryBot.create(:user, barcode: 'ID100I', swipecard_code: '1234567') @user.grant_administrator session[:user] = @user.id - @parent_plate = FactoryBot.create :plate - @parent_plate2 = FactoryBot.create :plate - @parent_plate3 = FactoryBot.create :plate + @parent_plate = FactoryBot.create(:plate) + @parent_plate2 = FactoryBot.create(:plate) + @parent_plate3 = FactoryBot.create(:plate) end context '#new' do @@ -246,7 +246,7 @@ class PlatesControllerTest < ActionController::TestCase context 'with one source plate' do setup do - @well = create :well + @well = create(:well) @parent_plate.wells << [@well] @parent_raw_barcode = @parent_plate.machine_barcode end @@ -325,7 +325,7 @@ class PlatesControllerTest < ActionController::TestCase context 'when we have 2 parents' do setup do - @well2 = create :well + @well2 = create(:well) @parent_plate2.wells << [@well2] @parent2_raw_barcode = @parent_plate2.machine_barcode end diff --git a/test/controllers/projects_controller_test.rb b/test/controllers/projects_controller_test.rb index 97c380512b..f87eb869c1 100644 --- a/test/controllers/projects_controller_test.rb +++ b/test/controllers/projects_controller_test.rb @@ -17,7 +17,7 @@ class ProjectsControllerTest < ActionController::TestCase setup do @controller = ProjectsController.new @request = ActionController::TestRequest.create(@controller) - @user = FactoryBot.create :user + @user = FactoryBot.create(:user) session[:user] = @user.id end @@ -29,7 +29,7 @@ class ProjectsControllerTest < ActionController::TestCase end context '#create' do - setup { @request_type_1 = FactoryBot.create :request_type } + setup { @request_type_1 = FactoryBot.create(:request_type) } context 'successfully create a new project' do setup do @@ -103,7 +103,7 @@ class ProjectsControllerTest < ActionController::TestCase context "POST '/create'" do context 'with JSON data' do setup do - @user = FactoryBot.create :user, api_key: 'abc' + @user = FactoryBot.create(:user, api_key: 'abc') session[:user] = @user.id @json_data = <<-END_OF_JSON_DATA diff --git a/test/controllers/qc_files_controller_test.rb b/test/controllers/qc_files_controller_test.rb index 457bedd0eb..d889a06ab5 100644 --- a/test/controllers/qc_files_controller_test.rb +++ b/test/controllers/qc_files_controller_test.rb @@ -24,7 +24,7 @@ class QcFilesControllerTest < ActionController::TestCase @controller = QcFilesController.new @request = ActionController::TestRequest.create(@controller) - @user = create :user + @user = create(:user) session[:user] = @user.id end diff --git a/test/controllers/qc_reports_controller_test.rb b/test/controllers/qc_reports_controller_test.rb index 13fe8c231e..3cfb2fabab 100644 --- a/test/controllers/qc_reports_controller_test.rb +++ b/test/controllers/qc_reports_controller_test.rb @@ -10,11 +10,11 @@ class QcReportsControllerTest < ActionController::TestCase @request = ActionController::TestRequest.create(@controller) @request.env['HTTP_REFERER'] = '/' - @user = create :user + @user = create(:user) session[:user] = @user.id - @study = create :study - @product = create :product - @product_criteria = create :product_criteria, product: @product + @study = create(:study) + @product = create(:product) + @product_criteria = create(:product_criteria, product: @product) end should_require_login(:index) diff --git a/test/controllers/receptacles_controller_test.rb b/test/controllers/receptacles_controller_test.rb index 888c5db1c5..fc1f6a5d15 100644 --- a/test/controllers/receptacles_controller_test.rb +++ b/test/controllers/receptacles_controller_test.rb @@ -6,7 +6,7 @@ class ReceptaclesControllerTest < ActionController::TestCase setup do @controller = ReceptaclesController.new @request = ActionController::TestRequest.create(@controller) - @user = create :admin, api_key: 'abc' + @user = create(:admin, api_key: 'abc') session[:user] = @user.id end @@ -18,9 +18,9 @@ class ReceptaclesControllerTest < ActionController::TestCase @asset = create(:sample_tube).receptacle @sample = @asset.primary_aliquot.sample - @study = create :study - @project = create :project, enforce_quotas: true - @request_type = create :request_type + @study = create(:study) + @project = create(:project, enforce_quotas: true) + @request_type = create(:request_type) @json_data = valid_json_create_request(@asset, @request_type, @study, @project) @request.accept = @request.env['CONTENT_TYPE'] = 'application/json' diff --git a/test/controllers/requests_comments_controller_test.rb b/test/controllers/requests_comments_controller_test.rb index 40b0fed56d..c29977b468 100644 --- a/test/controllers/requests_comments_controller_test.rb +++ b/test/controllers/requests_comments_controller_test.rb @@ -8,7 +8,7 @@ class CommentsControllerTest < ActionController::TestCase setup do @controller = Requests::CommentsController.new @request = ActionController::TestRequest.create(@controller) - @user = create :user + @user = create(:user) session[:user] = @user.id end @@ -24,9 +24,9 @@ class CommentsControllerTest < ActionController::TestCase context 'with an ajax request' do setup do - @rq = create :request + @rq = create(:request) - %w[this is a test].each { |description| create :comment, description:, commentable: @rq } + %w[this is a test].each { |description| create(:comment, description:, commentable: @rq) } end should 'return a ul of comments' do diff --git a/test/controllers/requests_controller_test.rb b/test/controllers/requests_controller_test.rb index 6f3f5ee04f..cfdf338251 100644 --- a/test/controllers/requests_controller_test.rb +++ b/test/controllers/requests_controller_test.rb @@ -8,7 +8,7 @@ class RequestsControllerTest < ActionController::TestCase setup do @controller = RequestsController.new @request = ActionController::TestRequest.create(@controller) - @user = FactoryBot.create :admin + @user = FactoryBot.create(:admin) end should_require_login @@ -18,10 +18,10 @@ class RequestsControllerTest < ActionController::TestCase should 'cancel request' do request = - FactoryBot.create :request, + FactoryBot.create(:request, user: @user, request_type: FactoryBot.create(:request_type), - study: FactoryBot.create(:study, name: 'ReqCon2') + study: FactoryBot.create(:study, name: 'ReqCon2')) get :cancel, params: { id: request.id } assert_equal flash[:notice], "Request #{request.id} has been cancelled" @@ -31,11 +31,11 @@ class RequestsControllerTest < ActionController::TestCase should 'cancel started request' do request = - FactoryBot.create :request, + FactoryBot.create(:request, state: 'started', user: @user, request_type: FactoryBot.create(:request_type), - study: FactoryBot.create(:study, name: 'ReqCon2') + study: FactoryBot.create(:study, name: 'ReqCon2')) get :cancel, params: { id: request.id } assert_equal flash[:error], "Request #{request.id} can't be cancelled" @@ -48,10 +48,10 @@ class RequestsControllerTest < ActionController::TestCase should 'when quotas is copied and redirect' do @request_initial = - FactoryBot.create :request, + FactoryBot.create(:request, user: @user, request_type: FactoryBot.create(:request_type), - study: FactoryBot.create(:study, name: 'ReqCon2') + study: FactoryBot.create(:study, name: 'ReqCon2')) get :copy, params: { id: @request_initial.id } @new_request = Request.last @@ -61,11 +61,11 @@ class RequestsControllerTest < ActionController::TestCase should 'set failed requests to pending' do @request_initial = - FactoryBot.create :request, + FactoryBot.create(:request, user: @user, request_type: FactoryBot.create(:request_type), study: FactoryBot.create(:study, name: 'ReqCon2'), - state: 'failed' + state: 'failed') get :copy, params: { id: @request_initial.id } @new_request = Request.last @@ -82,10 +82,10 @@ class RequestsControllerTest < ActionController::TestCase @prop_value_after = 666 @our_request = - FactoryBot.create :request, + FactoryBot.create(:request, user: @user, request_type: FactoryBot.create(:request_type), - study: FactoryBot.create(:study, name: 'ReqCon') + study: FactoryBot.create(:study, name: 'ReqCon')) @params = { request_metadata_attributes: { read_length: '37' @@ -123,11 +123,11 @@ class RequestsControllerTest < ActionController::TestCase @project = FactoryBot.create(:project_with_order, name: 'Prj1') @reqwest = - FactoryBot.create :request, + FactoryBot.create(:request, user: @user, request_type: FactoryBot.create(:request_type), study: FactoryBot.create(:study, name: 'ReqCon XXX'), - project: @project + project: @project) end context 'update invalid and failed' do diff --git a/test/controllers/robots_controller_test.rb b/test/controllers/robots_controller_test.rb index 2ec0154ea1..ec3a91fbb6 100644 --- a/test/controllers/robots_controller_test.rb +++ b/test/controllers/robots_controller_test.rb @@ -7,9 +7,9 @@ class RobotsControllerTest < ActionController::TestCase context 'Robots' do setup do - @user = FactoryBot.create :admin + @user = FactoryBot.create(:admin) session[:user] = @user - @robot = FactoryBot.create :robot + @robot = FactoryBot.create(:robot) end should_require_login diff --git a/test/controllers/sample_manifests_controller_test.rb b/test/controllers/sample_manifests_controller_test.rb index b3a320cff0..eef13b7cfb 100644 --- a/test/controllers/sample_manifests_controller_test.rb +++ b/test/controllers/sample_manifests_controller_test.rb @@ -8,7 +8,7 @@ class SampleManifestsControllerTest < ActionController::TestCase setup do @controller = Sdb::SampleManifestsController.new @request = ActionController::TestRequest.create(@controller) - @user = create :user + @user = create(:user) session[:user] = @user.id SampleManifestExcel.configure do |config| @@ -18,7 +18,7 @@ class SampleManifestsControllerTest < ActionController::TestCase end context '#show' do - setup { @sample_manifest = create :sample_manifest_with_samples } + setup { @sample_manifest = create(:sample_manifest_with_samples) } should 'return expected sample manifest' do get :show, params: { id: @sample_manifest.id } @@ -44,11 +44,11 @@ class SampleManifestsControllerTest < ActionController::TestCase build(:plate_barcode, barcode: 'SQPD-26'), build(:plate_barcode, barcode: 'SQPD-27') ) - study = create :study + study = create(:study) supplier = Supplier.new(name: 'test') supplier.save - barcode_printer = create :barcode_printer + barcode_printer = create(:barcode_printer) LabelPrinter::PmbClient.stubs(:get_label_template_by_name).returns('data' => [{ 'id' => 15 }]) RestClient.expects(:post) diff --git a/test/controllers/samples_controller_test.rb b/test/controllers/samples_controller_test.rb index 3c0bfb9795..a66a80ed91 100644 --- a/test/controllers/samples_controller_test.rb +++ b/test/controllers/samples_controller_test.rb @@ -42,7 +42,7 @@ class SamplesControllerTest < ActionController::TestCase # TODO: Test without admin context 'when logged in' do setup do - @user = FactoryBot.create :user + @user = FactoryBot.create(:user) @controller.stubs(:logged_in?).returns(@user) session[:user] = @user.id end @@ -50,8 +50,8 @@ class SamplesControllerTest < ActionController::TestCase context '#add_to_study' do setup do @initial_study_sample_count = StudySample.count - @sample = FactoryBot.create :sample - @study = FactoryBot.create :study + @sample = FactoryBot.create(:sample) + @study = FactoryBot.create(:study) put :add_to_study, params: { id: @sample.id, study: { id: @study.id } } end should 'change StudySample.count from 0 to 1' do diff --git a/test/controllers/studies_asset_groups_controller_test.rb b/test/controllers/studies_asset_groups_controller_test.rb index 458a785b1c..38c0e1a2cc 100644 --- a/test/controllers/studies_asset_groups_controller_test.rb +++ b/test/controllers/studies_asset_groups_controller_test.rb @@ -13,11 +13,11 @@ class AssetGroupsControllerTest < ActionController::TestCase @study_count_a = Study.count @controller = Studies::AssetGroupsController.new @request = ActionController::TestRequest.create(@controller) - @user = FactoryBot.create :user + @user = FactoryBot.create(:user) session[:user] = @user.id @controller.stubs(:logged_in?).returns(@user) - @study = FactoryBot.create :study - @asset_group = FactoryBot.create :asset_group + @study = FactoryBot.create(:study) + @asset_group = FactoryBot.create(:asset_group) end %w[index new].each do |controller_method| @@ -124,10 +124,10 @@ class AssetGroupsControllerTest < ActionController::TestCase context '#print_labels' do should 'send print request' do - @user = create :user + @user = create(:user) @controller.stubs(:current_user).returns(@user) - @asset = create :child_plate - barcode_printer = create :barcode_printer + @asset = create(:child_plate) + barcode_printer = create(:barcode_printer) RestClient.expects(:post) diff --git a/test/controllers/studies_events_controller_test.rb b/test/controllers/studies_events_controller_test.rb index e82c0dbc3e..55e51bcd93 100644 --- a/test/controllers/studies_events_controller_test.rb +++ b/test/controllers/studies_events_controller_test.rb @@ -9,9 +9,9 @@ class EventsControllerTest < ActionController::TestCase @controller = Studies::EventsController.new @request = ActionController::TestRequest.create(@controller) - @user = create :user + @user = create(:user) session[:user] = @user.id - @study = create :study + @study = create(:study) end should_require_login(:index, resource: 'event', parent: 'study') diff --git a/test/controllers/studies_sample_controller_test.rb b/test/controllers/studies_sample_controller_test.rb index 262a8b3969..b621ab2fb9 100644 --- a/test/controllers/studies_sample_controller_test.rb +++ b/test/controllers/studies_sample_controller_test.rb @@ -9,7 +9,7 @@ class SamplesControllerTest < ActionController::TestCase @controller = Studies::SamplesController.new @request = ActionController::TestRequest.create(@controller) - @user = create :user + @user = create(:user) session[:user] = @user.id end diff --git a/test/controllers/workflows_controller_test.rb b/test/controllers/workflows_controller_test.rb index 1372097f3f..2c527c2175 100644 --- a/test/controllers/workflows_controller_test.rb +++ b/test/controllers/workflows_controller_test.rb @@ -10,15 +10,15 @@ class WorkflowsControllerTest < ActionController::TestCase @controller = WorkflowsController.new @request = ActionController::TestRequest.create(@controller) - @user = FactoryBot.create :user + @user = FactoryBot.create(:user) session[:user] = @user.id - @pipeline_user = FactoryBot.create :pipeline_admin + @pipeline_user = FactoryBot.create(:pipeline_admin) end context '#stage' do # rubocop:todo Metrics/BlockLength setup do - @pipeline = FactoryBot.create :pipeline, name: 'Generic workflow' + @pipeline = FactoryBot.create(:pipeline, name: 'Generic workflow') @ws1 = @pipeline.workflow # :item_limit => 5 @ws2 = FactoryBot.create(:pipeline, name: 'Old workflow').workflow @@ -26,38 +26,38 @@ class WorkflowsControllerTest < ActionController::TestCase @batch = @pipeline.batches.create! @task1 = - FactoryBot.create :task, + FactoryBot.create(:task, name: 'Q20 Check', location: '', workflow: @ws1, sorted: 0, - sti_type: 'SetDescriptorsTask' + sti_type: 'SetDescriptorsTask') @task2 = - FactoryBot.create :task, + FactoryBot.create(:task, name: 'Submit batch', location: 'http://someurl', workflow: @ws1, sorted: 1, - sti_type: 'SetDescriptorsTask' + sti_type: 'SetDescriptorsTask') @task3 = - FactoryBot.create :task, + FactoryBot.create(:task, name: 'Q20 Check', location: '', workflow: @ws2, sorted: 0, - sti_type: 'SetDescriptorsTask' + sti_type: 'SetDescriptorsTask') @task4 = - FactoryBot.create :task, + FactoryBot.create(:task, name: 'Submit batch', location: 'http://someurl', workflow: @ws2, sorted: 1, - sti_type: 'SetDescriptorsTask' - @library1 = FactoryBot.create :library_tube - @lane1 = FactoryBot.create :lane + sti_type: 'SetDescriptorsTask') + @library1 = FactoryBot.create(:library_tube) + @lane1 = FactoryBot.create(:lane) @lane1.labware.parents << @library1 - @library2 = FactoryBot.create :library_tube - @lane2 = FactoryBot.create :lane + @library2 = FactoryBot.create(:library_tube) + @lane2 = FactoryBot.create(:lane) @lane2.labware.parents << @library2 @item1 = @pipeline.request_types.last.create!(asset: @library1, target_asset: @lane1) @@ -65,11 +65,11 @@ class WorkflowsControllerTest < ActionController::TestCase @item2 = @pipeline.request_types.last.create!(asset: @library2, target_asset: @lane2) @batch.batch_requests.create!(request: @item2, position: 2) - FactoryBot.create :descriptor, task: @task2, name: 'Chip Barcode', kind: 'ExternalBarcode', selection: {} - FactoryBot.create :descriptor, task: @task2, name: 'Comment', kind: 'Text', selection: {} - FactoryBot.create :descriptor, task: @task2, name: 'Passed?', kind: 'Selection', selection: {} + FactoryBot.create(:descriptor, task: @task2, name: 'Chip Barcode', kind: 'ExternalBarcode', selection: {}) + FactoryBot.create(:descriptor, task: @task2, name: 'Comment', kind: 'Text', selection: {}) + FactoryBot.create(:descriptor, task: @task2, name: 'Passed?', kind: 'Selection', selection: {}) - @user = FactoryBot.create :admin + @user = FactoryBot.create(:admin) session[:user] = @user.id @batch_events_size = @batch.lab_events.size end diff --git a/test/functional/external_validator_test.rb b/test/functional/external_validator_test.rb index 623edeb318..0c9e697797 100644 --- a/test/functional/external_validator_test.rb +++ b/test/functional/external_validator_test.rb @@ -5,7 +5,7 @@ class ExternalValidatorTest < ActiveSupport::TestCase context 'A submission with a validated request type' do setup do - @validated_request_type = FactoryBot.create :validated_request_type + @validated_request_type = FactoryBot.create(:validated_request_type) @assets = [create(:sample_tube)] # We don't want to trigger validation just yet! diff --git a/test/functional/pre_cap_groups_test.rb b/test/functional/pre_cap_groups_test.rb index 47d2d90e7b..ae1f0cbd27 100644 --- a/test/functional/pre_cap_groups_test.rb +++ b/test/functional/pre_cap_groups_test.rb @@ -16,8 +16,8 @@ def with_pools(*pools) context 'A plate' do setup do - @plate = create :pooling_plate - @pools = create_list :pre_capture_pool, 3 + @plate = create(:pooling_plate) + @pools = create_list(:pre_capture_pool, 3) end context 'with two distinct pools' do @@ -45,7 +45,7 @@ def with_pools(*pools) context 'when transfers are created' do setup do - @target_plate = create :plate_with_empty_wells + @target_plate = create(:plate_with_empty_wells) @transfer = Transfer::BetweenPlates.create!( source: @plate.reload, @@ -114,12 +114,12 @@ def with_pools(*pools) # We need to ensure we still see all pools, regardless of which # plate they were made on. setup do - @plate = create :input_plate_for_pooling - @test_plate = create :non_stock_pooling_plate - @pools = create_list :pre_capture_pool, 3 + @plate = create(:input_plate_for_pooling) + @test_plate = create(:non_stock_pooling_plate) + @pools = create_list(:pre_capture_pool, 3) with_pools(%w[A1 B1 C1], %w[D1 E1 F1]) transfers = @test_plate.wells.each_with_object({}) { |w, hash| hash[w.map_description] = w.map_description } - create :transfer_between_plates, transfers:, source: @plate, destination: @test_plate + create(:transfer_between_plates, transfers:, source: @plate, destination: @test_plate) end should 'report the pools from the stock plate' do diff --git a/test/lib/label_printer/batch_tube_test.rb b/test/lib/label_printer/batch_tube_test.rb index a3df154ff5..e4ed73a183 100644 --- a/test/lib/label_printer/batch_tube_test.rb +++ b/test/lib/label_printer/batch_tube_test.rb @@ -7,12 +7,12 @@ class BatchTubeTest < ActiveSupport::TestCase context 'stock' do should 'return the right tubes and top line' do - library_tube_with_stock_tube = create :library_tube - stock_library_tube = create :stock_library_tube + library_tube_with_stock_tube = create(:library_tube) + stock_library_tube = create(:stock_library_tube) stock_library_tube.children << library_tube_with_stock_tube - request = create :library_creation_request, target_asset: library_tube_with_stock_tube - @batch = create :batch + request = create(:library_creation_request, target_asset: library_tube_with_stock_tube) + @batch = create(:batch) @batch.requests << request printable = { request.id => 'on' } @@ -27,8 +27,8 @@ class BatchTubeTest < ActiveSupport::TestCase context 'no stock' do should 'return the right tubes and top line' do - request = create :library_creation_request, target_asset: (create :library_tube, barcode: '111') - @batch = create :batch + request = create(:library_creation_request, target_asset: create(:library_tube, barcode: '111')) + @batch = create(:batch) @batch.requests << request printable = { request.id => 'on' } diff --git a/test/lib/label_printer/labels_multiplication_test.rb b/test/lib/label_printer/labels_multiplication_test.rb index c2cd55b1a2..66d7930ecf 100644 --- a/test/lib/label_printer/labels_multiplication_test.rb +++ b/test/lib/label_printer/labels_multiplication_test.rb @@ -17,10 +17,10 @@ class ExampleLabelTest < ActiveSupport::TestCase def setup @example_label = ExampleLabel.new - @plate1 = create :plate, name: 'Plate 1', barcode: 'SQPD-1111' - @plate2 = create :plate, name: 'Plate 2', barcode: 'SQPD-2222' - @plate3 = create :plate, name: 'Plate 3', barcode: 'SQPD-3333' - @plate4 = create :plate, name: 'Plate 4', barcode: 'SQPD-4444' + @plate1 = create(:plate, name: 'Plate 1', barcode: 'SQPD-1111') + @plate2 = create(:plate, name: 'Plate 2', barcode: 'SQPD-2222') + @plate3 = create(:plate, name: 'Plate 3', barcode: 'SQPD-3333') + @plate4 = create(:plate, name: 'Plate 4', barcode: 'SQPD-4444') @label = { left: 'Plate 1', right: 'SQPD', barcode: '1111', label_name: 'main_label' } @labels = [ diff --git a/test/lib/label_printer/plate_creator_test.rb b/test/lib/label_printer/plate_creator_test.rb index f99f00e3d2..00a5c03a93 100644 --- a/test/lib/label_printer/plate_creator_test.rb +++ b/test/lib/label_printer/plate_creator_test.rb @@ -19,20 +19,20 @@ class PlateCreatorTest < ActiveSupport::TestCase def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength @parent_barcode = 'SQPD-1234' - @studies = create_list :study, 1 - parent = create :source_plate, barcode: parent_barcode, studies: @studies - well = create :well_with_sample_and_plate, plate: parent + @studies = create_list(:study, 1) + parent = create(:source_plate, barcode: parent_barcode, studies: @studies) + well = create(:well_with_sample_and_plate, plate: parent) @barcode1 = 'SQPD-1111' @purpose_name = 'test purpose' - plate_purpose = create :plate_purpose, name: purpose_name + plate_purpose = create(:plate_purpose, name: purpose_name) @plate1 = - create :child_plate, + create(:child_plate, parent:, barcode: barcode1, plate_purpose:, well_count: 1, well_factory: :untagged_well, - studies: @studies + studies: @studies) @plates = [plate1] @user = 'user' @study_abbreviation = 'WTCCC' diff --git a/test/lib/label_printer/plate_to_tube_test.rb b/test/lib/label_printer/plate_to_tube_test.rb index f9b775aefc..c9559a2887 100644 --- a/test/lib/label_printer/plate_to_tube_test.rb +++ b/test/lib/label_printer/plate_to_tube_test.rb @@ -12,8 +12,8 @@ def setup # rubocop:todo Metrics/AbcSize @prefix = 'NT' @barcode1 = '1111' @asset_name = 'tube name' - @tube1 = create :sample_tube, barcode: barcode1, name: asset_name - @sample_tubes = create_list :sample_tube, 4 + @tube1 = create(:sample_tube, barcode: barcode1, name: asset_name) + @sample_tubes = create_list(:sample_tube, 4) sample_tubes.unshift(tube1) options = { sample_tubes: } @tube_label = LabelPrinter::Label::PlateToTubes.new(options) diff --git a/test/lib/label_printer/print_job_test.rb b/test/lib/label_printer/print_job_test.rb index 6013187aec..97696bca94 100644 --- a/test/lib/label_printer/print_job_test.rb +++ b/test/lib/label_printer/print_job_test.rb @@ -13,8 +13,8 @@ class PrintJobTest < ActiveSupport::TestCase :labels_attributes def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength - @barcode_printer = create :barcode_printer - @plates = create_list :plate, 1, well_count: 1, well_factory: :untagged_well + @barcode_printer = create(:barcode_printer) + @plates = create_list(:plate, 1, well_count: 1, well_factory: :untagged_well) @plate = plates[0] @plate_purpose = plate.plate_purpose @label_template_name = barcode_printer.barcode_printer_type.label_template_name diff --git a/test/lib/label_printer/sample_manifest_multiplex_test.rb b/test/lib/label_printer/sample_manifest_multiplex_test.rb index a2af73cb14..9b05daade6 100644 --- a/test/lib/label_printer/sample_manifest_multiplex_test.rb +++ b/test/lib/label_printer/sample_manifest_multiplex_test.rb @@ -9,7 +9,7 @@ class SampleManifestMultiplexTest < ActiveSupport::TestCase attr_reader :only_first_label, :manifest, :tube_label, :tube1, :prefix, :barcode1, :label, :study_abbreviation def setup # rubocop:todo Metrics/AbcSize - @manifest = create :sample_manifest, asset_type: 'multiplexed_library', count: 3 + @manifest = create(:sample_manifest, asset_type: 'multiplexed_library', count: 3) @manifest.generate diff --git a/test/lib/label_printer/sample_manifest_plate_test.rb b/test/lib/label_printer/sample_manifest_plate_test.rb index 8881b6ce87..8faa16bf3d 100644 --- a/test/lib/label_printer/sample_manifest_plate_test.rb +++ b/test/lib/label_printer/sample_manifest_plate_test.rb @@ -21,9 +21,9 @@ class SampleManifestPlateTest < ActiveSupport::TestCase build(:plate_barcode, barcode: 'SQPD-24') ) - @purpose = create :plate_purpose + @purpose = create(:plate_purpose) - @manifest = create :sample_manifest, count: 2, purpose: @purpose + @manifest = create(:sample_manifest, count: 2, purpose: @purpose) @manifest.generate @plates = @manifest.send(:core_behaviour).plates diff --git a/test/lib/label_printer/sample_manifest_tube_test.rb b/test/lib/label_printer/sample_manifest_tube_test.rb index 92f3ac423f..97f6a810cb 100644 --- a/test/lib/label_printer/sample_manifest_tube_test.rb +++ b/test/lib/label_printer/sample_manifest_tube_test.rb @@ -9,7 +9,7 @@ class SampleManifestTubeTest < ActiveSupport::TestCase attr_reader :manifest, :tube_label, :tube1, :tube2, :tube3, :tubes, :prefix, :barcode1, :label def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength - @manifest = create :sample_manifest, asset_type: '1dtube', purpose: Tube::Purpose.standard_sample_tube, count: 3 + @manifest = create(:sample_manifest, asset_type: '1dtube', purpose: Tube::Purpose.standard_sample_tube, count: 3) @manifest.generate @tube1 = manifest.printables[0] @tube2 = manifest.printables[1] diff --git a/test/performance/plate_creation_test.rb b/test/performance/plate_creation_test.rb index c3aae1deec..9df00742c4 100644 --- a/test/performance/plate_creation_test.rb +++ b/test/performance/plate_creation_test.rb @@ -11,7 +11,7 @@ class PlateCreationTest < ActionDispatch::PerformanceTest # output: 'tmp/performance', formats: [:flat] } SIZE = 6 def setup - @purpose = create :plate_purpose + @purpose = create(:plate_purpose) end test 'PlatePurpose.create' do diff --git a/test/performance/state_change_test.rb b/test/performance/state_change_test.rb index 9f087ccb3b..77bfb10988 100644 --- a/test/performance/state_change_test.rb +++ b/test/performance/state_change_test.rb @@ -10,11 +10,11 @@ class StateChangeTest < ActionDispatch::PerformanceTest # self.profile_options = { runs: 5, metrics: [:wall_time, :memory], # output: 'tmp/performance', formats: [:flat] } def setup - @source = create :transfer_plate, well_count: 96 - @destination = create :plate, well_count: 96 + @source = create(:transfer_plate, well_count: 96) + @destination = create(:plate, well_count: 96) transfers = @source.wells.each_with_object({}) { |w, h| h[w.map_description] = w.map_description } @transfer = create(:transfer_between_plates, source: @source, destination: @destination, transfers:) - @user = create :user + @user = create(:user) end test 'StateChange.create' do diff --git a/test/performance/transfer_request_collection_test.rb b/test/performance/transfer_request_collection_test.rb index 2392bd9c16..a77fc935ce 100644 --- a/test/performance/transfer_request_collection_test.rb +++ b/test/performance/transfer_request_collection_test.rb @@ -18,7 +18,7 @@ def setup target_asset = FactoryBot.create_list(:empty_well, SIZE) @transfer_requests_attributes = Array.new(SIZE) { |i| { source_asset: asset[i].uuid, target_asset: target_asset[i].uuid } } - @user = FactoryBot.create :user + @user = FactoryBot.create(:user) @api_key = FactoryBot.create(:api_application).key end diff --git a/test/performance/work_completion_tubes_test.rb b/test/performance/work_completion_tubes_test.rb index 985a21fe95..a8ed17f00d 100644 --- a/test/performance/work_completion_tubes_test.rb +++ b/test/performance/work_completion_tubes_test.rb @@ -9,104 +9,104 @@ class WorkCompletionTubesTest < ActionDispatch::PerformanceTest # THis setup mimic the end of the GBS pipeline. # rubocop:todo Metrics/PerceivedComplexity, Metrics/AbcSize def setup # rubocop:todo Metrics/CyclomaticComplexity, Metrics/MethodLength - @user = create :user + @user = create(:user) tested_wells = 2 - input_plate_1 = create :input_plate, well_count: tested_wells, well_factory: :tagged_well - input_plate_2 = create :input_plate, well_count: tested_wells, well_factory: :tagged_well - input_plate_3 = create :input_plate, well_count: tested_wells, well_factory: :tagged_well - input_plate_4 = create :input_plate, well_count: tested_wells, well_factory: :tagged_well + input_plate_1 = create(:input_plate, well_count: tested_wells, well_factory: :tagged_well) + input_plate_2 = create(:input_plate, well_count: tested_wells, well_factory: :tagged_well) + input_plate_3 = create(:input_plate, well_count: tested_wells, well_factory: :tagged_well) + input_plate_4 = create(:input_plate, well_count: tested_wells, well_factory: :tagged_well) - library_request_type = create :library_request_type + library_request_type = create(:library_request_type) submission_request_types = [library_request_type] target_submission_1 = - create :library_submission, assets: input_plate_1.wells, request_types: submission_request_types + create(:library_submission, assets: input_plate_1.wells, request_types: submission_request_types) target_submission_2 = - create :library_submission, assets: input_plate_2.wells, request_types: submission_request_types + create(:library_submission, assets: input_plate_2.wells, request_types: submission_request_types) target_submission_3 = - create :library_submission, assets: input_plate_3.wells, request_types: submission_request_types + create(:library_submission, assets: input_plate_3.wells, request_types: submission_request_types) target_submission_4 = - create :library_submission, assets: input_plate_4.wells, request_types: submission_request_types - decoy_submission = create :library_submission, assets: input_plate_1.wells, request_types: submission_request_types + create(:library_submission, assets: input_plate_4.wells, request_types: submission_request_types) + decoy_submission = create(:library_submission, assets: input_plate_1.wells, request_types: submission_request_types) input_plate_1.wells.each do |well| next if well.aliquots.empty? - create :library_request, + create(:library_request, request_type: library_request_type, asset: well, submission: target_submission_1, - state: 'started' - create :library_request, + state: 'started') + create(:library_request, request_type: library_request_type, asset: well, submission: decoy_submission, - state: 'started' + state: 'started') end input_plate_2.wells.each do |well| next if well.aliquots.empty? - create :library_request, + create(:library_request, request_type: library_request_type, asset: well, submission: target_submission_2, - state: 'started' + state: 'started') end input_plate_3.wells.each do |well| next if well.aliquots.empty? - create :library_request, + create(:library_request, request_type: library_request_type, asset: well, submission: target_submission_3, - state: 'started' + state: 'started') end input_plate_4.wells.each do |well| next if well.aliquots.empty? - create :library_request, + create(:library_request, request_type: library_request_type, asset: well, submission: target_submission_4, - state: 'started' + state: 'started') end # The decoy submission represents a submission which we don't care about # The target plate is the downstream plate we are going to be passing. target_plate_1 = - create :target_plate, parent: input_plate_1, well_count: tested_wells, submission: target_submission_1 + create(:target_plate, parent: input_plate_1, well_count: tested_wells, submission: target_submission_1) target_plate_2 = - create :target_plate, parent: input_plate_2, well_count: tested_wells, submission: target_submission_2 + create(:target_plate, parent: input_plate_2, well_count: tested_wells, submission: target_submission_2) target_plate_3 = - create :target_plate, parent: input_plate_3, well_count: tested_wells, submission: target_submission_3 + create(:target_plate, parent: input_plate_3, well_count: tested_wells, submission: target_submission_3) target_plate_4 = - create :target_plate, parent: input_plate_4, well_count: tested_wells, submission: target_submission_4 + create(:target_plate, parent: input_plate_4, well_count: tested_wells, submission: target_submission_4) # Build the tube graphs - tube_1_2 = create :new_stock_multiplexed_library_tube, parents: [target_plate_1, target_plate_2] + tube_1_2 = create(:new_stock_multiplexed_library_tube, parents: [target_plate_1, target_plate_2]) [target_plate_1, target_plate_2].flat_map(&:wells) - .each { |well| create :transfer_request, asset: well, target_asset: tube_1_2 } + .each { |well| create(:transfer_request, asset: well, target_asset: tube_1_2) } - tube_3 = create :new_stock_multiplexed_library_tube, parents: [target_plate_3] + tube_3 = create(:new_stock_multiplexed_library_tube, parents: [target_plate_3]) - target_plate_3.wells.each { |well| create :transfer_request, asset: well, target_asset: tube_3 } + target_plate_3.wells.each { |well| create(:transfer_request, asset: well, target_asset: tube_3) } - tube_4 = create :new_stock_multiplexed_library_tube, parents: [target_plate_4] + tube_4 = create(:new_stock_multiplexed_library_tube, parents: [target_plate_4]) - target_plate_4.wells.each { |well| create :transfer_request, asset: well, target_asset: tube_4 } + target_plate_4.wells.each { |well| create(:transfer_request, asset: well, target_asset: tube_4) } thirds = [tube_1_2, tube_3, tube_4].map do |start| - second = create :new_stock_multiplexed_library_tube # , parents: [start] - create :transfer_request, asset: start, target_asset: second - third = create :new_stock_multiplexed_library_tube # , parents: [second] - create :transfer_request, asset: second, target_asset: third + second = create(:new_stock_multiplexed_library_tube) # , parents: [start] + create(:transfer_request, asset: start, target_asset: second) + third = create(:new_stock_multiplexed_library_tube) # , parents: [second] + create(:transfer_request, asset: second, target_asset: third) third end - @target_tube = create :multiplexed_library_tube, parents: thirds - thirds.each { |third| create :transfer_request, asset: third, target_asset: @target_tube } + @target_tube = create(:multiplexed_library_tube, parents: thirds) + thirds.each { |third| create(:transfer_request, asset: third, target_asset: @target_tube) } end # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity diff --git a/test/performance/work_completions_test.rb b/test/performance/work_completions_test.rb index d6d54f4c8f..7ad19d51f8 100644 --- a/test/performance/work_completions_test.rb +++ b/test/performance/work_completions_test.rb @@ -7,36 +7,36 @@ class WorkCompletionsTest < ActionDispatch::PerformanceTest self.profile_options = { runs: 1, metrics: %i[wall_time memory], formats: [:flat] } def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength - @user = create :user + @user = create(:user) tested_wells = 96 - input_plate = create :input_plate, well_count: tested_wells - library_request_type = create :library_request_type - multiplex_request_type = create :multiplex_request_type + input_plate = create(:input_plate, well_count: tested_wells) + library_request_type = create(:library_request_type) + multiplex_request_type = create(:multiplex_request_type) submission_request_types = [library_request_type, multiplex_request_type] - @target_submission = create :library_submission, assets: input_plate.wells, request_types: submission_request_types - decoy_submission = create :library_submission, assets: input_plate.wells, request_types: submission_request_types + @target_submission = create(:library_submission, assets: input_plate.wells, request_types: submission_request_types) + decoy_submission = create(:library_submission, assets: input_plate.wells, request_types: submission_request_types) # The decoy submission represents a submission which we don't care about # The target plate is the downstream plate we are going to be passing. - @target_plate = create :target_plate, parent: input_plate, well_count: tested_wells + @target_plate = create(:target_plate, parent: input_plate, well_count: tested_wells) input_plate.wells.each do |well| - create :library_request, + create(:library_request, request_type: library_request_type, asset: well, submission: @target_submission, - state: 'started' - create :library_request, + state: 'started') + create(:library_request, request_type: library_request_type, asset: well, submission: decoy_submission, - state: 'started' + state: 'started') end submission_request_types[1..].each do |downstream_type| input_plate.wells.count.times do - create :multiplex_request, request_type: downstream_type, submission: @target_submission - create :multiplex_request, request_type: downstream_type, submission: decoy_submission + create(:multiplex_request, request_type: downstream_type, submission: @target_submission) + create(:multiplex_request, request_type: downstream_type, submission: decoy_submission) end end end diff --git a/test/shoulda_macros/sanger_macros.rb b/test/shoulda_macros/sanger_macros.rb index fbb5ba45e9..95f4950928 100644 --- a/test/shoulda_macros/sanger_macros.rb +++ b/test/shoulda_macros/sanger_macros.rb @@ -46,11 +46,11 @@ def should_require_login(*actions) # rubocop:todo Metrics/CyclomaticComplexity, session[:user] = nil if params[:resource].present? resource = params.delete(:resource) - params['id'] = (create resource).id + params['id'] = create(resource).id end if params[:parent].present? parent_resource = params.delete(:parent) - params["#{parent_resource}_id"] = (create parent_resource).id + params["#{parent_resource}_id"] = create(parent_resource).id end begin get(action, params:) diff --git a/test/shoulda_macros/sanger_macros/resource_test.rb b/test/shoulda_macros/sanger_macros/resource_test.rb index 9e33d2163e..9dfb0d3865 100644 --- a/test/shoulda_macros/sanger_macros/resource_test.rb +++ b/test/shoulda_macros/sanger_macros/resource_test.rb @@ -50,7 +50,7 @@ def resource_test(resource_name, kwords) index_url = "#{parent_resource}_#{resource_name.to_s.pluralize}_path(@#{parent_resource})" setup do - parent = create parent_resource + parent = create(parent_resource) @factory_options[parent_resource.to_sym] = parent @input_params["#{parent_resource}_id"] = parent.id end @@ -96,7 +96,7 @@ def resource_test(resource_name, kwords) if actions.include?('show') context "should show #{resource_name}" do setup do - @object = create resource_name, @factory_options + @object = create(resource_name, @factory_options) @input_params[:id] = @object.id get :show, params: @input_params end @@ -107,7 +107,7 @@ def resource_test(resource_name, kwords) if actions.include?('edit') context 'should get edit' do setup do - @object = create resource_name, @factory_options + @object = create(resource_name, @factory_options) @input_params[:id] = @object.id get :edit, params: @input_params end @@ -118,7 +118,7 @@ def resource_test(resource_name, kwords) if actions.include?('update') context 'should update' do setup do - @object = create resource_name + @object = create(resource_name) @input_params[resource_name] = @create_options @input_params[:id] = @object.id put :update, params: @input_params @@ -130,7 +130,7 @@ def resource_test(resource_name, kwords) if actions.include?('destroy') context 'should destroy' do setup do - @object = create resource_name + @object = create(resource_name) @input_params[:id] = @object.id delete :destroy, params: @input_params end @@ -141,7 +141,7 @@ def resource_test(resource_name, kwords) context 'should not have untested action' do untested_actions.each do |action| should action.to_s do - @object = create resource_name + @object = create(resource_name) @input_params[:id] = @object.id assert_raise AbstractController::ActionNotFound do get action, params: @input_params @@ -154,7 +154,7 @@ def resource_test(resource_name, kwords) if other_actions.include?('status') context 'should show status' do setup do - @object = create resource_name + @object = create(resource_name) get :status, params: { id: @object.id } end should respond_with :success @@ -166,7 +166,7 @@ def resource_test(resource_name, kwords) if actions.include?('index') context 'when using XML to access a list ' do setup do - @object = create resource_name, @factory_options + @object = create(resource_name, @factory_options) @request.accept = 'application/xml' get :index, params: @input_params end @@ -182,7 +182,7 @@ def resource_test(resource_name, kwords) context 'when using XML to access a single object' do setup do @request.accept = 'application/xml' - @object = create resource_name, @factory_options + @object = create(resource_name, @factory_options) @input_params[:id] = @object.id get :show, params: @input_params end @@ -197,7 +197,7 @@ def resource_test(resource_name, kwords) if actions.include?('index') context 'when using JSON to access a list ' do setup do - @object = create resource_name, @factory_options + @object = create(resource_name, @factory_options) @request.accept = 'text/x-json' get :index, params: @input_params end @@ -210,7 +210,7 @@ def resource_test(resource_name, kwords) if actions.include?('show') context 'when using JSON to access a single object' do setup do - @object = create resource_name, @factory_options + @object = create(resource_name, @factory_options) @request.accept = 'text/x-json' @input_params[:id] = @object.id get :show, params: @input_params diff --git a/test/unit/accession_service_test.rb b/test/unit/accession_service_test.rb index 4219237cf7..e67a45ce3e 100644 --- a/test/unit/accession_service_test.rb +++ b/test/unit/accession_service_test.rb @@ -14,8 +14,8 @@ def assert_tag(tag_label, value) # temporary test for hotfix context 'A sample with a strain' do setup do - @study = create :open_study, accession_number: 'accss' - @sample = create :sample, studies: [@study] + @study = create(:open_study, accession_number: 'accss') + @sample = create(:sample, studies: [@study]) @sample.sample_metadata.sample_strain_att = 'my strain' end @@ -26,8 +26,8 @@ def assert_tag(tag_label, value) context 'A sample with a gender' do setup do - @study = create :managed_study, accession_number: 'accss' - @sample = create :sample, studies: [@study] + @study = create(:managed_study, accession_number: 'accss') + @sample = create(:sample, studies: [@study]) @sample.sample_metadata.gender = 'male' end @@ -38,8 +38,8 @@ def assert_tag(tag_label, value) context 'A sample with a donor_id' do setup do - @study = create :managed_study, accession_number: 'accss' - @sample = create :sample, studies: [@study] + @study = create(:managed_study, accession_number: 'accss') + @sample = create(:sample, studies: [@study]) @sample.sample_metadata.donor_id = '123456789' end @@ -54,9 +54,9 @@ def assert_tag(tag_label, value) context 'A sample with a country_of_origin' do setup do - @country = create :insdc_country, name: 'Freedonia' - @study = create :managed_study, accession_number: 'accss' - @sample = create :sample, studies: [@study] + @country = create(:insdc_country, name: 'Freedonia') + @study = create(:managed_study, accession_number: 'accss') + @sample = create(:sample, studies: [@study]) end context 'with unexistent country' do @@ -96,8 +96,8 @@ def assert_tag(tag_label, value) context 'A sample with a collection date' do setup do - @study = create :managed_study, accession_number: 'accss' - @sample = create :sample, studies: [@study] + @study = create(:managed_study, accession_number: 'accss') + @sample = create(:sample, studies: [@study]) end context 'with unexistent date_of_sample_collection' do diff --git a/test/unit/aliquot_indexer_test.rb b/test/unit/aliquot_indexer_test.rb index 61f52ab7a0..f368142bba 100644 --- a/test/unit/aliquot_indexer_test.rb +++ b/test/unit/aliquot_indexer_test.rb @@ -7,10 +7,10 @@ class AliquotIndexerTest < ActiveSupport::TestCase context 'which are dual indexed' do setup do @pre_count = AliquotIndex.count - @lane = create :lane + @lane = create(:lane) @tags = [1, 8, 2, 4].map { |map_id| create(:tag, map_id:) } @tag2s = [1, 2].map { |map_id| create(:tag, map_id:) } * 2 - @aliquots = Array.new(4) { |i| create :aliquot, receptacle: @lane, tag: @tags[i], tag2: @tag2s[i] } + @aliquots = Array.new(4) { |i| create(:aliquot, receptacle: @lane, tag: @tags[i], tag2: @tag2s[i]) } @aliquot_index = [1, 4, 2, 3] end @@ -35,7 +35,7 @@ class AliquotIndexerTest < ActiveSupport::TestCase context 'when phix is added' do setup do - @phix = create :spiked_buffer, aliquot_attributes: { tag: @tags[2], tag2: nil } + @phix = create(:spiked_buffer, aliquot_attributes: { tag: @tags[2], tag2: nil }) @lane.labware.parents << @phix @aliquot_index = [1, 5, 3, 4] end @@ -63,9 +63,9 @@ class AliquotIndexerTest < ActiveSupport::TestCase context 'which are single indexed' do setup do @pre_count = AliquotIndex.count - @lane = create :lane + @lane = create(:lane) @tags = [1, 8, 2, 4].map { |map_id| create(:tag, map_id:) } - @aliquots = Array.new(4) { |i| create :aliquot, receptacle: @lane, tag: @tags[i], tag2_id: -1 } + @aliquots = Array.new(4) { |i| create(:aliquot, receptacle: @lane, tag: @tags[i], tag2_id: -1) } @aliquot_index = [1, 4, 2, 3] end @@ -90,7 +90,7 @@ class AliquotIndexerTest < ActiveSupport::TestCase context 'when phix is added' do setup do - @phix = create :spiked_buffer, aliquot_attributes: { tag: @tags[2], tag2: nil } + @phix = create(:spiked_buffer, aliquot_attributes: { tag: @tags[2], tag2: nil }) @lane.labware.parents << @phix @aliquot_index = [1, 5, 3, 4] end @@ -118,9 +118,9 @@ class AliquotIndexerTest < ActiveSupport::TestCase context 'which are single indexed with i5 (tag2) tags' do setup do @pre_count = AliquotIndex.count - @lane = create :lane + @lane = create(:lane) @tags = [1, 8, 2, 4].map { |map_id| create(:tag, map_id:) } - @aliquots = Array.new(4) { |i| create :aliquot, receptacle: @lane, tag_id: -1, tag2: @tags[i] } + @aliquots = Array.new(4) { |i| create(:aliquot, receptacle: @lane, tag_id: -1, tag2: @tags[i]) } @aliquot_index = [1, 4, 2, 3] end @@ -145,7 +145,7 @@ class AliquotIndexerTest < ActiveSupport::TestCase context 'when phix is added' do setup do - @phix = create :spiked_buffer, aliquot_attributes: { tag: @tags[2], tag2: nil } + @phix = create(:spiked_buffer, aliquot_attributes: { tag: @tags[2], tag2: nil }) @lane.labware.parents << @phix @aliquot_index = [1, 5, 3, 4] end diff --git a/test/unit/aliquot_receptacle_test.rb b/test/unit/aliquot_receptacle_test.rb index 0a87bb4a0b..44d1e667e5 100644 --- a/test/unit/aliquot_receptacle_test.rb +++ b/test/unit/aliquot_receptacle_test.rb @@ -4,7 +4,7 @@ class ReceptacleTest < ActiveSupport::TestCase context 'Receptacle' do - setup { @receptacle = create :receptacle } + setup { @receptacle = create(:receptacle) } [ ['Untagged', [:untagged_aliquot]], diff --git a/test/unit/asset_group_test.rb b/test/unit/asset_group_test.rb index 0ed308bd99..7e72b61b0a 100644 --- a/test/unit/asset_group_test.rb +++ b/test/unit/asset_group_test.rb @@ -16,8 +16,8 @@ class AssetGroupTest < ActiveSupport::TestCase @asset3 = mock('Asset 3') @asset3.stubs(:id).returns(3) @assets = [] - @study = create :study - @asset_group = create :asset_group, study_id: @study.id + @study = create(:study) + @asset_group = create(:asset_group, study_id: @study.id) @asset_group.stubs(:assets).returns([@asset1, @asset2]) end @@ -52,8 +52,8 @@ class AssetGroupTest < ActiveSupport::TestCase @asset2.stubs(:id).returns(2) @asset2.stubs(:sti_type).returns('Well') @assets = [] - @study = create :study - @asset_group = create :asset_group, study_id: @study.id + @study = create(:study) + @asset_group = create(:asset_group, study_id: @study.id) @asset_group.stubs(:assets).returns([@asset1, @asset2]) end @@ -77,8 +77,8 @@ class AssetGroupTest < ActiveSupport::TestCase @asset2.stubs(:id).returns(2) @asset2.stubs(:sti_type).returns('Tube') @assets = [] - @study = create :study - @asset_group = create :asset_group, study_id: @study.id + @study = create(:study) + @asset_group = create(:asset_group, study_id: @study.id) @asset_group.stubs(:assets).returns([@asset1, @asset2]) end @@ -91,17 +91,17 @@ class AssetGroupTest < ActiveSupport::TestCase setup do @ag_count = AssetGroup.count Study.destroy_all - @study = create :study + @study = create(:study) end should 'not allow an AssetGroup to be created without a study' do assert_raises ActiveRecord::RecordInvalid do - @asset_group = create :asset_group, study_id: nil + @asset_group = create(:asset_group, study_id: nil) end end should 'not allow an AssetGroup to be created without a name' do assert_raises ActiveRecord::RecordInvalid do - @asset_group = create :asset_group, name: '', study_id: @study.id + @asset_group = create(:asset_group, name: '', study_id: @study.id) end end @@ -110,14 +110,14 @@ class AssetGroupTest < ActiveSupport::TestCase end should 'only allow a name to be used once' do - create :asset_group, name: 'Another-Name', study_id: @study.id + create(:asset_group, name: 'Another-Name', study_id: @study.id) assert_raises ActiveRecord::RecordInvalid do - create :asset_group, name: 'Another-Name', study_id: @study.id + create(:asset_group, name: 'Another-Name', study_id: @study.id) end end context '#all_samples_have_accession_numbers?' do - setup { @asset_group = build :asset_group } + setup { @asset_group = build(:asset_group) } context 'where all samples' do setup do 2.times do |_i| @@ -164,7 +164,7 @@ class AssetGroupTest < ActiveSupport::TestCase end context '#all_samples_have_accession_numbers? On saved asset groups' do - setup { @asset_group = create :asset_group } + setup { @asset_group = create(:asset_group) } context 'where all samples' do setup do 2.times do |_i| diff --git a/test/unit/asset_link_test.rb b/test/unit/asset_link_test.rb index 263c7b53ba..55019d3923 100644 --- a/test/unit/asset_link_test.rb +++ b/test/unit/asset_link_test.rb @@ -5,8 +5,8 @@ class AssetLinkTest < ActiveSupport::TestCase context 'AssetLink::Job' do setup do - @source_tube = create :tube - @destination_tube = create :tube + @source_tube = create(:tube) + @destination_tube = create(:tube) @job_count = Delayed::Job.count AssetLink::Job.create(@source_tube, [@destination_tube]) end diff --git a/test/unit/barcode_printer_test.rb b/test/unit/barcode_printer_test.rb index 40669baf18..e6c6f1b46c 100644 --- a/test/unit/barcode_printer_test.rb +++ b/test/unit/barcode_printer_test.rb @@ -6,10 +6,10 @@ class BarcodePrinterTest < ActiveSupport::TestCase attr_reader :barcode_printer, :printer_for_384_wells_plate def setup - @barcode_printer = create :barcode_printer, name: 'test_printer' + @barcode_printer = create(:barcode_printer, name: 'test_printer') printer384 = BarcodePrinterType.find_by(name: '384 Well Plate') || create(:barcode_printer_type, name: '384 Well Plate') - @printer_for_384_wells_plate = create :barcode_printer, barcode_printer_type: printer384 + @printer_for_384_wells_plate = create(:barcode_printer, barcode_printer_type: printer384) end test 'should know if it can print on plates with 384 wells' do @@ -36,7 +36,7 @@ def setup accept: 'application/vnd.api+json' ) .returns(201) - create :barcode_printer, name: 'test_printer' + create(:barcode_printer, name: 'test_printer') configatron.register_printers_automatically = false end end diff --git a/test/unit/batch_test.rb b/test/unit/batch_test.rb index 2ed51a8523..fceffa4aa4 100644 --- a/test/unit/batch_test.rb +++ b/test/unit/batch_test.rb @@ -5,7 +5,7 @@ class BatchTest < ActiveSupport::TestCase context 'A batch' do context 'on its own' do - setup { @batch = build :batch } + setup { @batch = build(:batch) } should 'have begin in pending then change to started' do assert_equal @batch.state, 'pending' @@ -18,11 +18,11 @@ class BatchTest < ActiveSupport::TestCase context 'modifying request positions within a batch' do setup do - @pipeline = create :pipeline + @pipeline = create(:pipeline) # Weirdly, this is actually FASTER than factories by a substantial amount @requests = Array.new(10) { @pipeline.request_types.last.create! } - @batch = create :batch, requests: @requests, pipeline: @pipeline + @batch = create(:batch, requests: @requests, pipeline: @pipeline) end context '#assign_positions_to_requests!' do @@ -49,11 +49,11 @@ class BatchTest < ActiveSupport::TestCase context 'when batch is created' do setup do - @pipeline = create :pipeline - @request1 = create :request, request_type: @pipeline.request_types.first - @request2 = create :request, request_type: @pipeline.request_types.first + @pipeline = create(:pipeline) + @request1 = create(:request, request_type: @pipeline.request_types.first) + @request2 = create(:request, request_type: @pipeline.request_types.first) - @batch = create :batch, requests: [@request1, @request2], pipeline: @pipeline + @batch = create(:batch, requests: [@request1, @request2], pipeline: @pipeline) end should 'be able to call start_requests' do @@ -87,7 +87,7 @@ class BatchTest < ActiveSupport::TestCase context 'batch #has_event(event_name)' do setup do - @batch = create :batch + @batch = create(:batch) @batch.start!(create(:user)) @lab_event = LabEvent.new @@ -115,9 +115,9 @@ class BatchTest < ActiveSupport::TestCase context '#requests_by_study' do setup do - @pipeline = create :pipeline, locale: 'Internal' - @batch = create :batch, pipeline: @pipeline - @study1 = create :study + @pipeline = create(:pipeline, locale: 'Internal') + @batch = create(:batch, pipeline: @pipeline) + @study1 = create(:study) end context 'with no requests' do @@ -128,8 +128,8 @@ class BatchTest < ActiveSupport::TestCase context 'with 1 request' do setup do - @study2 = create :study - @request1 = create :request, request_type: @pipeline.request_types.last, study: @study1, batch: @batch + @study2 = create(:study) + @request1 = create(:request, request_type: @pipeline.request_types.last, study: @study1, batch: @batch) end should 'return correct studies' do @@ -140,10 +140,10 @@ class BatchTest < ActiveSupport::TestCase context 'with 2 requests from different studies' do setup do - @study2 = create :study - @study3 = create :study - @request1 = create :request, request_type: @pipeline.request_types.last, study: @study1 - @request2 = create :request, request_type: @pipeline.request_types.last, study: @study2 + @study2 = create(:study) + @study3 = create(:study) + @request1 = create(:request, request_type: @pipeline.request_types.last, study: @study1) + @request2 = create(:request, request_type: @pipeline.request_types.last, study: @study2) @batch.requests << @request1 << @request2 end @@ -157,9 +157,9 @@ class BatchTest < ActiveSupport::TestCase context '#plate_ids_in_study' do setup do - @pipeline = create :pipeline - @batch = create :batch, pipeline: @pipeline - @study1 = create :study + @pipeline = create(:pipeline) + @batch = create(:batch, pipeline: @pipeline) + @study1 = create(:study) end context 'with no requests' do @@ -170,12 +170,12 @@ class BatchTest < ActiveSupport::TestCase context 'with 2 request on a different plates' do setup do - @study2 = create :study - @plate1 = create :plate - @well1 = create :well, plate: @plate1 + @study2 = create(:study) + @plate1 = create(:plate) + @well1 = create(:well, plate: @plate1) - @plate2 = create :plate - @well2 = create :well, plate: @plate2 + @plate2 = create(:plate) + @well2 = create(:well, plate: @plate2) @batch.requests = [ @pipeline.request_types.last.create!(study: @study1, asset: @well1), @@ -203,7 +203,7 @@ class BatchTest < ActiveSupport::TestCase should_have_instance_methods :assigned_user, :start, :fail, :workflow, :started?, :released?, :qc_state - setup { @pipeline = create :sequencing_pipeline, name: 'Pipeline for BatchTest' } + setup { @pipeline = create(:sequencing_pipeline, name: 'Pipeline for BatchTest') } context 'create requests' do setup do @@ -237,7 +237,7 @@ class BatchTest < ActiveSupport::TestCase # send_fail_event will be used once since only one request is not a resource /@request1 # EventSender.expects(:send_fail_event).returns(true).times(1) EventSender.stubs(:send_fail_event).returns(true) - @control = create :sample_tube, resource: true + @control = create(:sample_tube, resource: true) @batch = @pipeline.batches.create! @request1, @request2 = @@ -335,8 +335,8 @@ class BatchTest < ActiveSupport::TestCase context '#public methods' do setup do - @asset1 = create :sample_tube, barcode: '123456' - @asset2 = create :sample_tube, barcode: '654321' + @asset1 = create(:sample_tube, barcode: '123456') + @asset2 = create(:sample_tube, barcode: '654321') @request1 = @pipeline.request_types.last.create!(asset: @asset1) @request2 = @pipeline.request_types.last.create!(asset: @asset2) @@ -371,14 +371,14 @@ class BatchTest < ActiveSupport::TestCase end should 'return user login' do - @user = create :user + @user = create(:user) @batch.assignee_id = @user.id assert 'lg1', @batch.assigned_user end context 'with control' do setup do - @control = create :sample_tube, resource: true + @control = create(:sample_tube, resource: true) @request = @pipeline.request_types.last.create!(asset: @control) @batch.batch_requests.create!(request: @request, position: 3) end @@ -434,7 +434,7 @@ class BatchTest < ActiveSupport::TestCase context '#reset!' do context 'once started' do - setup { @batch = create :batch, pipeline: @pipeline, state: 'started' } + setup { @batch = create(:batch, pipeline: @pipeline, state: 'started') } should 'raise an exception' do assert_raise AASM::InvalidTransition do @@ -449,10 +449,10 @@ class BatchTest < ActiveSupport::TestCase }.each do |pipeline_type, request_factory| context "of a #{pipeline_type}" do setup do - @pipeline = create pipeline_type - @batch = create :batch, pipeline: @pipeline - @pending_request = create request_factory, request_type: @pipeline.request_types.last - @pending_request_2 = create request_factory, request_type: @pipeline.request_types.last + @pipeline = create(pipeline_type) + @batch = create(:batch, pipeline: @pipeline) + @pending_request = create(request_factory, request_type: @pipeline.request_types.last) + @pending_request_2 = create(request_factory, request_type: @pipeline.request_types.last) @batch.requests << @pending_request << @pending_request_2 end @@ -483,8 +483,8 @@ class BatchTest < ActiveSupport::TestCase context '#qc_previous_state!' do setup do - @user = create :user - @batch = create :batch, pipeline: @pipeline + @user = create(:user) + @batch = create(:batch, pipeline: @pipeline) @batch.update!(qc_state: 'qc_completed') end should 'move batch to previous qc state' do @@ -503,16 +503,16 @@ class BatchTest < ActiveSupport::TestCase context "when swapping #{left_position} and #{right_position}" do setup do # Create a batch with a couple of requests positioned appropriately - @left_batch = create :batch, pipeline: @pipeline - @original_left_request = create :batch_request, batch_id: @left_batch.id, position: left_position - create :batch_request, batch_id: @left_batch.id, position: 1 + @left_batch = create(:batch, pipeline: @pipeline) + @original_left_request = create(:batch_request, batch_id: @left_batch.id, position: left_position) + create(:batch_request, batch_id: @left_batch.id, position: 1) # Now create another batch that we'll swap the requests between - @right_batch = create :batch, pipeline: @pipeline - @original_right_request = create :batch_request, batch_id: @right_batch.id, position: right_position - create :batch_request, batch_id: @right_batch.id, position: 2 + @right_batch = create(:batch, pipeline: @pipeline) + @original_right_request = create(:batch_request, batch_id: @right_batch.id, position: right_position) + create(:batch_request, batch_id: @right_batch.id, position: 2) - @user = create :user + @user = create(:user) end should 'swap lanes given 2 batches and swap requests.' do @@ -546,12 +546,12 @@ class BatchTest < ActiveSupport::TestCase context '#detach_request' do setup do - @library_prep_pipeline = create :pipeline, name: 'Library Prep Pipeline' - @lib_prep_batch = create :batch, pipeline: @library_prep_pipeline - @sample_tube = create :sample_tube, name: 'sample tube 1' - @library_tube = create :library_tube, name: 'lib tube 1' - @lib_prep_request = create :library_request, state: 'started', asset: @sample_tube, target_asset: @library_tube - @pe_seq_request = create :sequencing_request, state: 'pending', asset: @library_tube + @library_prep_pipeline = create(:pipeline, name: 'Library Prep Pipeline') + @lib_prep_batch = create(:batch, pipeline: @library_prep_pipeline) + @sample_tube = create(:sample_tube, name: 'sample tube 1') + @library_tube = create(:library_tube, name: 'lib tube 1') + @lib_prep_request = create(:library_request, state: 'started', asset: @sample_tube, target_asset: @library_tube) + @pe_seq_request = create(:sequencing_request, state: 'pending', asset: @library_tube) @lib_prep_batch.requests << @lib_prep_request end @@ -593,23 +593,23 @@ class BatchTest < ActiveSupport::TestCase context '#last_completed_task' do setup do - @library_prep_pipeline = create :pipeline, name: 'Library Prep Pipeline' - @task1 = create :task, workflow: @library_prep_pipeline.workflow, name: 'Task 1', sorted: 0 - @task2 = create :task, workflow: @library_prep_pipeline.workflow, name: 'Task 2', sorted: 1 - @task3 = create :task, workflow: @library_prep_pipeline.workflow, name: 'Task 3', sorted: 2 + @library_prep_pipeline = create(:pipeline, name: 'Library Prep Pipeline') + @task1 = create(:task, workflow: @library_prep_pipeline.workflow, name: 'Task 1', sorted: 0) + @task2 = create(:task, workflow: @library_prep_pipeline.workflow, name: 'Task 2', sorted: 1) + @task3 = create(:task, workflow: @library_prep_pipeline.workflow, name: 'Task 3', sorted: 2) - @batch = create :batch, pipeline: @library_prep_pipeline, state: 'started' + @batch = create(:batch, pipeline: @library_prep_pipeline, state: 'started') @batch.requests << @library_prep_pipeline.request_types.last.create!(state: 'started') # NO idea why descriptors are added twice here, or why the descriptors # implementation appears to be so complicated. I've converted this from # mocks to use factories instead, I'm keeping the duplicate tasks # until I can work out why they were added. - @event1 = create :lab_event, description: 'Complete', batch: @batch + @event1 = create(:lab_event, description: 'Complete', batch: @batch) @event1.add_new_descriptor 'task_id', @task1.id.to_s @event1.add_new_descriptor 'task_id', @task1.id.to_s - @event2 = create :lab_event, description: 'Complete', batch: @batch + @event2 = create(:lab_event, description: 'Complete', batch: @batch) @event2.add_new_descriptor 'task_id', @task2.id.to_s @event2.add_new_descriptor 'task_id', @task2.id.to_s @@ -639,11 +639,11 @@ class BatchTest < ActiveSupport::TestCase # JG: The QC state machine on batch is near non-existent, and all events # just push the batch into the next state. Here we advance the qc_state # to try and model what appears to be the intended behaviour. - @pipeline = create :sequencing_pipeline - @batch = create :batch, pipeline: @pipeline + @pipeline = create(:sequencing_pipeline) + @batch = create(:batch, pipeline: @pipeline) @batch.update!(qc_state: 'qc_manual_in_progress') @requests = - create_list :sequencing_request_with_assets, 2, state: 'started', request_type: @pipeline.request_types.first + create_list(:sequencing_request_with_assets, 2, state: 'started', request_type: @pipeline.request_types.first) @batch.requests = @requests end @@ -684,14 +684,14 @@ class BatchTest < ActiveSupport::TestCase context 'ready? all requests before creating batch' do setup do - @library_tube = create :library_tube, sample_count: 1 + @library_tube = create(:library_tube, sample_count: 1) @library_creation_request = create(:library_creation_request_for_testing_sequencing_requests, target_asset: @library_tube) - @pipeline = create :sequencing_pipeline + @pipeline = create(:sequencing_pipeline) @library_tube.create_scanned_into_lab_event!(content: '2018-01-01') - @batch = build :batch, pipeline: @pipeline + @batch = build(:batch, pipeline: @pipeline) @request_type = @batch.pipeline.request_types.first @sequencing_request = create(:sequencing_request, asset: @library_tube, request_type: @request_type) @batch.requests << @sequencing_request diff --git a/test/unit/cherrypick_task_test.rb b/test/unit/cherrypick_task_test.rb index de5921fb2f..88d4cc569f 100644 --- a/test/unit/cherrypick_task_test.rb +++ b/test/unit/cherrypick_task_test.rb @@ -48,7 +48,7 @@ def maps_for(num, from = 0, order = 'column') pp.save! end - @task = build :cherrypick_task + @task = build(:cherrypick_task) @robot = mock('robot') @robot.stubs(:max_beds).returns(2) diff --git a/test/unit/data_release_test.rb b/test/unit/data_release_test.rb index 2c0f998930..f1dee7e4af 100644 --- a/test/unit/data_release_test.rb +++ b/test/unit/data_release_test.rb @@ -4,7 +4,7 @@ class DataReleaseTest < ActiveSupport::TestCase context 'A study' do - setup { @study = create :study } + setup { @study = create(:study) } context '#valid_data_release_properties?' do context 'and data_release enforced' do setup do diff --git a/test/unit/event_factory_test.rb b/test/unit/event_factory_test.rb index 3d301a2b6d..a6492c89dc 100644 --- a/test/unit/event_factory_test.rb +++ b/test/unit/event_factory_test.rb @@ -7,13 +7,13 @@ class EventFactoryTest < ActiveSupport::TestCase context 'An EventFactory' do setup do - @user = create :user, login: 'south', email: 'south@example.com' - @bad_user = create :user, login: 'bad_south', email: '' - @project = create :project, name: 'hello world' - role = create :owner_role, authorizable: @project + @user = create(:user, login: 'south', email: 'south@example.com') + @bad_user = create(:user, login: 'bad_south', email: '') + @project = create(:project, name: 'hello world') + role = create(:owner_role, authorizable: @project) role.users << @user << @bad_user - @request_type = create :request_type, key: 'library_creation', name: 'Library creation' - @request = create :request, request_type: @request_type, user: @user, project: @project + @request_type = create(:request_type, key: 'library_creation', name: 'Library creation') + @request = create(:request, request_type: @request_type, user: @user, project: @project) @emails = ActionMailer::Base.deliveries @emails.clear @labware = create(:sample_tube, retention_instruction: 'return_to_customer_after_2_years') @@ -22,8 +22,8 @@ class EventFactoryTest < ActiveSupport::TestCase context '#new_project' do setup do @event_count = Event.count - admin = create :role, name: 'administrator' - user1 = create :user, login: 'abc123' + admin = create(:role, name: 'administrator') + user1 = create(:user, login: 'abc123') user1.roles << admin EventFactory.new_project(@project, @user) end @@ -42,10 +42,10 @@ class EventFactoryTest < ActiveSupport::TestCase context '#project_approved' do setup do @event_count = Event.count - role = create :manager_role, authorizable: @project + role = create(:manager_role, authorizable: @project) role.users << @user - admin = create :role, name: 'administrator' - user1 = create :user, login: 'west' + admin = create(:role, name: 'administrator') + user1 = create(:user, login: 'west') user1.roles << admin EventFactory.project_approved(@project, @user) end @@ -65,17 +65,17 @@ class EventFactoryTest < ActiveSupport::TestCase setup do @event_count = Event.count ::ActionMailer::Base.deliveries = [] - role = create :manager_role, authorizable: @project + role = create(:manager_role, authorizable: @project) role.users << @user - @user1 = create :user, login: 'north' + @user1 = create(:user, login: 'north') @request.user = @user1 - follower = create :role, name: 'follower' - @user2 = create :user, login: 'west' + follower = create(:role, name: 'follower') + @user2 = create(:user, login: 'west') @user2.roles << follower - @study = create :study, user: @user2 + @study = create(:study, user: @user2) @submission = FactoryHelp.submission(project: @project, study: @study, assets: [create(:sample_tube)]) - @request = create :request, study: @study, project: @project, submission: @submission - @user3 = create :user, login: 'east' + @request = create(:request, study: @study, project: @project, submission: @submission) + @user3 = create(:user, login: 'east') message = 'An error has occurred' EventFactory.request_update_note_to_manager(@request, @user3, message) end diff --git a/test/unit/event_test.rb b/test/unit/event_test.rb index 6858b57e80..7e51bc97d9 100644 --- a/test/unit/event_test.rb +++ b/test/unit/event_test.rb @@ -36,8 +36,8 @@ class EventTest < ActiveSupport::TestCase context 'when related to a Request' do setup do - @study = create :study - @request = create :request, study: @study + @study = create(:study) + @request = create(:request, study: @study) @settings = { eventful_id: @request.id, eventful_type: 'Request', @@ -65,8 +65,8 @@ class EventTest < ActiveSupport::TestCase context '#update_request' do setup do - @study = create :study - @request = create :request, study: @study, state: 'started' + @study = create(:study) + @request = create(:request, study: @study, state: 'started') @settings = { eventful_id: @request.id, eventful_type: 'Request', @@ -118,18 +118,18 @@ class EventTest < ActiveSupport::TestCase context 'when created with a' do setup do - @library_creation_request_type = create :request_type, name: 'Library creation', key: 'library_creation' + @library_creation_request_type = create(:request_type, name: 'Library creation', key: 'library_creation') @mx_library_creation_request_type = - create :request_type, name: 'Multiplexed library creation', key: 'multiplexed_library_creation' - @pe_sequencing_request_type = create :request_type, name: 'Paired end sequencing', key: 'paired_end_sequencing' + create(:request_type, name: 'Multiplexed library creation', key: 'multiplexed_library_creation') + @pe_sequencing_request_type = create(:request_type, name: 'Paired end sequencing', key: 'paired_end_sequencing') @control = create(:sample_tube, resource: true) - @library_creation_request = create :request, request_type: @library_creation_request_type - @multiplexed_library_creation_request = create :request, request_type: @mx_library_creation_request_type - @pe_sequencing_request = create :request, request_type: @pe_sequencing_request_type + @library_creation_request = create(:request, request_type: @library_creation_request_type) + @multiplexed_library_creation_request = create(:request, request_type: @mx_library_creation_request_type) + @pe_sequencing_request = create(:request, request_type: @pe_sequencing_request_type) @request_for_control = - create :request, request_type: @pe_sequencing_request_type, asset: @control, state: 'started' + create(:request, request_type: @pe_sequencing_request_type, asset: @control, state: 'started') @requests = [@library_creation_request, @multiplexed_library_creation_request, @pe_sequencing_request] end diff --git a/test/unit/eventful_entry_test.rb b/test/unit/eventful_entry_test.rb index a196821f4a..9e6fe5ce7c 100644 --- a/test/unit/eventful_entry_test.rb +++ b/test/unit/eventful_entry_test.rb @@ -13,8 +13,8 @@ class EventfulEntry < ApplicationRecord class EventfulEntryTest < ActiveSupport::TestCase context 'A model using events' do setup do - @request_type = create :request_type - @study = create :study + @request_type = create(:request_type) + @study = create(:study) @test_subject = EventfulEntry.create(request_type_id: @request_type.id, study_id: @study.id) @event = Event.new(eventful_id: @test_subject.id, eventful_type: @test_subject.class.to_s, family: 'Billing') diff --git a/test/unit/flexible_submission_test.rb b/test/unit/flexible_submission_test.rb index e8e0e98e62..86bbb69536 100644 --- a/test/unit/flexible_submission_test.rb +++ b/test/unit/flexible_submission_test.rb @@ -6,7 +6,7 @@ class FlexibleSubmissionTest < ActiveSupport::TestCase context 'FlexibleSubmission' do setup do @assets = create(:two_column_plate).wells.to_a - @pooling = create :pooling_method + @pooling = create(:pooling_method) end should belong_to :study @@ -14,13 +14,13 @@ class FlexibleSubmissionTest < ActiveSupport::TestCase context 'build (Submission factory)' do setup do - @study = create :study - @project = create :project - @user = create :user + @study = create(:study) + @project = create(:project) + @user = create(:user) @library_creation_request_type = - create :well_request_type, target_purpose: nil, for_multiplexing: true, pooling_method: @pooling - @sequencing_request_type = create :sequencing_request_type + create(:well_request_type, target_purpose: nil, for_multiplexing: true, pooling_method: @pooling) + @sequencing_request_type = create(:sequencing_request_type) @request_type_ids = [@library_creation_request_type.id, @sequencing_request_type.id] @@ -66,12 +66,12 @@ class FlexibleSubmissionTest < ActiveSupport::TestCase context 'with qc_criteria' do setup do - @our_product_criteria = create :product_criteria - @current_report = create :qc_report, product_criteria: @our_product_criteria - @stock_well = create :well + @our_product_criteria = create(:product_criteria) + @current_report = create(:qc_report, product_criteria: @our_product_criteria) + @stock_well = create(:well) @metric = - create :qc_metric, asset: @stock_well, qc_report: @current_report, qc_decision: 'failed', proceed: true + create(:qc_metric, asset: @stock_well, qc_report: @current_report, qc_decision: 'failed', proceed: true) @assets.each do |qced_well| qced_well.stock_wells.attach!([@stock_well]) @@ -109,8 +109,8 @@ class FlexibleSubmissionTest < ActiveSupport::TestCase context 'cross study/project submissions' do setup do - @study_b = create :study - @project_b = create :project + @study_b = create(:study) + @project_b = create(:project) @request_count = Request.count end @@ -178,7 +178,7 @@ class FlexibleSubmissionTest < ActiveSupport::TestCase context 'On pooled assets' do setup do @request_count = Request.count - @pooled = create :cross_pooled_well + @pooled = create(:cross_pooled_well) @sub = create( :flexible_submission, @@ -205,13 +205,13 @@ class FlexibleSubmissionTest < ActiveSupport::TestCase context 'with target asset creation' do setup do - @study = create :study - @project = create :project - @user = create :user - mx_purpose = create :mx_tube_purpose + @study = create(:study) + @project = create(:project) + @user = create(:user) + mx_purpose = create(:mx_tube_purpose) @library_creation_request_type = - create :well_request_type, for_multiplexing: true, target_purpose: mx_purpose, pooling_method: @pooling - @sequencing_request_type = create :sequencing_request_type + create(:well_request_type, for_multiplexing: true, target_purpose: mx_purpose, pooling_method: @pooling) + @sequencing_request_type = create(:sequencing_request_type) @request_type_ids = [@library_creation_request_type.id, @sequencing_request_type.id] @@ -275,20 +275,20 @@ class FlexibleSubmissionTest < ActiveSupport::TestCase context 'process with a multiplier for request type' do setup do - @study = create :study - @project = create :project - @user = create :user + @study = create(:study) + @project = create(:project) + @user = create(:user) - @ux_request_type = create :well_request_type, target_purpose: nil, for_multiplexing: false + @ux_request_type = create(:well_request_type, target_purpose: nil, for_multiplexing: false) @mx_request_type = - create :well_request_type, target_purpose: nil, for_multiplexing: true, pooling_method: @pooling + create(:well_request_type, target_purpose: nil, for_multiplexing: true, pooling_method: @pooling) @pe_request_type = - create :request_type, + create(:request_type, asset_type: 'LibraryTube', initial_state: 'pending', name: 'PE sequencing', order: 2, - key: 'pe_sequencing' + key: 'pe_sequencing') @request_type_ids = [@mx_request_type.id, @pe_request_type.id] @@ -338,20 +338,20 @@ class FlexibleSubmissionTest < ActiveSupport::TestCase context 'correctly calculate multipliers' do setup do - @study = create :study - @project = create :project - @user = create :user + @study = create(:study) + @project = create(:project) + @user = create(:user) - @ux_request_type = create :well_request_type, target_purpose: nil, for_multiplexing: false + @ux_request_type = create(:well_request_type, target_purpose: nil, for_multiplexing: false) @mx_request_type = - create :well_request_type, target_purpose: nil, for_multiplexing: true, pooling_method: @pooling + create(:well_request_type, target_purpose: nil, for_multiplexing: true, pooling_method: @pooling) @pe_request_type = - create :request_type, + create(:request_type, asset_type: 'LibraryTube', initial_state: 'pending', name: 'PE sequencing', order: 2, - key: 'pe_sequencing' + key: 'pe_sequencing') @mx_request_type_ids = [@mx_request_type.id, @pe_request_type.id] @ux_request_type_ids = [@ux_request_type.id, @pe_request_type.id] diff --git a/test/unit/import_fluidigm_data_test.rb b/test/unit/import_fluidigm_data_test.rb index 7ff92bd50a..593577f7dd 100644 --- a/test/unit/import_fluidigm_data_test.rb +++ b/test/unit/import_fluidigm_data_test.rb @@ -29,35 +29,35 @@ def create_fluidigm_file end def create_stock_plate(barcode) - create :plate, + create(:plate, name: "Stock plate #{barcode}", well_count: 1, well_factory: :untagged_well, purpose: PlatePurpose.stock_plate_purpose, - barcode: + barcode:) end def create_plate_with_fluidigm(_barcode, fluidigm_barcode, stock_plate) - fgp = create :fluidigm_96_purpose + fgp = create(:fluidigm_96_purpose) plate_target = create(:plate, size: 96, purpose: fgp, well_count: 1, well_factory: :empty_well, fluidigm_barcode:) well_target = plate_target.wells.first - create :final_cherrypick_for_fluidigm_request, + create(:final_cherrypick_for_fluidigm_request, state: 'passed', asset: stock_plate.wells.first, target_asset: well_target, request_metadata_attributes: { target_purpose_id: fgp.id }, - request_type: @fluidigm_request_type + request_type: @fluidigm_request_type) plate_target end context 'With a fluidigm file' do setup do - @fluidigm_request_type = create :request_type, key: 'pick_to_fluidigm' + @fluidigm_request_type = create(:request_type, key: 'pick_to_fluidigm') @fluidigm_file = create_fluidigm_file @stock_plate = create_stock_plate('SQPD-8765432') @plate1 = create_plate_with_fluidigm('1234567', '1381832088', @stock_plate) diff --git a/test/unit/lab_interface/workflow_test.rb b/test/unit/lab_interface/workflow_test.rb index 80594c137a..42f299e0ae 100644 --- a/test/unit/lab_interface/workflow_test.rb +++ b/test/unit/lab_interface/workflow_test.rb @@ -8,13 +8,13 @@ class WorkflowTest < ActiveSupport::TestCase should belong_to :pipeline setup do - pipeline = create :pipeline, name: 'Pipeline for WorkflowTest' + pipeline = create(:pipeline, name: 'Pipeline for WorkflowTest') @workflow = pipeline.workflow @workflow.update!(name: 'Workflow for WorkflowTest') - task = create :task, workflow: @workflow - create :descriptor, task:, name: 'prop', value: 'something', key: 'something' - create :descriptor, task:, name: 'prop_2', value: 'upstairs', key: 'upstairs' + task = create(:task, workflow: @workflow) + create(:descriptor, task:, name: 'prop', value: 'something', key: 'something') + create(:descriptor, task:, name: 'prop_2', value: 'upstairs', key: 'upstairs') end subject { @workflow } diff --git a/test/unit/lib_pool_norm_tube_generator_test.rb b/test/unit/lib_pool_norm_tube_generator_test.rb index d66911e562..a7a02e266c 100644 --- a/test/unit/lib_pool_norm_tube_generator_test.rb +++ b/test/unit/lib_pool_norm_tube_generator_test.rb @@ -15,7 +15,7 @@ def valid_plate def setup @user = create(:admin) @study = create(:study) - create :between_tubes_transfer_template # Needed by LibPoolNormTubeGenerator.new + create(:between_tubes_transfer_template) # Needed by LibPoolNormTubeGenerator.new end def mock_transfer(generator) diff --git a/test/unit/library_tube_test.rb b/test/unit/library_tube_test.rb index 2753551959..9bff6287e3 100644 --- a/test/unit/library_tube_test.rb +++ b/test/unit/library_tube_test.rb @@ -4,12 +4,12 @@ class LibraryTubeTest < ActiveSupport::TestCase context 'A Library tube' do - setup { @library_tube = create :library_tube } + setup { @library_tube = create(:library_tube) } context '#has_stock_asset?' do setup do - @library_tube_with_stock_tube = create :library_tube - @stock_library_tube = create :stock_library_tube + @library_tube_with_stock_tube = create(:library_tube) + @stock_library_tube = create(:stock_library_tube) @stock_library_tube.children << @library_tube_with_stock_tube end diff --git a/test/unit/messaging/messenger_creator_test.rb b/test/unit/messaging/messenger_creator_test.rb index 99beccbbb2..5a6fa8dad9 100644 --- a/test/unit/messaging/messenger_creator_test.rb +++ b/test/unit/messaging/messenger_creator_test.rb @@ -5,13 +5,13 @@ class MessengerCreatorTest < ActiveSupport::TestCase context '#messenger_creator' do setup do - @purpose = FactoryBot.build :plate_purpose - @plate = FactoryBot.build :plate, plate_purpose: @purpose + @purpose = FactoryBot.build(:plate_purpose) + @plate = FactoryBot.build(:plate, plate_purpose: @purpose) end context 'with SelfFinder' do setup do - @messenger_creator = FactoryBot.build :messenger_creator, purpose: @purpose + @messenger_creator = FactoryBot.build(:messenger_creator, purpose: @purpose) @start_count = Messenger.count end @@ -33,7 +33,7 @@ class MessengerCreatorTest < ActiveSupport::TestCase context 'with WellFinder' do setup do @messenger_creator = - build :messenger_creator, purpose: @purpose, target_finder_class: 'WellFinder', root: 'well' + build(:messenger_creator, purpose: @purpose, target_finder_class: 'WellFinder', root: 'well') @start_count = Messenger.count @plate.save 3.times { @plate.wells << build(:well) } diff --git a/test/unit/multiplexed_library_tube_test.rb b/test/unit/multiplexed_library_tube_test.rb index f1f55ac50a..4eb8b702a9 100644 --- a/test/unit/multiplexed_library_tube_test.rb +++ b/test/unit/multiplexed_library_tube_test.rb @@ -4,11 +4,11 @@ class MultiplexedLibraryTubeTest < ActiveSupport::TestCase context 'A multiplexed Library tube' do - setup { @multiplexed_library_tube = create :multiplexed_library_tube } + setup { @multiplexed_library_tube = create(:multiplexed_library_tube) } context '#has_stock_asset?' do setup do - @multiplexed_library_tube_with_stock_tube = create :multiplexed_library_tube - @stock_multiplexed_library_tube = create :stock_multiplexed_library_tube + @multiplexed_library_tube_with_stock_tube = create(:multiplexed_library_tube) + @stock_multiplexed_library_tube = create(:stock_multiplexed_library_tube) @stock_multiplexed_library_tube.children << @multiplexed_library_tube_with_stock_tube end diff --git a/test/unit/parsers/quant_parser_test.rb b/test/unit/parsers/quant_parser_test.rb index bb45d82fa4..8463c16acf 100644 --- a/test/unit/parsers/quant_parser_test.rb +++ b/test/unit/parsers/quant_parser_test.rb @@ -28,7 +28,7 @@ def read_file(filename) context 'processing the file' do setup do @parser = Parsers.parser_for(@filename, nil, @content) - @plate = create :plate, well_count: 18 + @plate = create(:plate, well_count: 18) @default_conc = @plate.wells.first.get_concentration @plate.update_qc_values_with_parser(@parser) @wells = @plate.reload.wells.index_by(&:map_description) @@ -56,8 +56,8 @@ def read_file(filename) @filename = Rails.root.join('test/data/complete_quant_test.csv').to_s @content = read_file @filename @parser = Parsers.parser_for(@filename, nil, @content) - @plate = create :working_dilution_plate, well_count: 18, plate_metadata_attributes: { dilution_factor: 10 } - @parent = create :plate, well_count: 18 + @plate = create(:working_dilution_plate, well_count: 18, plate_metadata_attributes: { dilution_factor: 10 }) + @parent = create(:plate, well_count: 18) @plate.parents << @parent @default_conc = @plate.wells.reload.first.get_concentration @plate.update_qc_values_with_parser(@parser) @@ -106,7 +106,7 @@ def read_file(filename) context 'processing the file' do setup do @parser = Parsers.parser_for(@filename, nil, @content) - @plate = create :plate, well_count: 18 + @plate = create(:plate, well_count: 18) @default_conc = @plate.wells.first.get_concentration @plate.update_qc_values_with_parser(@parser) @wells = @plate.wells.reload.index_by(&:map_description) diff --git a/test/unit/pipeline_test.rb b/test/unit/pipeline_test.rb index 08e69eb38e..77d0e573e0 100644 --- a/test/unit/pipeline_test.rb +++ b/test/unit/pipeline_test.rb @@ -14,10 +14,10 @@ class PipelineTest < ActiveSupport::TestCase context 'sequencing_pipeline#read length consistency among batch requests' do setup do - @sample = create :sample + @sample = create(:sample) - @request_type = create :request_type, name: 'sequencing', target_asset_type: nil - @pipeline = create :sequencing_pipeline, name: 'sequencing pipeline', request_types: [@request_type] + @request_type = create(:request_type, name: 'sequencing', target_asset_type: nil) + @pipeline = create(:sequencing_pipeline, name: 'sequencing pipeline', request_types: [@request_type]) @request1 = create( :sequencing_request, @@ -36,7 +36,7 @@ class PipelineTest < ActiveSupport::TestCase end should 'return true if not any request was selected' do - @batch = create :batch + @batch = create(:batch) assert @pipeline.is_read_length_consistent_for_batch?(@batch) end @@ -59,7 +59,7 @@ class PipelineTest < ActiveSupport::TestCase end should 'check that other pipelines are not affected by different read_length attributes' do - @pipeline2 = create :pipeline, name: 'other pipeline', request_types: [@request_type] + @pipeline2 = create(:pipeline, name: 'other pipeline', request_types: [@request_type]) @request1 = create( :sequencing_request, @@ -85,10 +85,10 @@ class PipelineTest < ActiveSupport::TestCase context 'sequencing_pipeline#requested_flowcell_type consistency among batch requests' do setup do - @sample = create :sample + @sample = create(:sample) - @request_type = create :request_type, name: 'sequencing', target_asset_type: nil - @pipeline = create :sequencing_pipeline, name: 'sequencing pipeline', request_types: [@request_type] + @request_type = create(:request_type, name: 'sequencing', target_asset_type: nil) + @pipeline = create(:sequencing_pipeline, name: 'sequencing pipeline', request_types: [@request_type]) @request1 = create( :sequencing_request, @@ -107,7 +107,7 @@ class PipelineTest < ActiveSupport::TestCase end should 'return true if no request was selected' do - @batch = create :batch + @batch = create(:batch) assert @pipeline.is_flowcell_type_consistent_for_batch?(@batch) end @@ -124,7 +124,7 @@ class PipelineTest < ActiveSupport::TestCase end should 'check that other pipelines are not affected by different requested_flowcell_type attributes' do - @pipeline2 = create :pipeline, name: 'other pipeline', request_types: [@request_type] + @pipeline2 = create(:pipeline, name: 'other pipeline', request_types: [@request_type]) @request1 = create( :sequencing_request, diff --git a/test/unit/plate_creator_test.rb b/test/unit/plate_creator_test.rb index 9e77d7f439..f3554593be 100644 --- a/test/unit/plate_creator_test.rb +++ b/test/unit/plate_creator_test.rb @@ -6,15 +6,15 @@ class CreatorTest < ActiveSupport::TestCase attr_reader :creator, :barcode_printer def setup - @creator_purpose = create :plate_purpose - @creator = create :plate_creator, plate_purposes: [@creator_purpose] - @barcode_printer = create :barcode_printer + @creator_purpose = create(:plate_purpose) + @creator = create(:plate_creator, plate_purposes: [@creator_purpose]) + @barcode_printer = create(:barcode_printer) end test 'should send request to print labels' do PlateBarcode.stubs(:create_barcode).returns(build(:plate_barcode)) - scanned_user = create :user + scanned_user = create(:user) create_asset_group = 'No' RestClient.expects(:post) @@ -41,8 +41,8 @@ def setup LabelPrinter::PrintJob.any_instance.stubs(:execute).returns(true) - parent = create :plate_with_untagged_wells - user = create :user + parent = create(:plate_with_untagged_wells) + user = create(:user) plate_count = Plate.count create_asset_group = 'No' diff --git a/test/unit/plate_owner_test.rb b/test/unit/plate_owner_test.rb index 3d6d1c79f0..5f1339dccd 100644 --- a/test/unit/plate_owner_test.rb +++ b/test/unit/plate_owner_test.rb @@ -17,8 +17,8 @@ class OwnerTest < ActionController::TestCase @barcode_printer.stubs(:each).returns(@barcode_printer) @barcode_printer.stubs(:blank?).returns(true) - @user = create :user - @parent_plate = create :plate + @user = create(:user) + @parent_plate = create(:plate) @pc_event = PlateCreation.create(user: @user, parent: @parent_plate, child_purpose: create(:plate_purpose)) @child_plate = @pc_event.child @@ -30,7 +30,7 @@ class OwnerTest < ActionController::TestCase end should 'be updated when stuff happens' do - @user2 = create :user + @user2 = create(:user) @tf_event = Transfer::BetweenPlates.create!( source: @parent_plate, diff --git a/test/unit/plate_template_test.rb b/test/unit/plate_template_test.rb index 1655aaee86..d341a1ba9a 100644 --- a/test/unit/plate_template_test.rb +++ b/test/unit/plate_template_test.rb @@ -6,7 +6,7 @@ class PlateTemplateTest < ActiveSupport::TestCase context 'A plate template' do context 'with no empty wells' do setup do - @template = create :plate_template + @template = create(:plate_template) @old_wells = Well.count @old_asset_link = AssetLink.count @template.update_params!(name: 'a', value: '2', wells: {}) @@ -19,7 +19,7 @@ class PlateTemplateTest < ActiveSupport::TestCase context 'with 1 empty well' do setup do - @template = create :plate_template + @template = create(:plate_template) @old_wells = Well.count @template.update_params!(name: 'a', value: '2', wells: { 'A1' => '123' }) end @@ -30,7 +30,7 @@ class PlateTemplateTest < ActiveSupport::TestCase context 'with 2 empty wells' do setup do - @template = create :plate_template + @template = create(:plate_template) @old_wells = Well.count @old_asset_link = AssetLink.count @template.update_params!(name: 'a', value: '2', wells: { 'A1' => '123', 'B3' => '345' }) diff --git a/test/unit/plate_test.rb b/test/unit/plate_test.rb index 860b709754..74907fb83f 100644 --- a/test/unit/plate_test.rb +++ b/test/unit/plate_test.rb @@ -5,7 +5,7 @@ class PlateTest < ActiveSupport::TestCase def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) - purpose = create :plate_purpose + purpose = create(:plate_purpose) purpose.create!( :do_not_create_wells, name: "Cherrypicked #{plate_barcode}", @@ -44,8 +44,8 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) context '#iteration' do setup do - @parent = create :plate, created_at: 6.hours.ago - tested_purpose = create :plate_purpose + @parent = create(:plate, created_at: 6.hours.ago) + tested_purpose = create(:plate_purpose) @parent.children << @child_a = create(:plate, plate_purpose: tested_purpose, created_at: 5.hours.ago) @parent.children << @child_b = create(:plate, plate_purpose: tested_purpose, created_at: 4.hours.ago) @child_b.children << @dummy = create(:plate, plate_purpose: tested_purpose, created_at: 3.hours.ago) @@ -63,9 +63,9 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) context '#plate_ids_from_requests' do setup do - @plate1 = create :plate, :with_wells, well_count: 1 + @plate1 = create(:plate, :with_wells, well_count: 1) @well1 = @plate1.wells.first - @request1 = create :well_request, asset: @well1 + @request1 = create(:well_request, asset: @well1) end context 'with 1 request' do @@ -80,7 +80,7 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) setup do @well2 = Well.new @plate1.wells << @well2 - @request2 = create :well_request, asset: @well2 + @request2 = create(:well_request, asset: @well2) end context 'with a valid well assets' do should 'return a single plate ID' do @@ -93,12 +93,12 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) context 'with multiple requests on different plates' do setup do @well2 = Well.new - @plate2 = create :plate, :with_wells, well_count: 1 + @plate2 = create(:plate, :with_wells, well_count: 1) @well2 = @plate2.wells.first - @request2 = create :well_request, asset: @well2 + @request2 = create(:well_request, asset: @well2) @well3 = Well.new @plate1.wells << @well3 - @request3 = create :well_request, asset: @well3 + @request3 = create(:well_request, asset: @well3) end context 'with a valid well assets' do should 'return 2 plate IDs' do @@ -113,10 +113,10 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) context 'Plate priority' do setup do - @plate = create :transfer_plate + @plate = create(:transfer_plate) user = create(:user) @plate.wells.each_with_index do |well, index| - create :request, asset: well, submission: Submission.create!(priority: index + 1, user:) + create(:request, asset: well, submission: Submission.create!(priority: index + 1, user:)) end end @@ -161,7 +161,7 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) context 'with existing well data' do setup do - @plate = create :plate_with_empty_wells, well_count: 3 + @plate = create(:plate_with_empty_wells, well_count: 3) @plate.wells.first.set_concentration('12') @plate.wells.first.set_molarity('34') @plate.update_qc_values_with_parser(MockParser.new) @@ -203,13 +203,13 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) context '::with_descendants_owned_by' do setup do - @user = create :user - @source_plate = create :source_plate - @child_plate = create :child_plate, parent: @source_plate + @user = create(:user) + @source_plate = create(:source_plate) + @child_plate = create(:child_plate, parent: @source_plate) end should 'find source plates with owners' do - create :plate_owner, user: @user, plate: @child_plate + create(:plate_owner, user: @user, plate: @child_plate) assert_includes Plate.with_descendants_owned_by(@user), @source_plate end diff --git a/test/unit/product_catalogue/library_driven_test.rb b/test/unit/product_catalogue/library_driven_test.rb index c055cb5fe2..a6933e210f 100644 --- a/test/unit/product_catalogue/library_driven_test.rb +++ b/test/unit/product_catalogue/library_driven_test.rb @@ -6,21 +6,21 @@ class LibraryDrivenTest < ActiveSupport::TestCase context 'When using a ProductCatalogue that is library driven' do setup do def link_product_with_pc(product, product_catalogue, library_type_name) - FactoryBot.create :product_product_catalogue, + FactoryBot.create(:product_product_catalogue, product:, product_catalogue:, - selection_criterion: library_type_name + selection_criterion: library_type_name) end # We'll create a product catalogue that will contain [@product, @product2, @product3] - @product = FactoryBot.create :product - @product2 = FactoryBot.create :product - @product3 = FactoryBot.create :product + @product = FactoryBot.create(:product) + @product2 = FactoryBot.create(:product) + @product3 = FactoryBot.create(:product) - @library_type = FactoryBot.create :library_type, name: 'LibraryType 1' - @library_type2 = FactoryBot.create :library_type, name: 'LibraryType 2' + @library_type = FactoryBot.create(:library_type, name: 'LibraryType 1') + @library_type2 = FactoryBot.create(:library_type, name: 'LibraryType 2') - @product_catalogue = FactoryBot.create :library_driven_product_catalogue + @product_catalogue = FactoryBot.create(:library_driven_product_catalogue) # The selection criterion is the library type name link_product_with_pc(@product, @product_catalogue, @library_type.name) @@ -32,7 +32,7 @@ def link_product_with_pc(product, product_catalogue, library_type_name) context 'with no library or incorrect type' do setup do @submission_template = - FactoryBot.create :submission_template, + FactoryBot.create(:submission_template, name: 'ST 1', product_catalogue: @product_catalogue, submission_parameters: { @@ -40,15 +40,15 @@ def link_product_with_pc(product, product_catalogue, library_type_name) request_options: { library_type: 'Another library' } - } + }) @submission_template2 = - FactoryBot.create :submission_template, + FactoryBot.create(:submission_template, name: 'ST 2', product_catalogue: @product_catalogue, submission_parameters: { request_type_ids_list: [] - } + }) end should 'not select any product (return nil)' do order = @submission_template.new_order @@ -70,7 +70,7 @@ def link_product_with_pc(product, product_catalogue, library_type_name) context 'with a library type selected' do setup do @submission_template = - FactoryBot.create :submission_template, + FactoryBot.create(:submission_template, name: 'ST 1', product_catalogue: @product_catalogue, submission_parameters: { @@ -78,10 +78,10 @@ def link_product_with_pc(product, product_catalogue, library_type_name) request_options: { library_type: @library_type.name } - } + }) @submission_template2 = - FactoryBot.create :submission_template, + FactoryBot.create(:submission_template, name: 'ST 2', product_catalogue: @product_catalogue, submission_parameters: { @@ -89,7 +89,7 @@ def link_product_with_pc(product, product_catalogue, library_type_name) request_options: { library_type: @library_type2.name } - } + }) end should 'selects the right product for this submission using the library type' do @@ -104,12 +104,12 @@ def link_product_with_pc(product, product_catalogue, library_type_name) context 'without a library type selected' do setup do @submission_template3 = - FactoryBot.create :submission_template, + FactoryBot.create(:submission_template, name: 'ST 3', product_catalogue: @product_catalogue, submission_parameters: { request_type_ids_list: [] - } + }) end should 'select the first product of the default products' do @@ -120,7 +120,7 @@ def link_product_with_pc(product, product_catalogue, library_type_name) context 'with a library type unsupported by the product catalogue' do setup do @submission_template4 = - FactoryBot.create :submission_template, + FactoryBot.create(:submission_template, name: 'ST 4', product_catalogue: @product_catalogue, submission_parameters: { @@ -128,7 +128,7 @@ def link_product_with_pc(product, product_catalogue, library_type_name) request_options: { library_type: 'Standard' } - } + }) end should 'select the first product of the default products' do order = @submission_template4.new_order @@ -137,12 +137,12 @@ def link_product_with_pc(product, product_catalogue, library_type_name) end context 'with a library type that matches more than one product' do setup do - @product4 = FactoryBot.create :product + @product4 = FactoryBot.create(:product) link_product_with_pc(@product4, @product_catalogue, @library_type.name) @submission_template5 = - FactoryBot.create :submission_template, + FactoryBot.create(:submission_template, name: 'ST 5', product_catalogue: @product_catalogue, submission_parameters: { @@ -150,7 +150,7 @@ def link_product_with_pc(product, product_catalogue, library_type_name) request_options: { library_type: @library_type.name } - } + }) end should 'select the first product of the default products' do order = @submission_template5.new_order diff --git a/test/unit/product_catalogue_test.rb b/test/unit/product_catalogue_test.rb index abb7a78427..96de57b9a4 100644 --- a/test/unit/product_catalogue_test.rb +++ b/test/unit/product_catalogue_test.rb @@ -9,8 +9,8 @@ class ProductCatalogueTest < ActiveSupport::TestCase context 'with single product behaviour' do setup do - @catalogue = create :single_product_catalogue - @product = create :product + @catalogue = create(:single_product_catalogue) + @product = create(:product) @catalogue.products << @product end @@ -24,14 +24,14 @@ class ProductCatalogueTest < ActiveSupport::TestCase context 'with invalid behaviour' do should 'reject non-existant behaviours' do assert_raise(ActiveRecord::RecordInvalid) do - create :product_catalogue, selection_behaviour: 'InvalidSelectionBehaviour' + create(:product_catalogue, selection_behaviour: 'InvalidSelectionBehaviour') end end end context 'with global constants for behaviour' do should 'reject behaviours' do - assert_raise(ActiveRecord::RecordInvalid) { create :product_catalogue, selection_behaviour: 'File' } + assert_raise(ActiveRecord::RecordInvalid) { create(:product_catalogue, selection_behaviour: 'File') } end end end @@ -40,7 +40,7 @@ class ProductCatalogueTest < ActiveSupport::TestCase setup do @catalogue_count = ProductCatalogue.count - @existing_product = create :product, name: 'pre_existing' + @existing_product = create(:product, name: 'pre_existing') @product_count = Product.count @product_product_catalogue_count = ProductProductCatalogue.count diff --git a/test/unit/product_criteria/advanced_test.rb b/test/unit/product_criteria/advanced_test.rb index a339714010..266392d2a6 100644 --- a/test/unit/product_criteria/advanced_test.rb +++ b/test/unit/product_criteria/advanced_test.rb @@ -28,10 +28,10 @@ class ProductCriteriaAdvancedTest < ActiveSupport::TestCase context 'with a list of target wells' do setup do @well_attribute = - create :well_attribute, concentration: 800, current_volume: 100, gel_pass: 'OKAY', gender_markers: %w[M M U] - @well = create :well, well_attribute: @well_attribute + create(:well_attribute, concentration: 800, current_volume: 100, gel_pass: 'OKAY', gender_markers: %w[M M U]) + @well = create(:well, well_attribute: @well_attribute) - @target_wells = create_list :well, 7 + @target_wells = create_list(:well, 7) @target_wells[4].well_attribute.update(concentration: 30, updated_at: 1.hour.from_now) @criteria = ProductCriteria::Advanced.new(@params, @well, @target_wells) end @@ -50,8 +50,8 @@ class ProductCriteriaAdvancedTest < ActiveSupport::TestCase context 'with a good well' do setup do - @well_attribute = create :well_attribute, concentration: 800, measured_volume: 200 - @well = create :well, well_attribute: @well_attribute + @well_attribute = create(:well_attribute, concentration: 800, measured_volume: 200) + @well = create(:well, well_attribute: @well_attribute) @criteria = ProductCriteria::Advanced.new(@params, @well) end @@ -63,8 +63,8 @@ class ProductCriteriaAdvancedTest < ActiveSupport::TestCase context 'with a bad well' do setup do - @well_attribute = create :well_attribute, concentration: 200, measured_volume: 50 - @well = create :well, well_attribute: @well_attribute + @well_attribute = create(:well_attribute, concentration: 200, measured_volume: 50) + @well = create(:well, well_attribute: @well_attribute) @criteria = ProductCriteria::Advanced.new(@params, @well) end @@ -76,8 +76,8 @@ class ProductCriteriaAdvancedTest < ActiveSupport::TestCase context 'with a very bad well' do setup do - @well_attribute = create :well_attribute, concentration: 1, measured_volume: 30_000 - @well = create :well, well_attribute: @well_attribute + @well_attribute = create(:well_attribute, concentration: 1, measured_volume: 30_000) + @well = create(:well, well_attribute: @well_attribute) @criteria = ProductCriteria::Advanced.new(@params, @well) end diff --git a/test/unit/product_criteria/basic_test.rb b/test/unit/product_criteria/basic_test.rb index 37777794af..001babfb3e 100644 --- a/test/unit/product_criteria/basic_test.rb +++ b/test/unit/product_criteria/basic_test.rb @@ -28,9 +28,9 @@ class ProductCriteriaBasicTest < ActiveSupport::TestCase context 'with a bad well' do setup do @well_attribute = - create :well_attribute, concentration: 1, current_volume: 30_000, gel_pass: 'OKAY', gender_markers: %w[M M U] - @well = create :well, well_attribute: @well_attribute - @sample = create :sample, sample_metadata_attributes: { gender: 'female' } + create(:well_attribute, concentration: 1, current_volume: 30_000, gel_pass: 'OKAY', gender_markers: %w[M M U]) + @well = create(:well, well_attribute: @well_attribute) + @sample = create(:sample, sample_metadata_attributes: { gender: 'female' }) @well.samples << @sample @criteria = ProductCriteria::Basic.new(@params, @well) end @@ -56,9 +56,9 @@ class ProductCriteriaBasicTest < ActiveSupport::TestCase context 'with a good well' do setup do @well_attribute = - create :well_attribute, concentration: 800, current_volume: 100, gel_pass: 'OKAY', gender_markers: %w[M M U] - @well = create :well, well_attribute: @well_attribute - @sample = create :sample, sample_metadata_attributes: { gender: 'male' } + create(:well_attribute, concentration: 800, current_volume: 100, gel_pass: 'OKAY', gender_markers: %w[M M U]) + @well = create(:well, well_attribute: @well_attribute) + @sample = create(:sample, sample_metadata_attributes: { gender: 'male' }) @well.samples << @sample @criteria = ProductCriteria::Basic.new(@params, @well) end diff --git a/test/unit/product_criteria_test.rb b/test/unit/product_criteria_test.rb index f1689e01fb..11d77e69ec 100644 --- a/test/unit/product_criteria_test.rb +++ b/test/unit/product_criteria_test.rb @@ -10,24 +10,24 @@ class ProductCriteriaTest < ActiveSupport::TestCase should validate_presence_of :behaviour setup do - @product_a = create :product + @product_a = create(:product) @criteria_a = - create :product_criteria, product: @product_a, configuration: { total_micrograms: { greater_than: 50 } } + create(:product_criteria, product: @product_a, configuration: { total_micrograms: { greater_than: 50 } }) end should 'only allow one active criteria per product per stage' do - assert_raise(ActiveRecord::RecordInvalid) { create :product_criteria, product: @product_a } + assert_raise(ActiveRecord::RecordInvalid) { create(:product_criteria, product: @product_a) } end should 'allow multiple active criteria with different stages' do - @criteria_b = create :product_criteria, product: @product_a, stage: 'another_stage' + @criteria_b = create(:product_criteria, product: @product_a, stage: 'another_stage') assert @criteria_b.valid? end should 'allow products with the same name if one is deprecated' do @criteria_a.deprecated_at = Time.zone.now @criteria_a.save - @criteria_2 = create :product_criteria, product: @product_a + @criteria_2 = create(:product_criteria, product: @product_a) assert @criteria_2.valid? end @@ -35,7 +35,7 @@ class ProductCriteriaTest < ActiveSupport::TestCase assert_equal 1, @criteria_a.version @criteria_a.deprecated_at = Time.zone.now @criteria_a.save - @criteria_b = create :product_criteria, product: @product_a + @criteria_b = create(:product_criteria, product: @product_a) assert_equal 2, @criteria_b.version end @@ -63,7 +63,7 @@ class ProductCriteriaTest < ActiveSupport::TestCase end should 'validate wells with the provided criteria' do - well_attribute = create :well_attribute, concentration: 800, current_volume: 100 + well_attribute = create(:well_attribute, concentration: 800, current_volume: 100) well = create(:well, well_attribute:) assesment = @criteria_a.assess(well) assert assesment.is_a?(ProductCriteria::Basic) diff --git a/test/unit/product_test.rb b/test/unit/product_test.rb index 20b7804a02..cbcc66e0ef 100644 --- a/test/unit/product_test.rb +++ b/test/unit/product_test.rb @@ -11,18 +11,18 @@ class ProductTest < ActiveSupport::TestCase should validate_presence_of :name should 'only allow one active product with each name' do - @product_a = create :product - assert_raise(ActiveRecord::RecordInvalid) { @product_b = create :product, name: @product_a.name } + @product_a = create(:product) + assert_raise(ActiveRecord::RecordInvalid) { @product_b = create(:product, name: @product_a.name) } end should 'allow products with the same name if one is deprecated' do - @product_a = create :product, deprecated_at: Time.zone.now - @product_b = create :product, name: @product_a.name + @product_a = create(:product, deprecated_at: Time.zone.now) + @product_b = create(:product, name: @product_a.name) assert @product_b.valid? end should 'not be destroyable' do - @product_a = create :product + @product_a = create(:product) # ActiveRecord::RecordNotDestroyed is the Rails4 exception for this # Added here as Rails 2 is a bit useless with appropriate exceptions @@ -30,7 +30,7 @@ class ProductTest < ActiveSupport::TestCase end should 'be deprecatable' do - @product_a = create :product + @product_a = create(:product) @product_a.deprecate! assert @product_a.deprecated? assert @product_a.deprecated_at != nil @@ -39,8 +39,8 @@ class ProductTest < ActiveSupport::TestCase context 'Product' do setup do - @product_a = create :product, deprecated_at: Time.zone.now - @product_b = create :product + @product_a = create(:product, deprecated_at: Time.zone.now) + @product_b = create(:product) end context '::active' do diff --git a/test/unit/purpose_test.rb b/test/unit/purpose_test.rb index 7107b7dc65..8020415d11 100644 --- a/test/unit/purpose_test.rb +++ b/test/unit/purpose_test.rb @@ -4,6 +4,6 @@ class PurposeTest < ActiveSupport::TestCase context 'A purpose' do - setup { @purpose = create :purpose } + setup { @purpose = create(:purpose) } end end diff --git a/test/unit/qc_file_test.rb b/test/unit/qc_file_test.rb index 2bbbc077f7..dae247325f 100644 --- a/test/unit/qc_file_test.rb +++ b/test/unit/qc_file_test.rb @@ -6,7 +6,7 @@ class QcFileTest < ActiveSupport::TestCase context QcFile do context 'with an asset' do setup do - @plate = create :plate + @plate = create(:plate) @parser = Object.new Parsers.expects(:parser_for).returns(@parser) end diff --git a/test/unit/qc_metric_test.rb b/test/unit/qc_metric_test.rb index 3573fb0649..10eef529bf 100644 --- a/test/unit/qc_metric_test.rb +++ b/test/unit/qc_metric_test.rb @@ -27,7 +27,7 @@ class QcMetricTest < ActiveSupport::TestCase ['manually_passed', nil, false] ].each do |qc_state, proceed_state, poor_quality_proceed| should "return #{poor_quality_proceed} when the qc_state is #{qc_state} and proceed is #{proceed_state}" do - qc = create :qc_metric, qc_decision: qc_state, proceed: proceed_state + qc = create(:qc_metric, qc_decision: qc_state, proceed: proceed_state) assert_equal poor_quality_proceed, qc.poor_quality_proceed end end @@ -42,22 +42,22 @@ class QcMetricTest < ActiveSupport::TestCase ['unprocessable', false, true] ].each do |qc_state, proceedable, set_suboptimal| should "#{proceedable ? '' : 'not '}allow the proceed flag to be set to Y when #{qc_state}" do - qc = create :qc_metric, qc_decision: qc_state + qc = create(:qc_metric, qc_decision: qc_state) qc.human_proceed = 'Y' assert_equal proceedable, qc.proceed end should "allow the proceed flag to be set to N when #{qc_state}" do - qc = create :qc_metric, qc_decision: qc_state + qc = create(:qc_metric, qc_decision: qc_state) qc.human_proceed = 'N' assert_equal false, qc.proceed end should "#{set_suboptimal ? '' : 'not '}flag the aliquot as suboptimal when #{qc_state}" do - aliquot = create :aliquot - well = create :well + aliquot = create(:aliquot) + well = create(:well) well.aliquots << aliquot - create :qc_metric, qc_decision: qc_state, asset: well + create(:qc_metric, qc_decision: qc_state, asset: well) # The data NEEDS to be persisted, so we reload to check this is the case. aliquot.reload diff --git a/test/unit/qc_report_file_test.rb b/test/unit/qc_report_file_test.rb index e76e47bfd0..b6996b8e79 100644 --- a/test/unit/qc_report_file_test.rb +++ b/test/unit/qc_report_file_test.rb @@ -62,20 +62,20 @@ class QcReport::FileTest < ActiveSupport::TestCase context 'given a file with a report' do setup do - @product = create :product, name: 'Demo Product' - @criteria = create :product_criteria, product: @product, version: 1 - @study = create :study, name: 'Example study' + @product = create(:product, name: 'Demo Product') + @criteria = create(:product_criteria, product: @product, version: 1) + @study = create(:study, name: 'Example study') Timecop.freeze(DateTime.parse('01/01/2015')) do @report = - create :qc_report, + create(:qc_report, study: @study, exclude_existing: false, product_criteria: @criteria, - state: 'awaiting_proceed' + state: 'awaiting_proceed') end @asset_ids = [] 2.times do |i| - create :qc_metric, qc_report: @report, qc_decision: %w[passed failed][i], asset: create(:well, id: i + 1) + create(:qc_metric, qc_report: @report, qc_decision: %w[passed failed][i], asset: create(:well, id: i + 1)) end @file = fixture_file_upload("#{Rails.root}/test/data/qc_report.csv", 'text/csv') @@ -104,20 +104,20 @@ class QcReport::FileTest < ActiveSupport::TestCase context 'On overriding' do setup do - @product = FactoryBot.build :product, name: 'Demo Product' - @criteria = FactoryBot.build :product_criteria, product: @product, version: 1 - @study = FactoryBot.build :study, name: 'Example study' + @product = FactoryBot.build(:product, name: 'Demo Product') + @criteria = FactoryBot.build(:product_criteria, product: @product, version: 1) + @study = FactoryBot.build(:study, name: 'Example study') Timecop.freeze(DateTime.parse('01/01/2015')) do @report = - create :qc_report, + create(:qc_report, study: @study, exclude_existing: false, product_criteria: @criteria, - state: 'awaiting_proceed' + state: 'awaiting_proceed') end @asset_ids = [] 2.times do |i| - m = create :qc_metric, qc_report: @report, qc_decision: %w[passed failed][i], asset: create(:well, id: i + 1) + m = create(:qc_metric, qc_report: @report, qc_decision: %w[passed failed][i], asset: create(:well, id: i + 1)) @asset_ids << m.asset_id end @file = fixture_file_upload("#{Rails.root}/test/data/qc_report.csv", 'text/csv') @@ -135,19 +135,19 @@ class QcReport::FileTest < ActiveSupport::TestCase context 'With missing assets' do setup do - @product = FactoryBot.build :product, name: 'Demo Product' - @criteria = FactoryBot.build :product_criteria, product: @product, version: 1 - @study = FactoryBot.build :study, name: 'Example study' + @product = FactoryBot.build(:product, name: 'Demo Product') + @criteria = FactoryBot.build(:product_criteria, product: @product, version: 1) + @study = FactoryBot.build(:study, name: 'Example study') Timecop.freeze(DateTime.parse('01/01/2015')) do @report = - create :qc_report, + create(:qc_report, study: @study, exclude_existing: false, product_criteria: @criteria, - state: 'awaiting_proceed' + state: 'awaiting_proceed') end @asset_ids = [] - 2.times { |i| create :qc_metric, qc_report: @report, qc_decision: %w[passed failed][i] } + 2.times { |i| create(:qc_metric, qc_report: @report, qc_decision: %w[passed failed][i]) } @file = fixture_file_upload("#{Rails.root}/test/data/qc_report.csv", 'text/csv') @qcr_file = QcReport::File.new(@file, true, 'qc_report.csv', 'text/csv') diff --git a/test/unit/qc_report_presenter_test.rb b/test/unit/qc_report_presenter_test.rb index 1860405699..eacac79d85 100644 --- a/test/unit/qc_report_presenter_test.rb +++ b/test/unit/qc_report_presenter_test.rb @@ -27,28 +27,28 @@ class QcReportPresenterTest < ActiveSupport::TestCase STATE_ARRAY = %w[passed failed].freeze setup do - @product = create :product, name: 'Demo Product' - @criteria = create :product_criteria, product: @product, version: 1 - @study = create :study, name: 'Example study' + @product = create(:product, name: 'Demo Product') + @criteria = create(:product_criteria, product: @product, version: 1) + @study = create(:study, name: 'Example study') Timecop.freeze(DateTime.parse('01/01/2015')) do @report = - create :qc_report, + create(:qc_report, study: @study, exclude_existing: false, created_at: DateTime.parse('01/01/2015 00:00:00'), - product_criteria: @criteria + product_criteria: @criteria) end @asset_ids = [] 2.times do |i| m = - create :qc_metric, + create(:qc_metric, qc_report: @report, qc_decision: STATE_ARRAY[i], metrics: { total_micrograms: 10, comment: 'X', sanger_sample_id: 'EG' - } + }) @asset_ids << m.asset_id end end diff --git a/test/unit/qc_report_test.rb b/test/unit/qc_report_test.rb index 9413a7ff2a..c8fbb1ab31 100644 --- a/test/unit/qc_report_test.rb +++ b/test/unit/qc_report_test.rb @@ -15,26 +15,26 @@ class QcReportTest < ActiveSupport::TestCase context 'A QcReport' do context 'including existing' do setup do - @study = create :study - @other_study = create :study - @stock_plate = create :plate, purpose: PlatePurpose.find_or_create_by(name: 'Stock plate') + @study = create(:study) + @other_study = create(:study) + @stock_plate = create(:plate, purpose: PlatePurpose.find_or_create_by(name: 'Stock plate')) [@study, @other_study].each do |study| 2.times do |i| - attribute = create :well_attribute, current_volume: 500, concentration: 200 + attribute = create(:well_attribute, current_volume: 500, concentration: 200) sample = create(:study_sample, study:).sample sample.update!(sanger_sample_id: 'TEST1') well = - create :well, + create(:well, samples: [sample], plate: @stock_plate, map: create(:map, location_id: i), - well_attribute: attribute + well_attribute: attribute) well.aliquots.each { |a| a.update!(study:) } end end - @qc_report = create :qc_report, study: @study + @qc_report = create(:qc_report, study: @study) @qc_metric_count = QcMetric.count Delayed::Worker.new.work_off end @@ -65,65 +65,65 @@ class QcReportTest < ActiveSupport::TestCase context 'excluding existing' do # rubocop:todo Metrics/BlockLength setup do - @study = create :study - @stock_plate = create :plate, purpose: PlatePurpose.find_or_create_by(name: 'Stock plate') + @study = create(:study) + @stock_plate = create(:plate, purpose: PlatePurpose.find_or_create_by(name: 'Stock plate')) - @current_criteria = create :product_criteria - @other_criteria = create :product_criteria + @current_criteria = create(:product_criteria) + @other_criteria = create(:product_criteria) @matching_report = - create :qc_report, + create(:qc_report, study: @study, exclude_existing: true, product_criteria: @current_criteria, - report_identifier: 'Override' - @other_report = create :qc_report, study: @study, exclude_existing: true, product_criteria: @other_criteria + report_identifier: 'Override') + @other_report = create(:qc_report, study: @study, exclude_existing: true, product_criteria: @other_criteria) - @attribute = create :well_attribute, current_volume: 500, concentration: 200 + @attribute = create(:well_attribute, current_volume: 500, concentration: 200) sample = create(:study_sample, study: @study).sample @unreported_sample = well = - create :well, + create(:well, samples: [sample], plate: @stock_plate, map: create(:map, location_id: 1), - well_attribute: @attribute + well_attribute: @attribute) well.aliquots.each { |a| a.update!(study: @study) } sample = create(:study_sample, study: @study).sample well = - create :well, + create(:well, samples: [sample], plate: @stock_plate, map: create(:map, location_id: 2), - well_attribute: @attribute + well_attribute: @attribute) well.aliquots.each { |a| a.update!(study: @study) } - create :qc_metric, asset: well, qc_report: @matching_report + create(:qc_metric, asset: well, qc_report: @matching_report) sample = create(:study_sample, study: @study).sample @other_reported_sample = well = - create :well, + create(:well, samples: [sample], plate: @stock_plate, map: create(:map, location_id: 3), - well_attribute: @attribute + well_attribute: @attribute) well.aliquots.each { |a| a.update!(study: @study) } - create :qc_metric, asset: well, qc_report: @other_report + create(:qc_metric, asset: well, qc_report: @other_report) sample = create(:study_sample, study: @study).sample well = - create :well, + create(:well, samples: [sample], plate: @stock_plate, map: create(:map, location_id: 4), - well_attribute: @attribute + well_attribute: @attribute) well.aliquots.each { |a| a.update!(study: @study) } - create :qc_metric, asset: well, qc_report: @matching_report - create :qc_metric, asset: well, qc_report: @other_report + create(:qc_metric, asset: well, qc_report: @matching_report) + create(:qc_metric, asset: well, qc_report: @other_report) - @qc_report = create :qc_report, study: @study, exclude_existing: true, product_criteria: @current_criteria + @qc_report = create(:qc_report, study: @study, exclude_existing: true, product_criteria: @current_criteria) @qc_metric_count = QcMetric.count @qc_report.generate! end @@ -141,7 +141,7 @@ class QcReportTest < ActiveSupport::TestCase context 'QcReport state machine' do setup do - @qc_report = create :qc_report + @qc_report = create(:qc_report) # Stub out report generation as it advances the state machine @qc_report.stubs(:generate_report) diff --git a/test/unit/sample_test.rb b/test/unit/sample_test.rb index 35c7fe7847..e12b0dcc3b 100644 --- a/test/unit/sample_test.rb +++ b/test/unit/sample_test.rb @@ -22,9 +22,9 @@ def assert_accession_service(type) context 'when used in older assets' do setup do - @sample = create :sample - @tube_a = create :empty_library_tube - @tube_b = create :empty_sample_tube + @sample = create(:sample) + @tube_a = create(:empty_library_tube) + @tube_b = create(:empty_sample_tube) create(:aliquot, sample: @sample, receptacle: @tube_b) create(:aliquot, sample: @sample, receptacle: @tube_a) @@ -36,7 +36,7 @@ def assert_accession_service(type) end context '#accession_number?' do - setup { @sample = create :sample } + setup { @sample = create(:sample) } context 'with nil accession number' do setup { @sample.sample_metadata.sample_ebi_accession_number = nil } should 'return false' do @@ -60,9 +60,9 @@ def assert_accession_service(type) context '#accession service' do context 'with one study' do setup do - @sample = create :sample - @study = create :open_study, accession_number: 'ENA123' - create :study_sample, study: @study, sample: @sample + @sample = create(:sample) + @study = create(:open_study, accession_number: 'ENA123') + create(:study_sample, study: @study, sample: @sample) end should 'delegate to the study' do assert_equal @study, @sample.primary_study @@ -71,9 +71,9 @@ def assert_accession_service(type) end context 'with one un-accessioned study' do setup do - @sample = create :sample - @study = create :open_study - create :study_sample, study: @study, sample: @sample + @sample = create(:sample) + @study = create(:open_study) + create(:study_sample, study: @study, sample: @sample) end should 'not delegate to the study' do assert_accession_service(:unsuitable) @@ -81,9 +81,9 @@ def assert_accession_service(type) end context 'with one un-accessioned, never study' do setup do - @sample = create :sample - @study = create :not_app_study - create :study_sample, study: @study, sample: @sample + @sample = create(:sample) + @study = create(:not_app_study) + create(:study_sample, study: @study, sample: @sample) end should 'not delegate to the study' do assert_accession_service(:none) @@ -94,11 +94,11 @@ def assert_accession_service(type) # and it reduces the risk of accidentally making human data public context 'with an ena and an ega study' do setup do - @sample = create :sample - @study = create :open_study, accession_number: 'ENA123' - @study_b = create :managed_study, accession_number: 'ENA123' - create :study_sample, study: @study, sample: @sample - create :study_sample, study: @study_b, sample: @sample + @sample = create(:sample) + @study = create(:open_study, accession_number: 'ENA123') + @study_b = create(:managed_study, accession_number: 'ENA123') + create(:study_sample, study: @study, sample: @sample) + create(:study_sample, study: @study_b, sample: @sample) end should 'delegate to the ega study' do assert_accession_service(:ega) @@ -107,11 +107,11 @@ def assert_accession_service(type) context 'with an ena and an ega study in the other order' do setup do - @sample = create :sample - @study = create :open_study, accession_number: 'ENA123' - @study_b = create :managed_study, accession_number: 'ENA123' - create :study_sample, study: @study_b, sample: @sample - create :study_sample, study: @study, sample: @sample + @sample = create(:sample) + @study = create(:open_study, accession_number: 'ENA123') + @study_b = create(:managed_study, accession_number: 'ENA123') + create(:study_sample, study: @study_b, sample: @sample) + create(:study_sample, study: @study, sample: @sample) end should 'still delegate to the ega study' do assert_accession_service(:ega) @@ -122,11 +122,11 @@ def assert_accession_service(type) # could be an issue. context 'with an accessioned ena but un-accessioned ena' do setup do - @sample = create :sample - @study = create :open_study, accession_number: 'ENA123' - @study_b = create :managed_study - create :study_sample, study: @study_b, sample: @sample - create :study_sample, study: @study, sample: @sample + @sample = create(:sample) + @study = create(:open_study, accession_number: 'ENA123') + @study_b = create(:managed_study) + create(:study_sample, study: @study_b, sample: @sample) + create(:study_sample, study: @study, sample: @sample) end should 'not delegate to either study' do assert_accession_service(:unsuitable) diff --git a/test/unit/sample_tube_test.rb b/test/unit/sample_tube_test.rb index 2e447c5c78..82d7830c9d 100644 --- a/test/unit/sample_tube_test.rb +++ b/test/unit/sample_tube_test.rb @@ -15,10 +15,10 @@ class SampleTubeTest < ActiveSupport::TestCase context 'can be rendered as a stock resource' do setup do Timecop.freeze(DateTime.parse('2012-03-11 10:22:42')) do - @sample_tube = create :empty_sample_tube, barcode: '12345' - @study = create :study - @sample = create :sample - @aliquot = create :aliquot, study: @study, sample: @sample, receptacle: @sample_tube + @sample_tube = create(:empty_sample_tube, barcode: '12345') + @study = create(:study) + @sample = create(:sample) + @aliquot = create(:aliquot, study: @study, sample: @sample, receptacle: @sample_tube) @messenger = @sample_tube.register_stock! end end diff --git a/test/unit/stock_library_tube_test.rb b/test/unit/stock_library_tube_test.rb index f5d9398859..c2fafd1393 100644 --- a/test/unit/stock_library_tube_test.rb +++ b/test/unit/stock_library_tube_test.rb @@ -4,7 +4,7 @@ class StockLibraryTubeTest < ActiveSupport::TestCase context 'A stock Library tube' do - setup { @stock_library = create :stock_library_tube } + setup { @stock_library = create(:stock_library_tube) } context '#has_stock_asset?' do should 'return false' do diff --git a/test/unit/stock_multiplexed_library_tube_test.rb b/test/unit/stock_multiplexed_library_tube_test.rb index fc1bf283db..cac41b8ad8 100644 --- a/test/unit/stock_multiplexed_library_tube_test.rb +++ b/test/unit/stock_multiplexed_library_tube_test.rb @@ -4,7 +4,7 @@ class StockMultiplexedLibraryTubeTest < ActiveSupport::TestCase context 'A stock multiplexed Library tube' do - setup { @stock_multiplexed_library = create :stock_multiplexed_library_tube } + setup { @stock_multiplexed_library = create(:stock_multiplexed_library_tube) } context '#has_stock_asset?' do should 'return false' do diff --git a/test/unit/submission_template_test.rb b/test/unit/submission_template_test.rb index 225e22ebaa..acc00995f8 100644 --- a/test/unit/submission_template_test.rb +++ b/test/unit/submission_template_test.rb @@ -7,7 +7,7 @@ class SubmissionTemplateTest < ActiveSupport::TestCase should validate_presence_of :product_catalogue setup do - @template = FactoryBot.build :submission_template + @template = FactoryBot.build(:submission_template) @product = create(:product) @template.product_catalogue.products << @product end @@ -31,9 +31,9 @@ class SubmissionTemplateTest < ActiveSupport::TestCase context 'without input_field_infos' do setup do - @library_type = create :library_type - @test_request_typ_b = create :library_creation_request_type, :with_library_types, library_type: @library_type - @test_request_type = create :sequencing_request_type + @library_type = create(:library_type) + @test_request_typ_b = create(:library_creation_request_type, :with_library_types, library_type: @library_type) + @test_request_type = create(:sequencing_request_type) @order.request_types = [@test_request_typ_b, @test_request_type] @order.request_type_ids_list = [[@test_request_typ_b.id], [@test_request_type.id]] end diff --git a/test/unit/tag_qc/lot_test.rb b/test/unit/tag_qc/lot_test.rb index 57a3a80124..3ef6b36eb8 100644 --- a/test/unit/tag_qc/lot_test.rb +++ b/test/unit/tag_qc/lot_test.rb @@ -14,7 +14,7 @@ class LotTest < ActiveSupport::TestCase should belong_to :template context 'when validating' do - setup { create :lot } + setup { create(:lot) } should validate_uniqueness_of(:lot_number).case_insensitive end @@ -22,14 +22,14 @@ class LotTest < ActiveSupport::TestCase context '#lot' do setup do PlateBarcode.stubs(:create_barcode).returns(build(:plate_barcode)) - @lot = create :lot + @lot = create(:lot) @mock_asset = Labware.new @mock_asset.stubs(:save!).returns(true) @mock_purpose = mock('Purpose') @mock_purpose.stubs('create!').returns(@mock_asset) @lot.stubs(:target_purpose).returns(@mock_purpose) - @user = create :user + @user = create(:user) end should 'validate the template type' do diff --git a/test/unit/tag_qc/plate_conversion_test.rb b/test/unit/tag_qc/plate_conversion_test.rb index 5724a37bcb..f83b53484c 100644 --- a/test/unit/tag_qc/plate_conversion_test.rb +++ b/test/unit/tag_qc/plate_conversion_test.rb @@ -10,8 +10,8 @@ class PlateConversionTest < ActiveSupport::TestCase context '#stamp' do should 'convert plates to a new purpose' do - @plate = create :plate - @user = create :user + @plate = create(:plate) + @user = create(:user) @purpose_b = PlatePurpose.new(name: 'test_purpose') PlateConversion.create!(target: @plate, user: @user, purpose: @purpose_b) @@ -20,9 +20,9 @@ class PlateConversionTest < ActiveSupport::TestCase end should 'set parents when supplied' do - @plate = create :plate - @parent = create :plate - @user = create :user + @plate = create(:plate) + @parent = create(:plate) + @user = create(:user) @purpose_b = PlatePurpose.new(name: 'test_purpose') PlateConversion.create!(target: @plate, user: @user, purpose: @purpose_b, parent: @parent) diff --git a/test/unit/tag_qc/qc_decision_test.rb b/test/unit/tag_qc/qc_decision_test.rb index 3d28c23dc9..10e3450280 100644 --- a/test/unit/tag_qc/qc_decision_test.rb +++ b/test/unit/tag_qc/qc_decision_test.rb @@ -13,12 +13,12 @@ class QcDecisionTest < ActiveSupport::TestCase context '#qc_decision' do setup do - @lot = create :lot - @user = create :user + @lot = create(:lot) + @user = create(:user) @user.roles.create!(name: 'qa_manager') - @user_b = create :user - @qcable_a = create :qcable, lot: @lot, state: 'pending' - @qcable_b = create :qcable, lot: @lot, state: 'pending' + @user_b = create(:user) + @qcable_a = create(:qcable, lot: @lot, state: 'pending') + @qcable_b = create(:qcable, lot: @lot, state: 'pending') end context 'with valid data' do diff --git a/test/unit/tag_qc/qcable_test.rb b/test/unit/tag_qc/qcable_test.rb index d105a27754..03c97f5b45 100644 --- a/test/unit/tag_qc/qcable_test.rb +++ b/test/unit/tag_qc/qcable_test.rb @@ -24,13 +24,13 @@ class QcableTest < ActiveSupport::TestCase context '#qcable' do setup do - @mock_purpose = build :tube_purpose, default_state: 'created' - @mock_lot = create :lot + @mock_purpose = build(:tube_purpose, default_state: 'created') + @mock_lot = create(:lot) @mock_lot.expects(:target_purpose).returns(@mock_purpose).twice end should 'create an asset of the given purpose' do - factory_attributes = attributes_for :qcable, lot: @mock_lot + factory_attributes = attributes_for(:qcable, lot: @mock_lot) @qcable = Qcable.create!(factory_attributes) assert_equal 'created', @qcable.state end @@ -38,16 +38,16 @@ class QcableTest < ActiveSupport::TestCase context '#qcable pre-pending' do setup do - @mock_purpose = build :tube_purpose, default_state: 'pending' + @mock_purpose = build(:tube_purpose, default_state: 'pending') @template = FactoryBot.build(:tag2_layout_template) - @lot_type = create :tag2_lot_type, target_purpose: @mock_purpose - @mock_lot = create :tag2_lot, lot_type: @lot_type + @lot_type = create(:tag2_lot_type, target_purpose: @mock_purpose) + @mock_lot = create(:tag2_lot, lot_type: @lot_type) end should 'create an asset of the given purpose' do # We can't use factory bot directly here, as it results in the initial state being # set BEFORE the lot is assigned. - factory_attributes = attributes_for :qcable, lot: @mock_lot + factory_attributes = attributes_for(:qcable, lot: @mock_lot) @qcable = Qcable.create!(factory_attributes) assert_equal @mock_purpose, @qcable.asset.purpose assert_equal 'pending', @qcable.state diff --git a/test/unit/tag_qc/stamp_test.rb b/test/unit/tag_qc/stamp_test.rb index 3074f432c5..abc75fdd21 100644 --- a/test/unit/tag_qc/stamp_test.rb +++ b/test/unit/tag_qc/stamp_test.rb @@ -18,29 +18,29 @@ class StampTest < ActiveSupport::TestCase context '#stamp' do should 'transition qcables to pending' do - @qcable = create :qcable_with_asset + @qcable = create(:qcable_with_asset) # Unfortunately we can't do this, as stamp looks for qcables directly. # @qcable.expects(:do_stamp!).returns(true) sqc = Stamp::StampQcable.new(bed: '1', order: 1, qcable: @qcable) - @stamp = create :stamp, stamp_qcables: [sqc] + @stamp = create(:stamp, stamp_qcables: [sqc]) assert_equal 'pending', @qcable.reload.state end should 'transfer samples' do - @qcable = create :qcable_with_asset + @qcable = create(:qcable_with_asset) # Unfortunately we can't do this, as stamp looks for qcables directly. # @qcable.expects(:do_stamp!).returns(true) sqc = Stamp::StampQcable.new(bed: '1', order: 1, qcable: @qcable) - @stamp = create :stamp, stamp_qcables: [sqc] + @stamp = create(:stamp, stamp_qcables: [sqc]) assert_equal 'pending', @qcable.reload.state assert_equal 1, @qcable.asset.wells.located_at('A2').first.aliquots.count end should 'clone the aliquots' do - @qcable = create :qcable_with_asset, state: 'created' + @qcable = create(:qcable_with_asset, state: 'created') @qcable_2 = @qcable.lot.qcables.create!( qcable_creator: @qcable.qcable_creator, @@ -50,7 +50,7 @@ class StampTest < ActiveSupport::TestCase sqc = Stamp::StampQcable.new(bed: '1', order: 1, qcable: @qcable) sqc_2 = Stamp::StampQcable.new(bed: '2', order: 2, qcable: @qcable_2) - @stamp = create :stamp, stamp_qcables: [sqc, sqc_2] + @stamp = create(:stamp, stamp_qcables: [sqc, sqc_2]) assert_equal 'pending', @qcable.reload.state assert_equal 1, @qcable.asset.wells.located_at('A2').first.aliquots.count assert_equal 'pending', @qcable_2.reload.state diff --git a/test/unit/tasks/plate_transfer_task_test.rb b/test/unit/tasks/plate_transfer_task_test.rb index b9554e2080..e5e11d7a88 100644 --- a/test/unit/tasks/plate_transfer_task_test.rb +++ b/test/unit/tasks/plate_transfer_task_test.rb @@ -18,17 +18,17 @@ class PlateTransferTaskTest < ActiveSupport::TestCase context 'PlateTransferHandler' do setup do @workflows_controller = DummyWorkflowController.new - @task = create :plate_transfer_task + @task = create(:plate_transfer_task) @params = 'UNUSED_PARAMS' - @batch = create :batch + @batch = create(:batch) @workflows_controller.batch = @batch - @source_plate = create :plate - @user = build :user + @source_plate = create(:plate) + @user = build(:user) @source_plate.wells = %w[A1 B1 C1].map do |loc| create(:well_with_sample_and_without_plate).tap do |w| w.map = Map.find_by(description: loc, asset_size: 96) - request = create :pac_bio_sample_prep_request, asset: w + request = create(:pac_bio_sample_prep_request, asset: w) @batch.requests << request end end @@ -104,10 +104,10 @@ class PlateTransferTaskTest < ActiveSupport::TestCase context 'when spanning multiple plates' do setup do - plate_b = create :plate + plate_b = create(:plate) plate_b.wells << create(:well_with_sample_and_without_plate).tap do |w| w.map = Map.find_by(description: 'A1', asset_size: 96) - request = create :well_request, asset: w, target_asset: create(:pac_bio_library_tube) + request = create(:well_request, asset: w, target_asset: create(:pac_bio_library_tube)) w.requests << request @batch.requests << request end diff --git a/test/unit/transfer_templates/between_tubes_by_submission_test.rb b/test/unit/transfer_templates/between_tubes_by_submission_test.rb index 6f4ba2de12..10ff698f68 100644 --- a/test/unit/transfer_templates/between_tubes_by_submission_test.rb +++ b/test/unit/transfer_templates/between_tubes_by_submission_test.rb @@ -5,17 +5,17 @@ class TransferBetweenTubesBySubmissionTest < ActiveSupport::TestCase context 'A transfer between tubes by submission' do setup do - @user = create :user + @user = create(:user) - @tube_a = create :new_stock_multiplexed_library_tube - @plate_transfer_a = create :transfer_from_plate_to_tube_with_transfers, destination: @tube_a + @tube_a = create(:new_stock_multiplexed_library_tube) + @plate_transfer_a = create(:transfer_from_plate_to_tube_with_transfers, destination: @tube_a) @plate_a = @plate_transfer_a.source - @submission = create :submission_without_order + @submission = create(:submission_without_order) - @final_tube = create :multiplexed_library_tube + @final_tube = create(:multiplexed_library_tube) @plate_a.wells.each do |well| - create :library_completion, asset: well, target_asset: @final_tube, submission: @submission + create(:library_completion, asset: well, target_asset: @final_tube, submission: @submission) Well::Link.create(type: 'stock', source_well: well, target_well: well) well.transfer_requests_as_source.each do |request| request.submission = @submission @@ -36,12 +36,12 @@ class TransferBetweenTubesBySubmissionTest < ActiveSupport::TestCase # This gives us a little more versatility context 'in multiple rounds' do setup do - @tube_b = create :new_stock_multiplexed_library_tube - @plate_transfer_b = create :transfer_from_plate_to_tube_with_transfers, destination: @tube_b + @tube_b = create(:new_stock_multiplexed_library_tube) + @plate_transfer_b = create(:transfer_from_plate_to_tube_with_transfers, destination: @tube_b) @plate_b = @plate_transfer_b.source @plate_b.wells.each do |well| - create :library_completion, asset: well, target_asset: @final_tube, submission: @submission + create(:library_completion, asset: well, target_asset: @final_tube, submission: @submission) Well::Link.create(type: 'stock', source_well: well, target_well: well) well.transfer_requests_as_source.each do |request| request.submission = @submission diff --git a/test/unit/tube_test.rb b/test/unit/tube_test.rb index 966ef27e2f..7a4e8cc5e6 100644 --- a/test/unit/tube_test.rb +++ b/test/unit/tube_test.rb @@ -4,7 +4,7 @@ class TubeTest < ActiveSupport::TestCase test '#barcode! should add barcode to a tube' do - tube = create :unbarcoded_tube + tube = create(:unbarcoded_tube) assert_not tube.barcode_number tube.barcode! assert tube.barcode_number diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 1328f2fc37..124727a364 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -6,7 +6,7 @@ class UserTest < ActiveSupport::TestCase context 'A User' do context 'authenticate' do setup do - @user = create :admin, login: 'xyz987', api_key: 'my_key', crypted_password: '1' + @user = create(:admin, login: 'xyz987', api_key: 'my_key', crypted_password: '1') @ldap = mock('LDAP') @ldap.stubs(:bind).returns(true) Net::LDAP.stubs(:new).returns(@ldap) @@ -22,7 +22,7 @@ class UserTest < ActiveSupport::TestCase end context 'is an administrator' do - setup { @user = create :admin } + setup { @user = create(:admin) } should 'be able to access admin functions' do assert @user.administrator? @@ -34,7 +34,7 @@ class UserTest < ActiveSupport::TestCase end context 'is a manager' do - setup { @user = create :manager } + setup { @user = create(:manager) } should 'not be able to access admin functions' do assert_not @user.administrator? @@ -50,7 +50,7 @@ class UserTest < ActiveSupport::TestCase end context 'is an owner' do - setup { @user = create :owner } + setup { @user = create(:owner) } should 'not be able to access admin functions' do assert_not @user.administrator? @@ -63,9 +63,9 @@ class UserTest < ActiveSupport::TestCase context 'admins and emails' do setup do - admin = create :role, name: 'administrator' - user1 = create :user, login: 'bla' - user2 = create :user, login: 'wow' + admin = create(:role, name: 'administrator') + user1 = create(:user, login: 'bla') + user2 = create(:user, login: 'wow') user2.roles << admin user1.roles << admin end @@ -81,7 +81,7 @@ class UserTest < ActiveSupport::TestCase context '#name' do context 'when profile is complete' do setup do - @user = create :user, first_name: 'Alan', last_name: 'Brown' + @user = create(:user, first_name: 'Alan', last_name: 'Brown') assert @user.valid? end should 'return full name' do @@ -90,7 +90,7 @@ class UserTest < ActiveSupport::TestCase end context 'when profile is incomplete' do setup do - @user = create :user, login: 'abc123', first_name: 'Alan', last_name: nil + @user = create(:user, login: 'abc123', first_name: 'Alan', last_name: nil) assert @user.valid? end should 'return login' do @@ -101,7 +101,7 @@ class UserTest < ActiveSupport::TestCase context '#new_api_key' do setup do - @user = create :user, first_name: 'Alan', last_name: 'Brown' + @user = create(:user, first_name: 'Alan', last_name: 'Brown') @old_api_key = @user.api_key @user.new_api_key @user.save @@ -113,7 +113,7 @@ class UserTest < ActiveSupport::TestCase end context 'without a swipecard_code' do - setup { @user = create :user } + setup { @user = create(:user) } should 'not have a swipecard code' do assert_equal false, @user.swipecard_code? @@ -126,7 +126,7 @@ class UserTest < ActiveSupport::TestCase end context 'is a data_access_coordinator' do - setup { @user = create :data_access_coordinator } + setup { @user = create(:data_access_coordinator) } should 'be able to access data_access_coordinator functions' do assert @user.data_access_coordinator? From 0d8dc0a3ed21d668fe4fab240b6291ce038f199f Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 26 Sep 2024 12:12:23 +0100 Subject: [PATCH 137/158] style: prettier yarn prettier --write . --- .../driver_files_controller_spec.rb | 14 +- .../npg_actions/assets_controller_spec.rb | 42 +++--- spec/controllers/samples_controller_spec.rb | 10 +- .../submissions_controller_spec.rb | 30 ++-- spec/factories/batch_factories.rb | 12 +- ...ncorrect_submission_id_on_transfer_spec.rb | 30 ++-- .../looking_up_labware_history_spec.rb | 14 +- .../perform_a_tag_substitution_spec.rb | 84 ++++++----- ..._for_fluidigm_pipeline_micro_litre_spec.rb | 16 +- .../following_a_sequencing_pipeline_spec.rb | 54 ++++--- ...line_with_compound_sample_creation_spec.rb | 50 ++++--- spec/models/api/aliquot_io_spec.rb | 22 +-- spec/models/api/library_tube_io_spec.rb | 3 +- spec/models/api/messages/flowcell_io_spec.rb | 34 +++-- .../messages/well_stock_resource_io_spec.rb | 10 +- spec/models/api/order_io_spec.rb | 32 ++-- .../api/pac_bio_library_tube_io_spec.rb | 24 +-- spec/models/api/project_io_spec.rb | 20 +-- spec/models/api/sample_io_spec.rb | 120 +++++++-------- spec/models/api/study_io_spec.rb | 28 ++-- spec/models/api/well_io_spec.rb | 10 +- spec/models/broadcast_event/lab_event_spec.rb | 16 +- spec/models/broadcast_event/qc_assay_spec.rb | 28 ++-- .../initial_stock_tube_purpose_spec.rb | 24 +-- spec/models/linear_submission_spec.rb | 57 ++++--- spec/models/location_report_spec.rb | 44 +++--- spec/models/phi_x/spiked_buffer_spec.rb | 34 +++-- spec/models/qc_report_spec.rb | 84 ++++++----- .../sample_compound_aliquot_transfer_spec.rb | 86 ++++++----- spec/models/request/traction/grid_ion_spec.rb | 16 +- spec/models/request_information_type_spec.rb | 14 +- spec/models/robot/pick_data_spec.rb | 24 +-- .../verification/source_dest_beds_spec.rb | 12 +- .../source_dest_control_beds_spec.rb | 12 +- spec/models/sequencing_request_spec.rb | 16 +- .../state_changer/initial_stock_tube_spec.rb | 12 +- .../state_changer/standard_plate_spec.rb | 40 +++-- spec/models/tag_substitutions_spec.rb | 70 +++++---- spec/models/transfer_request_spec.rb | 140 ++++++++++-------- spec/models/well_spec.rb | 30 ++-- spec/models/work_completion_spec.rb | 16 +- spec/requests/plate_picks_request_spec.rb | 8 +- spec/shared_contexts/limber_shared_context.rb | 12 +- spec/uat_actions/plate_information_spec.rb | 24 +-- test/controllers/requests_controller_test.rb | 66 +++++---- test/controllers/workflows_controller_test.rb | 56 ++++--- test/lib/label_printer/plate_creator_test.rb | 16 +- .../performance/work_completion_tubes_test.rb | 60 ++++---- test/performance/work_completions_test.rb | 24 +-- test/unit/flexible_submission_test.rb | 28 ++-- test/unit/import_fluidigm_data_test.rb | 32 ++-- .../product_catalogue/library_driven_test.rb | 138 +++++++++-------- test/unit/qc_report_file_test.rb | 36 +++-- test/unit/qc_report_presenter_test.rb | 30 ++-- test/unit/qc_report_test.rb | 72 +++++---- 55 files changed, 1163 insertions(+), 873 deletions(-) diff --git a/spec/controllers/driver_files_controller_spec.rb b/spec/controllers/driver_files_controller_spec.rb index 8cb489f93f..9432118f91 100644 --- a/spec/controllers/driver_files_controller_spec.rb +++ b/spec/controllers/driver_files_controller_spec.rb @@ -16,12 +16,14 @@ let(:transfers) { { source_plate.wells[0] => destination_plate.wells.first } } let(:requests) do - create_list(:cherrypick_request, - 1, - asset: source_plate.wells.first, - target_asset: destination_plate.wells.first, - request_type: pipeline.request_types.first, - state: 'passed') + create_list( + :cherrypick_request, + 1, + asset: source_plate.wells.first, + target_asset: destination_plate.wells.first, + request_type: pipeline.request_types.first, + state: 'passed' + ) end let(:batch) { create(:batch, requests:, pipeline:, user: current_user) } diff --git a/spec/controllers/npg_actions/assets_controller_spec.rb b/spec/controllers/npg_actions/assets_controller_spec.rb index 8b0424b77a..ecfb62f757 100644 --- a/spec/controllers/npg_actions/assets_controller_spec.rb +++ b/spec/controllers/npg_actions/assets_controller_spec.rb @@ -10,28 +10,34 @@ let(:pipeline) { create(:sequencing_pipeline) } let(:batch) { create(:sequencing_batch, state: 'started', qc_state: 'qc_manual') } let(:valid_seq_request) do - create(:sequencing_request_with_assets, - batch:, - request_type: batch.pipeline.request_types.first, - study:, - target_asset: lane, - state: 'passed') + create( + :sequencing_request_with_assets, + batch:, + request_type: batch.pipeline.request_types.first, + study:, + target_asset: lane, + state: 'passed' + ) end let(:cancelled_seq_request) do - create(:sequencing_request_with_assets, - batch:, - request_type: batch.pipeline.request_types.first, - study:, - target_asset: lane, - state: 'cancelled') + create( + :sequencing_request_with_assets, + batch:, + request_type: batch.pipeline.request_types.first, + study:, + target_asset: lane, + state: 'cancelled' + ) end let(:failed_seq_request) do - create(:sequencing_request_with_assets, - batch:, - request_type: batch.pipeline.request_types.first, - study:, - target_asset: lane, - state: 'failed') + create( + :sequencing_request_with_assets, + batch:, + request_type: batch.pipeline.request_types.first, + study:, + target_asset: lane, + state: 'failed' + ) end before { post '/login', params: { login: user.login, password: 'password' } } diff --git a/spec/controllers/samples_controller_spec.rb b/spec/controllers/samples_controller_spec.rb index b8d745f0d0..286308f544 100644 --- a/spec/controllers/samples_controller_spec.rb +++ b/spec/controllers/samples_controller_spec.rb @@ -64,10 +64,12 @@ context 'when consent withdrawn starts off true' do let(:sample) do - create(:sample, - consent_withdrawn: true, - date_of_consent_withdrawn: Time.zone.today, - user_id_of_consent_withdrawn: current_user.id) + create( + :sample, + consent_withdrawn: true, + date_of_consent_withdrawn: Time.zone.today, + user_id_of_consent_withdrawn: current_user.id + ) end context 'when changing withdraw consent' do diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index df4ce5a6fb..4d15730d21 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -27,8 +27,10 @@ @plate = build(:plate, barcode: 'SQPD-123456') %w[A1 A2 A3 B1 B2 B3 C1 C2 C3].each do |location| well = - build(:well_with_sample_and_without_plate, - map: Map.find_by(description: location, asset_shape: @asset_shape, asset_size: @asset_size)) + build( + :well_with_sample_and_without_plate, + map: Map.find_by(description: location, asset_shape: @asset_shape, asset_size: @asset_size) + ) @plate.wells << well end build( @@ -156,9 +158,11 @@ before do @new_plate = create(:plate, plate_purpose: @plate.purpose) @well = - create(:well, - map: Map.find_by(description: 'A1', asset_shape: @asset_shape, asset_size: @asset_size), - plate: @new_plate) + create( + :well, + map: Map.find_by(description: 'A1', asset_shape: @asset_shape, asset_size: @asset_size), + plate: @new_plate + ) create(:aliquot, sample: Sample.find_by(name: @samples.first), receptacle: @well) post( :create, @@ -201,8 +205,10 @@ @wd_plate = create(:working_dilution_plate) %w[A1 A2 A3 B1 B2 B3 C1 C2 C3].each do |location| well = - create(:empty_well, - map: Map.find_by(description: location, asset_shape: @asset_shape, asset_size: @asset_size)) + create( + :empty_well, + map: Map.find_by(description: location, asset_shape: @asset_shape, asset_size: @asset_size) + ) well.aliquots.create(sample: @plate.wells.located_at(location).first.aliquots.first.sample) @wd_plate.wells << well end @@ -297,10 +303,12 @@ @asset_b = create(:sample_tube, sample: @sample) @secondary_submission = create(:submission) @secondary_order = - create(:order, - assets: [@asset_b.receptacle], - template_name: @shared_template, - submission: @secondary_submission) + create( + :order, + assets: [@asset_b.receptacle], + template_name: @shared_template, + submission: @secondary_submission + ) @submission = create(:submission) @order = create(:order, assets: [@asset_a.receptacle], template_name: @shared_template, submission: @submission) end diff --git a/spec/factories/batch_factories.rb b/spec/factories/batch_factories.rb index 250f5e46b5..887e522a42 100644 --- a/spec/factories/batch_factories.rb +++ b/spec/factories/batch_factories.rb @@ -57,11 +57,13 @@ after(:build) do |batch, evaluator| evaluator.assets.each_with_index.each do |asset, index| - create(:pac_bio_sequencing_request, - asset:, - target_asset: evaluator.target_plate.wells[index], - request_type: batch.pipeline.request_types.first, - batch:) + create( + :pac_bio_sequencing_request, + asset:, + target_asset: evaluator.target_plate.wells[index], + request_type: batch.pipeline.request_types.first, + batch: + ) end end end diff --git a/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb b/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb index 7f7ceb5ca7..e2ba91bd24 100644 --- a/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb +++ b/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb @@ -113,10 +113,12 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # it 'will create the transfer requests using the submissions ids from the Repooling requests' do # Now we create the transfer requests that represent the pool from before - create(:transfer_between_plates, - transfers: pool_transfer1, - source: pcr_xp_plate1, - destination: prepool_plate) + create( + :transfer_between_plates, + transfers: pool_transfer1, + source: pcr_xp_plate1, + destination: prepool_plate + ) # The new transfer requests should have the submission id from the pooling requests (4,5,6), not 1 s_ids = prepool_plate.wells.map(&:transfer_requests_as_target).flatten.map(&:submission_id) @@ -148,10 +150,12 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # end it 'creates the transfer with the right submission id' do - create(:transfer_between_plates, - transfers: pool_transfer2, - source: pcr_xp_plate1, - destination: prepool_plate) + create( + :transfer_between_plates, + transfers: pool_transfer2, + source: pcr_xp_plate1, + destination: prepool_plate + ) s_ids = prepool_plate.wells.map(&:transfer_requests_as_target).flatten.map(&:submission_id) expect(s_ids.uniq).to eq([submission_f, submission_g]) @@ -194,10 +198,12 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # # There are 2 pools with equal configuration, so it does not know which pooling requests we are # referring to when creating the transfer requests. expect do - create(:transfer_between_plates, - transfers: pool_transfer3, - source: pcr_xp_plate1, - destination: prepool_plate) + create( + :transfer_between_plates, + transfers: pool_transfer3, + source: pcr_xp_plate1, + destination: prepool_plate + ) end.to raise_error(ActiveRecord::RecordInvalid) end end diff --git a/spec/features/labware/looking_up_labware_history_spec.rb b/spec/features/labware/looking_up_labware_history_spec.rb index 8a633e4393..3f5932904c 100644 --- a/spec/features/labware/looking_up_labware_history_spec.rb +++ b/spec/features/labware/looking_up_labware_history_spec.rb @@ -7,12 +7,14 @@ let(:tube) { create(:tube) } let!(:asset_audit) do - create(:asset_audit, - asset: tube, - created_at: Time.zone.parse('June 16, 2020 15:36'), - metadata: { - 'metadata key' => 'metadata value' - }) + create( + :asset_audit, + asset: tube, + created_at: Time.zone.parse('June 16, 2020 15:36'), + metadata: { + 'metadata key' => 'metadata value' + } + ) end it 'displays asset audits', :js do diff --git a/spec/features/perform_a_tag_substitution_spec.rb b/spec/features/perform_a_tag_substitution_spec.rb index ad2b16b32f..25489026fb 100644 --- a/spec/features/perform_a_tag_substitution_spec.rb +++ b/spec/features/perform_a_tag_substitution_spec.rb @@ -21,42 +21,54 @@ let(:user) { create(:user) } before do - create(:aliquot, - sample: sample_a, - tag: sample_a_orig_tag, - tag2: sample_a_orig_tag2, - library: library_tube_a, - receptacle: library_tube_a) - create(:aliquot, - sample: sample_b, - tag: sample_b_orig_tag, - tag2: sample_b_orig_tag2, - library: library_tube_b, - receptacle: library_tube_b) - create(:aliquot, - sample: sample_a, - tag: sample_a_orig_tag, - tag2: sample_a_orig_tag2, - library: library_tube_a, - receptacle: mx_library_tube) - create(:aliquot, - sample: sample_b, - tag: sample_b_orig_tag, - tag2: sample_b_orig_tag2, - library: library_tube_b, - receptacle: mx_library_tube) - create(:aliquot, - sample: sample_a, - tag: sample_a_orig_tag, - tag2: sample_a_orig_tag2, - library: library_tube_a, - receptacle: lane) - create(:aliquot, - sample: sample_b, - tag: sample_b_orig_tag, - tag2: sample_b_orig_tag2, - library: library_tube_b, - receptacle: lane) + create( + :aliquot, + sample: sample_a, + tag: sample_a_orig_tag, + tag2: sample_a_orig_tag2, + library: library_tube_a, + receptacle: library_tube_a + ) + create( + :aliquot, + sample: sample_b, + tag: sample_b_orig_tag, + tag2: sample_b_orig_tag2, + library: library_tube_b, + receptacle: library_tube_b + ) + create( + :aliquot, + sample: sample_a, + tag: sample_a_orig_tag, + tag2: sample_a_orig_tag2, + library: library_tube_a, + receptacle: mx_library_tube + ) + create( + :aliquot, + sample: sample_b, + tag: sample_b_orig_tag, + tag2: sample_b_orig_tag2, + library: library_tube_b, + receptacle: mx_library_tube + ) + create( + :aliquot, + sample: sample_a, + tag: sample_a_orig_tag, + tag2: sample_a_orig_tag2, + library: library_tube_a, + receptacle: lane + ) + create( + :aliquot, + sample: sample_b, + tag: sample_b_orig_tag, + tag2: sample_b_orig_tag2, + library: library_tube_b, + receptacle: lane + ) end it 'Performing a tag swap' do diff --git a/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb b/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb index a4d3192af4..2e1ba039f5 100644 --- a/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb +++ b/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb @@ -26,13 +26,15 @@ plate.wells.each_with_index { |well, index| well.well_attribute.update!(measured_volume: 30 + (index % 30)) } end assets.each do |asset| - create(:cherrypick_for_fluidigm_request, - asset:, - request_type: pipeline.request_types.first, - submission:, - study:, - project:, - target_purpose:) + create( + :cherrypick_for_fluidigm_request, + asset:, + request_type: pipeline.request_types.first, + submission:, + study:, + project:, + target_purpose: + ) end allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode, barcode: 'SQPD-2')) diff --git a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb index 1b74765dd2..23ad3a3683 100644 --- a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb +++ b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb @@ -10,12 +10,14 @@ let(:spiked_buffer) { create(:spiked_buffer, :tube_barcode) } let(:requests) do asset = create(:multiplexed_library_tube, :scanned_into_lab, sample_count: 2) - create_list(:sequencing_request_with_assets, - 2, - request_type: pipeline.request_types.first, - asset:, - target_asset: nil, - submission: create(:submission)) + create_list( + :sequencing_request_with_assets, + 2, + request_type: pipeline.request_types.first, + asset:, + target_asset: nil, + submission: create(:submission) + ) end before { requests } @@ -119,24 +121,28 @@ before do batch.requests.each_with_index do |request, i| - create(:lab_event, - eventful: request, - batch:, - user:, - description: 'Specify Dilution Volume', - descriptors: { - 'Concentration' => (1.2 + i).to_s - }) - create(:lab_event, - eventful: request, - batch:, - user:, - description: 'Set descriptors', - descriptors: { - 'Workflow (Standard or Xp)' => 'XP', - 'Lane loading concentration (pM)' => '23', - '+4 field of weirdness' => "Something else #{i}" - }) + create( + :lab_event, + eventful: request, + batch:, + user:, + description: 'Specify Dilution Volume', + descriptors: { + 'Concentration' => (1.2 + i).to_s + } + ) + create( + :lab_event, + eventful: request, + batch:, + user:, + description: 'Set descriptors', + descriptors: { + 'Workflow (Standard or Xp)' => 'XP', + 'Lane loading concentration (pM)' => '23', + '+4 field of weirdness' => "Something else #{i}" + } + ) lane = create(:lane) request.update(target_asset: lane) lane.labware.parents << spiked_buffer diff --git a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb index 55e2026cb7..98ea80cbd1 100644 --- a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb +++ b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb @@ -13,36 +13,42 @@ let(:tag2) { create(:tag, oligo: 'C') } let(:aliquot1) do - create(:aliquot, - tag_id: tag.id, - tag2_id: tag2.id, - tag_depth: 1, - study: study1, - project: project1, - library_type: 'Standard', - library_id: 54) + create( + :aliquot, + tag_id: tag.id, + tag2_id: tag2.id, + tag_depth: 1, + study: study1, + project: project1, + library_type: 'Standard', + library_id: 54 + ) end let(:aliquot2) do - create(:aliquot, - tag_id: tag.id, - tag2_id: tag2.id, - tag_depth: 2, - study: study1, - project: project1, - library_type: 'Standard', - library_id: 54) + create( + :aliquot, + tag_id: tag.id, + tag2_id: tag2.id, + tag_depth: 2, + study: study1, + project: project1, + library_type: 'Standard', + library_id: 54 + ) end let(:requests) do asset = create(:multiplexed_library_tube, :scanned_into_lab, sample_count: 2) asset.aliquots = [aliquot1, aliquot2] asset.reload - create_list(:sequencing_request_with_assets, - 2, - request_type: pipeline.request_types.first, - asset:, - target_asset: nil, - submission: create(:submission)) + create_list( + :sequencing_request_with_assets, + 2, + request_type: pipeline.request_types.first, + asset:, + target_asset: nil, + submission: create(:submission) + ) end before { requests } diff --git a/spec/models/api/aliquot_io_spec.rb b/spec/models/api/aliquot_io_spec.rb index dcfa580544..25d5c65947 100644 --- a/spec/models/api/aliquot_io_spec.rb +++ b/spec/models/api/aliquot_io_spec.rb @@ -4,16 +4,18 @@ RSpec.describe Api::AliquotIO do subject do - create(:aliquot, - receptacle: well, - sample:, - study:, - project:, - library: well, - tag:, - insert_size_from: 100, - insert_size_to: 200, - bait_library:) + create( + :aliquot, + receptacle: well, + sample:, + study:, + project:, + library: well, + tag:, + insert_size_from: 100, + insert_size_to: 200, + bait_library: + ) end let(:well) { create(:empty_well) } diff --git a/spec/models/api/library_tube_io_spec.rb b/spec/models/api/library_tube_io_spec.rb index 2efe2fd649..bd32f72e56 100644 --- a/spec/models/api/library_tube_io_spec.rb +++ b/spec/models/api/library_tube_io_spec.rb @@ -4,7 +4,8 @@ RSpec.describe Api::LibraryTubeIO do subject do - create(:empty_library_tube, public_name: 'ABC', closed: false, aliquots:, volume: 12.0, concentration: 8.0) end + create(:empty_library_tube, public_name: 'ABC', closed: false, aliquots:, volume: 12.0, concentration: 8.0) + end let(:sample) { create(:sample) } let(:tag) { create(:tag) } diff --git a/spec/models/api/messages/flowcell_io_spec.rb b/spec/models/api/messages/flowcell_io_spec.rb index 1c6bba3bb7..574e240a47 100644 --- a/spec/models/api/messages/flowcell_io_spec.rb +++ b/spec/models/api/messages/flowcell_io_spec.rb @@ -11,12 +11,14 @@ let(:sequencing_batch) { create(:sequencing_batch, pipeline: sequencing_pipeline) } let!(:request_1) do - create(:complete_sequencing_request, - asset: mx_tube1, - batch: sequencing_batch, - target_asset: lane1, - request_type:, - event_descriptors: request_data) + create( + :complete_sequencing_request, + asset: mx_tube1, + batch: sequencing_batch, + target_asset: lane1, + request_type:, + event_descriptors: request_data + ) end let(:mx_tube1) { create(:multiplexed_library_tube, sample_count: 1) } @@ -50,15 +52,17 @@ context 'with updated events' do before do - create(:lab_event, - eventful: request_1, - batch: request_1.batch, - descriptors: { - 'Chip Barcode' => 'new_fcb', - 'PhiX %' => '1', - 'Workflow (Standard or Xp)' => 'xp', - 'Lane loading concentration (pM)' => '30' - }) + create( + :lab_event, + eventful: request_1, + batch: request_1.batch, + descriptors: { + 'Chip Barcode' => 'new_fcb', + 'PhiX %' => '1', + 'Workflow (Standard or Xp)' => 'xp', + 'Lane loading concentration (pM)' => '30' + } + ) end let(:request_data) do diff --git a/spec/models/api/messages/well_stock_resource_io_spec.rb b/spec/models/api/messages/well_stock_resource_io_spec.rb index a423d5890c..d11ec77611 100644 --- a/spec/models/api/messages/well_stock_resource_io_spec.rb +++ b/spec/models/api/messages/well_stock_resource_io_spec.rb @@ -13,10 +13,12 @@ let(:sample) { create(:sample) } let(:plate_barcode) { build(:plate_barcode) } let(:well) do - create(:well, - map: Map.find_by!(description: 'A1', asset_shape: AssetShape.default, asset_size: 96), - plate: create(:plate, barcode: plate_barcode.barcode), - well_attribute: create(:complete_well_attribute)) + create( + :well, + map: Map.find_by!(description: 'A1', asset_shape: AssetShape.default, asset_size: 96), + plate: create(:plate, barcode: plate_barcode.barcode), + well_attribute: create(:complete_well_attribute) + ) end let(:study) { create(:study) } let(:aliquot) { create(:aliquot, study:, sample:, receptacle: well) } diff --git a/spec/models/api/order_io_spec.rb b/spec/models/api/order_io_spec.rb index dbf0d6d896..8b9089c4a9 100644 --- a/spec/models/api/order_io_spec.rb +++ b/spec/models/api/order_io_spec.rb @@ -4,21 +4,23 @@ RSpec.describe Api::OrderIO do subject do - create(:order, - user:, - template_name: 'Cool template', - study:, - project:, - comments: 'Good', - request_options: { - read_length: '200', - library_type: 'Standard', - fragment_size_required_from: '10', - fragment_size_required_to: '20', - bait_library_name: 'EG', - sequencing_type: 'MagBead', - insert_size: 12 - }) + create( + :order, + user:, + template_name: 'Cool template', + study:, + project:, + comments: 'Good', + request_options: { + read_length: '200', + library_type: 'Standard', + fragment_size_required_from: '10', + fragment_size_required_to: '20', + bait_library_name: 'EG', + sequencing_type: 'MagBead', + insert_size: 12 + } + ) end let(:user) { create(:user) } diff --git a/spec/models/api/pac_bio_library_tube_io_spec.rb b/spec/models/api/pac_bio_library_tube_io_spec.rb index 9b9c719c3e..6fa6dd36fb 100644 --- a/spec/models/api/pac_bio_library_tube_io_spec.rb +++ b/spec/models/api/pac_bio_library_tube_io_spec.rb @@ -4,17 +4,19 @@ RSpec.describe Api::PacBioLibraryTubeIO do subject do - create(:pac_bio_library_tube, - :scanned_into_lab, - concentration: 8.0, - volume: 12.0, - pac_bio_library_tube_metadata_attributes: { - prep_kit_barcode: 999, - binding_kit_barcode: 233, - smrt_cells_available: 5, - movie_length: 100, - protocol: 'xyzzy' - }) + create( + :pac_bio_library_tube, + :scanned_into_lab, + concentration: 8.0, + volume: 12.0, + pac_bio_library_tube_metadata_attributes: { + prep_kit_barcode: 999, + binding_kit_barcode: 233, + smrt_cells_available: 5, + movie_length: 100, + protocol: 'xyzzy' + } + ) end let(:expected_json) do diff --git a/spec/models/api/project_io_spec.rb b/spec/models/api/project_io_spec.rb index bbc333a910..2c5ce6ec9a 100644 --- a/spec/models/api/project_io_spec.rb +++ b/spec/models/api/project_io_spec.rb @@ -31,15 +31,17 @@ context 'with roles and collaborators' do subject do - create(:project, - approved: true, - project_metadata_attributes: { - collaborators: 'Test', - external_funding_source: 'Tooth fairy', - sequencing_budget_cost_centre: '123', - funding_comments: 'It is funded', - project_manager: - }) + create( + :project, + approved: true, + project_metadata_attributes: { + collaborators: 'Test', + external_funding_source: 'Tooth fairy', + sequencing_budget_cost_centre: '123', + funding_comments: 'It is funded', + project_manager: + } + ) end let(:project_manager) { create(:project_manager) } diff --git a/spec/models/api/sample_io_spec.rb b/spec/models/api/sample_io_spec.rb index e84589ae8f..adaee0b73e 100644 --- a/spec/models/api/sample_io_spec.rb +++ b/spec/models/api/sample_io_spec.rb @@ -4,65 +4,67 @@ RSpec.describe Api::SampleIO do subject do - create(:sample, - name: 'sample_testing_messages', - component_samples: [comp_sample1, comp_sample2], - updated_by_manifest: true, - control: true, - control_type: 'positive', - sample_metadata_attributes: { - supplier_name: 'A name', - phenotype: 'positive', - gc_content: 'Neutral', - dna_source: 'Genomic', - volume: 'N/A', - sibling: '209_210', - is_resubmitted: true, - date_of_sample_collection: '02-Oct', - date_of_sample_extraction: '02-Oct', - sample_extraction_method: '5', - sample_purified: 'N', - purification_method: 'Other', - concentration: '100', - concentration_determined_by: 'Nanodrop', - sample_type: 'MDA', - sample_storage_conditions: '+4C', - genotype: 'WT', - age: '10 weeks', - cell_type: 'iPSC-derived microglia', - disease_state: 'Healthy', - compound: 'lomitapide', - dose: '10 uM', - immunoprecipitate: 'antiKdm1a, ab17721, 4ug/IP', - growth_condition: 'Oxford N2 media without geltrex', - organism_part: 'Primary T cells', - time_point: '2020-03-18', - disease: 'Tumour Growing', - subject: '19', - treatment: '10uM lomitapide in 0.1% ethanol', - date_of_consent_withdrawn: DateTime.new(2021, 3, 19, 13, 36, 51), - user_id_of_consent_withdrawn: user.id, - reference_genome_id: reference_genome.id, - organism: 'rat', - sample_ebi_accession_number: 18_374_739_430, - sample_common_name: 'mouse', - sample_description: 'desc', - sample_taxon_id: 2, - father: 'fred', - mother: 'frieda', - replicate: 'yes', - ethnicity: 'stuff', - gender: 'female', - cohort: 'this one', - country_of_origin: 'uk', - geographical_region: 'cambridge', - sample_public_name: 'public_name', - sample_sra_hold: 'Hold', - sample_strain_att: 'stuff about strain', - consent_withdrawn: false, - donor_id: 2, - developmental_stage: 'thing' - }) + create( + :sample, + name: 'sample_testing_messages', + component_samples: [comp_sample1, comp_sample2], + updated_by_manifest: true, + control: true, + control_type: 'positive', + sample_metadata_attributes: { + supplier_name: 'A name', + phenotype: 'positive', + gc_content: 'Neutral', + dna_source: 'Genomic', + volume: 'N/A', + sibling: '209_210', + is_resubmitted: true, + date_of_sample_collection: '02-Oct', + date_of_sample_extraction: '02-Oct', + sample_extraction_method: '5', + sample_purified: 'N', + purification_method: 'Other', + concentration: '100', + concentration_determined_by: 'Nanodrop', + sample_type: 'MDA', + sample_storage_conditions: '+4C', + genotype: 'WT', + age: '10 weeks', + cell_type: 'iPSC-derived microglia', + disease_state: 'Healthy', + compound: 'lomitapide', + dose: '10 uM', + immunoprecipitate: 'antiKdm1a, ab17721, 4ug/IP', + growth_condition: 'Oxford N2 media without geltrex', + organism_part: 'Primary T cells', + time_point: '2020-03-18', + disease: 'Tumour Growing', + subject: '19', + treatment: '10uM lomitapide in 0.1% ethanol', + date_of_consent_withdrawn: DateTime.new(2021, 3, 19, 13, 36, 51), + user_id_of_consent_withdrawn: user.id, + reference_genome_id: reference_genome.id, + organism: 'rat', + sample_ebi_accession_number: 18_374_739_430, + sample_common_name: 'mouse', + sample_description: 'desc', + sample_taxon_id: 2, + father: 'fred', + mother: 'frieda', + replicate: 'yes', + ethnicity: 'stuff', + gender: 'female', + cohort: 'this one', + country_of_origin: 'uk', + geographical_region: 'cambridge', + sample_public_name: 'public_name', + sample_sra_hold: 'Hold', + sample_strain_att: 'stuff about strain', + consent_withdrawn: false, + donor_id: 2, + developmental_stage: 'thing' + } + ) end let(:user) { create(:user) } diff --git a/spec/models/api/study_io_spec.rb b/spec/models/api/study_io_spec.rb index 8bd5cd05b8..aafec9cbfd 100644 --- a/spec/models/api/study_io_spec.rb +++ b/spec/models/api/study_io_spec.rb @@ -4,19 +4,21 @@ RSpec.describe Api::StudyIO do subject do - create(:study, - ethically_approved: true, - study_metadata_attributes: { - faculty_sponsor: create(:faculty_sponsor, name: 'John Smith'), - data_release_strategy: 'open', - data_release_timing: 'standard', - reference_genome:, - array_express_accession_number: 'AE111', - ega_policy_accession_number: 'EGA222', - ega_dac_accession_number: 'DAC333', - program: create(:program, name: 'General'), - contaminated_human_data_access_group: 'contaminated human data access group test' - }) + create( + :study, + ethically_approved: true, + study_metadata_attributes: { + faculty_sponsor: create(:faculty_sponsor, name: 'John Smith'), + data_release_strategy: 'open', + data_release_timing: 'standard', + reference_genome:, + array_express_accession_number: 'AE111', + ega_policy_accession_number: 'EGA222', + ega_dac_accession_number: 'DAC333', + program: create(:program, name: 'General'), + contaminated_human_data_access_group: 'contaminated human data access group test' + } + ) end let(:reference_genome) { create(:reference_genome) } diff --git a/spec/models/api/well_io_spec.rb b/spec/models/api/well_io_spec.rb index 4a8919fa1f..e2278274db 100644 --- a/spec/models/api/well_io_spec.rb +++ b/spec/models/api/well_io_spec.rb @@ -41,10 +41,12 @@ context 'with multiple samples' do subject do # As of the current records, the 'description' and 'asset_size' attributes can uniquely identify a map. - create(:well_with_sample_and_without_plate, - map: Map.find_by(description: 'A1', asset_size: plate.size), - plate:, - aliquot_count: 2) + create( + :well_with_sample_and_without_plate, + map: Map.find_by(description: 'A1', asset_size: plate.size), + plate:, + aliquot_count: 2 + ) end let(:plate) { create(:plate, barcode: 'SQPD-1') } diff --git a/spec/models/broadcast_event/lab_event_spec.rb b/spec/models/broadcast_event/lab_event_spec.rb index cf8cab9d0a..ac7e9aa2ed 100644 --- a/spec/models/broadcast_event/lab_event_spec.rb +++ b/spec/models/broadcast_event/lab_event_spec.rb @@ -18,13 +18,15 @@ let(:stock_asset) { request.asset.labware } let(:lab_event) do - create(:lab_event, - description: 'Read 1 Lin/block/hyb/load', - descriptors: { - 'key_a' => 'value a', - 'key_b' => 'value b' - }, - eventful:) + create( + :lab_event, + description: 'Read 1 Lin/block/hyb/load', + descriptors: { + 'key_a' => 'value a', + 'key_b' => 'value b' + }, + eventful: + ) end let(:user) { create(:user) } diff --git a/spec/models/broadcast_event/qc_assay_spec.rb b/spec/models/broadcast_event/qc_assay_spec.rb index c702034d98..0fe996b778 100644 --- a/spec/models/broadcast_event/qc_assay_spec.rb +++ b/spec/models/broadcast_event/qc_assay_spec.rb @@ -27,12 +27,14 @@ context 'A single assay qc_assay' do let(:qc_assay) do - create(:qc_assay, - lot_number:, - qc_results: [ - build(:qc_result_concentration, asset: well1, assay_type: 'Example Assay', assay_version: 'v0.0'), - build(:qc_result_concentration, asset: well2, assay_type: 'Example Assay', assay_version: 'v0.0') - ]) + create( + :qc_assay, + lot_number:, + qc_results: [ + build(:qc_result_concentration, asset: well1, assay_type: 'Example Assay', assay_version: 'v0.0'), + build(:qc_result_concentration, asset: well2, assay_type: 'Example Assay', assay_version: 'v0.0') + ] + ) end describe '#to_json' do @@ -100,12 +102,14 @@ # The API supports multiple different assays types being conducted at the same time, # but event wise these should be distinguishable. let(:qc_assay) do - create(:qc_assay, - lot_number:, - qc_results: [ - build(:qc_result_concentration, asset: well1, assay_type: 'Example Assay', assay_version: 'v0.0'), - build(:qc_result_concentration, asset: well2, assay_type: 'Other Assay', assay_version: 'v0.0') - ]) + create( + :qc_assay, + lot_number:, + qc_results: [ + build(:qc_result_concentration, asset: well1, assay_type: 'Example Assay', assay_version: 'v0.0'), + build(:qc_result_concentration, asset: well2, assay_type: 'Other Assay', assay_version: 'v0.0') + ] + ) end describe '#to_json' do diff --git a/spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb b/spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb index ce3b1a37a8..3cc164ce07 100644 --- a/spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb +++ b/spec/models/illumina_htp/initial_stock_tube_purpose_spec.rb @@ -33,11 +33,13 @@ submission: sibling_submission, state: sibling_state end - create(:multiplex_request, - asset: parents_sibling_well, - target_asset: target_tube, - submission: sibling_submission, - request_type: sibling_request_type) + create( + :multiplex_request, + asset: parents_sibling_well, + target_asset: target_tube, + submission: sibling_submission, + request_type: sibling_request_type + ) end context 'which has been created' do @@ -98,11 +100,13 @@ end before do - create(:transfer_request, - asset: sibling_tube, - target_asset: sibling_descendant, - submission: sibling_submission, - state: 'passed') + create( + :transfer_request, + asset: sibling_tube, + target_asset: sibling_descendant, + submission: sibling_submission, + state: 'passed' + ) end it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording diff --git a/spec/models/linear_submission_spec.rb b/spec/models/linear_submission_spec.rb index 1435c29efe..94b281d9df 100644 --- a/spec/models/linear_submission_spec.rb +++ b/spec/models/linear_submission_spec.rb @@ -32,8 +32,13 @@ well end let(:expected_metric) do - create(:qc_metric, asset: stock_well, qc_report: current_report, qc_decision: 'manually_failed', -proceed: true) + create( + :qc_metric, + asset: stock_well, + qc_report: current_report, + qc_decision: 'manually_failed', + proceed: true + ) end let(:mpx_submission) do create( @@ -219,31 +224,37 @@ context 'when we have a multiplier for request type' do let(:assets) { create_list(:sample_tube, 2) } let(:mx_request_type) do - create(:multiplexed_library_creation_request_type, - asset_type: 'SampleTube', - target_asset_type: 'LibraryTube', - initial_state: 'pending', - name: 'Multiplexed Library Creation', - order: 1, - key: 'multiplexed_library_creation') + create( + :multiplexed_library_creation_request_type, + asset_type: 'SampleTube', + target_asset_type: 'LibraryTube', + initial_state: 'pending', + name: 'Multiplexed Library Creation', + order: 1, + key: 'multiplexed_library_creation' + ) end let(:lib_request_type) do - create(:library_creation_request_type, - :with_library_types, - asset_type: 'SampleTube', - target_asset_type: 'LibraryTube', - initial_state: 'pending', - name: 'Library Creation', - order: 1, - key: 'library_creation') + create( + :library_creation_request_type, + :with_library_types, + asset_type: 'SampleTube', + target_asset_type: 'LibraryTube', + initial_state: 'pending', + name: 'Library Creation', + order: 1, + key: 'library_creation' + ) end let(:sequencing_request_type) do - create(:request_type, - asset_type: 'LibraryTube', - initial_state: 'pending', - name: 'PE sequencing', - order: 2, - key: 'pe_sequencing') + create( + :request_type, + asset_type: 'LibraryTube', + initial_state: 'pending', + name: 'PE sequencing', + order: 2, + key: 'pe_sequencing' + ) end context 'when a multiplication factor of 5 is provided' do diff --git a/spec/models/location_report_spec.rb b/spec/models/location_report_spec.rb index 0050c4ecbe..615be2d388 100644 --- a/spec/models/location_report_spec.rb +++ b/spec/models/location_report_spec.rb @@ -25,16 +25,20 @@ ) end let!(:plt_1_asset_audit) do - create(:asset_audit, - asset: plate_1, - created_at: Time.zone.parse('June 15, 2020 15:41'), - key: 'slf_receive_plates', - message: "Process '...' performed on instrument Reception fridge") - create(:asset_audit, - asset: plate_1, - created_at: Time.zone.parse('June 16, 2020 15:42'), - key: 'slf_receive_plates', - message: "Process '...' performed on instrument Reception fridge") + create( + :asset_audit, + asset: plate_1, + created_at: Time.zone.parse('June 15, 2020 15:41'), + key: 'slf_receive_plates', + message: "Process '...' performed on instrument Reception fridge" + ) + create( + :asset_audit, + asset: plate_1, + created_at: Time.zone.parse('June 16, 2020 15:42'), + key: 'slf_receive_plates', + message: "Process '...' performed on instrument Reception fridge" + ) # return the last audit only end let(:plt_1_purpose) { plate_1.plate_purpose.name } @@ -46,10 +50,12 @@ let(:retention_value) { 'Long term storage' } let(:plate_1_custom_metadatum_collection) { create(:custom_metadatum_collection, asset: plate_1, user:) } let(:plate_1_custom_metadatum) do - create(:custom_metadatum, - custom_metadatum_collection: plate_1_custom_metadatum_collection, - key: retention_key, - value: retention_value) + create( + :custom_metadatum, + custom_metadatum_collection: plate_1_custom_metadatum_collection, + key: retention_key, + value: retention_value + ) end let(:plate_2) do @@ -80,10 +86,12 @@ # add retention instruction metadata to plate 3 custom metadatum collection let(:plate_3_custom_metadatum_collection) { create(:custom_metadatum_collection, asset: plate_3, user:) } let(:plate_3_custom_metadatum) do - create(:custom_metadatum, - custom_metadatum_collection: plate_3_custom_metadatum_collection, - key: retention_key, - value: retention_value) + create( + :custom_metadatum, + custom_metadatum_collection: plate_3_custom_metadatum_collection, + key: retention_key, + value: retention_value + ) end let(:headers_line) do diff --git a/spec/models/phi_x/spiked_buffer_spec.rb b/spec/models/phi_x/spiked_buffer_spec.rb index f4a25b83da..265c40ff27 100644 --- a/spec/models/phi_x/spiked_buffer_spec.rb +++ b/spec/models/phi_x/spiked_buffer_spec.rb @@ -62,14 +62,16 @@ let(:study_id) { nil } let(:phi_x_spiked_buffer) do - build(:phi_x_spiked_buffer, - name: 'Example', - parent_barcode: parent.human_barcode, - parent: nil, - concentration: '0.8', - volume: '10', - number: 2, - study_id:) + build( + :phi_x_spiked_buffer, + name: 'Example', + parent_barcode: parent.human_barcode, + parent: nil, + concentration: '0.8', + volume: '10', + number: 2, + study_id: + ) end before { save } @@ -145,13 +147,15 @@ describe '#tags' do let(:phi_x_spiked_buffer) do - build(:phi_x_spiked_buffer, - name: 'Example', - parent_barcode: parent.human_barcode, - parent: nil, - concentration: '0.8', - volume: '10', - number: 2) + build( + :phi_x_spiked_buffer, + name: 'Example', + parent_barcode: parent.human_barcode, + parent: nil, + concentration: '0.8', + volume: '10', + number: 2 + ) end context 'when single' do diff --git a/spec/models/qc_report_spec.rb b/spec/models/qc_report_spec.rb index 394bdc5707..b1a438b27e 100644 --- a/spec/models/qc_report_spec.rb +++ b/spec/models/qc_report_spec.rb @@ -25,11 +25,13 @@ sample = create(:study_sample, study:).sample sample.update!(sanger_sample_id: 'TEST1') well = - create(:well, - samples: [sample], - plate: stock_plate, - map: create(:map, location_id: i), - well_attribute: attribute) + create( + :well, + samples: [sample], + plate: stock_plate, + map: create(:map, location_id: i), + well_attribute: attribute + ) well.aliquots.each { |a| a.update!(study:) } end end @@ -80,11 +82,13 @@ @other_criteria = create(:product_criteria) @matching_report = - create(:qc_report, - study:, - exclude_existing: true, - product_criteria: current_criteria, - report_identifier: 'Override') + create( + :qc_report, + study:, + exclude_existing: true, + product_criteria: current_criteria, + report_identifier: 'Override' + ) @other_report = create(:qc_report, study:, exclude_existing: true, product_criteria: other_criteria) @attribute = create(:well_attribute, current_volume: 500, concentration: 200) @@ -92,41 +96,49 @@ sample = create(:study_sample, study:).sample @unreported_sample = well = - create(:well, - samples: [sample], - plate: stock_plate, - map: create(:map, location_id: 1), - well_attribute: attribute) + create( + :well, + samples: [sample], + plate: stock_plate, + map: create(:map, location_id: 1), + well_attribute: attribute + ) well.aliquots.each { |a| a.update!(study:) } sample = create(:study_sample, study:).sample well = - create(:well, - samples: [sample], - plate: stock_plate, - map: create(:map, location_id: 2), - well_attribute: attribute) + create( + :well, + samples: [sample], + plate: stock_plate, + map: create(:map, location_id: 2), + well_attribute: attribute + ) well.aliquots.each { |a| a.update!(study:) } create(:qc_metric, asset: well, qc_report: matching_report) sample = create(:study_sample, study:).sample @other_reported_sample = well = - create(:well, - samples: [sample], - plate: stock_plate, - map: create(:map, location_id: 3), - well_attribute: attribute) + create( + :well, + samples: [sample], + plate: stock_plate, + map: create(:map, location_id: 3), + well_attribute: attribute + ) well.aliquots.each { |a| a.update!(study:) } create(:qc_metric, asset: well, qc_report: other_report) sample = create(:study_sample, study:).sample well = - create(:well, - samples: [sample], - plate: stock_plate, - map: create(:map, location_id: 4), - well_attribute: attribute) + create( + :well, + samples: [sample], + plate: stock_plate, + map: create(:map, location_id: 4), + well_attribute: attribute + ) well.aliquots.each { |a| a.update!(study:) } create(:qc_metric, asset: well, qc_report: matching_report) create(:qc_metric, asset: well, qc_report: other_report) @@ -173,11 +185,13 @@ create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[2])) @qc_report = - create(:qc_report, - study:, - exclude_existing: false, - product_criteria: create(:product_criteria), - plate_purposes: plate_purpose_names) + create( + :qc_report, + study:, + exclude_existing: false, + product_criteria: create(:product_criteria), + plate_purposes: plate_purpose_names + ) qc_report.generate! end diff --git a/spec/models/request/sample_compound_aliquot_transfer_spec.rb b/spec/models/request/sample_compound_aliquot_transfer_spec.rb index 608dac72ef..0b2a692020 100644 --- a/spec/models/request/sample_compound_aliquot_transfer_spec.rb +++ b/spec/models/request/sample_compound_aliquot_transfer_spec.rb @@ -30,9 +30,11 @@ context 'when there is no tag clash, using tags 1 and 2' do let(:aliquot1) do - create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, project: project1) end + create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, project: project1) + end let(:aliquot2) do - create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[2].id, project: project1) end + create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[2].id, project: project1) + end it 'returns false' do expect(sequencing_request).not_to be_compound_samples_needed @@ -55,26 +57,30 @@ describe '#transfer_aliquots_into_compound_sample_aliquots' do let(:aliquot1) do - create(:aliquot, - sample: samples[0], - tag_id: tags[0].id, - tag2_id: tags[1].id, - tag_depth: 1, - study: study1, - project: project1, - library_type: 'Standard', - library_id: 54) + create( + :aliquot, + sample: samples[0], + tag_id: tags[0].id, + tag2_id: tags[1].id, + tag_depth: 1, + study: study1, + project: project1, + library_type: 'Standard', + library_id: 54 + ) end let(:aliquot2) do - create(:aliquot, - sample: samples[1], - tag_id: tags[0].id, - tag2_id: tags[1].id, - tag_depth: 2, - study: study1, - project: project1, - library_type: 'Standard', - library_id: 54) + create( + :aliquot, + sample: samples[1], + tag_id: tags[0].id, + tag2_id: tags[1].id, + tag_depth: 2, + study: study1, + project: project1, + library_type: 'Standard', + library_id: 54 + ) end context 'when no compound sample exists with the component samples' do @@ -223,26 +229,30 @@ context 'when there are two compound samples' do let(:samples_extra) { create_list(:sample, 2) } let(:aliquot3) do - create(:aliquot, - sample: samples_extra[0], - tag_id: tags_extra[0].id, - tag2_id: tags_extra[1].id, - tag_depth: 1, - study: study2, - project: project2, - library_type: 'Standard', - library_id: 55) + create( + :aliquot, + sample: samples_extra[0], + tag_id: tags_extra[0].id, + tag2_id: tags_extra[1].id, + tag_depth: 1, + study: study2, + project: project2, + library_type: 'Standard', + library_id: 55 + ) end let(:aliquot4) do - create(:aliquot, - sample: samples_extra[1], - tag_id: tags_extra[0].id, - tag2_id: tags_extra[1].id, - tag_depth: 2, - study: study2, - project: project2, - library_type: 'Standard', - library_id: 55) + create( + :aliquot, + sample: samples_extra[1], + tag_id: tags_extra[0].id, + tag2_id: tags_extra[1].id, + tag_depth: 2, + study: study2, + project: project2, + library_type: 'Standard', + library_id: 55 + ) end let(:tags_extra) { create_list(:tag, 2) } let(:source) { create(:receptacle, aliquots: [aliquot1, aliquot2, aliquot3, aliquot4]) } diff --git a/spec/models/request/traction/grid_ion_spec.rb b/spec/models/request/traction/grid_ion_spec.rb index 725ec2b013..b297029646 100644 --- a/spec/models/request/traction/grid_ion_spec.rb +++ b/spec/models/request/traction/grid_ion_spec.rb @@ -5,13 +5,15 @@ describe Request::Traction::GridIon do subject do - build(:request_traction_grid_ion, - asset: well, - request_metadata_attributes: metadata, - order:, - submission:, - request_type:, - state:) + build( + :request_traction_grid_ion, + asset: well, + request_metadata_attributes: metadata, + order:, + submission:, + request_type:, + state: + ) end let(:order) { build(:order, submission:, assets: [well], request_types: [request_type.id]) } diff --git a/spec/models/request_information_type_spec.rb b/spec/models/request_information_type_spec.rb index 5383355688..21759188d2 100644 --- a/spec/models/request_information_type_spec.rb +++ b/spec/models/request_information_type_spec.rb @@ -10,12 +10,14 @@ let(:batch) { create(:batch) } let(:request) do - create(:sequencing_request, - request_metadata_attributes: { - read_length: 76, - created_at: Date.parse('2021-03-01') - }, - batch:) + create( + :sequencing_request, + request_metadata_attributes: { + read_length: 76, + created_at: Date.parse('2021-03-01') + }, + batch: + ) end context 'when key is a request metadata' do diff --git a/spec/models/robot/pick_data_spec.rb b/spec/models/robot/pick_data_spec.rb index a64b3f7993..cc5d9785cb 100644 --- a/spec/models/robot/pick_data_spec.rb +++ b/spec/models/robot/pick_data_spec.rb @@ -44,11 +44,13 @@ let(:requests) do transfers.map do |source, target| - create(:cherrypick_request, - asset: source, - target_asset: target, - request_type: pipeline.request_types.first, - state: 'passed') + create( + :cherrypick_request, + asset: source, + target_asset: target, + request_type: pipeline.request_types.first, + state: 'passed' + ) end end @@ -168,11 +170,13 @@ context 'when we create the requests in different order' do let(:requests) do transfers.to_a.reverse.map do |source, target| - create(:cherrypick_request, - asset: source, - target_asset: target, - request_type: pipeline.request_types.first, - state: 'passed') + create( + :cherrypick_request, + asset: source, + target_asset: target, + request_type: pipeline.request_types.first, + state: 'passed' + ) end end diff --git a/spec/models/robot/verification/source_dest_beds_spec.rb b/spec/models/robot/verification/source_dest_beds_spec.rb index 1a6aa4aa08..136b2caebb 100644 --- a/spec/models/robot/verification/source_dest_beds_spec.rb +++ b/spec/models/robot/verification/source_dest_beds_spec.rb @@ -62,11 +62,13 @@ let(:requests) do transfers.map do |source, target| - create(:cherrypick_request, - asset: source, - target_asset: target, - request_type: pipeline.request_types.first, - state: 'passed') + create( + :cherrypick_request, + asset: source, + target_asset: target, + request_type: pipeline.request_types.first, + state: 'passed' + ) end end diff --git a/spec/models/robot/verification/source_dest_control_beds_spec.rb b/spec/models/robot/verification/source_dest_control_beds_spec.rb index 9db26bf8e7..f4969abdeb 100644 --- a/spec/models/robot/verification/source_dest_control_beds_spec.rb +++ b/spec/models/robot/verification/source_dest_control_beds_spec.rb @@ -57,11 +57,13 @@ let(:requests) do transfers.map do |source, target| - create(:cherrypick_request, - asset: source, - target_asset: target, - request_type: pipeline.request_types.first, - state: 'passed') + create( + :cherrypick_request, + asset: source, + target_asset: target, + request_type: pipeline.request_types.first, + state: 'passed' + ) end end diff --git a/spec/models/sequencing_request_spec.rb b/spec/models/sequencing_request_spec.rb index 6bdb27086e..5d9b8a4fd2 100644 --- a/spec/models/sequencing_request_spec.rb +++ b/spec/models/sequencing_request_spec.rb @@ -38,12 +38,16 @@ context 'with upstream requests' do before do library_tube.create_scanned_into_lab_event!(content: '2018-01-01') - create(:library_creation_request_for_testing_sequencing_requests, - target_asset: library_tube, - state: library_request_1_state) - create(:library_creation_request_for_testing_sequencing_requests, - target_asset: library_tube, - state: library_request_2_state) + create( + :library_creation_request_for_testing_sequencing_requests, + target_asset: library_tube, + state: library_request_1_state + ) + create( + :library_creation_request_for_testing_sequencing_requests, + target_asset: library_tube, + state: library_request_2_state + ) end # Nothing has happened yet! diff --git a/spec/models/state_changer/initial_stock_tube_spec.rb b/spec/models/state_changer/initial_stock_tube_spec.rb index 9b09079fdd..cbcfe7c5c0 100644 --- a/spec/models/state_changer/initial_stock_tube_spec.rb +++ b/spec/models/state_changer/initial_stock_tube_spec.rb @@ -12,11 +12,13 @@ let(:submission) { build_stubbed(:submission) } let(:well) { create(:well) } let!(:transfer_request) do - create(:transfer_request, - asset: well, - target_asset: labware.receptacle, - state: transfer_request_state, - outer_request: request) + create( + :transfer_request, + asset: well, + target_asset: labware.receptacle, + state: transfer_request_state, + outer_request: request + ) end let!(:request) { create(:customer_request, asset: well, state: request_state, submission:) } diff --git a/spec/models/state_changer/standard_plate_spec.rb b/spec/models/state_changer/standard_plate_spec.rb index 56b20e3d5f..912d0e1aa9 100644 --- a/spec/models/state_changer/standard_plate_spec.rb +++ b/spec/models/state_changer/standard_plate_spec.rb @@ -119,30 +119,36 @@ target_well: target_wells['A1'], source_well: parent_wells['A1'] ) - create(:transfer_request, - asset: parent_wells['A1'], - target_asset: target_wells['A1'], - outer_request: source_well_a1_request) + create( + :transfer_request, + asset: parent_wells['A1'], + target_asset: target_wells['A1'], + outer_request: source_well_a1_request + ) target_wells['B1'].stock_well_links << build( :stock_well_link, target_well: target_wells['B1'], source_well: parent_wells['A1'] ) - create(:transfer_request, - asset: parent_wells['A1'], - target_asset: target_wells['B1'], - outer_request: source_well_a1_request) + create( + :transfer_request, + asset: parent_wells['A1'], + target_asset: target_wells['B1'], + outer_request: source_well_a1_request + ) target_wells['C1'].stock_well_links << build( :stock_well_link, target_well: target_wells['C1'], source_well: parent_wells['A1'] ) - create(:transfer_request, - asset: parent_wells['A1'], - target_asset: target_wells['C1'], - outer_request: source_well_a1_request) + create( + :transfer_request, + asset: parent_wells['A1'], + target_asset: target_wells['C1'], + outer_request: source_well_a1_request + ) # D1 created by transferring from parent B1 (2nd library request) target_wells['D1'].stock_well_links << build( @@ -150,10 +156,12 @@ target_well: target_wells['D1'], source_well: parent_wells['B1'] ) - create(:transfer_request, - asset: parent_wells['B1'], - target_asset: target_wells['D1'], - outer_request: source_well_b1_request) + create( + :transfer_request, + asset: parent_wells['B1'], + target_asset: target_wells['D1'], + outer_request: source_well_b1_request + ) end context 'when the other wells are not failed' do diff --git a/spec/models/tag_substitutions_spec.rb b/spec/models/tag_substitutions_spec.rb index 8f8175877e..c5dd4d1ae2 100644 --- a/spec/models/tag_substitutions_spec.rb +++ b/spec/models/tag_substitutions_spec.rb @@ -66,47 +66,57 @@ let(:sample_b_new_tag) { sample_a_orig_tag } let!(:library_aliquot_a) do - create(:aliquot, - sample: sample_a, - tag: sample_a_orig_tag, - tag2: sample_a_orig_tag2, - library: library_tube_a, - receptacle: library_tube_a) + create( + :aliquot, + sample: sample_a, + tag: sample_a_orig_tag, + tag2: sample_a_orig_tag2, + library: library_tube_a, + receptacle: library_tube_a + ) end let!(:library_aliquot_b) do - create(:aliquot, - sample: sample_b, - tag: sample_b_orig_tag, - tag2: sample_b_orig_tag2, - library: library_tube_b, - receptacle: library_tube_b) + create( + :aliquot, + sample: sample_b, + tag: sample_b_orig_tag, + tag2: sample_b_orig_tag2, + library: library_tube_b, + receptacle: library_tube_b + ) end let!(:mx_aliquot_a) do - create(:aliquot, - sample: sample_a, - tag: sample_a_orig_tag, - tag2: sample_a_orig_tag2, - library: library_tube_a, - receptacle: mx_library_tube) + create( + :aliquot, + sample: sample_a, + tag: sample_a_orig_tag, + tag2: sample_a_orig_tag2, + library: library_tube_a, + receptacle: mx_library_tube + ) end let!(:mx_aliquot_b) do - create(:aliquot, - sample: sample_b, - tag: sample_b_orig_tag, - tag2: sample_b_orig_tag2, - library: library_tube_b, - receptacle: mx_library_tube) + create( + :aliquot, + sample: sample_b, + tag: sample_b_orig_tag, + tag2: sample_b_orig_tag2, + library: library_tube_b, + receptacle: mx_library_tube + ) end let!(:mx_aliquot_c) { create(:tagged_aliquot, library: library_tube_b, receptacle: mx_library_tube) } let!(:lane) { create(:lane) } let!(:lane_aliquot_a) do - create(:aliquot, - sample: sample_a, - tag: sample_a_orig_tag, - tag2: sample_a_orig_tag2, - library: library_tube_a, - receptacle: lane) + create( + :aliquot, + sample: sample_a, + tag: sample_a_orig_tag, + tag2: sample_a_orig_tag2, + library: library_tube_a, + receptacle: lane + ) end let!(:flowcell_message) do diff --git a/spec/models/transfer_request_spec.rb b/spec/models/transfer_request_spec.rb index e9d9de3a7d..4359fb9935 100644 --- a/spec/models/transfer_request_spec.rb +++ b/spec/models/transfer_request_spec.rb @@ -16,20 +16,24 @@ end let(:library_request) do - create(:library_request, - asset: source, - initial_study: example_study, - initial_project: example_project, - state: library_state) + create( + :library_request, + asset: source, + initial_study: example_study, + initial_project: example_project, + state: library_state + ) end context 'with volume' do subject do - create(:transfer_request, - asset: source, - target_asset: destination, - submission: library_request.submission, - volume: 4.5) + create( + :transfer_request, + asset: source, + target_asset: destination, + submission: library_request.submission, + volume: 4.5 + ) end let(:library_state) { 'pending' } @@ -68,11 +72,13 @@ context 'with a primer panel' do let(:library_request) do - create(:gbs_request, - state: 'pending', - asset: source, - initial_study: example_study, - initial_project: example_project) + create( + :gbs_request, + state: 'pending', + asset: source, + initial_study: example_study, + initial_project: example_project + ) end it 'sets appropriate metadata on the aliquots' do @@ -102,20 +108,24 @@ end let(:library_request) do - create(:library_request, - asset: source, - initial_study: example_study, - initial_project: example_project, - state: library_state) + create( + :library_request, + asset: source, + initial_study: example_study, + initial_project: example_project, + state: library_state + ) end let(:dummy_library_request) do - create(:library_request, - asset: source, - initial_study: example_study, - initial_project: example_project, - state: library_state, - submission: library_request.submission) + create( + :library_request, + asset: source, + initial_study: example_study, + initial_project: example_project, + state: library_state, + submission: library_request.submission + ) end context 'with a pending library request' do @@ -361,8 +371,12 @@ let(:source_asset) { create(:tube) } before do - create(:transfer_request, asset: last_well, target_asset: source_asset, -submission: library_request.submission) + create( + :transfer_request, + asset: last_well, + target_asset: source_asset, + submission: library_request.submission + ) end it { is_expected.to eq library_request } @@ -443,47 +457,57 @@ let(:target_well) { create(:empty_well) } let(:submission) { create(:submission) } let(:order) do - create(:library_order, - submission:, - request_types: [library_request_type.id, multiplex_request_type.id], - assets: [source_well_a, source_well_b]) + create( + :library_order, + submission:, + request_types: [library_request_type.id, multiplex_request_type.id], + assets: [source_well_a, source_well_b] + ) end let(:multiplexed_library_tube) { create(:multiplexed_library_tube, aliquots: []) } let(:library_request_a) do - create(:library_request, - asset: source_well_a, - target_asset: target_well, - submission:, - order:, - state: 'passed', - request_type: library_request_type) + create( + :library_request, + asset: source_well_a, + target_asset: target_well, + submission:, + order:, + state: 'passed', + request_type: library_request_type + ) end let(:library_request_b) do - create(:library_request, - asset: source_well_b, - target_asset: target_well, - submission:, - order:, - state: 'passed', - request_type: library_request_type) + create( + :library_request, + asset: source_well_b, + target_asset: target_well, + submission:, + order:, + state: 'passed', + request_type: library_request_type + ) end # While source and target assets are the same, we actually have two requests let(:multiplex_request_a) do - create(:multiplex_request, - asset: target_well, - target_asset: multiplexed_library_tube, - submission:, - order:, - request_type: multiplex_request_type) + create( + :multiplex_request, + asset: target_well, + target_asset: multiplexed_library_tube, + submission:, + order:, + request_type: multiplex_request_type + ) end let(:multiplex_request_b) do - create(:multiplex_request, - asset: target_well, - target_asset: multiplexed_library_tube, - submission:, - order:, - request_type: multiplex_request_type) + create( + :multiplex_request, + asset: target_well, + target_asset: multiplexed_library_tube, + submission:, + order:, + request_type: multiplex_request_type + ) end # Order here matters diff --git a/spec/models/well_spec.rb b/spec/models/well_spec.rb index 88b0a3dc7f..b5ee955be0 100644 --- a/spec/models/well_spec.rb +++ b/spec/models/well_spec.rb @@ -470,20 +470,26 @@ @other_criteria = create(:product_criteria) @old_report = - create(:qc_report, - product_criteria: @our_product_criteria, - created_at: 1.day.ago, - report_identifier: "A#{Time.zone.now}") + create( + :qc_report, + product_criteria: @our_product_criteria, + created_at: 1.day.ago, + report_identifier: "A#{Time.zone.now}" + ) @current_report = - create(:qc_report, - product_criteria: @our_product_criteria, - created_at: 1.hour.ago, - report_identifier: "B#{Time.zone.now}") + create( + :qc_report, + product_criteria: @our_product_criteria, + created_at: 1.hour.ago, + report_identifier: "B#{Time.zone.now}" + ) @unrelated_report = - create(:qc_report, - product_criteria: @other_criteria, - created_at: Time.zone.now, - report_identifier: "C#{Time.zone.now}") + create( + :qc_report, + product_criteria: @other_criteria, + created_at: Time.zone.now, + report_identifier: "C#{Time.zone.now}" + ) @stock_well = create(:well) diff --git a/spec/models/work_completion_spec.rb b/spec/models/work_completion_spec.rb index ef71d58b27..6b43c7cec0 100644 --- a/spec/models/work_completion_spec.rb +++ b/spec/models/work_completion_spec.rb @@ -37,13 +37,15 @@ let(:input_plate2) { create(:input_plate, well_count: tested_wells, well_factory: :tagged_well) } let(:build_library_requests2) do input_plate2.wells.each do |well| - create_list(:library_request, - requests_per_well, - request_type: library_request_type, - asset: well, - submission: target_submission2, - state: 'started', - order: order2) + create_list( + :library_request, + requests_per_well, + request_type: library_request_type, + asset: well, + submission: target_submission2, + state: 'started', + order: order2 + ) end end let(:target_submission2) do diff --git a/spec/requests/plate_picks_request_spec.rb b/spec/requests/plate_picks_request_spec.rb index ef57ad8bfd..b09ddd77bb 100644 --- a/spec/requests/plate_picks_request_spec.rb +++ b/spec/requests/plate_picks_request_spec.rb @@ -7,9 +7,11 @@ let(:plate) { create(:plate, well_count: 1) } let(:destination_plate) { create(:plate, well_count: 1) } let(:released_cherrypick_batch) do - build(:cherrypick_batch, - state: 'released', - request_attributes: [{ asset: plate.wells[0], target_asset: destination_plate.wells.first, state: 'passed' }]) + build( + :cherrypick_batch, + state: 'released', + request_attributes: [{ asset: plate.wells[0], target_asset: destination_plate.wells.first, state: 'passed' }] + ) end let(:released_other_batch) { build(:batch, state: 'released', request_attributes: [{ asset: plate.wells[0] }]) } let(:pending_cherrypick_batch) do diff --git a/spec/shared_contexts/limber_shared_context.rb b/spec/shared_contexts/limber_shared_context.rb index 45d204da45..2d270880a9 100644 --- a/spec/shared_contexts/limber_shared_context.rb +++ b/spec/shared_contexts/limber_shared_context.rb @@ -47,11 +47,13 @@ state: library_state, order: ) - create(:library_request, - request_type: library_request_type, - asset: well, - submission: decoy_submission, - state: library_state) + create( + :library_request, + request_type: library_request_type, + asset: well, + submission: decoy_submission, + state: library_state + ) end end diff --git a/spec/uat_actions/plate_information_spec.rb b/spec/uat_actions/plate_information_spec.rb index 6f806275e1..a05d144f66 100644 --- a/spec/uat_actions/plate_information_spec.rb +++ b/spec/uat_actions/plate_information_spec.rb @@ -140,19 +140,23 @@ plate_wells.last.requests_as_source << req3 req4 = - create(:library_creation_request, - asset: plate_wells.first, - submission: submission2, - request_type:, - state: 'started') + create( + :library_creation_request, + asset: plate_wells.first, + submission: submission2, + request_type:, + state: 'started' + ) plate_wells.first.requests_as_source << req4 req5 = - create(:library_creation_request, - asset: plate_wells.last, - submission: submission2, - request_type:, - state: 'started') + create( + :library_creation_request, + asset: plate_wells.last, + submission: submission2, + request_type:, + state: 'started' + ) plate_wells.last.requests_as_source << req5 end diff --git a/test/controllers/requests_controller_test.rb b/test/controllers/requests_controller_test.rb index cfdf338251..0e3c71e4f3 100644 --- a/test/controllers/requests_controller_test.rb +++ b/test/controllers/requests_controller_test.rb @@ -18,10 +18,12 @@ class RequestsControllerTest < ActionController::TestCase should 'cancel request' do request = - FactoryBot.create(:request, - user: @user, - request_type: FactoryBot.create(:request_type), - study: FactoryBot.create(:study, name: 'ReqCon2')) + FactoryBot.create( + :request, + user: @user, + request_type: FactoryBot.create(:request_type), + study: FactoryBot.create(:study, name: 'ReqCon2') + ) get :cancel, params: { id: request.id } assert_equal flash[:notice], "Request #{request.id} has been cancelled" @@ -31,11 +33,13 @@ class RequestsControllerTest < ActionController::TestCase should 'cancel started request' do request = - FactoryBot.create(:request, - state: 'started', - user: @user, - request_type: FactoryBot.create(:request_type), - study: FactoryBot.create(:study, name: 'ReqCon2')) + FactoryBot.create( + :request, + state: 'started', + user: @user, + request_type: FactoryBot.create(:request_type), + study: FactoryBot.create(:study, name: 'ReqCon2') + ) get :cancel, params: { id: request.id } assert_equal flash[:error], "Request #{request.id} can't be cancelled" @@ -48,10 +52,12 @@ class RequestsControllerTest < ActionController::TestCase should 'when quotas is copied and redirect' do @request_initial = - FactoryBot.create(:request, - user: @user, - request_type: FactoryBot.create(:request_type), - study: FactoryBot.create(:study, name: 'ReqCon2')) + FactoryBot.create( + :request, + user: @user, + request_type: FactoryBot.create(:request_type), + study: FactoryBot.create(:study, name: 'ReqCon2') + ) get :copy, params: { id: @request_initial.id } @new_request = Request.last @@ -61,11 +67,13 @@ class RequestsControllerTest < ActionController::TestCase should 'set failed requests to pending' do @request_initial = - FactoryBot.create(:request, - user: @user, - request_type: FactoryBot.create(:request_type), - study: FactoryBot.create(:study, name: 'ReqCon2'), - state: 'failed') + FactoryBot.create( + :request, + user: @user, + request_type: FactoryBot.create(:request_type), + study: FactoryBot.create(:study, name: 'ReqCon2'), + state: 'failed' + ) get :copy, params: { id: @request_initial.id } @new_request = Request.last @@ -82,10 +90,12 @@ class RequestsControllerTest < ActionController::TestCase @prop_value_after = 666 @our_request = - FactoryBot.create(:request, - user: @user, - request_type: FactoryBot.create(:request_type), - study: FactoryBot.create(:study, name: 'ReqCon')) + FactoryBot.create( + :request, + user: @user, + request_type: FactoryBot.create(:request_type), + study: FactoryBot.create(:study, name: 'ReqCon') + ) @params = { request_metadata_attributes: { read_length: '37' @@ -123,11 +133,13 @@ class RequestsControllerTest < ActionController::TestCase @project = FactoryBot.create(:project_with_order, name: 'Prj1') @reqwest = - FactoryBot.create(:request, - user: @user, - request_type: FactoryBot.create(:request_type), - study: FactoryBot.create(:study, name: 'ReqCon XXX'), - project: @project) + FactoryBot.create( + :request, + user: @user, + request_type: FactoryBot.create(:request_type), + study: FactoryBot.create(:study, name: 'ReqCon XXX'), + project: @project + ) end context 'update invalid and failed' do diff --git a/test/controllers/workflows_controller_test.rb b/test/controllers/workflows_controller_test.rb index 2c527c2175..bcd0f813d6 100644 --- a/test/controllers/workflows_controller_test.rb +++ b/test/controllers/workflows_controller_test.rb @@ -26,33 +26,41 @@ class WorkflowsControllerTest < ActionController::TestCase @batch = @pipeline.batches.create! @task1 = - FactoryBot.create(:task, - name: 'Q20 Check', - location: '', - workflow: @ws1, - sorted: 0, - sti_type: 'SetDescriptorsTask') + FactoryBot.create( + :task, + name: 'Q20 Check', + location: '', + workflow: @ws1, + sorted: 0, + sti_type: 'SetDescriptorsTask' + ) @task2 = - FactoryBot.create(:task, - name: 'Submit batch', - location: 'http://someurl', - workflow: @ws1, - sorted: 1, - sti_type: 'SetDescriptorsTask') + FactoryBot.create( + :task, + name: 'Submit batch', + location: 'http://someurl', + workflow: @ws1, + sorted: 1, + sti_type: 'SetDescriptorsTask' + ) @task3 = - FactoryBot.create(:task, - name: 'Q20 Check', - location: '', - workflow: @ws2, - sorted: 0, - sti_type: 'SetDescriptorsTask') + FactoryBot.create( + :task, + name: 'Q20 Check', + location: '', + workflow: @ws2, + sorted: 0, + sti_type: 'SetDescriptorsTask' + ) @task4 = - FactoryBot.create(:task, - name: 'Submit batch', - location: 'http://someurl', - workflow: @ws2, - sorted: 1, - sti_type: 'SetDescriptorsTask') + FactoryBot.create( + :task, + name: 'Submit batch', + location: 'http://someurl', + workflow: @ws2, + sorted: 1, + sti_type: 'SetDescriptorsTask' + ) @library1 = FactoryBot.create(:library_tube) @lane1 = FactoryBot.create(:lane) @lane1.labware.parents << @library1 diff --git a/test/lib/label_printer/plate_creator_test.rb b/test/lib/label_printer/plate_creator_test.rb index 00a5c03a93..f680a2a430 100644 --- a/test/lib/label_printer/plate_creator_test.rb +++ b/test/lib/label_printer/plate_creator_test.rb @@ -26,13 +26,15 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength @purpose_name = 'test purpose' plate_purpose = create(:plate_purpose, name: purpose_name) @plate1 = - create(:child_plate, - parent:, - barcode: barcode1, - plate_purpose:, - well_count: 1, - well_factory: :untagged_well, - studies: @studies) + create( + :child_plate, + parent:, + barcode: barcode1, + plate_purpose:, + well_count: 1, + well_factory: :untagged_well, + studies: @studies + ) @plates = [plate1] @user = 'user' @study_abbreviation = 'WTCCC' diff --git a/test/performance/work_completion_tubes_test.rb b/test/performance/work_completion_tubes_test.rb index a8ed17f00d..aec669d758 100644 --- a/test/performance/work_completion_tubes_test.rb +++ b/test/performance/work_completion_tubes_test.rb @@ -32,43 +32,53 @@ def setup # rubocop:todo Metrics/CyclomaticComplexity, Metrics/MethodLength input_plate_1.wells.each do |well| next if well.aliquots.empty? - create(:library_request, - request_type: library_request_type, - asset: well, - submission: target_submission_1, - state: 'started') - create(:library_request, - request_type: library_request_type, - asset: well, - submission: decoy_submission, - state: 'started') + create( + :library_request, + request_type: library_request_type, + asset: well, + submission: target_submission_1, + state: 'started' + ) + create( + :library_request, + request_type: library_request_type, + asset: well, + submission: decoy_submission, + state: 'started' + ) end input_plate_2.wells.each do |well| next if well.aliquots.empty? - create(:library_request, - request_type: library_request_type, - asset: well, - submission: target_submission_2, - state: 'started') + create( + :library_request, + request_type: library_request_type, + asset: well, + submission: target_submission_2, + state: 'started' + ) end input_plate_3.wells.each do |well| next if well.aliquots.empty? - create(:library_request, - request_type: library_request_type, - asset: well, - submission: target_submission_3, - state: 'started') + create( + :library_request, + request_type: library_request_type, + asset: well, + submission: target_submission_3, + state: 'started' + ) end input_plate_4.wells.each do |well| next if well.aliquots.empty? - create(:library_request, - request_type: library_request_type, - asset: well, - submission: target_submission_4, - state: 'started') + create( + :library_request, + request_type: library_request_type, + asset: well, + submission: target_submission_4, + state: 'started' + ) end # The decoy submission represents a submission which we don't care about diff --git a/test/performance/work_completions_test.rb b/test/performance/work_completions_test.rb index 7ad19d51f8..b13eab53b7 100644 --- a/test/performance/work_completions_test.rb +++ b/test/performance/work_completions_test.rb @@ -22,16 +22,20 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength @target_plate = create(:target_plate, parent: input_plate, well_count: tested_wells) input_plate.wells.each do |well| - create(:library_request, - request_type: library_request_type, - asset: well, - submission: @target_submission, - state: 'started') - create(:library_request, - request_type: library_request_type, - asset: well, - submission: decoy_submission, - state: 'started') + create( + :library_request, + request_type: library_request_type, + asset: well, + submission: @target_submission, + state: 'started' + ) + create( + :library_request, + request_type: library_request_type, + asset: well, + submission: decoy_submission, + state: 'started' + ) end submission_request_types[1..].each do |downstream_type| input_plate.wells.count.times do diff --git a/test/unit/flexible_submission_test.rb b/test/unit/flexible_submission_test.rb index 86bbb69536..c5a127aae8 100644 --- a/test/unit/flexible_submission_test.rb +++ b/test/unit/flexible_submission_test.rb @@ -283,12 +283,14 @@ class FlexibleSubmissionTest < ActiveSupport::TestCase @mx_request_type = create(:well_request_type, target_purpose: nil, for_multiplexing: true, pooling_method: @pooling) @pe_request_type = - create(:request_type, - asset_type: 'LibraryTube', - initial_state: 'pending', - name: 'PE sequencing', - order: 2, - key: 'pe_sequencing') + create( + :request_type, + asset_type: 'LibraryTube', + initial_state: 'pending', + name: 'PE sequencing', + order: 2, + key: 'pe_sequencing' + ) @request_type_ids = [@mx_request_type.id, @pe_request_type.id] @@ -346,12 +348,14 @@ class FlexibleSubmissionTest < ActiveSupport::TestCase @mx_request_type = create(:well_request_type, target_purpose: nil, for_multiplexing: true, pooling_method: @pooling) @pe_request_type = - create(:request_type, - asset_type: 'LibraryTube', - initial_state: 'pending', - name: 'PE sequencing', - order: 2, - key: 'pe_sequencing') + create( + :request_type, + asset_type: 'LibraryTube', + initial_state: 'pending', + name: 'PE sequencing', + order: 2, + key: 'pe_sequencing' + ) @mx_request_type_ids = [@mx_request_type.id, @pe_request_type.id] @ux_request_type_ids = [@ux_request_type.id, @pe_request_type.id] diff --git a/test/unit/import_fluidigm_data_test.rb b/test/unit/import_fluidigm_data_test.rb index 593577f7dd..694bf2bbb3 100644 --- a/test/unit/import_fluidigm_data_test.rb +++ b/test/unit/import_fluidigm_data_test.rb @@ -29,12 +29,14 @@ def create_fluidigm_file end def create_stock_plate(barcode) - create(:plate, - name: "Stock plate #{barcode}", - well_count: 1, - well_factory: :untagged_well, - purpose: PlatePurpose.stock_plate_purpose, - barcode:) + create( + :plate, + name: "Stock plate #{barcode}", + well_count: 1, + well_factory: :untagged_well, + purpose: PlatePurpose.stock_plate_purpose, + barcode: + ) end def create_plate_with_fluidigm(_barcode, fluidigm_barcode, stock_plate) @@ -43,14 +45,16 @@ def create_plate_with_fluidigm(_barcode, fluidigm_barcode, stock_plate) well_target = plate_target.wells.first - create(:final_cherrypick_for_fluidigm_request, - state: 'passed', - asset: stock_plate.wells.first, - target_asset: well_target, - request_metadata_attributes: { - target_purpose_id: fgp.id - }, - request_type: @fluidigm_request_type) + create( + :final_cherrypick_for_fluidigm_request, + state: 'passed', + asset: stock_plate.wells.first, + target_asset: well_target, + request_metadata_attributes: { + target_purpose_id: fgp.id + }, + request_type: @fluidigm_request_type + ) plate_target end diff --git a/test/unit/product_catalogue/library_driven_test.rb b/test/unit/product_catalogue/library_driven_test.rb index a6933e210f..acb170d4be 100644 --- a/test/unit/product_catalogue/library_driven_test.rb +++ b/test/unit/product_catalogue/library_driven_test.rb @@ -6,10 +6,12 @@ class LibraryDrivenTest < ActiveSupport::TestCase context 'When using a ProductCatalogue that is library driven' do setup do def link_product_with_pc(product, product_catalogue, library_type_name) - FactoryBot.create(:product_product_catalogue, - product:, - product_catalogue:, - selection_criterion: library_type_name) + FactoryBot.create( + :product_product_catalogue, + product:, + product_catalogue:, + selection_criterion: library_type_name + ) end # We'll create a product catalogue that will contain [@product, @product2, @product3] @@ -32,23 +34,27 @@ def link_product_with_pc(product, product_catalogue, library_type_name) context 'with no library or incorrect type' do setup do @submission_template = - FactoryBot.create(:submission_template, - name: 'ST 1', - product_catalogue: @product_catalogue, - submission_parameters: { - request_type_ids_list: [], - request_options: { - library_type: 'Another library' - } - }) + FactoryBot.create( + :submission_template, + name: 'ST 1', + product_catalogue: @product_catalogue, + submission_parameters: { + request_type_ids_list: [], + request_options: { + library_type: 'Another library' + } + } + ) @submission_template2 = - FactoryBot.create(:submission_template, - name: 'ST 2', - product_catalogue: @product_catalogue, - submission_parameters: { - request_type_ids_list: [] - }) + FactoryBot.create( + :submission_template, + name: 'ST 2', + product_catalogue: @product_catalogue, + submission_parameters: { + request_type_ids_list: [] + } + ) end should 'not select any product (return nil)' do order = @submission_template.new_order @@ -70,26 +76,30 @@ def link_product_with_pc(product, product_catalogue, library_type_name) context 'with a library type selected' do setup do @submission_template = - FactoryBot.create(:submission_template, - name: 'ST 1', - product_catalogue: @product_catalogue, - submission_parameters: { - request_type_ids_list: [], - request_options: { - library_type: @library_type.name - } - }) + FactoryBot.create( + :submission_template, + name: 'ST 1', + product_catalogue: @product_catalogue, + submission_parameters: { + request_type_ids_list: [], + request_options: { + library_type: @library_type.name + } + } + ) @submission_template2 = - FactoryBot.create(:submission_template, - name: 'ST 2', - product_catalogue: @product_catalogue, - submission_parameters: { - request_type_ids_list: [], - request_options: { - library_type: @library_type2.name - } - }) + FactoryBot.create( + :submission_template, + name: 'ST 2', + product_catalogue: @product_catalogue, + submission_parameters: { + request_type_ids_list: [], + request_options: { + library_type: @library_type2.name + } + } + ) end should 'selects the right product for this submission using the library type' do @@ -104,12 +114,14 @@ def link_product_with_pc(product, product_catalogue, library_type_name) context 'without a library type selected' do setup do @submission_template3 = - FactoryBot.create(:submission_template, - name: 'ST 3', - product_catalogue: @product_catalogue, - submission_parameters: { - request_type_ids_list: [] - }) + FactoryBot.create( + :submission_template, + name: 'ST 3', + product_catalogue: @product_catalogue, + submission_parameters: { + request_type_ids_list: [] + } + ) end should 'select the first product of the default products' do @@ -120,15 +132,17 @@ def link_product_with_pc(product, product_catalogue, library_type_name) context 'with a library type unsupported by the product catalogue' do setup do @submission_template4 = - FactoryBot.create(:submission_template, - name: 'ST 4', - product_catalogue: @product_catalogue, - submission_parameters: { - request_type_ids_list: [], - request_options: { - library_type: 'Standard' - } - }) + FactoryBot.create( + :submission_template, + name: 'ST 4', + product_catalogue: @product_catalogue, + submission_parameters: { + request_type_ids_list: [], + request_options: { + library_type: 'Standard' + } + } + ) end should 'select the first product of the default products' do order = @submission_template4.new_order @@ -142,15 +156,17 @@ def link_product_with_pc(product, product_catalogue, library_type_name) link_product_with_pc(@product4, @product_catalogue, @library_type.name) @submission_template5 = - FactoryBot.create(:submission_template, - name: 'ST 5', - product_catalogue: @product_catalogue, - submission_parameters: { - request_type_ids_list: [], - request_options: { - library_type: @library_type.name - } - }) + FactoryBot.create( + :submission_template, + name: 'ST 5', + product_catalogue: @product_catalogue, + submission_parameters: { + request_type_ids_list: [], + request_options: { + library_type: @library_type.name + } + } + ) end should 'select the first product of the default products' do order = @submission_template5.new_order diff --git a/test/unit/qc_report_file_test.rb b/test/unit/qc_report_file_test.rb index b6996b8e79..c8555d3362 100644 --- a/test/unit/qc_report_file_test.rb +++ b/test/unit/qc_report_file_test.rb @@ -67,11 +67,13 @@ class QcReport::FileTest < ActiveSupport::TestCase @study = create(:study, name: 'Example study') Timecop.freeze(DateTime.parse('01/01/2015')) do @report = - create(:qc_report, - study: @study, - exclude_existing: false, - product_criteria: @criteria, - state: 'awaiting_proceed') + create( + :qc_report, + study: @study, + exclude_existing: false, + product_criteria: @criteria, + state: 'awaiting_proceed' + ) end @asset_ids = [] 2.times do |i| @@ -109,11 +111,13 @@ class QcReport::FileTest < ActiveSupport::TestCase @study = FactoryBot.build(:study, name: 'Example study') Timecop.freeze(DateTime.parse('01/01/2015')) do @report = - create(:qc_report, - study: @study, - exclude_existing: false, - product_criteria: @criteria, - state: 'awaiting_proceed') + create( + :qc_report, + study: @study, + exclude_existing: false, + product_criteria: @criteria, + state: 'awaiting_proceed' + ) end @asset_ids = [] 2.times do |i| @@ -140,11 +144,13 @@ class QcReport::FileTest < ActiveSupport::TestCase @study = FactoryBot.build(:study, name: 'Example study') Timecop.freeze(DateTime.parse('01/01/2015')) do @report = - create(:qc_report, - study: @study, - exclude_existing: false, - product_criteria: @criteria, - state: 'awaiting_proceed') + create( + :qc_report, + study: @study, + exclude_existing: false, + product_criteria: @criteria, + state: 'awaiting_proceed' + ) end @asset_ids = [] 2.times { |i| create(:qc_metric, qc_report: @report, qc_decision: %w[passed failed][i]) } diff --git a/test/unit/qc_report_presenter_test.rb b/test/unit/qc_report_presenter_test.rb index eacac79d85..f9eb036a80 100644 --- a/test/unit/qc_report_presenter_test.rb +++ b/test/unit/qc_report_presenter_test.rb @@ -32,23 +32,27 @@ class QcReportPresenterTest < ActiveSupport::TestCase @study = create(:study, name: 'Example study') Timecop.freeze(DateTime.parse('01/01/2015')) do @report = - create(:qc_report, - study: @study, - exclude_existing: false, - created_at: DateTime.parse('01/01/2015 00:00:00'), - product_criteria: @criteria) + create( + :qc_report, + study: @study, + exclude_existing: false, + created_at: DateTime.parse('01/01/2015 00:00:00'), + product_criteria: @criteria + ) end @asset_ids = [] 2.times do |i| m = - create(:qc_metric, - qc_report: @report, - qc_decision: STATE_ARRAY[i], - metrics: { - total_micrograms: 10, - comment: 'X', - sanger_sample_id: 'EG' - }) + create( + :qc_metric, + qc_report: @report, + qc_decision: STATE_ARRAY[i], + metrics: { + total_micrograms: 10, + comment: 'X', + sanger_sample_id: 'EG' + } + ) @asset_ids << m.asset_id end end diff --git a/test/unit/qc_report_test.rb b/test/unit/qc_report_test.rb index c8fbb1ab31..ea75265275 100644 --- a/test/unit/qc_report_test.rb +++ b/test/unit/qc_report_test.rb @@ -25,11 +25,13 @@ class QcReportTest < ActiveSupport::TestCase sample = create(:study_sample, study:).sample sample.update!(sanger_sample_id: 'TEST1') well = - create(:well, - samples: [sample], - plate: @stock_plate, - map: create(:map, location_id: i), - well_attribute: attribute) + create( + :well, + samples: [sample], + plate: @stock_plate, + map: create(:map, location_id: i), + well_attribute: attribute + ) well.aliquots.each { |a| a.update!(study:) } end end @@ -72,11 +74,13 @@ class QcReportTest < ActiveSupport::TestCase @other_criteria = create(:product_criteria) @matching_report = - create(:qc_report, - study: @study, - exclude_existing: true, - product_criteria: @current_criteria, - report_identifier: 'Override') + create( + :qc_report, + study: @study, + exclude_existing: true, + product_criteria: @current_criteria, + report_identifier: 'Override' + ) @other_report = create(:qc_report, study: @study, exclude_existing: true, product_criteria: @other_criteria) @attribute = create(:well_attribute, current_volume: 500, concentration: 200) @@ -84,41 +88,49 @@ class QcReportTest < ActiveSupport::TestCase sample = create(:study_sample, study: @study).sample @unreported_sample = well = - create(:well, - samples: [sample], - plate: @stock_plate, - map: create(:map, location_id: 1), - well_attribute: @attribute) + create( + :well, + samples: [sample], + plate: @stock_plate, + map: create(:map, location_id: 1), + well_attribute: @attribute + ) well.aliquots.each { |a| a.update!(study: @study) } sample = create(:study_sample, study: @study).sample well = - create(:well, - samples: [sample], - plate: @stock_plate, - map: create(:map, location_id: 2), - well_attribute: @attribute) + create( + :well, + samples: [sample], + plate: @stock_plate, + map: create(:map, location_id: 2), + well_attribute: @attribute + ) well.aliquots.each { |a| a.update!(study: @study) } create(:qc_metric, asset: well, qc_report: @matching_report) sample = create(:study_sample, study: @study).sample @other_reported_sample = well = - create(:well, - samples: [sample], - plate: @stock_plate, - map: create(:map, location_id: 3), - well_attribute: @attribute) + create( + :well, + samples: [sample], + plate: @stock_plate, + map: create(:map, location_id: 3), + well_attribute: @attribute + ) well.aliquots.each { |a| a.update!(study: @study) } create(:qc_metric, asset: well, qc_report: @other_report) sample = create(:study_sample, study: @study).sample well = - create(:well, - samples: [sample], - plate: @stock_plate, - map: create(:map, location_id: 4), - well_attribute: @attribute) + create( + :well, + samples: [sample], + plate: @stock_plate, + map: create(:map, location_id: 4), + well_attribute: @attribute + ) well.aliquots.each { |a| a.update!(study: @study) } create(:qc_metric, asset: well, qc_report: @matching_report) create(:qc_metric, asset: well, qc_report: @other_report) From aa966033eec71d71cd5418ab203b986c6e5dcda8 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 26 Sep 2024 12:34:51 +0100 Subject: [PATCH 138/158] style: rubocop and prettier merged code bundle exec rubocop -a yarn prettier --write . rubocop --auto-gen-config --no-exclude-limit --- .rubocop_todo.yml | 17 ++++++++++------- spec/bulk_submission_excel/download_spec.rb | 4 ++-- .../generate_a_bulk_submission_template_spec.rb | 12 ++++++------ .../populate_numer_of_samples_per_pool_spec.rb | 2 +- spec/uat_actions/tube_submission_spec.rb | 4 ++-- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c22b28f640..f9695382dd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-26 11:14:55 UTC using RuboCop version 1.66.1. +# on 2024-09-26 11:33:58 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -723,7 +723,7 @@ RSpec/EmptyExampleGroup: - 'spec/models/pulldown/requests_spec.rb' - 'spec/models/tag_substitutions_spec.rb' -# Offense count: 380 +# Offense count: 382 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: @@ -746,6 +746,7 @@ RSpec/ExampleLength: - 'spec/lib/lab_where_client_spec.rb' - 'spec/lib/limber/helper_spec.rb' - 'spec/lib/mbrave_tags_creator_spec.rb' + - 'spec/lib/populate_numer_of_samples_per_pool_spec.rb' - 'spec/lib/retention_instructions_spec.rb' - 'spec/models/aliquot_spec.rb' - 'spec/models/bait_library_type_spec.rb' @@ -760,7 +761,7 @@ RSpec/ExampleLength: - 'spec/models/location_report_form_spec.rb' - 'spec/models/map_spec.rb' - 'spec/models/orders/order_spec.rb' - - 'spec/models/parsers/cardinal_pbmc_count_parser_spec.rb' + - 'spec/models/parsers/pbmc_count_parser_spec.rb' - 'spec/models/plate/quad_creator_spec.rb' - 'spec/models/plate_volume_spec.rb' - 'spec/models/pooling_spec.rb' @@ -849,7 +850,7 @@ RSpec/ExampleLength: - 'spec/views/samples/index_html_erb_spec.rb' - 'spec/views/samples/show_html_erb_spec.rb' -# Offense count: 291 +# Offense count: 272 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. # DisallowedExamples: works @@ -985,7 +986,7 @@ RSpec/MultipleDescribes: - 'spec/lib/label_printer/asset_labels_spec.rb' - 'spec/models/qc_result/qc_result_spec.rb' -# Offense count: 911 +# Offense count: 915 # Configuration parameters: Max. RSpec/MultipleExpectations: Exclude: @@ -1083,7 +1084,7 @@ RSpec/MultipleExpectations: - 'spec/models/lot_type_spec.rb' - 'spec/models/map_spec.rb' - 'spec/models/orders/order_spec.rb' - - 'spec/models/parsers/cardinal_pbmc_count_parser_spec.rb' + - 'spec/models/parsers/pbmc_count_parser_spec.rb' - 'spec/models/phi_x/spiked_buffer_spec.rb' - 'spec/models/phi_x/stock_spec.rb' - 'spec/models/plate/quad_creator_spec.rb' @@ -1218,12 +1219,13 @@ RSpec/MultipleExpectations: - 'spec/uat_actions/integration_suite_tools_spec.rb' - 'spec/uat_actions/plate_information_spec.rb' - 'spec/uat_actions/test_submission_spec.rb' + - 'spec/uat_actions/tube_submission_spec.rb' - 'spec/uat_actions/uat_actions_spec.rb' - 'spec/views/labware/retention_instruction_spec.rb' - 'spec/views/labware/show_chromium_chip_spec.rb' - 'spec/views/samples/index_html_erb_spec.rb' -# Offense count: 1037 +# Offense count: 1041 # Configuration parameters: AllowSubject, Max. RSpec/MultipleMemoizedHelpers: Exclude: @@ -1363,6 +1365,7 @@ RSpec/MultipleMemoizedHelpers: - 'spec/uat_actions/generate_tagged_plates_spec.rb' - 'spec/uat_actions/plate_information_spec.rb' - 'spec/uat_actions/test_submission_spec.rb' + - 'spec/uat_actions/tube_submission_spec.rb' - 'spec/uat_actions/uat_actions_spec.rb' - 'spec/views/labware/show_chromium_chip_spec.rb' - 'spec/views/labware/show_html_erb_spec.rb' diff --git a/spec/bulk_submission_excel/download_spec.rb b/spec/bulk_submission_excel/download_spec.rb index d625855de4..b83ead3477 100644 --- a/spec/bulk_submission_excel/download_spec.rb +++ b/spec/bulk_submission_excel/download_spec.rb @@ -16,7 +16,7 @@ let(:download) do described_class.new( - assets: assets, + assets:, column_list: columns, range_list: ranges, defaults: { @@ -30,7 +30,7 @@ let(:columns) { configuration.columns.all.dup } let(:ranges) { configuration.ranges.dup } let(:assets) { create(:plate_with_untagged_wells).wells } - let(:submission_template) { create :library_and_sequencing_template } + let(:submission_template) { create(:library_and_sequencing_template) } after { File.delete(test_file) if File.exist?(test_file) } diff --git a/spec/features/generate_a_bulk_submission_template_spec.rb b/spec/features/generate_a_bulk_submission_template_spec.rb index 3329d12200..454c4b1ce1 100644 --- a/spec/features/generate_a_bulk_submission_template_spec.rb +++ b/spec/features/generate_a_bulk_submission_template_spec.rb @@ -3,13 +3,13 @@ require 'rails_helper' describe 'Generate a bulk submission spreadsheet', :bulk_submission_excel, :js do - let!(:user) { create :user } + let!(:user) { create(:user) } let!(:plate) { create(:plate_with_untagged_wells, well_count: 30) } # We only use two wells of out partial plate in our submission. However we are generating 13 # to ensure we are only using the specified well. The other two will be ignored. let!(:partial_plate) { create(:plate_with_untagged_wells, well_count: 13) } - let!(:submission_template) { create :library_and_sequencing_template } + let!(:submission_template) { create(:library_and_sequencing_template) } let(:iso_date) { Time.current.utc.strftime('%Y%m%d') } let(:filename) { "#{plate.human_barcode}_to_#{partial_plate.human_barcode}_#{iso_date}_#{user.login}.xlsx" } @@ -37,8 +37,8 @@ end context 'with a primer panel submission' do - let!(:submission_template) { create :heron_library_and_sequencing_template } - let!(:primer_panel) { create :primer_panel } + let!(:submission_template) { create(:heron_library_and_sequencing_template) } + let!(:primer_panel) { create(:primer_panel) } it 'populates the primer panel column' do # Regression test for https://github.com/sanger/sequencescape/issues/2582 @@ -58,8 +58,8 @@ end context 'with a bait_library submission' do - let!(:submission_template) { create :isc_library_and_sequencing_template } - let!(:bait_library) { create :bait_library } + let!(:submission_template) { create(:isc_library_and_sequencing_template) } + let!(:bait_library) { create(:bait_library) } it 'populates the primer panel column' do # Regression test for https://github.com/sanger/sequencescape/issues/2582 diff --git a/spec/lib/populate_numer_of_samples_per_pool_spec.rb b/spec/lib/populate_numer_of_samples_per_pool_spec.rb index 3686ce8d97..0f2cdf641e 100644 --- a/spec/lib/populate_numer_of_samples_per_pool_spec.rb +++ b/spec/lib/populate_numer_of_samples_per_pool_spec.rb @@ -21,7 +21,7 @@ def run_rake_task_with_args(task_name, *args) it 'populating number of samples per pool' do submission = create(:submission) tube = create(:tube) - request = create(:well_request, asset: tube, submission: submission) + request = create(:well_request, asset: tube, submission:) # Execute run_rake_task_with_args('number_of_samples_per_pool:populate', samples_per_pool, submission.reload.id) diff --git a/spec/uat_actions/tube_submission_spec.rb b/spec/uat_actions/tube_submission_spec.rb index f6c631b92d..b66d74b390 100644 --- a/spec/uat_actions/tube_submission_spec.rb +++ b/spec/uat_actions/tube_submission_spec.rb @@ -4,9 +4,9 @@ describe UatActions::TubeSubmission do context 'with valid options' do - let(:tube) { create :sample_tube, purpose: create(:sample_tube_purpose) } + let(:tube) { create(:sample_tube, purpose: create(:sample_tube_purpose)) } let(:tube_barcode) { tube.barcodes.last.barcode } - let(:submission_template) { create :pbmc_pooling_submission_template } + let(:submission_template) { create(:pbmc_pooling_submission_template) } let(:parameters) { { submission_template_name: submission_template.name, tube_barcodes: tube_barcode } } let(:uat_action) { described_class.new(parameters) } let(:report) do From 25c6d8323666285845fb800dc1c6e9f5ee043b9e Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 26 Sep 2024 13:08:18 +0100 Subject: [PATCH 139/158] build: restore factory and capybara bot exclusions --- .rubocop.yml | 8 +++++ .rubocop_todo.yml | 74 +---------------------------------------------- 2 files changed, 9 insertions(+), 73 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fe48e19f14..3584993ad7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -181,6 +181,14 @@ Rails/RedundantPresenceValidationOnBelongsTo: Rails/UniqueValidationWithoutIndex: Enabled: false +# Factory Bot +FactoryBot/FactoryAssociationWithStrategy: + Enabled: false + +# Capybara +Capybara/ClickLinkOrButtonStyle: + Enabled: false + # Disabling newly introduced cops until we have time to sort out the offenses Rails/I18nLocaleTexts: # new in 2.14 Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f9695382dd..2028d1174f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,83 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-26 11:33:58 UTC using RuboCop version 1.66.1. +# on 2024-09-26 12:06:07 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 157 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: link_or_button, strict -Capybara/ClickLinkOrButtonStyle: - Exclude: - - 'features/support/step_definitions/authentication_steps.rb' - - 'features/support/step_definitions/bulk_submission_steps.rb' - - 'features/support/step_definitions/contact_steps.rb' - - 'features/support/step_definitions/web_steps.rb' - - 'spec/features/admin/changing_user_roles_spec.rb' - - 'spec/features/assets/asset_submission_spec.rb' - - 'spec/features/assets/upload_and_retrieve_qc_file_spec.rb' - - 'spec/features/batches/failing_requests_spec.rb' - - 'spec/features/batches/sort_requests_spec.rb' - - 'spec/features/contact_us_spec.rb' - - 'spec/features/create_printer_spec.rb' - - 'spec/features/creating_a_quad_stamp_spec.rb' - - 'spec/features/lab_view_spec.rb' - - 'spec/features/labware/looking_up_labware_history_spec.rb' - - 'spec/features/labware/retention_instruction_spec.rb' - - 'spec/features/location_reports/location_reports_spec.rb' - - 'spec/features/perform_a_tag_substitution_spec.rb' - - 'spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb' - - 'spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb' - - 'spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb' - - 'spec/features/pipelines/viewing_request_comments_spec.rb' - - 'spec/features/sample_logistics/lab/stock_stamping_spec.rb' - - 'spec/features/sample_manifests/create_manifest_spec.rb' - - 'spec/features/sample_manifests/track_sample_manifest_updates_spec.rb' - - 'spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb' - - 'spec/features/shared_examples/cherrypicking.rb' - - 'spec/features/studies/accession_all_samples_spec.rb' - - 'spec/features/studies/change_study_roles_spec.rb' - - 'spec/features/studies/create_study_spec.rb' - - 'spec/features/studies/edit_study_spec.rb' - - 'spec/features/studies/manage_study_spec.rb' - - 'spec/features/studies/qc_reports_spec.rb' - - 'spec/features/studies/view_study_properties_spec.rb' - - 'spec/features/studies/view_study_request_links_spec.rb' - - 'spec/features/submissions/bulk_submissions_spec.rb' - - 'spec/support/user_login.rb' - -# Offense count: 62 -# Configuration parameters: Include. -# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb -FactoryBot/FactoryAssociationWithStrategy: - Exclude: - - 'spec/factories/accession/samples.rb' - - 'spec/factories/accession/submissions.rb' - - 'spec/factories/aliquots.rb' - - 'spec/factories/batch_factories.rb' - - 'spec/factories/lib_pcr_xp_factories.rb' - - 'spec/factories/phix_factories.rb' - - 'spec/factories/pipelines_factories.rb' - - 'spec/factories/plate_barcode_factories.rb' - - 'spec/factories/plate_factories.rb' - - 'spec/factories/poly_metadata_factories.rb' - - 'spec/factories/purpose_factories.rb' - - 'spec/factories/request_factories.rb' - - 'spec/factories/request_type_factories.rb' - - 'spec/factories/roles.rb' - - 'spec/factories/sample_manifest_excel/test_download_plates.rb' - - 'spec/factories/sample_manifest_factories.rb' - - 'spec/factories/submission_factories.rb' - - 'spec/factories/tag_set_factories.rb' - - 'spec/factories/tube_factories.rb' - - 'spec/factories/tube_rack.rb' - - 'spec/factories/user_factories.rb' - - 'spec/factories/user_query_factories.rb' - - 'spec/factories/well_factories.rb' - - 'spec/factories/z_tag_qc_factories.rb' - # Offense count: 21 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedMethods, AllowedPatterns. From 5a594f06f1ecd08930b00eefad241b77354d740e Mon Sep 17 00:00:00 2001 From: Stuart McHattie Date: Thu, 26 Sep 2024 14:23:34 +0100 Subject: [PATCH 140/158] Remove redundant value definition for matching key in arguments --- app/models/plate_creation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/plate_creation.rb b/app/models/plate_creation.rb index 3066eec729..70b86ed327 100644 --- a/app/models/plate_creation.rb +++ b/app/models/plate_creation.rb @@ -34,7 +34,7 @@ def children private :children def create_children! - self.child = child_purpose.create!(sanger_barcode: sanger_barcode) + self.child = child_purpose.create!(sanger_barcode:) end private :create_children! end From dd3105a809bbaf6c8e3f938d8ba01b1a6ccd6834 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 26 Sep 2024 14:38:19 +0100 Subject: [PATCH 141/158] style: set Style/HashSyntax EnforcedShorthandSyntax to consistent --- .rubocop.yml | 4 + .rubocop_todo.yml | 19 +- app/api/core/endpoint/basic_handler/paged.rb | 2 +- app/api/core/io/collection.rb | 2 +- app/api/core/io/json/stream.rb | 2 +- app/api/core/service.rb | 2 +- .../bulk_submission_excel/download.rb | 9 +- app/controllers/batches_controller.rb | 2 +- .../concerns/plate_picks/batches_json.rb | 2 +- app/controllers/driver_files_controller.rb | 2 +- app/controllers/plate_picks_controller.rb | 2 +- app/controllers/qc_reports_controller.rb | 4 +- app/controllers/receptacles_controller.rb | 2 +- app/controllers/studies_controller.rb | 2 +- app/controllers/study_reports_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/controllers/workflows_controller.rb | 2 +- app/helpers/application_helper.rb | 6 +- app/helpers/assets_helper.rb | 2 +- app/helpers/bootstrap_helper.rb | 2 +- app/helpers/compound_sample_helper.rb | 5 +- app/helpers/prototype_replacement_helper.rb | 2 +- app/heron/factories/plate.rb | 2 +- app/heron/factories/sample.rb | 2 +- app/heron/factories/tube.rb | 2 +- app/heron/factories/tube_rack.rb | 6 +- app/jobs/export_pool_xp_to_traction_job.rb | 4 +- .../sample_manifest/generate_wells_job.rb | 2 +- app/middleware/api/root_service.rb | 2 +- app/models/accessionable/dac.rb | 2 +- app/models/accessionable/policy.rb | 2 +- app/models/add_spiked_in_control_task.rb | 7 +- app/models/aliquot.rb | 6 +- app/models/asset_audit.rb | 2 +- app/models/attributable/association.rb | 7 +- app/models/attributable/attribute.rb | 6 +- app/models/barcode.rb | 2 +- app/models/barcode/barcodeable.rb | 2 +- app/models/batch.rb | 14 +- app/models/batch/state_machine_behaviour.rb | 4 +- app/models/batch_request.rb | 2 +- app/models/bulk_submission.rb | 10 +- app/models/bulk_transfer.rb | 8 +- app/models/cherrypick_request.rb | 2 +- app/models/compound_aliquot.rb | 4 +- app/models/event/labware_failed_event.rb | 2 +- app/models/event/sample_logistics_qc_event.rb | 8 +- app/models/event/scanned_into_lab_event.rb | 2 +- app/models/event_sender.rb | 4 +- .../illumina_htp/requests/gbs_request.rb | 6 +- .../illumina_htp/requests/heron_request.rb | 6 +- .../requests/heron_tailed_request.rb | 6 +- app/models/lab_event.rb | 2 +- app/models/labwhere_reception.rb | 9 +- app/models/lib_pool_norm_tube_generator.rb | 8 +- app/models/library_creation_request.rb | 8 +- .../location_report/location_report_form.rb | 16 +- app/models/metadata.rb | 2 +- app/models/metadata/form_builder.rb | 4 +- app/models/order.rb | 2 +- app/models/phi_x/spiked_buffer.rb | 2 +- app/models/phi_x/stock.rb | 8 +- app/models/pick_list.rb | 8 +- app/models/pick_list/record_cache.rb | 2 +- app/models/plate.rb | 4 +- app/models/plate/creator.rb | 10 +- app/models/plate/fluidigm_behaviour.rb | 4 +- app/models/plate/quad_creator.rb | 4 +- app/models/plate_barcode.rb | 2 +- app/models/plate_volume.rb | 2 +- app/models/pooling.rb | 9 +- app/models/presenters/qc_report_presenter.rb | 2 +- app/models/qc_file.rb | 2 +- app/models/qc_report.rb | 7 +- app/models/qcable_creator.rb | 4 +- app/models/report_fail.rb | 2 +- app/models/request.rb | 6 +- app/models/request/library_creation.rb | 8 +- .../sample_compound_aliquot_transfer.rb | 2 +- app/models/request_factory.rb | 4 +- app/models/request_type/validation.rb | 2 +- app/models/role/user_role_helper.rb | 2 +- app/models/sample.rb | 2 +- app/models/sample_manifest.rb | 4 +- app/models/sample_manifest/core_behaviour.rb | 2 +- .../sample_manifest/library_tube_behaviour.rb | 2 +- .../multiplexed_library_behaviour.rb | 2 +- app/models/sample_manifest/plate_behaviour.rb | 2 +- .../sample_manifest/sample_tube_behaviour.rb | 2 +- .../sample_manifest/shared_tube_behaviour.rb | 6 +- app/models/sample_manifest/uploader.rb | 3 +- app/models/sequencing_pipeline.rb | 2 +- app/models/set_descriptors_task.rb | 14 +- app/models/state_change.rb | 8 +- app/models/state_changer/mx_tube.rb | 4 +- app/models/state_changer/standard_plate.rb | 4 +- app/models/stock_stamper.rb | 2 +- app/models/study/poly_metadata_handler.rb | 2 +- app/models/study_report/well_details.rb | 4 +- .../submission/asset_group_behaviour.rb | 2 +- .../submission/flexible_request_graph.rb | 8 +- app/models/submission/linear_request_graph.rb | 6 +- app/models/submission/submission_creator.rb | 10 +- app/models/supplier.rb | 2 +- app/models/tag2_layout_template.rb | 2 +- app/models/tag_layout_template.rb | 6 +- app/models/tag_substitution.rb | 2 +- .../tasks/add_spiked_in_control_handler.rb | 4 +- app/models/tasks/base_handler.rb | 2 +- app/models/tasks/cherrypick_handler.rb | 2 +- app/models/tasks/set_descriptors_handler.rb | 8 +- app/models/tube.rb | 4 +- app/models/user/authentication.rb | 6 +- app/models/uuid.rb | 4 +- app/resources/api/v2/tube_rack_resource.rb | 2 +- .../sample_manifest_excel/download.rb | 11 +- .../upload/processor/base.rb | 4 +- .../upload/processor/tube_rack.rb | 2 +- .../sample_manifest_excel/upload/rows.rb | 2 +- .../worksheet/data_worksheet.rb | 2 +- .../worksheet/test_worksheet.rb | 10 +- .../sequencescape_excel/column.rb | 6 +- .../sequencescape_excel/range_list.rb | 2 +- .../specialised_field/dual_index_tag_well.rb | 2 +- .../specialised_field/volume.rb | 2 +- .../sequencescape_excel/worksheet/base.rb | 2 +- .../generate_plate_concentrations.rb | 4 +- .../uat_actions/generate_plates.rb | 2 +- .../uat_actions/generate_primer_panel.rb | 4 +- .../uat_actions/generate_project.rb | 2 +- .../uat_actions/generate_qc_results.rb | 2 +- .../uat_actions/generate_sample_manifest.rb | 2 +- .../uat_actions/generate_tag_group.rb | 4 +- .../generate_tag_layout_template.rb | 4 +- .../uat_actions/generate_tag_plates.rb | 4 +- .../uat_actions/generate_tube_racks.rb | 4 +- app/uat_actions/uat_actions/generate_tubes.rb | 2 +- app/uat_actions/uat_actions/static_records.rb | 10 +- .../uat_actions/test_submission.rb | 8 +- .../uat_actions/tube_submission.rb | 8 +- ...4_migrate_sanger_barcodes_to_new_tables.rb | 4 +- ...52_migrate_other_barcodes_to_new_tables.rb | 4 +- ...815_remove_flexible_cherrypick_pipeline.rb | 2 +- ...30512102847_add_missing_insdc_countries.rb | 2 +- db/seeds/0001_tube_purposes.rb | 4 +- db/seeds/0001_workflows.rb | 48 +-- db/seeds/0015_tags.rb | 2 +- db/seeds/0016_tag_layout_templates.rb | 8 +- db/seeds/0019_plate_creators.rb | 2 +- db/seeds/3000_library_types_setup.rb | 18 +- db/seeds/9999_tag_qc_setup.rb | 4 +- features/support/accession_service.rb | 2 +- features/support/barcode_service.rb | 2 +- features/support/capybara.rb | 4 +- ...97_change_request_type_on_request_steps.rb | 9 +- ...equest_xml_exception_on_nil_study_steps.rb | 9 +- ...3383_bug_NPG_batch_state_released_steps.rb | 4 +- ...5_add_bait_library_editor_to_admin_view.rb | 6 +- ...92_links_from_study_workflow_view_steps.rb | 2 +- ..._descriptors_etc_to_table_columns_steps.rb | 2 +- .../4759010_bug_on_reset_batches_steps.rb | 4 +- ...sting_additional_hiseq_sequencing_steps.rb | 2 +- .../5197615_external_release_flag_steps.rb | 4 +- .../5397680_sequenome_plate_details_steps.rb | 2 +- ...xternal_data_release_interactions_steps.rb | 2 +- ...0471_truncate_sample_name_barcode_steps.rb | 2 +- ...play_concentration_inbox_pipeline_steps.rb | 2 +- .../step_definitions/65192392_tag_qc_steps.rb | 36 +- ...01_batch_request_recycling_broken_steps.rb | 6 +- ...9309_pulldown_cherrypick_pipeline_steps.rb | 3 +- .../support/step_definitions/api_steps.rb | 2 +- .../support/step_definitions/asset_steps.rb | 4 +- .../step_definitions/authentication_steps.rb | 2 +- .../support/step_definitions/barcode_steps.rb | 2 +- .../custom_metadatum_collection_steps.rb | 2 +- ...splay_submitted_at_inbox_pipeline_steps.rb | 3 +- .../step_definitions/genotyping_steps.rb | 17 +- .../step_definitions/pipeline_steps.rb | 8 +- .../support/step_definitions/plate_steps.rb | 31 +- .../step_definitions/pulldown_steps.rb | 12 +- .../step_definitions/sample_manifest_steps.rb | 3 +- .../step_definitions/study_report_steps.rb | 4 +- .../support/step_definitions/study_steps.rb | 4 +- .../step_definitions/submission_steps.rb | 2 +- .../step_definitions/tag_layout_steps.rb | 9 +- .../step_definitions/transfer_steps.rb | 2 +- .../support/step_definitions/tube_steps.rb | 2 +- .../support/step_definitions/user_steps.rb | 2 +- .../support/step_definitions/web_steps.rb | 6 +- lib/accession/accession/contact.rb | 2 +- lib/acts_as_descriptable.rb | 2 +- lib/event_factory.rb | 8 +- lib/insdc/import_countries.rb | 2 +- .../label_printer/label/base_plate.rb | 2 +- lib/label_printer/label_printer/pmb_client.rb | 2 +- lib/label_printer/label_printer/print_job.rb | 6 +- lib/limber/helper.rb | 4 +- lib/mbrave_tags_creator.rb | 12 +- lib/object_space_profile.rb | 2 +- lib/product_helpers.rb | 2 +- lib/record_loader/pipeline_loader.rb | 6 +- ...ipeline_request_information_type_loader.rb | 6 +- lib/record_loader/request_type_loader.rb | 2 +- lib/tasks/add_heron_product.rake | 2 +- .../add_missing_asset_audit_records.rake | 2 +- lib/tasks/add_traction_records.rake | 2 +- lib/tasks/benchmark_plate_transfer.rake | 8 +- lib/tasks/devour.rake | 2 +- lib/tasks/limber.rake | 12 +- lib/tasks/limber_dev.rake | 6 +- lib/views_schema.rb | 4 +- lib/working_setup/standard_seeder.rb | 10 +- spec/api/dilution_plate_purpose_spec.rb | 2 +- spec/api/extraction_attributes_spec.rb | 2 +- spec/api/multiplexed_library_tube_spec.rb | 2 +- spec/api/plate_purpose_spec.rb | 2 +- spec/api/request_types_spec.rb | 2 +- spec/api/specific_tube_creation_spec.rb | 6 +- spec/api/state_change_spec.rb | 27 +- spec/api/submission_pool_spec.rb | 30 +- spec/api/tube_creation_spec.rb | 6 +- .../data_worksheet_spec.rb | 4 +- spec/bulk_submission_excel/download_spec.rb | 2 +- .../api/v2/heron/plates_controller_spec.rb | 6 +- .../v2/heron/tube_racks_controller_spec.rb | 2 +- .../driver_files_controller_spec.rb | 2 +- .../labwhere_receptions_controller_spec.rb | 4 +- .../npg_actions/assets_controller_spec.rb | 12 +- .../receptacles_controller_spec.rb | 2 +- .../report_fails_controller_spec.rb | 4 +- .../robot_verifications_controller_spec.rb | 14 +- spec/controllers/searches_controller_spec.rb | 2 +- spec/factories/barcode_factories.rb | 4 +- spec/factories/batch_factories.rb | 4 +- spec/factories/lib_pcr_xp_factories.rb | 2 +- spec/factories/pipelines_factories.rb | 6 +- spec/factories/plate_factories.rb | 11 +- spec/factories/pulldown_factories.rb | 8 +- spec/factories/request_type_factories.rb | 16 +- spec/factories/sample_manifest_factories.rb | 8 +- spec/factories/shared_traits.rb | 4 +- spec/factories/tag_group_factories.rb | 2 +- spec/factories/tube_factories.rb | 4 +- spec/factories/well_factories.rb | 4 +- spec/features/assets/asset_submission_spec.rb | 6 +- .../features/batches/failing_requests_spec.rb | 7 +- spec/features/batches/sort_requests_spec.rb | 2 +- ...ncorrect_submission_id_on_transfer_spec.rb | 2 +- .../patient_consent_withdrawl_spec.rb | 10 +- ..._for_fluidigm_pipeline_micro_litre_spec.rb | 10 +- .../cherrypick/cherrypick_pipeline_spec.rb | 6 +- .../pipelines/creating_an_empty_batch_spec.rb | 2 +- .../following_a_sequencing_pipeline_spec.rb | 14 +- ...line_with_compound_sample_creation_spec.rb | 2 +- .../viewing_request_comments_spec.rb | 4 +- ...r_for_manifests_with_tag_sequences_spec.rb | 47 ++- ...ransfers_on_repools_starts_repools_spec.rb | 8 +- spec/features/studies/qc_reports_spec.rb | 6 +- .../studies/view_study_request_links_spec.rb | 2 +- .../submissions/bulk_submissions_spec.rb | 2 +- spec/features/tag_set_spec.rb | 4 +- spec/helpers/batches_helper_spec.rb | 4 +- .../heron/factories/concerns/contents_spec.rb | 2 +- spec/heron/factories/plate_spec.rb | 10 +- spec/heron/factories/sample_spec.rb | 30 +- spec/heron/factories/tube_spec.rb | 2 +- spec/lib/label_printer/batch_plate_spec.rb | 14 +- spec/lib/label_printer/swipecard_spec.rb | 8 +- spec/lib/limber/helper_spec.rb | 4 +- ...populate_numer_of_samples_per_pool_spec.rb | 2 +- .../record_loader/request_type_loader_spec.rb | 2 +- .../tag_layout_templates_loader_spec.rb | 8 +- spec/models/aliquot_spec.rb | 6 +- spec/models/api/aliquot_io_spec.rb | 10 +- spec/models/api/batch_io_spec.rb | 2 +- spec/models/api/library_tube_io_spec.rb | 4 +- spec/models/api/messages/flowcell_io_spec.rb | 2 +- .../messages/well_stock_resource_io_spec.rb | 2 +- spec/models/api/order_io_spec.rb | 6 +- spec/models/api/project_io_spec.rb | 2 +- spec/models/api/request_io_spec.rb | 2 +- spec/models/api/sample_tube_io_spec.rb | 2 +- spec/models/api/study_io_spec.rb | 2 +- spec/models/api/well_io_spec.rb | 8 +- spec/models/barcode/format_handlers_spec.rb | 2 +- .../broadcast_event/broadcast_event_spec.rb | 2 +- spec/models/broadcast_event/lab_event_spec.rb | 13 +- .../broadcast_event/library_complete_spec.rb | 4 +- .../broadcast_event/pool_released_spec.rb | 16 +- spec/models/broadcast_event/qc_assay_spec.rb | 4 +- .../sequencing_complete_spec.rb | 6 +- spec/models/bulk_submission_spec.rb | 4 +- spec/models/cherrypick_request_spec.rb | 2 +- .../cherrypick_task/control_locator_spec.rb | 2 +- spec/models/comment_spec.rb | 14 +- spec/models/external_release_event_spec.rb | 2 +- spec/models/linear_submission_spec.rb | 53 +-- spec/models/location_report_spec.rb | 4 +- spec/models/lot_type_spec.rb | 2 +- spec/models/orders/order_spec.rb | 15 +- spec/models/phi_x/spiked_buffer_spec.rb | 2 +- spec/models/phi_x/stock_spec.rb | 4 +- spec/models/pick_list_spec.rb | 4 +- spec/models/plate/quad_creator_spec.rb | 4 +- spec/models/plate_spec.rb | 8 +- spec/models/pooling_spec.rb | 9 +- spec/models/qc_report_spec.rb | 14 +- spec/models/qcable_creator_spec.rb | 4 +- spec/models/qcable_spec.rb | 2 +- spec/models/racked_tube_spec.rb | 2 +- spec/models/receptacle_spec.rb | 2 +- spec/models/request/traction/grid_ion_spec.rb | 10 +- spec/models/request_information_type_spec.rb | 6 +- spec/models/request_spec.rb | 12 +- .../validator/library_type_validator_spec.rb | 12 +- spec/models/robot/generator/tecan_spec.rb | 2 +- spec/models/sample_manifest/generator_spec.rb | 4 +- spec/models/sample_manifest_spec.rb | 9 +- spec/models/sequencing_request_spec.rb | 32 +- spec/models/specific_tube_creations_spec.rb | 12 +- .../state_changer/initial_stock_tube_spec.rb | 2 +- spec/models/state_changer/input_plate_spec.rb | 8 +- spec/models/state_changer/mx_tube_spec.rb | 2 +- .../state_changer/qcable_labware_spec.rb | 2 +- .../qcable_library_plate_spec.rb | 8 +- .../state_changer/standard_plate_spec.rb | 8 +- spec/models/std_library_request_spec.rb | 4 +- spec/models/study_spec.rb | 28 +- spec/models/submission_spec.rb | 30 +- spec/models/tag_layout_template_spec.rb | 10 +- spec/models/tag_set_spec.rb | 10 +- spec/models/tasks/cherrypick_task_spec.rb | 10 +- spec/models/tasks/plate_template_task_spec.rb | 6 +- .../set_descriptors_handler/handler_spec.rb | 4 +- spec/models/transfer/between_plates_spec.rb | 6 +- .../transfer_request_collection_spec.rb | 22 +- spec/models/transfer_request_spec.rb | 28 +- spec/models/tube_purpose_spec.rb | 2 +- spec/models/tube_rack_spec.rb | 8 +- spec/models/tube_spec.rb | 10 +- spec/models/user_query_spec.rb | 2 +- spec/models/well_spec.rb | 10 +- spec/models/work_order_spec.rb | 4 +- spec/requests/api/v2/heron/plates_spec.rb | 2 +- spec/requests/api/v2/heron/tube_racks_spec.rb | 4 +- spec/requests/qc_files_spec.rb | 2 +- .../api/v2/plate_purpose_resource_spec.rb | 2 +- spec/resources/api/v2/well_resource_spec.rb | 2 +- .../upload/processor_spec.rb | 140 ++++++-- spec/sample_manifest_excel/upload/row_spec.rb | 54 +-- .../sample_manifest_excel/upload/rows_spec.rb | 6 +- .../upload/upload_spec.rb | 6 +- spec/sample_manifest_excel/worksheet_spec.rb | 50 +-- spec/sequencescape_excel/range_spec.rb | 13 +- .../specialised_field_spec.rb | 322 ++++++++++-------- spec/sequencescape_excel/validation_spec.rb | 16 +- spec/sequencescape_excel/worksheet_spec.rb | 2 +- spec/shared_contexts/limber_shared_context.rb | 2 +- spec/spec_helper.rb | 4 +- spec/support/api_helper.rb | 6 +- spec/support/api_v2_helper.rb | 4 +- .../generate_sample_manifest_spec.rb | 6 +- spec/uat_actions/plate_information_spec.rb | 87 ++++- spec/views/labware/show_chromium_chip_spec.rb | 2 +- spec/views/labware/show_html_erb_spec.rb | 2 +- .../tube_rack_summaries/show_html_erb_spec.rb | 2 +- test/controllers/batches_controller_test.rb | 6 +- .../requests_comments_controller_test.rb | 2 +- test/functional/pre_cap_groups_test.rb | 2 +- test/lib/label_printer/batch_tube_test.rb | 4 +- test/lib/label_printer/plate_creator_test.rb | 6 +- test/lib/label_printer/print_job_test.rb | 10 +- test/performance/state_change_test.rb | 2 +- test/unit/accession_service_test.rb | 2 +- test/unit/import_fluidigm_data_test.rb | 12 +- test/unit/lab_interface/workflow_test.rb | 4 +- .../unit/lib_pool_norm_tube_generator_test.rb | 2 +- test/unit/plate_test.rb | 4 +- .../product_catalogue/library_driven_test.rb | 4 +- 379 files changed, 1703 insertions(+), 1114 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3584993ad7..cb9b1cdbab 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -56,6 +56,10 @@ Rails: Lint/AmbiguousRegexpLiteral: Exclude: - features/support/step_definitions/**/* + +Style/HashSyntax: + EnforcedShorthandSyntax: consistent + # Enforces 1234565789 as 123_456_789: While nice when dealing with actual big # numbers, we're more likely to see it shout at us about barcodes. Style/NumericLiterals: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2028d1174f..93ce4d036c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-26 12:06:07 UTC using RuboCop version 1.66.1. +# on 2024-09-26 13:53:59 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -327,7 +327,7 @@ Metrics/CyclomaticComplexity: Exclude: - 'lib/limber/helper.rb' -# Offense count: 7 +# Offense count: 8 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Exclude: @@ -337,6 +337,7 @@ Metrics/MethodLength: - 'app/uat_actions/uat_actions/tube_submission.rb' - 'app/validators/novaseqx_pe_validator.rb' - 'lib/record_loader/application_record_loader.rb' + - 'test/unit/import_fluidigm_data_test.rb' # Offense count: 13 Naming/AccessorMethodName: @@ -651,7 +652,7 @@ RSpec/EmptyExampleGroup: - 'spec/models/pulldown/requests_spec.rb' - 'spec/models/tag_substitutions_spec.rb' -# Offense count: 382 +# Offense count: 389 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: @@ -1969,7 +1970,7 @@ Style/GlobalStdStream: - 'config/environments/production.rb' - 'lib/tasks/limber_dev.rake' -# Offense count: 41 +# Offense count: 42 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: @@ -1996,6 +1997,7 @@ Style/GuardClause: - 'app/models/presenters/grouped_pipeline_inbox_presenter.rb' - 'app/models/pulldown/requests/bait_library_request.rb' - 'app/models/qc_file.rb' + - 'app/models/request.rb' - 'app/models/robot_property.rb' - 'app/models/sample_manifest.rb' - 'app/models/study.rb' @@ -2040,15 +2042,6 @@ Style/HashEachMethods: - 'spec/sequencescape_excel/range_list_spec.rb' - 'test/unit/fluidigm_file_test.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent, either_consistent -Style/HashSyntax: - Exclude: - - 'spec/models/transfer_request_spec.rb' - # Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). Style/IdenticalConditionalBranches: diff --git a/app/api/core/endpoint/basic_handler/paged.rb b/app/api/core/endpoint/basic_handler/paged.rb index d4a741373d..39bc0fccb3 100644 --- a/app/api/core/endpoint/basic_handler/paged.rb +++ b/app/api/core/endpoint/basic_handler/paged.rb @@ -47,7 +47,7 @@ def page_of_results(target, page = 1, model = target) raise ActiveRecord::RecordNotFound, 'before the start of the results' if page <= 0 target - .paginate(page:, per_page: results_per_page, total_entries: model.count(:all)) + .paginate(page: page, per_page: results_per_page, total_entries: model.count(:all)) .tap do |results| raise ActiveRecord::RecordNotFound, 'past the end of the results' if (page > 1) && (page > results.total_pages) end diff --git a/app/api/core/io/collection.rb b/app/api/core/io/collection.rb index c05e05de0f..ac2b42e6b2 100644 --- a/app/api/core/io/collection.rb +++ b/app/api/core/io/collection.rb @@ -9,7 +9,7 @@ def as_json(options = {}) ::Core::Io::Registry .instance .lookup_for_object(object) - .object_json(object, options.merge(stream:, target: object, nested: true)) + .object_json(object, options.merge(stream: stream, target: object, nested: true)) end end end diff --git a/app/api/core/io/json/stream.rb b/app/api/core/io/json/stream.rb index bd2c07bfee..523117eec6 100644 --- a/app/api/core/io/json/stream.rb +++ b/app/api/core/io/json/stream.rb @@ -80,7 +80,7 @@ def object_encode(object, options) ::Core::Io::Registry .instance .lookup_for_object(object) - .object_json(object, options.merge(stream: self, object:, nested: true)) + .object_json(object, options.merge(stream: self, object: object, nested: true)) end end private :object_encode diff --git a/app/api/core/service.rb b/app/api/core/service.rb index b122aed9ab..2ea9b16d41 100644 --- a/app/api/core/service.rb +++ b/app/api/core/service.rb @@ -238,7 +238,7 @@ def each(&block) # rubocop:todo Metrics/AbcSize ::Core::Io::Registry .instance .lookup_for_object(object) - .as_json(response: self, target: object, stream:, object:, handled_by:) + .as_json(response: self, target: object, stream: stream, object: object, handled_by: handled_by) end end diff --git a/app/bulk_submission_excel/bulk_submission_excel/download.rb b/app/bulk_submission_excel/bulk_submission_excel/download.rb index 0bf511bb2d..f3ac36104b 100644 --- a/app/bulk_submission_excel/bulk_submission_excel/download.rb +++ b/app/bulk_submission_excel/bulk_submission_excel/download.rb @@ -22,7 +22,8 @@ def new_record? end def ranges_worksheet - @ranges_worksheet ||= SequencescapeExcel::Worksheet::RangesWorksheet.new(ranges: range_list, workbook:) if valid? + @ranges_worksheet ||= + SequencescapeExcel::Worksheet::RangesWorksheet.new(ranges: range_list, workbook: workbook) if valid? end def submission_template_id=(id) @@ -38,11 +39,11 @@ def data_worksheet @data_worksheet ||= BulkSubmissionExcel::Worksheet::DataWorksheet.new( - workbook:, + workbook: workbook, columns: column_list, - assets:, + assets: assets, ranges: range_list, - defaults: + defaults: defaults ) end diff --git a/app/controllers/batches_controller.rb b/app/controllers/batches_controller.rb index 90436c6f86..40dbb73554 100644 --- a/app/controllers/batches_controller.rb +++ b/app/controllers/batches_controller.rb @@ -401,7 +401,7 @@ def standard_create(requests) # rubocop:todo Metrics/CyclomaticComplexity return pipeline_error_on_batch_creation('Batches must contain at least one request') if requests.empty? begin - ActiveRecord::Base.transaction { @batch = @pipeline.batches.create!(requests:, user: current_user) } + ActiveRecord::Base.transaction { @batch = @pipeline.batches.create!(requests: requests, user: current_user) } rescue ActiveRecord::RecordNotUnique => e # We don't explicitly check for this on creation of batch_request for performance reasons, and the front end # usually ensures this situation isn't possible. However if the user opens duplicate tabs it is possible. diff --git a/app/controllers/concerns/plate_picks/batches_json.rb b/app/controllers/concerns/plate_picks/batches_json.rb index e92f4e19b3..5458059ceb 100644 --- a/app/controllers/concerns/plate_picks/batches_json.rb +++ b/app/controllers/concerns/plate_picks/batches_json.rb @@ -9,7 +9,7 @@ def initialize(batch_id, pick_information, plate_information) end def to_json(_ = nil) - { batch: { id: @batch_id.to_s, picks: } } + { batch: { id: @batch_id.to_s, picks: picks } } end private diff --git a/app/controllers/driver_files_controller.rb b/app/controllers/driver_files_controller.rb index 261be0b57e..3dcd917368 100644 --- a/app/controllers/driver_files_controller.rb +++ b/app/controllers/driver_files_controller.rb @@ -11,7 +11,7 @@ class DriverFilesController < ApplicationController def show @plate_barcode = @batch.plate_barcode(params[:barcode]) - generator = @robot.generator(batch: @batch, plate_barcode: @plate_barcode, pick_number:) + generator = @robot.generator(batch: @batch, plate_barcode: @plate_barcode, pick_number: pick_number) base_filename = "#{@batch.id}_batch_#{@plate_barcode}_#{pick_number}" send_data generator.as_text, type: generator.type, diff --git a/app/controllers/plate_picks_controller.rb b/app/controllers/plate_picks_controller.rb index e1abc3f105..b9015b4bfc 100644 --- a/app/controllers/plate_picks_controller.rb +++ b/app/controllers/plate_picks_controller.rb @@ -32,7 +32,7 @@ def plates # rubocop:todo Metrics/AbcSize plate: { id: plate.id, barcode: plate.machine_barcode, - batches:, + batches: batches, control: plate.pick_as_control? } } diff --git a/app/controllers/qc_reports_controller.rb b/app/controllers/qc_reports_controller.rb index 3759991916..00be5cc7ea 100644 --- a/app/controllers/qc_reports_controller.rb +++ b/app/controllers/qc_reports_controller.rb @@ -47,9 +47,9 @@ def create # rubocop:todo Metrics/AbcSize, Metrics/MethodLength exclude_existing = params[:qc_report][:exclude_existing] == '1' qc_report = QcReport.new( - study:, + study: study, product_criteria: @product.stock_criteria, - exclude_existing:, + exclude_existing: exclude_existing, plate_purposes: params[:qc_report][:plate_purposes].try(:reject, &:blank?) ) diff --git a/app/controllers/receptacles_controller.rb b/app/controllers/receptacles_controller.rb index 67881ae8aa..dfc929bd8c 100644 --- a/app/controllers/receptacles_controller.rb +++ b/app/controllers/receptacles_controller.rb @@ -154,7 +154,7 @@ def create_request # rubocop:todo Metrics/AbcSize assets: [@asset], request_types: [@request_type.id], request_options: request_options.to_unsafe_h, - submission:, + submission: submission, comments: params[:comments] ) resubmission_order.save! diff --git a/app/controllers/studies_controller.rb b/app/controllers/studies_controller.rb index b5695abb3f..7b12853eed 100644 --- a/app/controllers/studies_controller.rb +++ b/app/controllers/studies_controller.rb @@ -301,7 +301,7 @@ def self.role_helper(name, success_action, error_action) # rubocop:todo Metrics/ end @roles = @study.roles.reload - render partial: 'roles', status: + render partial: 'roles', status: status end end end diff --git a/app/controllers/study_reports_controller.rb b/app/controllers/study_reports_controller.rb index 660fdea4ce..bf7d15b54f 100644 --- a/app/controllers/study_reports_controller.rb +++ b/app/controllers/study_reports_controller.rb @@ -26,7 +26,7 @@ def new def create # rubocop:todo Metrics/AbcSize, Metrics/MethodLength study = Study.find_by(id: params[:study_report][:study]) - study_report = StudyReport.create!(study:, user: @current_user) + study_report = StudyReport.create!(study: study, user: @current_user) study_report.schedule_report diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2231dc9af4..6c5cee0fc2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -56,7 +56,7 @@ def print_swipecard_with_pmb(swipecard, printer) # rubocop:todo Metrics/MethodLe printer, LabelPrinter::Label::Swipecard, user_login: @user.login.truncate(10, omission: '..'), - swipecard:, + swipecard: swipecard, label_template_name: configatron.swipecard_pmb_template ) if print_job.execute diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb index 5815236d8d..e8cb84a6c8 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -94,7 +94,7 @@ def render_task(task, params) private def create_batch_events(batch, task) - event = batch.lab_events.build(description: 'Complete', user: current_user, batch:) + event = batch.lab_events.build(description: 'Complete', user: current_user, batch: batch) event.add_descriptor Descriptor.new(name: 'task_id', value: task.id) event.add_descriptor Descriptor.new(name: 'task', value: task.name) event.save! diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0b92c65c93..eec978db39 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -170,7 +170,7 @@ def request_count_link(study, asset, state, request_type) # rubocop:todo Metrics url_path = request_path(matching_requests.first) link_to count, url_path, html_options elsif count > 1 - url_path = study_requests_path(study, state:, request_type_id: request_type.id, asset_id: asset.id) + url_path = study_requests_path(study, state: state, request_type_id: request_type.id, asset_id: asset.id) link_to count, url_path, html_options end end @@ -230,7 +230,7 @@ def tab(name, target: nil, active: false, id: nil) tag.li(class: 'nav-item') do link_to name, "##{target}", - id:, + id: id, data: { toggle: 'tab' }, @@ -247,7 +247,7 @@ def tab_pane(name, id: nil, tab_id: nil, active: false, &) tab_id ||= "#{name}-tab".parameterize id ||= name.parameterize active_class = active ? 'active' : '' - tag.div(class: ['tab-pane', 'fade', 'show', active_class], id:, role: 'tabpanel', aria_labelledby: tab_id, &) + tag.div(class: ['tab-pane', 'fade', 'show', active_class], id: id, role: 'tabpanel', aria_labelledby: tab_id, &) end def display_boolean_results(result) diff --git a/app/helpers/assets_helper.rb b/app/helpers/assets_helper.rb index 1773f4b2cd..2b52f81545 100644 --- a/app/helpers/assets_helper.rb +++ b/app/helpers/assets_helper.rb @@ -56,7 +56,7 @@ def select_field_sorted_by_name(field, select_options_source, selected, can_edit select_tag( field, options_for_select(select_options_source.sorted_by_name.pluck(:name, :id), selected.try(:to_i)), - options.merge(disabled:, class: 'form-control select2') + options.merge(disabled: disabled, class: 'form-control select2') ) end end diff --git a/app/helpers/bootstrap_helper.rb b/app/helpers/bootstrap_helper.rb index d889e89e5f..be46cd96f4 100644 --- a/app/helpers/bootstrap_helper.rb +++ b/app/helpers/bootstrap_helper.rb @@ -128,7 +128,7 @@ def progress_bar(count) # rubocop:todo Metrics/MethodLength # rubocop:enable Layout/LineLength def loading_bar(id = 'update_loader', show: false, text: 'Loading') tag.div(class: 'loading-bar-placeholder') do - tag.div(id:, class: 'loading-bar-container', style: show ? '' : 'display: none;') do + tag.div(id: id, class: 'loading-bar-container', style: show ? '' : 'display: none;') do tag.div(text, class: 'loading-bar', role: 'progressbar') end end diff --git a/app/helpers/compound_sample_helper.rb b/app/helpers/compound_sample_helper.rb index 99095f780c..41cee51014 100644 --- a/app/helpers/compound_sample_helper.rb +++ b/app/helpers/compound_sample_helper.rb @@ -22,6 +22,9 @@ def find_compound_sample_for_component_samples(component_samples) # Generates the compound sample def create_compound_sample(study, component_samples) - study.samples.create!(name: SangerSampleId.generate_sanger_sample_id!(study.abbreviation), component_samples:) + study.samples.create!( + name: SangerSampleId.generate_sanger_sample_id!(study.abbreviation), + component_samples: component_samples + ) end end diff --git a/app/helpers/prototype_replacement_helper.rb b/app/helpers/prototype_replacement_helper.rb index 291302dd16..1dca76a984 100644 --- a/app/helpers/prototype_replacement_helper.rb +++ b/app/helpers/prototype_replacement_helper.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module PrototypeReplacementHelper def remote_button(label, url, data, html_options = {}) - form_tag url, remote: true, data:, class: 'remote-form' do + form_tag url, remote: true, data: data, class: 'remote-form' do submit_tag(label, html_options) end end diff --git a/app/heron/factories/plate.rb b/app/heron/factories/plate.rb index f8cfd7a8f2..902dcdaab9 100644 --- a/app/heron/factories/plate.rb +++ b/app/heron/factories/plate.rb @@ -38,7 +38,7 @@ def save # rubocop:todo Metrics/MethodLength ActiveRecord::Base.transaction do @plate = purpose.create! - Barcode.create!(labware: @plate, barcode:, format: barcode_format) + Barcode.create!(labware: @plate, barcode: barcode, format: barcode_format) create_contents! diff --git a/app/heron/factories/sample.rb b/app/heron/factories/sample.rb index d90e5fcf9c..883daf85f5 100644 --- a/app/heron/factories/sample.rb +++ b/app/heron/factories/sample.rb @@ -101,7 +101,7 @@ def all_fields_are_existing_columns end def params_for_sample_creation - { name: sanger_sample_id, sanger_sample_id: }.merge(params_for_sample_table) + { name: sanger_sample_id, sanger_sample_id: sanger_sample_id }.merge(params_for_sample_table) end def params_for_aliquot_creation diff --git a/app/heron/factories/tube.rb b/app/heron/factories/tube.rb index d7ef6f2860..aa3822ac39 100644 --- a/app/heron/factories/tube.rb +++ b/app/heron/factories/tube.rb @@ -16,7 +16,7 @@ def create return unless valid? @sample_tube = SampleTube.create! - Barcode.create!(labware_id: @sample_tube.id, barcode:, format: barcode_format) + Barcode.create!(labware_id: @sample_tube.id, barcode: barcode, format: barcode_format) @sample_tube end diff --git a/app/heron/factories/tube_rack.rb b/app/heron/factories/tube_rack.rb index e6708fde3b..59dd7cef3d 100644 --- a/app/heron/factories/tube_rack.rb +++ b/app/heron/factories/tube_rack.rb @@ -52,12 +52,12 @@ def save ActiveRecord::Base.transaction do @tube_rack = ::TubeRack.create!(size:, purpose:) - Barcode.create!(labware: tube_rack, barcode:, format: barcode_format) + Barcode.create!(labware: tube_rack, barcode: barcode, format: barcode_format) create_recipients! create_contents! - ::TubeRackStatus.create!(barcode:, status: :created, labware: @tube_rack) + ::TubeRackStatus.create!(barcode: barcode, status: :created, labware: @tube_rack) end true end @@ -85,7 +85,7 @@ def create_tubes!(tube_rack) recipients.keys.map do |coordinate| tube_factory = recipients[coordinate] sample_tube = tube_factory.create - RackedTube.create(tube: sample_tube, coordinate: unpad_coordinate(coordinate), tube_rack:) + RackedTube.create(tube: sample_tube, coordinate: unpad_coordinate(coordinate), tube_rack: tube_rack) end end diff --git a/app/jobs/export_pool_xp_to_traction_job.rb b/app/jobs/export_pool_xp_to_traction_job.rb index 593b8173d0..e30c7d5acc 100644 --- a/app/jobs/export_pool_xp_to_traction_job.rb +++ b/app/jobs/export_pool_xp_to_traction_job.rb @@ -99,8 +99,8 @@ def send_message(message, subject, version) begin channel = conn.create_channel exchange = channel.headers(configatron.amqp.isg.exchange, passive: true) - headers = { subject:, version:, encoder_type: 'binary' } - exchange.publish(message, headers:, persistent: true) + headers = { subject: subject, version: version, encoder_type: 'binary' } + exchange.publish(message, headers: headers, persistent: true) ensure conn.close end diff --git a/app/jobs/sample_manifest/generate_wells_job.rb b/app/jobs/sample_manifest/generate_wells_job.rb index e381259e5f..a2e090c863 100644 --- a/app/jobs/sample_manifest/generate_wells_job.rb +++ b/app/jobs/sample_manifest/generate_wells_job.rb @@ -22,7 +22,7 @@ def plate def create_sample_manifest_assets(well, sanger_sample_ids) sanger_sample_ids.each do |sanger_sample_id| - SampleManifestAsset.create(sanger_sample_id:, asset: well, sample_manifest:) + SampleManifestAsset.create(sanger_sample_id: sanger_sample_id, asset: well, sample_manifest: sample_manifest) end end diff --git a/app/middleware/api/root_service.rb b/app/middleware/api/root_service.rb index aa7a9dd8ca..28cc35f687 100644 --- a/app/middleware/api/root_service.rb +++ b/app/middleware/api/root_service.rb @@ -32,7 +32,7 @@ def @owner.each(&block) nested_stream.block('actions') do |actions_stream| endpoint .model_handler - .send(:actions, endpoint.model_handler, response: self, endpoint:) + .send(:actions, endpoint.model_handler, response: self, endpoint: endpoint) .map { |action, url| actions_stream.attribute(action, url) } end end diff --git a/app/models/accessionable/dac.rb b/app/models/accessionable/dac.rb index 0813e3df4b..2819e8cf0b 100644 --- a/app/models/accessionable/dac.rb +++ b/app/models/accessionable/dac.rb @@ -24,7 +24,7 @@ def xml # rubocop:todo Metrics/MethodLength xml = Builder::XmlMarkup.new xml.instruct! xml.DAC_SET('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') do - xml.DAC(alias: self.alias, accession: accession_number, center_name:) do + xml.DAC(alias: self.alias, accession: accession_number, center_name: center_name) do xml.CONTACTS do contacts.each do |contact| xml.CONTACT(name: contact[:name], email: contact[:email], organisation: contact[:organisation]) diff --git a/app/models/accessionable/policy.rb b/app/models/accessionable/policy.rb index b055b020ed..da8ade3600 100644 --- a/app/models/accessionable/policy.rb +++ b/app/models/accessionable/policy.rb @@ -31,7 +31,7 @@ def xml xml = Builder::XmlMarkup.new xml.instruct! xml.POLICY_SET('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') do - xml.POLICY(alias: self.alias, accession: accession_number, center_name:) do + xml.POLICY(alias: self.alias, accession: accession_number, center_name: center_name) do xml.TITLE title xml.DAC_REF(accession: dac_accession_number) xml.POLICY_FILE policy_url diff --git a/app/models/add_spiked_in_control_task.rb b/app/models/add_spiked_in_control_task.rb index 27531a7fc8..61f37433dc 100644 --- a/app/models/add_spiked_in_control_task.rb +++ b/app/models/add_spiked_in_control_task.rb @@ -30,7 +30,12 @@ def can_process?(batch) end def do_task(workflows_controller, params, user) - Tasks::AddSpikedInControlHandler::Handler.new(controller: workflows_controller, params:, task: self, user:).perform + Tasks::AddSpikedInControlHandler::Handler.new( + controller: workflows_controller, + params: params, + task: self, + user: user + ).perform end def fields_for(requests) diff --git a/app/models/aliquot.rb b/app/models/aliquot.rb index adec8d3a57..ed6b507b4a 100644 --- a/app/models/aliquot.rb +++ b/app/models/aliquot.rb @@ -115,7 +115,11 @@ def aliquot_index_value end def created_with_request_options - { fragment_size_required_from: insert_size_from, fragment_size_required_to: insert_size_to, library_type: } + { + fragment_size_required_from: insert_size_from, + fragment_size_required_to: insert_size_to, + library_type: library_type + } end # Validating the uniqueness of tags in rails was causing issues, as it was resulting the in the diff --git a/app/models/asset_audit.rb b/app/models/asset_audit.rb index 5379f57632..4a5da9e51f 100644 --- a/app/models/asset_audit.rb +++ b/app/models/asset_audit.rb @@ -18,6 +18,6 @@ class AssetAudit < ApplicationRecord private def broadcast_event - BroadcastEvent::AssetAudit.create!(seed: self, user: User.find_by(login: created_by), created_at:) + BroadcastEvent::AssetAudit.create!(seed: self, user: User.find_by(login: created_by), created_at: created_at) end end diff --git a/app/models/attributable/association.rb b/app/models/attributable/association.rb index 7404f97c9f..475ba4d744 100644 --- a/app/models/attributable/association.rb +++ b/app/models/attributable/association.rb @@ -71,7 +71,12 @@ def selection_options(_) end def to_field_info(*_args) - FieldInfo.new(display_name:, key: assignable_attribute_name, kind:, selection: selection_options(nil)) + FieldInfo.new( + display_name: display_name, + key: assignable_attribute_name, + kind: kind, + selection: selection_options(nil) + ) end def configure(target) # rubocop:todo Metrics/MethodLength diff --git a/app/models/attributable/attribute.rb b/app/models/attributable/attribute.rb index bb00ecba4b..58e0805956 100644 --- a/app/models/attributable/attribute.rb +++ b/app/models/attributable/attribute.rb @@ -86,7 +86,7 @@ def configure(model) # rubocop:todo Metrics/CyclomaticComplexity model.with_options(conditions) do |object| # false.blank? == true, so we exclude booleans here, they handle themselves further down. object.validates_presence_of(name) if required? && !boolean? - object.with_options(allow_nil: optional?, allow_blank:) do |required| + object.with_options(allow_nil: optional?, allow_blank: allow_blank) do |required| required.validates_inclusion_of(name, in: [true, false]) if boolean? if integer? || float? required.validates name, numericality: { only_integer: integer?, greater_than_or_equal_to: minimum } @@ -174,10 +174,10 @@ def selection_options(validator_source) def to_field_info(validator_source = nil) options = { # TODO[xxx]: currently only working for metadata, the only place attributes are used - display_name:, + display_name: display_name, key: assignable_attribute_name, default_value: find_default(validator_source), - kind:, + kind: kind, required: required? } options.update(selection: selection_options(validator_source)) if selection? diff --git a/app/models/barcode.rb b/app/models/barcode.rb index 2579227fc7..92576d6684 100644 --- a/app/models/barcode.rb +++ b/app/models/barcode.rb @@ -154,7 +154,7 @@ def self.build_sequencescape22(attributes) def self.build_sanger_barcode(attributes, format:) # We need to symbolize our hash keys to allow them to get passed in to named arguments. safe_attributes = attributes.slice(:number, :prefix, :human_barcode, :machine_barcode).symbolize_keys - new(format:, barcode: SBCF::SangerBarcode.new(**safe_attributes).human_barcode) + new(format: format, barcode: SBCF::SangerBarcode.new(**safe_attributes).human_barcode) end # Extract barcode from user input diff --git a/app/models/barcode/barcodeable.rb b/app/models/barcode/barcodeable.rb index f847fd0c3c..65f8062236 100644 --- a/app/models/barcode/barcodeable.rb +++ b/app/models/barcode/barcodeable.rb @@ -96,7 +96,7 @@ def foreign_barcode=(barcode) raise "Foreign Barcode: #{barcode} is already in use!" if Barcode.exists_for_format?(barcode_format, barcode) - barcodes << Barcode.new(format: barcode_format, barcode:) + barcodes << Barcode.new(format: barcode_format, barcode: barcode) end # ***** End getter and setter methods for foreign barcodes ***** diff --git a/app/models/batch.rb b/app/models/batch.rb index 6acf134986..27a67a1ab3 100644 --- a/app/models/batch.rb +++ b/app/models/batch.rb @@ -138,10 +138,10 @@ def fail(reason, comment, ignore_requests = false) raise StandardError, 'Can not fail batch without failing requests' if ignore_requests # create failures - failures.create(reason:, comment:, notify_remote: false) + failures.create(reason: reason, comment: comment, notify_remote: false) requests.each do |request| - request.failures.create(reason:, comment:, notify_remote: true) + request.failures.create(reason: reason, comment: comment, notify_remote: true) EventSender.send_fail_event(request, reason, comment, id) unless request.asset && request.asset.resource? end @@ -158,7 +158,7 @@ def fail_requests(requests_to_fail, reason, comment, fail_but_charge = false) # logger.debug "SENDING FAIL FOR REQUEST #{request.id}, BATCH #{id}, WITH REASON #{reason}" request.customer_accepts_responsibility! if fail_but_charge - request.failures.create(reason:, comment:, notify_remote: true) + request.failures.create(reason: reason, comment: comment, notify_remote: true) EventSender.send_fail_event(request, reason, comment, id) end update_batch_state(reason, comment) @@ -167,7 +167,7 @@ def fail_requests(requests_to_fail, reason, comment, fail_but_charge = false) # def update_batch_state(reason, comment) if requests.all?(&:terminated?) - failures.create(reason:, comment:, notify_remote: false) + failures.create(reason: reason, comment: comment, notify_remote: false) self.production_state = 'fail' save! end @@ -310,7 +310,7 @@ def verify_tube_layout(barcodes, user = nil) # rubocop:todo Metrics/AbcSize end end if errors.empty? - lab_events.create(description: 'Tube layout verified', user:) + lab_events.create(description: 'Tube layout verified', user: user) true else false @@ -331,7 +331,7 @@ def remove_request_ids(request_ids, reason = nil, comment = nil) Request .find(request_ids) .each do |request| - request.failures.create(reason:, comment:, notify_remote: true) + request.failures.create(reason: reason, comment: comment, notify_remote: true) detach_request(request) end update_batch_state(reason, comment) @@ -465,7 +465,7 @@ def robot_verified!(user_id) lab_events.create( description: 'Robot verified', message: 'Robot verification completed and source volumes updated.', - user_id: + user_id: user_id ) end diff --git a/app/models/batch/state_machine_behaviour.rb b/app/models/batch/state_machine_behaviour.rb index 316188f314..c37e35caa9 100644 --- a/app/models/batch/state_machine_behaviour.rb +++ b/app/models/batch/state_machine_behaviour.rb @@ -62,7 +62,7 @@ def complete_with_user!(user) def create_complete_batch_event_for(user) lab_events - .create!(batch: self, user:, description: 'Complete') + .create!(batch: self, user: user, description: 'Complete') .tap do |event| event.add_descriptor Descriptor.new(name: 'pipeline_id', value: pipeline.id) event.add_descriptor Descriptor.new(name: 'pipeline', value: pipeline.name) @@ -80,7 +80,7 @@ def release_with_user!(user) def create_release_batch_event_for(user) # rubocop:todo Metrics/AbcSize lab_events - .create!(batch: self, user:, description: 'Released') + .create!(batch: self, user: user, description: 'Released') .tap do |event| event.add_descriptor Descriptor.new(name: 'workflow_id', value: workflow.id) event.add_descriptor Descriptor.new(name: 'workflow', value: "Released from #{workflow.name}") diff --git a/app/models/batch_request.rb b/app/models/batch_request.rb index 7f1ed42a8f..c80d7191de 100644 --- a/app/models/batch_request.rb +++ b/app/models/batch_request.rb @@ -34,7 +34,7 @@ class BatchRequest < ApplicationRecord broadcast_with_warren def move_to_position!(position) - update!(sorting_requests_within_batch: true, position:) + update!(sorting_requests_within_batch: true, position: position) end private diff --git a/app/models/bulk_submission.rb b/app/models/bulk_submission.rb index cbcc2be48a..755c184a92 100644 --- a/app/models/bulk_submission.rb +++ b/app/models/bulk_submission.rb @@ -176,7 +176,7 @@ def process # rubocop:todo Metrics/CyclomaticComplexity submission = Submission.create!( name: submission_name, - user:, + user: user, orders: orders_processed, priority: max_priority(orders) ) @@ -355,11 +355,11 @@ def prepare_order(details) # rubocop:todo Metrics/CyclomaticComplexity # Set up the order attributes attributes = { - study:, - project:, - user:, + study: study, + project: project, + user: user, comments: details['comments'], - request_options:, + request_options: request_options, pre_cap_group: details['pre-capture group'] } diff --git a/app/models/bulk_transfer.rb b/app/models/bulk_transfer.rb index f2c93a50c5..cce2cfc221 100644 --- a/app/models/bulk_transfer.rb +++ b/app/models/bulk_transfer.rb @@ -42,7 +42,13 @@ class BulkTransfer < ApplicationRecord def build_transfers! ActiveRecord::Base.transaction do each_transfer do |source, destination, transfers| - Transfer::BetweenPlates.create!(source:, destination:, user:, transfers:, bulk_transfer_id: id) + Transfer::BetweenPlates.create!( + source: source, + destination: destination, + user: user, + transfers: transfers, + bulk_transfer_id: id + ) end end end diff --git a/app/models/cherrypick_request.rb b/app/models/cherrypick_request.rb index 9463bb69dd..d450d3671b 100644 --- a/app/models/cherrypick_request.rb +++ b/app/models/cherrypick_request.rb @@ -28,6 +28,6 @@ def reduce_source_volume # The transfer requests handle the actual transfer def transfer_aliquots - TransferRequest.create!(asset:, target_asset:, outer_request: self) + TransferRequest.create!(asset: asset, target_asset: target_asset, outer_request: self) end end diff --git a/app/models/compound_aliquot.rb b/app/models/compound_aliquot.rb index ccbbbd8ca4..97f082d4dd 100644 --- a/app/models/compound_aliquot.rb +++ b/app/models/compound_aliquot.rb @@ -59,8 +59,8 @@ def source_aliquots_have_same_project def aliquot_attributes { - tag_id:, - tag2_id:, + tag_id: tag_id, + tag2_id: tag2_id, library_type: default_library_type, study_id: default_compound_study.id, project_id: default_compound_project_id, diff --git a/app/models/event/labware_failed_event.rb b/app/models/event/labware_failed_event.rb index c7fb8c7bf2..00926664e9 100644 --- a/app/models/event/labware_failed_event.rb +++ b/app/models/event/labware_failed_event.rb @@ -11,7 +11,7 @@ def self.create_for_asset!(asset, failure_id, created_by) message: "Labware failed for reason: #{failure_id}", content: Time.zone.today.to_s, family: 'labware_failure', - created_by: + created_by: created_by ) end end diff --git a/app/models/event/sample_logistics_qc_event.rb b/app/models/event/sample_logistics_qc_event.rb index 045f50481f..be42944271 100644 --- a/app/models/event/sample_logistics_qc_event.rb +++ b/app/models/event/sample_logistics_qc_event.rb @@ -10,6 +10,12 @@ def self.create_gel_qc_for_asset!(asset, result, user) end def self.gel_qc_message(asset, message, family, user) - create!(eventful: asset, message:, content: Date.today.to_s, family:, created_by: user ? user.login : nil) + create!( + eventful: asset, + message: message, + content: Date.today.to_s, + family: family, + created_by: user ? user.login : nil + ) end end diff --git a/app/models/event/scanned_into_lab_event.rb b/app/models/event/scanned_into_lab_event.rb index 270d6ebba0..d37c26e5ed 100644 --- a/app/models/event/scanned_into_lab_event.rb +++ b/app/models/event/scanned_into_lab_event.rb @@ -9,7 +9,7 @@ def self.create_for_asset!(asset, location_barcode, created_by) message: "Scanned into #{location_barcode}", content: Date.today.to_s, family: 'scanned_into_lab', - created_by: + created_by: created_by ) end diff --git a/app/models/event_sender.rb b/app/models/event_sender.rb index 28a4d674fb..1ff68d4d28 100644 --- a/app/models/event_sender.rb +++ b/app/models/event_sender.rb @@ -21,7 +21,7 @@ def self.send_state_event(state, request, reason, comment, batch_id, user = nil) end def self.send_request_update(request, family, message, options = nil) - hash = { eventful: request, family:, message: } + hash = { eventful: request, family: family, message: message } create!(hash.merge(options || {})) end @@ -29,7 +29,7 @@ def self.send_pick_event(well, purpose_name, message, options = nil) hash = { eventful: well, family: PlatesHelper.event_family_for_pick(purpose_name), - message:, + message: message, content: Date.today.to_s } create!(hash.merge(options || {})) diff --git a/app/models/illumina_htp/requests/gbs_request.rb b/app/models/illumina_htp/requests/gbs_request.rb index 1ae49bee16..0cd3a89526 100644 --- a/app/models/illumina_htp/requests/gbs_request.rb +++ b/app/models/illumina_htp/requests/gbs_request.rb @@ -26,9 +26,9 @@ def aliquot_attributes { study_id: initial_study_id, project_id: initial_project_id, - library_type:, - insert_size:, - primer_panel_id:, + library_type: library_type, + insert_size: insert_size, + primer_panel_id: primer_panel_id, request_id: id } end diff --git a/app/models/illumina_htp/requests/heron_request.rb b/app/models/illumina_htp/requests/heron_request.rb index 75fb7ed19d..c02ad97e5e 100644 --- a/app/models/illumina_htp/requests/heron_request.rb +++ b/app/models/illumina_htp/requests/heron_request.rb @@ -30,9 +30,9 @@ def aliquot_attributes { study_id: initial_study_id, project_id: initial_project_id, - library_type:, - insert_size:, - primer_panel_id:, + library_type: library_type, + insert_size: insert_size, + primer_panel_id: primer_panel_id, request_id: id } end diff --git a/app/models/illumina_htp/requests/heron_tailed_request.rb b/app/models/illumina_htp/requests/heron_tailed_request.rb index ee8632cf00..1074322e88 100644 --- a/app/models/illumina_htp/requests/heron_tailed_request.rb +++ b/app/models/illumina_htp/requests/heron_tailed_request.rb @@ -42,9 +42,9 @@ def aliquot_attributes { study_id: initial_study_id, project_id: initial_project_id, - library_type:, - insert_size:, - primer_panel_id:, + library_type: library_type, + insert_size: insert_size, + primer_panel_id: primer_panel_id, library_id: asset_id, request_id: id } diff --git a/app/models/lab_event.rb b/app/models/lab_event.rb index 6169e9e3b5..9b8fbb5269 100644 --- a/app/models/lab_event.rb +++ b/app/models/lab_event.rb @@ -39,6 +39,6 @@ def add_new_descriptor(name, value) end def generate_broadcast_event - BroadcastEvent::LabEvent.create!(seed: self, user:) + BroadcastEvent::LabEvent.create!(seed: self, user: user) end end diff --git a/app/models/labwhere_reception.rb b/app/models/labwhere_reception.rb index 7470b5cf3b..7cd04df19e 100644 --- a/app/models/labwhere_reception.rb +++ b/app/models/labwhere_reception.rb @@ -47,7 +47,12 @@ def save # rubocop:todo Metrics/AbcSize return false unless valid? begin - scan = LabWhereClient::Scan.create(location_barcode:, user_code:, labware_barcodes: asset_barcodes) + scan = + LabWhereClient::Scan.create( + location_barcode: location_barcode, + user_code: user_code, + labware_barcodes: asset_barcodes + ) unless scan.valid? # Prepend the errors with 'Labwhere' to make it clear where the error came from @@ -64,7 +69,7 @@ def save # rubocop:todo Metrics/AbcSize assets.each do |asset| asset.events.create_scanned_into_lab!(location_barcode, user.login) - BroadcastEvent::LabwareReceived.create!(seed: asset, user:, properties: { location_barcode: }) + BroadcastEvent::LabwareReceived.create!(seed: asset, user: user, properties: { location_barcode: }) end valid? diff --git a/app/models/lib_pool_norm_tube_generator.rb b/app/models/lib_pool_norm_tube_generator.rb index d54d9d57e5..83dfb442db 100644 --- a/app/models/lib_pool_norm_tube_generator.rb +++ b/app/models/lib_pool_norm_tube_generator.rb @@ -53,7 +53,7 @@ def create! # rubocop:todo Metrics/AbcSize @asset_group = AssetGroup.create!( assets: destination_tubes.map(&:receptacle), - study:, + study: study, name: "#{plate.human_barcode}_qc_completed_tubes" ) end @@ -71,14 +71,14 @@ def create! # rubocop:todo Metrics/AbcSize private def create_lib_pool_norm_tube(tube) - destination_tube = transfer_template.create!(user:, source: tube).destination + destination_tube = transfer_template.create!(user: user, source: tube).destination destination_tubes << destination_tube destination_tube end def pass_and_complete(tube) - StateChange.create!(user:, target: tube, target_state: 'passed') - StateChange.create!(user:, target: tube, target_state: 'qc_complete') + StateChange.create!(user: user, target: tube, target_state: 'passed') + StateChange.create!(user: user, target: tube, target_state: 'qc_complete') end def check_state diff --git a/app/models/library_creation_request.rb b/app/models/library_creation_request.rb index 5c7eb85c9b..59d52da323 100644 --- a/app/models/library_creation_request.rb +++ b/app/models/library_creation_request.rb @@ -43,6 +43,12 @@ def on_started # @return [Hash] A hash of aliquot attributes # def aliquot_attributes - { study_id: initial_study_id, project_id: initial_project_id, library_type:, insert_size:, request_id: id } + { + study_id: initial_study_id, + project_id: initial_project_id, + library_type: library_type, + insert_size: insert_size, + request_id: id + } end end diff --git a/app/models/location_report/location_report_form.rb b/app/models/location_report/location_report_form.rb index fda732c781..3d6405eb3f 100644 --- a/app/models/location_report/location_report_form.rb +++ b/app/models/location_report/location_report_form.rb @@ -35,16 +35,16 @@ def location_report @location_report || @location_report = LocationReport.new( - user:, - name:, - report_type:, - location_barcode:, - faculty_sponsor_ids:, - study_id:, + user: user, + name: name, + report_type: report_type, + location_barcode: location_barcode, + faculty_sponsor_ids: faculty_sponsor_ids, + study_id: study_id, start_date: start_date&.to_datetime, end_date: end_date&.to_datetime, - plate_purpose_ids:, - barcodes: + plate_purpose_ids: plate_purpose_ids, + barcodes: barcodes ) end diff --git a/app/models/metadata.rb b/app/models/metadata.rb index 488385afe4..0c5010f150 100644 --- a/app/models/metadata.rb +++ b/app/models/metadata.rb @@ -23,7 +23,7 @@ def build_association(as_class, options) # rubocop:todo Metrics/MethodLength class_name = "#{name}::Metadata" default_options = { - class_name:, + class_name: class_name, dependent: :destroy, validate: true, autosave: true, diff --git a/app/models/metadata/form_builder.rb b/app/models/metadata/form_builder.rb index 08bec8a67e..8e41e21b47 100644 --- a/app/models/metadata/form_builder.rb +++ b/app/models/metadata/form_builder.rb @@ -59,7 +59,7 @@ def radio_select(method, choices, options = {}, html_options = {}) # rubocop:tod output << tag.div(class: %w[custom-control custom-radio custom-control-inline]) do value = option_value || label_text concat radio_button(method, value, class: 'custom-control-input', required: true) - concat label(method, label_text, class: 'custom-control-label', value:) + concat label(method, label_text, class: 'custom-control-label', value: value) end end end @@ -161,7 +161,7 @@ def finalize_related_fields partial: 'shared/metadata/related_fields', locals: { root: sanitized_object_name, - related:, + related: related, changing_fields: @changing } ) diff --git a/app/models/order.rb b/app/models/order.rb index 6c9289e086..518a85940d 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -286,7 +286,7 @@ def subject_type end def generate_broadcast_event - BroadcastEvent::OrderMade.create!(seed: self, user:) + BroadcastEvent::OrderMade.create!(seed: self, user: user) end def study_is_active diff --git a/app/models/phi_x/spiked_buffer.rb b/app/models/phi_x/spiked_buffer.rb index 53f538e7dc..1ffe84e786 100644 --- a/app/models/phi_x/spiked_buffer.rb +++ b/app/models/phi_x/spiked_buffer.rb @@ -112,7 +112,7 @@ def generate_spiked_buffers # rubocop:todo Metrics/AbcSize, Metrics/MethodLength receptacle.save! receptacle .transfer_requests_as_target - .build(asset: parent.receptacle, target_asset: receptacle, aliquot_attributes:) + .build(asset: parent.receptacle, target_asset: receptacle, aliquot_attributes: aliquot_attributes) .save! end parent.children << spiked_buffer diff --git a/app/models/phi_x/stock.rb b/app/models/phi_x/stock.rb index b826157cf7..4ce9ff644e 100644 --- a/app/models/phi_x/stock.rb +++ b/app/models/phi_x/stock.rb @@ -62,7 +62,13 @@ def generate_stocks # rubocop:todo Metrics/AbcSize .stock_purpose .create!(name: "#{name} ##{index + 1}") do |tube| tube.receptacle.qc_results.build(key: 'molarity', value: concentration, units: 'nM') - tube.receptacle.aliquots.build(sample: phi_x_sample, tag: i7_tag, tag2: i5_tag, library: tube, study_id:) + tube.receptacle.aliquots.build( + sample: phi_x_sample, + tag: i7_tag, + tag2: i5_tag, + library: tube, + study_id: study_id + ) end end end diff --git a/app/models/pick_list.rb b/app/models/pick_list.rb index 48cb4f8e10..53f01fc8cf 100644 --- a/app/models/pick_list.rb +++ b/app/models/pick_list.rb @@ -44,7 +44,9 @@ def pick_attributes=(picks) def pick_attributes orders.flat_map do |order| - order.assets.map { |source_receptacle| { source_receptacle:, study: order.study, project: order.project } } + order.assets.map do |source_receptacle| + { source_receptacle: source_receptacle, study: order.study, project: order.project } + end end end @@ -98,7 +100,7 @@ def request_type def build_order(pick_group, order_options) AutomatedOrder.new( - user:, + user: user, assets: pick_group.map(&:source_receptacle), request_types: [request_type_id], **order_options # Merge the order options into the arguments @@ -106,7 +108,7 @@ def build_order(pick_group, order_options) end def create_batch! - Batch.create!(requests: submission.requests.reload, pipeline:, user:) + Batch.create!(requests: submission.requests.reload, pipeline: pipeline, user: user) end def user diff --git a/app/models/pick_list/record_cache.rb b/app/models/pick_list/record_cache.rb index 5b07f9085e..2e4913cef3 100644 --- a/app/models/pick_list/record_cache.rb +++ b/app/models/pick_list/record_cache.rb @@ -41,7 +41,7 @@ def convert(entry) study_id, project_id = entry.values_at(:study_id, :project_id) other_keys = entry.except(*LABWARE_KEYS).to_hash source_receptacles.map do |source_receptacle| - other_keys.merge(source_receptacle:, study: study(study_id), project: project(project_id)) + other_keys.merge(source_receptacle: source_receptacle, study: study(study_id), project: project(project_id)) end end diff --git a/app/models/plate.rb b/app/models/plate.rb index 086fc5f859..79bc9c6530 100644 --- a/app/models/plate.rb +++ b/app/models/plate.rb @@ -63,7 +63,7 @@ def construct! # rubocop:todo Metrics/AbcSize # Warren::Message::Short keeps track of the class (Well) and id, and gets sent after # the transaction completes. This avoids us needing to instantiate wells, keeping the memory footprint # down. - ids.each { |id| Warren::Message::Short.new(class_name: 'Well', id:).queue(Warren.handler) } + ids.each { |id| Warren::Message::Short.new(class_name: 'Well', id: id).queue(Warren.handler) } end end end @@ -426,7 +426,7 @@ def update_qc_values_with_parser(parser) unit_value: value, assay_type: parser.assay_type, assay_version: parser.assay_version, - qc_assay: + qc_assay: qc_assay ) end end diff --git a/app/models/plate/creator.rb b/app/models/plate/creator.rb index f2cb945a20..f363f98f5f 100644 --- a/app/models/plate/creator.rb +++ b/app/models/plate/creator.rb @@ -81,8 +81,8 @@ def execute(source_plate_barcodes, barcode_printer, scanned_user, should_create_ LabelPrinter::PrintJob.new( barcode_printer.name, LabelPrinter::Label::PlateCreator, - plates:, - plate_purpose:, + plates: plates, + plate_purpose: plate_purpose, user_login: scanned_user.login ) @@ -131,7 +131,7 @@ def create_plates_from_tube_racks!( barcode_printer.name, LabelPrinter::Label::PlateCreator, plates: created_plates.pluck(:destinations).flatten.compact, - plate_purpose:, + plate_purpose: plate_purpose, user_login: scanned_user.login ) @@ -155,7 +155,7 @@ def create_asset_group(created_plates) # rubocop:todo Metrics/MethodLength ActiveRecord::Base.transaction do # TO DO: handle exceptions from this? - group = AssetGroup.create!(study:, name: asset_group_name) + group = AssetGroup.create!(study: study, name: asset_group_name) group.assets.concat(all_wells) end @@ -188,7 +188,7 @@ def asset_group_name end def tube_rack_to_plate_factories(tube_racks, plate_purpose) - tube_racks.map { |rack| ::Heron::Factories::PlateFromRack.new(tube_rack: rack, plate_purpose:) } + tube_racks.map { |rack| ::Heron::Factories::PlateFromRack.new(tube_rack: rack, plate_purpose: plate_purpose) } end def can_create_plates?(source_plate) diff --git a/app/models/plate/fluidigm_behaviour.rb b/app/models/plate/fluidigm_behaviour.rb index ff1fab6694..aa38b1cdb2 100644 --- a/app/models/plate/fluidigm_behaviour.rb +++ b/app/models/plate/fluidigm_behaviour.rb @@ -61,7 +61,7 @@ def apply_fluidigm_data(fluidigm_file) # rubocop:todo Metrics/AbcSize assay_version: 'v0.1', value: gender_markers, units: 'bases', - qc_assay: + qc_assay: qc_assay }, { asset: sw, @@ -70,7 +70,7 @@ def apply_fluidigm_data(fluidigm_file) # rubocop:todo Metrics/AbcSize assay_version: 'v0.1', value: loci_passed, units: 'bases', - qc_assay: + qc_assay: qc_assay } ] ) diff --git a/app/models/plate/quad_creator.rb b/app/models/plate/quad_creator.rb index ff283262a3..2e0b899270 100644 --- a/app/models/plate/quad_creator.rb +++ b/app/models/plate/quad_creator.rb @@ -67,7 +67,7 @@ def indexed_target_wells end def creation - @creation ||= PooledPlateCreation.new(user:, parents: @parents.values, child_purpose: target_purpose) + @creation ||= PooledPlateCreation.new(user: user, parents: @parents.values, child_purpose: target_purpose) end def transfer_request_collection @@ -98,7 +98,7 @@ def quadrant_metadata_collection quadrant_metadata["Quadrant #{quadrant_index + 1}"] = parent_barcodes[quadrant_name] || 'Empty' end @quadrant_metadata_collection ||= - CustomMetadatumCollection.new(user:, asset: target_plate, metadata: quadrant_metadata) + CustomMetadatumCollection.new(user: user, asset: target_plate, metadata: quadrant_metadata) end class << self diff --git a/app/models/plate_barcode.rb b/app/models/plate_barcode.rb index dfebbca72c..ae78803b73 100644 --- a/app/models/plate_barcode.rb +++ b/app/models/plate_barcode.rb @@ -36,7 +36,7 @@ def self.create_barcode_with_text(text) # Returns: # - Barcode instance, using Sequencescape22 format def self.create_child_barcodes(parent_barcode, count = 1) - response = fetch_response("#{site}/child-barcodes/#{prefix}/new", { barcode: parent_barcode, count: }) + response = fetch_response("#{site}/child-barcodes/#{prefix}/new", { barcode: parent_barcode, count: count }) response[:barcodes_group][:barcodes].map! { |barcode| Barcode.build_sequencescape22(barcode:) } end diff --git a/app/models/plate_volume.rb b/app/models/plate_volume.rb index 3f5ba6f7c1..13323336e4 100644 --- a/app/models/plate_volume.rb +++ b/app/models/plate_volume.rb @@ -51,7 +51,7 @@ def update_well_volumes units: 'ul', assay_type: ASSAY_TYPE, assay_version: ASSAY_VERSION, - qc_assay: + qc_assay: qc_assay ) end end diff --git a/app/models/pooling.rb b/app/models/pooling.rb index d4351bc351..09d6964a93 100644 --- a/app/models/pooling.rb +++ b/app/models/pooling.rb @@ -34,7 +34,7 @@ def transfer # pass in a Request Null object. This will disable the attempt to detect an outer request. # We don't use nil as its *far* to easy to end up with nil by accident, so basing key behaviour # off it is risky. - TransferRequest.create!(asset: source_asset, target_asset:, outer_request: Request::None.new) + TransferRequest.create!(asset: source_asset, target_asset: target_asset, outer_request: Request::None.new) end message[:notice] = message[:notice] + success end @@ -68,7 +68,12 @@ def print_job_required? def print_job @print_job ||= - LabelPrinter::PrintJob.new(barcode_printer, LabelPrinter::Label::MultiplexedTube, assets: target_assets, count:) + LabelPrinter::PrintJob.new( + barcode_printer, + LabelPrinter::Label::MultiplexedTube, + assets: target_assets, + count: count + ) end def message diff --git a/app/models/presenters/qc_report_presenter.rb b/app/models/presenters/qc_report_presenter.rb index 70c3d99d4f..fc9bec3d74 100644 --- a/app/models/presenters/qc_report_presenter.rb +++ b/app/models/presenters/qc_report_presenter.rb @@ -51,7 +51,7 @@ def created_date end def state_description - I18n.t(qc_report.state, scope: 'qc_reports.state_descriptions', default: :default, queue_count:) + I18n.t(qc_report.state, scope: 'qc_reports.state_descriptions', default: :default, queue_count: queue_count) end def to_csv(io) diff --git a/app/models/qc_file.rb b/app/models/qc_file.rb index d205f1fedb..1a68de750c 100644 --- a/app/models/qc_file.rb +++ b/app/models/qc_file.rb @@ -11,7 +11,7 @@ def has_qc_files # rubocop:todo Metrics/MethodLength has_many :qc_files, foreign_key: :asset_id, dependent: :destroy def add_qc_file(file, filename = nil) - opts = { uploaded_data: { tempfile: file, filename: } } + opts = { uploaded_data: { tempfile: file, filename: filename } } opts[:filename] = filename unless filename.nil? qc_files.create!(opts) if file.present? end diff --git a/app/models/qc_report.rb b/app/models/qc_report.rb index ae151675e5..3093e7b6a7 100644 --- a/app/models/qc_report.rb +++ b/app/models/qc_report.rb @@ -98,7 +98,12 @@ def generate_report # rubocop:todo Metrics/AbcSize ActiveRecord::Base.transaction do assets.each do |asset| criteria = product_criteria.assess(asset, connected_wells[asset.id]) - QcMetric.create!(asset:, qc_decision: criteria.qc_decision, metrics: criteria.metrics, qc_report: self) + QcMetric.create!( + asset: asset, + qc_decision: criteria.qc_decision, + metrics: criteria.metrics, + qc_report: self + ) end end end diff --git a/app/models/qcable_creator.rb b/app/models/qcable_creator.rb index 75c220a3f6..24deab41b0 100644 --- a/app/models/qcable_creator.rb +++ b/app/models/qcable_creator.rb @@ -24,11 +24,11 @@ def qcables_by_count! end def qcables_by_barcode! - barcodes.split(',').collect { |barcode| lot.qcables.create!(qcable_creator: self, barcode:) } + barcodes.split(',').collect { |barcode| lot.qcables.create!(qcable_creator: self, barcode: barcode) } end # Creates using the supplied plate barcode we received from baracoda def qcables_by_supplied_barcode! - lot.qcables.create!(qcable_creator: self, supplied_barcode:) + lot.qcables.create!(qcable_creator: self, supplied_barcode: supplied_barcode) end end diff --git a/app/models/report_fail.rb b/app/models/report_fail.rb index 343ec9210c..38466a5be5 100644 --- a/app/models/report_fail.rb +++ b/app/models/report_fail.rb @@ -39,7 +39,7 @@ def save failed_labware.each do |labware| labware.events.create_labware_failed!(failure_id, user.login) - BroadcastEvent::LabwareFailed.create!(seed: labware, user:, properties: { failure_reason: failure_id }) + BroadcastEvent::LabwareFailed.create!(seed: labware, user: user, properties: { failure_reason: failure_id }) end valid? diff --git a/app/models/request.rb b/app/models/request.rb index a55884b01c..76f86a6117 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -462,7 +462,9 @@ def next_request_type_id # CAUTION!: This may not behaves as expected. I'll be deprecating this soon. def next_requests_via_asset - target_asset.requests.where(submission_id:, request_type_id: next_request_type_id) if target_asset.present? + if target_asset.present? + target_asset.requests.where(submission_id: submission_id, request_type_id: next_request_type_id) + end end def next_requests_via_submission @@ -480,7 +482,7 @@ def previous_failed_requests? def add_comment(comment, user, title = nil) # Unscope comments to fix Rails 6 deprecation warnings. But I *think* this # essentially models the new behaviour in 6.1 So should be removable then - Comment.unscoped { comments.create(description: comment, user:, title:) } + Comment.unscoped { comments.create(description: comment, user: user, title: title) } end def return_pending_to_inbox! diff --git a/app/models/request/library_creation.rb b/app/models/request/library_creation.rb index cda3e0f283..98e4103006 100644 --- a/app/models/request/library_creation.rb +++ b/app/models/request/library_creation.rb @@ -63,7 +63,13 @@ def fragment_size_required_to # @return [Hash] A hash of aliquot attributes # def aliquot_attributes - { study_id: initial_study_id, project_id: initial_project_id, library_type:, insert_size:, request_id: id } + { + study_id: initial_study_id, + project_id: initial_project_id, + library_type: library_type, + insert_size: insert_size, + request_id: id + } end include Request::CustomerResponsibility diff --git a/app/models/request/sample_compound_aliquot_transfer.rb b/app/models/request/sample_compound_aliquot_transfer.rb index 40f7970991..5d346a4bad 100644 --- a/app/models/request/sample_compound_aliquot_transfer.rb +++ b/app/models/request/sample_compound_aliquot_transfer.rb @@ -53,7 +53,7 @@ def aliquots_by_tags_combination # For a group of source aliquots, find or create a compound sample containing the component samples # Assign the compound sample to the target asset def transfer_into_compound_sample_aliquot(source_aliquots) - compound_aliquot = CompoundAliquot.new(request: self, source_aliquots:) + compound_aliquot = CompoundAliquot.new(request: self, source_aliquots: source_aliquots) unless compound_aliquot.valid? raise Request::SampleCompoundAliquotTransfer::Error, compound_aliquot.errors.full_messages end diff --git a/app/models/request_factory.rb b/app/models/request_factory.rb index 8272d88455..f8283e616e 100644 --- a/app/models/request_factory.rb +++ b/app/models/request_factory.rb @@ -15,11 +15,11 @@ def self.copy_request(request) def self.create_assets_requests(assets, study) request_type = RequestType.create_asset - assets.each { |asset| request_type.create!(study:, asset:, state: 'passed') } + assets.each { |asset| request_type.create!(study: study, asset: asset, state: 'passed') } end def self.create_external_multiplexed_library_creation_requests(sources, target, study) request_type = RequestType.external_multiplexed_library_creation - sources.each { |asset| request_type.create!(study:, asset:, target_asset: target) } + sources.each { |asset| request_type.create!(study: study, asset: asset, target_asset: target) } end end diff --git a/app/models/request_type/validation.rb b/app/models/request_type/validation.rb index 867b677227..cc1c8a22e4 100644 --- a/app/models/request_type/validation.rb +++ b/app/models/request_type/validation.rb @@ -19,7 +19,7 @@ def create_validator(request_type) # rubocop:todo Metrics/MethodLength inclusion: { in: validator.valid_options, if: :"#{validator.request_option}_needs_checking?", - message:, + message: message, allow_blank: validator.allow_blank? } end diff --git a/app/models/role/user_role_helper.rb b/app/models/role/user_role_helper.rb index fa90b8225e..6f112553d9 100644 --- a/app/models/role/user_role_helper.rb +++ b/app/models/role/user_role_helper.rb @@ -18,7 +18,7 @@ def role?(role_name, authorizable = nil) # Grants a user the role_name, in cases like # owner, authorizable should indicate the owned resource def grant_role(role_name, authorizable = nil) - roles << Role.find_or_create_by!(name: role_name, authorizable:) + roles << Role.find_or_create_by!(name: role_name, authorizable: authorizable) end def remove_role(role_name, authorizable = nil) diff --git a/app/models/sample.rb b/app/models/sample.rb index 71f7e707d7..18bbf6814f 100644 --- a/app/models/sample.rb +++ b/app/models/sample.rb @@ -411,7 +411,7 @@ def rename_to!(new_name) 'name LIKE :wild OR id IN (:sm_ids) OR id = :qid', wild: "%#{query}%", sm_ids: md, - query:, + query: query, qid: query.to_i ) } diff --git a/app/models/sample_manifest.rb b/app/models/sample_manifest.rb index ce4ff54eac..2418ab3fb2 100644 --- a/app/models/sample_manifest.rb +++ b/app/models/sample_manifest.rb @@ -191,12 +191,12 @@ def create_sample_and_aliquot(sanger_sample_id, asset) def create_sample(sanger_sample_id) Sample - .create!(name: sanger_sample_id, sanger_sample_id:, sample_manifest: self) + .create!(name: sanger_sample_id, sanger_sample_id: sanger_sample_id, sample_manifest: self) .tap { |sample| sample.events.created_using_sample_manifest!(user) } end def created_broadcast_event - BroadcastEvent::SampleManifestCreated.create!(seed: self, user:) + BroadcastEvent::SampleManifestCreated.create!(seed: self, user: user) end def updated_broadcast_event(user_updating_manifest, updated_samples_ids) diff --git a/app/models/sample_manifest/core_behaviour.rb b/app/models/sample_manifest/core_behaviour.rb index c5b743133b..7513cee410 100644 --- a/app/models/sample_manifest/core_behaviour.rb +++ b/app/models/sample_manifest/core_behaviour.rb @@ -68,7 +68,7 @@ def tag_depth_for_sample(pools, receptacle, sanger_sample_id) module LibraryAssets def generate_sample_and_aliquot(sanger_sample_id, receptacle) create_sample(sanger_sample_id).tap do |sample| - receptacle.aliquots.create!(sample:, study:, library: receptacle) + receptacle.aliquots.create!(sample: sample, study: study, library: receptacle) study.samples << sample end end diff --git a/app/models/sample_manifest/library_tube_behaviour.rb b/app/models/sample_manifest/library_tube_behaviour.rb index 84ea03123c..1c1d5e30e8 100644 --- a/app/models/sample_manifest/library_tube_behaviour.rb +++ b/app/models/sample_manifest/library_tube_behaviour.rb @@ -24,7 +24,7 @@ def generate def io_samples samples.map do |sample| { - sample:, + sample: sample, container: { barcode: sample.primary_receptacle.human_barcode }, diff --git a/app/models/sample_manifest/multiplexed_library_behaviour.rb b/app/models/sample_manifest/multiplexed_library_behaviour.rb index 972f09ba71..3929604807 100644 --- a/app/models/sample_manifest/multiplexed_library_behaviour.rb +++ b/app/models/sample_manifest/multiplexed_library_behaviour.rb @@ -26,7 +26,7 @@ def generate_mx_library def io_samples samples.map do |sample| { - sample:, + sample: sample, container: { barcode: sample.primary_receptacle.human_barcode }, diff --git a/app/models/sample_manifest/plate_behaviour.rb b/app/models/sample_manifest/plate_behaviour.rb index b053d91e99..70e2eaea54 100644 --- a/app/models/sample_manifest/plate_behaviour.rb +++ b/app/models/sample_manifest/plate_behaviour.rb @@ -40,7 +40,7 @@ def io_samples samples.map do |sample| container = sample.primary_receptacle { - sample:, + sample: sample, container: { barcode: container.plate.human_barcode, position: container.map.description.sub(/^([^\d]+)(\d)$/, '\10\2') diff --git a/app/models/sample_manifest/sample_tube_behaviour.rb b/app/models/sample_manifest/sample_tube_behaviour.rb index bf43090b4b..1ab84b0a9e 100644 --- a/app/models/sample_manifest/sample_tube_behaviour.rb +++ b/app/models/sample_manifest/sample_tube_behaviour.rb @@ -16,7 +16,7 @@ def generate end def io_samples - samples.map { |sample| { sample:, container: { barcode: sample.primary_receptacle.human_barcode } } } + samples.map { |sample| { sample: sample, container: { barcode: sample.primary_receptacle.human_barcode } } } end def acceptable_purposes diff --git a/app/models/sample_manifest/shared_tube_behaviour.rb b/app/models/sample_manifest/shared_tube_behaviour.rb index 2f13c1f0f3..1285e9a541 100644 --- a/app/models/sample_manifest/shared_tube_behaviour.rb +++ b/app/models/sample_manifest/shared_tube_behaviour.rb @@ -26,7 +26,11 @@ def generate_tubes(tube_purpose, number_of_tubes = count) # rubocop:todo Metrics Array.new(number_of_tubes) do tube = tube_purpose.create! sanger_sample_id = SangerSampleId.generate_sanger_sample_id!(study_abbreviation, sanger_ids.shift) - SampleManifestAsset.create!(sanger_sample_id:, asset: tube.receptacle, sample_manifest: @manifest) + SampleManifestAsset.create!( + sanger_sample_id: sanger_sample_id, + asset: tube.receptacle, + sample_manifest: @manifest + ) tube end diff --git a/app/models/sample_manifest/uploader.rb b/app/models/sample_manifest/uploader.rb index 2f3db1df36..b3229733ab 100644 --- a/app/models/sample_manifest/uploader.rb +++ b/app/models/sample_manifest/uploader.rb @@ -23,7 +23,8 @@ def initialize(file, configuration, user, override) @user = user @override = override @tag_group = create_tag_group - @upload = SampleManifestExcel::Upload::Base.new(file:, column_list: self.configuration.columns.all, override:) + @upload = + SampleManifestExcel::Upload::Base.new(file: file, column_list: self.configuration.columns.all, override: override) end def run! diff --git a/app/models/sequencing_pipeline.rb b/app/models/sequencing_pipeline.rb index 64d922ce5e..71b25ace0e 100644 --- a/app/models/sequencing_pipeline.rb +++ b/app/models/sequencing_pipeline.rb @@ -74,7 +74,7 @@ def detach_request_from_batch(batch, request) end def on_start_batch(batch, user) - BroadcastEvent::SequencingStart.create!(seed: batch, user:, properties: {}, created_at: DateTime.now) + BroadcastEvent::SequencingStart.create!(seed: batch, user: user, properties: {}, created_at: DateTime.now) end def post_release_batch(batch, _user) diff --git a/app/models/set_descriptors_task.rb b/app/models/set_descriptors_task.rb index 6c14aa6397..8c67042fd7 100644 --- a/app/models/set_descriptors_task.rb +++ b/app/models/set_descriptors_task.rb @@ -17,11 +17,21 @@ def can_process?(batch) end def render_task(workflows_controller, params, user) - Tasks::SetDescriptorsHandler::Handler.new(controller: workflows_controller, params:, task: self, user:).render + Tasks::SetDescriptorsHandler::Handler.new( + controller: workflows_controller, + params: params, + task: self, + user: user + ).render end def do_task(workflows_controller, params, user) - Tasks::SetDescriptorsHandler::Handler.new(controller: workflows_controller, params:, task: self, user:).perform + Tasks::SetDescriptorsHandler::Handler.new( + controller: workflows_controller, + params: params, + task: self, + user: user + ).perform end # diff --git a/app/models/state_change.rb b/app/models/state_change.rb index 53aa097160..93157297f1 100644 --- a/app/models/state_change.rb +++ b/app/models/state_change.rb @@ -65,10 +65,10 @@ def state_changer def update_state_of_target state_changer.new( labware: target, - target_state:, - user:, - contents:, - customer_accepts_responsibility: + target_state: target_state, + user: user, + contents: contents, + customer_accepts_responsibility: customer_accepts_responsibility ).update_labware_state end end diff --git a/app/models/state_changer/mx_tube.rb b/app/models/state_changer/mx_tube.rb index 9600afc584..03380b8f9d 100644 --- a/app/models/state_changer/mx_tube.rb +++ b/app/models/state_changer/mx_tube.rb @@ -13,7 +13,9 @@ def associated_requests end def generate_events_for(orders) - orders.each { |order_id| BroadcastEvent::PoolReleased.create!(seed: labware, user:, properties: { order_id: }) } + orders.each do |order_id| + BroadcastEvent::PoolReleased.create!(seed: labware, user: user, properties: { order_id: }) + end end def transfer_requests diff --git a/app/models/state_changer/standard_plate.rb b/app/models/state_changer/standard_plate.rb index 467216c1bd..9453b1e783 100644 --- a/app/models/state_changer/standard_plate.rb +++ b/app/models/state_changer/standard_plate.rb @@ -43,7 +43,9 @@ def pending_orders end def generate_events_for(orders) - orders.each { |order_id| BroadcastEvent::LibraryStart.create!(seed: labware, user:, properties: { order_id: }) } + orders.each do |order_id| + BroadcastEvent::LibraryStart.create!(seed: labware, user: user, properties: { order_id: }) + end end def update_transfer_requests diff --git a/app/models/stock_stamper.rb b/app/models/stock_stamper.rb index a72771d24c..e0db550511 100644 --- a/app/models/stock_stamper.rb +++ b/app/models/stock_stamper.rb @@ -40,7 +40,7 @@ def execute def generate_tecan_gwl_file_as_text picking_data = generate_tecan_data layout = Robot::Verification::SourceDestBeds.new.layout_data_object(picking_data) - @file_content = Robot::Generator::Tecan.new(picking_data:, layout:, total_volume: 0).as_text + @file_content = Robot::Generator::Tecan.new(picking_data: picking_data, layout: layout, total_volume: 0).as_text end def generate_tecan_data # rubocop:todo Metrics/AbcSize diff --git a/app/models/study/poly_metadata_handler.rb b/app/models/study/poly_metadata_handler.rb index 1dd1f7ebed..7aa7c99f08 100644 --- a/app/models/study/poly_metadata_handler.rb +++ b/app/models/study/poly_metadata_handler.rb @@ -99,7 +99,7 @@ def handle_scrna_core_pbmc_donor_pooling_required_number_of_cells(key, value) if value.blank? poly_metadatum&.destroy! elsif poly_metadatum&.value != value - poly_metadatum ||= PolyMetadatum.new(key:, metadatable: @study) + poly_metadatum ||= PolyMetadatum.new(key: key, metadatable: @study) poly_metadatum.value = value poly_metadatum.save! end diff --git a/app/models/study_report/well_details.rb b/app/models/study_report/well_details.rb index f1a66bc6cc..2d61827754 100644 --- a/app/models/study_report/well_details.rb +++ b/app/models/study_report/well_details.rb @@ -41,8 +41,8 @@ def qc_report # rubocop:todo Metrics/AbcSize plate_barcode: plate.human_barcode, measured_volume: well_attribute.measured_volume, current_volume: well_attribute.current_volume, - gel_qc_date:, - pico_date:, + gel_qc_date: gel_qc_date, + pico_date: pico_date, qc_started_date: plate.qc_started_date, sequenom_stamp_date: plate.sequenom_stamp_date, quantity: well_attribute.quantity_in_micro_grams.try(:round, 3), diff --git a/app/models/submission/asset_group_behaviour.rb b/app/models/submission/asset_group_behaviour.rb index c4d3b6ff80..2b6e9fb1b3 100644 --- a/app/models/submission/asset_group_behaviour.rb +++ b/app/models/submission/asset_group_behaviour.rb @@ -40,7 +40,7 @@ def create_our_asset_group group_name = asset_group_name group_name = uuid if asset_group_name.blank? - asset_group = study.asset_groups.create!(name: group_name, user:, assets:) + asset_group = study.asset_groups.create!(name: group_name, user: user, assets: assets) update!(asset_group_id: asset_group.id) end private :create_our_asset_group diff --git a/app/models/submission/flexible_request_graph.rb b/app/models/submission/flexible_request_graph.rb index 8a4728e384..a2106ca74f 100644 --- a/app/models/submission/flexible_request_graph.rb +++ b/app/models/submission/flexible_request_graph.rb @@ -108,7 +108,7 @@ def build! # rubocop:todo Metrics/AbcSize source_asset_metrics_target_assets do |source_asset, qc_metrics, target_asset| chain .order - .create_request_of_type!(request_type, asset: source_asset, target_asset:) + .create_request_of_type!(request_type, asset: source_asset, target_asset: target_asset) .tap do |request| if source_asset&.labware.present? && target_asset&.labware.present? AssetLink.create_edge(source_asset.labware, target_asset.labware) @@ -117,7 +117,9 @@ def build! # rubocop:todo Metrics/AbcSize request.qc_metrics = qc_metrics.compact.uniq request.update_responsibilities! - comments.each { |comment| request.comments.create!(user:, description: comment) } if comments.present? + if comments.present? + comments.each { |comment| request.comments.create!(user: user, description: comment) } + end end end end @@ -193,7 +195,7 @@ def associate_built_requests! downstream_requests.each do |request| request.update!(initial_study: nil) if request.initial_study != study request.update!(initial_project: nil) if request.initial_project != project - comments.each { |comment| request.comments.create!(user:, description: comment) } if comments.present? + comments.each { |comment| request.comments.create!(user: user, description: comment) } if comments.present? end end diff --git a/app/models/submission/linear_request_graph.rb b/app/models/submission/linear_request_graph.rb index 7a9cd9d385..0e2ca84894 100644 --- a/app/models/submission/linear_request_graph.rb +++ b/app/models/submission/linear_request_graph.rb @@ -87,7 +87,7 @@ def create_request_chain!(request_type_and_multiplier_pairs, source_data_set, mu qc_metrics = source_data.qc_metric target_asset = target_assets[index] - create_request_of_type!(request_type, asset: source_asset, target_asset:).tap do |request| + create_request_of_type!(request_type, asset: source_asset, target_asset: target_asset).tap do |request| # TODO: AssetLink is supposed to disappear at some point in the future because it makes no real sense # given that the request graph describes this relationship. # JG: Its removal only really makes sense if we can walk the request graph in a timely manner. @@ -100,7 +100,7 @@ def create_request_chain!(request_type_and_multiplier_pairs, source_data_set, mu request.update_responsibilities! if comments.present? - comments.split("\n").each { |comment| request.comments.create!(user:, description: comment) } + comments.split("\n").each { |comment| request.comments.create!(user: user, description: comment) } end end end @@ -142,7 +142,7 @@ def associate_built_requests(assets) # rubocop:todo Metrics/AbcSize request.update!(initial_study: nil) if request.initial_study != study request.update!(initial_project: nil) if request.initial_project != project if comments.present? - comments.split("\n").each { |comment| request.comments.create!(user:, description: comment) } + comments.split("\n").each { |comment| request.comments.create!(user: user, description: comment) } end end end diff --git a/app/models/submission/submission_creator.rb b/app/models/submission/submission_creator.rb index 9c635b872c..59d7d9ea89 100644 --- a/app/models/submission/submission_creator.rb +++ b/app/models/submission/submission_creator.rb @@ -101,7 +101,7 @@ def save # rubocop:todo Metrics/AbcSize submission.orders << new_order else - @submission = new_order.create_submission(user: order.user, priority:) + @submission = new_order.create_submission(user: order.user, priority: priority) end new_order.save! @@ -222,13 +222,13 @@ def create_order # rubocop:todo Metrics/AbcSize order_role = OrderRole.find_by(role: order_params.delete('order_role')) if order_params.present? new_order = template.new_order( - study:, - project:, + study: study, + project: project, user: @user, request_options: order_params, - comments:, + comments: comments, pre_cap_group: pre_capture_plex_group, - order_role: + order_role: order_role ) if order_params new_order.request_type_multiplier do |sequencing_request_type_id| diff --git a/app/models/supplier.rb b/app/models/supplier.rb index b5922c2121..b226387918 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -11,6 +11,6 @@ class Supplier < ApplicationRecord # Named scope for search by query string behaviour scope :for_search_query, ->(query) do - where(['suppliers.name IS NOT NULL AND (suppliers.name LIKE :like)', { like: "%#{query}%", query: }]) + where(['suppliers.name IS NOT NULL AND (suppliers.name LIKE :like)', { like: "%#{query}%", query: query }]) end end diff --git a/app/models/tag2_layout_template.rb b/app/models/tag2_layout_template.rb index be7d91f940..ea3b1163a8 100644 --- a/app/models/tag2_layout_template.rb +++ b/app/models/tag2_layout_template.rb @@ -25,7 +25,7 @@ def stamp_to(_) def record_template_use(plate) plate.submissions.each do |submission| - Tag2Layout::TemplateSubmission.create!(submission:, tag2_layout_template: self) + Tag2Layout::TemplateSubmission.create!(submission: submission, tag2_layout_template: self) end end diff --git a/app/models/tag_layout_template.rb b/app/models/tag_layout_template.rb index ebc2011800..ff6f8cdd01 100644 --- a/app/models/tag_layout_template.rb +++ b/app/models/tag_layout_template.rb @@ -59,7 +59,11 @@ def tag_layout_attributes def record_template_use(plate, enforce_uniqueness) plate.submissions.each do |submission| - TagLayout::TemplateSubmission.create!(submission:, tag_layout_template: self, enforce_uniqueness:) + TagLayout::TemplateSubmission.create!( + submission: submission, + tag_layout_template: self, + enforce_uniqueness: enforce_uniqueness + ) end end end diff --git a/app/models/tag_substitution.rb b/app/models/tag_substitution.rb index 808d276231..a7932b473f 100644 --- a/app/models/tag_substitution.rb +++ b/app/models/tag_substitution.rb @@ -170,7 +170,7 @@ def apply_comments commented_assets.map do |asset_id| { commentable_id: asset_id, - commentable_type:, + commentable_type: commentable_type, user_id: @user&.id, description: comment_text, title: "Tag Substitution #{@ticket}" diff --git a/app/models/tasks/add_spiked_in_control_handler.rb b/app/models/tasks/add_spiked_in_control_handler.rb index 5179c9c3fd..8805672f12 100644 --- a/app/models/tasks/add_spiked_in_control_handler.rb +++ b/app/models/tasks/add_spiked_in_control_handler.rb @@ -52,10 +52,10 @@ def process_request(request) lane.direct_spiked_in_buffer = nil lane.direct_spiked_in_buffer = phi_x_tube if phi_x_tube LabEvent.create!( - batch:, + batch: batch, description: task.name, descriptors: descriptors_for(phi_x_tube), - user:, + user: user, eventful: request ) end diff --git a/app/models/tasks/base_handler.rb b/app/models/tasks/base_handler.rb index 3f8afc2846..0d273fba01 100644 --- a/app/models/tasks/base_handler.rb +++ b/app/models/tasks/base_handler.rb @@ -21,7 +21,7 @@ def initialize(controller:, params:, task:, user:) private def create_batch_events - event = batch.lab_events.build(description: 'Complete', user:, batch:) + event = batch.lab_events.build(description: 'Complete', user: user, batch: batch) event.add_descriptor Descriptor.new(name: 'task_id', value: task.id) event.add_descriptor Descriptor.new(name: 'task', value: task.name) event.save! diff --git a/app/models/tasks/cherrypick_handler.rb b/app/models/tasks/cherrypick_handler.rb index 581ec8fa4a..f01431917c 100644 --- a/app/models/tasks/cherrypick_handler.rb +++ b/app/models/tasks/cherrypick_handler.rb @@ -162,7 +162,7 @@ def do_cherrypick_task(_task, params) # rubocop:todo Metrics/CyclomaticComplexit plate_purpose.create!( :do_not_create_wells, name: "Cherrypicked #{plate_barcode.barcode}", - size:, + size: size, sanger_barcode: plate_barcode ) { |new_plate| new_plate.fluidigm_barcode = fluidigm_plate if fluidigm_plate.present? } end diff --git a/app/models/tasks/set_descriptors_handler.rb b/app/models/tasks/set_descriptors_handler.rb index 1dce3cf6d5..c4446d183c 100644 --- a/app/models/tasks/set_descriptors_handler.rb +++ b/app/models/tasks/set_descriptors_handler.rb @@ -32,7 +32,13 @@ def params end def process_request(request) - LabEvent.create!(batch:, description: @task.name, descriptors: descriptors(request), user:, eventful: request) + LabEvent.create!( + batch: batch, + description: @task.name, + descriptors: descriptors(request), + user: user, + eventful: request + ) # Some receptacles are flagged as 'resource'. There are 43 of these in the production database, # all are from 2009 - 2010. diff --git a/app/models/tube.rb b/app/models/tube.rb index 134c8c755a..9a10a6d7d4 100644 --- a/app/models/tube.rb +++ b/app/models/tube.rb @@ -94,7 +94,7 @@ def self.create_with_barcode!(*args, &) # this is to control the order of barcode addition so that it gets set as the 'primary' barcode foreign_barcode = attributes.delete(:foreign_barcode) - tube = create!(attributes.merge(sanger_barcode: { prefix:, number: barcode }), &) + tube = create!(attributes.merge(sanger_barcode: { prefix: prefix, number: barcode }), &) tube.foreign_barcode = foreign_barcode if foreign_barcode tube.reload @@ -111,7 +111,7 @@ def extract_barcode(args, attributes) end def validate_barcode(barcode, prefix) - human = SBCF::SangerBarcode.new(prefix:, number: barcode).human_barcode + human = SBCF::SangerBarcode.new(prefix: prefix, number: barcode).human_barcode raise "Barcode: #{barcode} already used!" if Barcode.exists?(barcode: human) end diff --git a/app/models/user/authentication.rb b/app/models/user/authentication.rb index 07b10cb09a..fb54b2be2d 100644 --- a/app/models/user/authentication.rb +++ b/app/models/user/authentication.rb @@ -18,7 +18,7 @@ def update_profile_via_ldap # rubocop:todo Metrics/AbcSize filter = Net::LDAP::Filter.eq('uid', login) treebase = 'ou=people,dc=sanger,dc=ac,dc=uk' - ldap_profile = ldap.search(base: treebase, filter:)[0] + ldap_profile = ldap.search(base: treebase, filter: filter)[0] # If we have two or more records, something is off with LDAP @@ -61,8 +61,8 @@ def authenticate_with_ldap(login, password) # rubocop:todo Metrics/AbcSize, Metr encryption: :simple_tls, auth: { method: :simple, - username:, - password: + username: username, + password: password } ) begin diff --git a/app/models/uuid.rb b/app/models/uuid.rb index 573e1d15f3..ff2223d269 100644 --- a/app/models/uuid.rb +++ b/app/models/uuid.rb @@ -133,7 +133,7 @@ def self.generate_uuids!(resource_type, resource_ids) ids_missing_uuids = filter_uncreated_uuids(resource_type, resource_ids) uuids_to_create = - ids_missing_uuids.map { |id| create!(resource_type:, resource_id: id, external_id: generate_uuid) } + ids_missing_uuids.map { |id| create!(resource_type: resource_type, resource_id: id, external_id: generate_uuid) } # Uuid.import uuids_to_create unless uuids_to_create.empty? @@ -142,7 +142,7 @@ def self.generate_uuids!(resource_type, resource_ids) # ids is a string of internal_ids def self.filter_uncreated_uuids(resource_type, resource_ids) - existing_uuids = where(resource_type:, resource_id: resource_ids) + existing_uuids = where(resource_type: resource_type, resource_id: resource_ids) resource_ids - existing_uuids.pluck(:resource_id) end diff --git a/app/resources/api/v2/tube_rack_resource.rb b/app/resources/api/v2/tube_rack_resource.rb index c94efcefcb..72004ae850 100644 --- a/app/resources/api/v2/tube_rack_resource.rb +++ b/app/resources/api/v2/tube_rack_resource.rb @@ -68,7 +68,7 @@ def tube_locations=(tube_locations) tube_locations.each do |coordinate, tube| tube_uuid = tube[:uuid] raise "No tube found for UUID '#{tube_uuid}'" unless tubes.key?(tube_uuid) - RackedTube.create(coordinate:, tube: tubes[tube_uuid], tube_rack: @model) + RackedTube.create(coordinate: coordinate, tube: tubes[tube_uuid], tube_rack: @model) end end diff --git a/app/sample_manifest_excel/sample_manifest_excel/download.rb b/app/sample_manifest_excel/sample_manifest_excel/download.rb index b50b059809..99761de642 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/download.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/download.rb @@ -18,9 +18,16 @@ def initialize(sample_manifest, column_list, range_list) return unless valid? - @ranges_worksheet = SequencescapeExcel::Worksheet::RangesWorksheet.new(ranges: range_list, workbook:, password:) + @ranges_worksheet = + SequencescapeExcel::Worksheet::RangesWorksheet.new(ranges: range_list, workbook: workbook, password: password) @data_worksheet = - Worksheet::DataWorksheet.new(workbook:, columns: column_list, sample_manifest:, ranges: range_list, password:) + Worksheet::DataWorksheet.new( + workbook: workbook, + columns: column_list, + sample_manifest: sample_manifest, + ranges: range_list, + password: password + ) end def password diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb index 58bce3f19a..797e90c0e8 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/processor/base.rb @@ -113,10 +113,10 @@ def disable_match_expectation def update_downstream_aliquots substituter = TagSubstitution.new( - substitutions:, + substitutions: substitutions, comment: 'Manifest updated', disable_clash_detection: true, - disable_match_expectation: + disable_match_expectation: disable_match_expectation ) @downstream_aliquots_updated = substituter.save || log_error_and_return_false(substituter.errors.full_messages.join('; ')) diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/processor/tube_rack.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/processor/tube_rack.rb index 01a8865377..9b8f27ec02 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/processor/tube_rack.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/processor/tube_rack.rb @@ -180,7 +180,7 @@ def link_tubes_to_racks(rack_barcode_to_tube_rack) tube_rack_barcode = @tube_barcode_to_rack_barcode[tube_barcode] tube_rack = rack_barcode_to_tube_rack[tube_rack_barcode] tube_barcode_to_coordinate = @rack_barcode_to_scan_results[tube_rack_barcode] - RackedTube.create!(tube_rack:, tube:, coordinate: tube_barcode_to_coordinate[tube_barcode]) + RackedTube.create!(tube_rack: tube_rack, tube: tube, coordinate: tube_barcode_to_coordinate[tube_barcode]) end end diff --git a/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb b/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb index 53bb975a3b..ceacc049f2 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb @@ -38,7 +38,7 @@ def data_at(row_num) def create_rows(cache) [].tap do |rows| data.each_with_index do |r, i| - row = Row.new(number: i + data.start_row + 1, data: r, columns:, cache:) + row = Row.new(number: i + data.start_row + 1, data: r, columns: columns, cache: cache) rows << row unless row.empty? end end diff --git a/app/sample_manifest_excel/sample_manifest_excel/worksheet/data_worksheet.rb b/app/sample_manifest_excel/sample_manifest_excel/worksheet/data_worksheet.rb index a22e59e8f1..8122299ee2 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/worksheet/data_worksheet.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/worksheet/data_worksheet.rb @@ -88,7 +88,7 @@ def create_row(detail) (sample_manifest.invalid_wells&.include?(detail.fetch(:position, nil)) ? [:disabled] : column.style) style = find_or_create_style(style_name)&.reference - row.add_cell column.attribute_value(detail), type: column.type, style: + row.add_cell column.attribute_value(detail), type: column.type, style: style end end end diff --git a/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb b/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb index 5c53de9ffc..12a59a7463 100644 --- a/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb +++ b/app/sample_manifest_excel/sample_manifest_excel/worksheet/test_worksheet.rb @@ -93,13 +93,13 @@ def create_sample_manifest # rubocop:todo Metrics/MethodLength study: ) when /tube_library/, /tube_chromium_library/ - FactoryBot.create(:sample_manifest, asset_type: 'library', study:) + FactoryBot.create(:sample_manifest, asset_type: 'library', study: study) when /tube_multiplexed_library/ - FactoryBot.create(:sample_manifest, asset_type: 'multiplexed_library', study:) + FactoryBot.create(:sample_manifest, asset_type: 'multiplexed_library', study: study) when /tube_rack/ - FactoryBot.create(:tube_rack_manifest, asset_type: 'tube_rack', study:) + FactoryBot.create(:tube_rack_manifest, asset_type: 'tube_rack', study: study) else - FactoryBot.create(:sample_manifest, asset_type: '1dtube', study:) + FactoryBot.create(:sample_manifest, asset_type: '1dtube', study: study) end end @@ -272,7 +272,7 @@ def create_tube_requests assets.each do |asset| FactoryBot.create( :external_multiplexed_library_tube_creation_request, - asset:, + asset: asset, target_asset: multiplexed_library_tube ) end diff --git a/app/sequencescape_excel/sequencescape_excel/column.rb b/app/sequencescape_excel/sequencescape_excel/column.rb index 201d824b2a..01306be6bd 100644 --- a/app/sequencescape_excel/sequencescape_excel/column.rb +++ b/app/sequencescape_excel/sequencescape_excel/column.rb @@ -118,13 +118,13 @@ def updated? # Update the column validation using the passed worksheet and found range. # Update the conditional formatting based on a range and worksheet. def update(first_row, last_row, ranges, worksheet) - self.range = { first_column: number, first_row:, last_row: } + self.range = { first_column: number, first_row: first_row, last_row: last_row } range = ranges.find_by(range_name) || NullRange.new - validation.update(range:, reference: self.range.reference, worksheet:) + validation.update(range: range, reference: self.range.reference, worksheet: worksheet) conditional_formattings.update( - self.range.references.merge(absolute_reference: range.absolute_reference, worksheet:) + self.range.references.merge(absolute_reference: range.absolute_reference, worksheet: worksheet) ) @updated = true diff --git a/app/sequencescape_excel/sequencescape_excel/range_list.rb b/app/sequencescape_excel/sequencescape_excel/range_list.rb index e462bcd8a7..9ef31cab36 100644 --- a/app/sequencescape_excel/sequencescape_excel/range_list.rb +++ b/app/sequencescape_excel/sequencescape_excel/range_list.rb @@ -54,7 +54,7 @@ def <=>(other) def create(ranges_data) {}.tap do |ranges| ranges_data.each_with_index do |(name, attributes), i| - attributes = attributes.merge(name:, first_row: i + 1) + attributes = attributes.merge(name: name, first_row: i + 1) ranges[name] = SequencescapeExcel::Range.new(attributes) end end diff --git a/app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb b/app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb index a754b0d569..1d00f3d7df 100644 --- a/app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb +++ b/app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb @@ -64,7 +64,7 @@ def well_index # i7 tag def tag - Tag.find_by(tag_group_id:, map_id: well_index) + Tag.find_by(tag_group_id: tag_group_id, map_id: well_index) end # i5 tag diff --git a/app/sequencescape_excel/sequencescape_excel/specialised_field/volume.rb b/app/sequencescape_excel/sequencescape_excel/specialised_field/volume.rb index 43cc474b92..16d7a53712 100644 --- a/app/sequencescape_excel/sequencescape_excel/specialised_field/volume.rb +++ b/app/sequencescape_excel/sequencescape_excel/specialised_field/volume.rb @@ -19,7 +19,7 @@ def create_qc_record ActiveRecord::Base.transaction do qc_assay = sample_manifest_asset.sample_manifest.find_or_create_qc_assay! asset.qc_results.build( - qc_assay:, + qc_assay: qc_assay, key: 'volume', value: value.to_f, assay_type: 'customer_supplied', diff --git a/app/sequencescape_excel/sequencescape_excel/worksheet/base.rb b/app/sequencescape_excel/sequencescape_excel/worksheet/base.rb index bc6f52b799..e6848a2acc 100644 --- a/app/sequencescape_excel/sequencescape_excel/worksheet/base.rb +++ b/app/sequencescape_excel/sequencescape_excel/worksheet/base.rb @@ -22,7 +22,7 @@ def initialize(attributes = {}) # Adds row to a worksheet with particular value, style and type for each cell def add_row(values = [], style = nil, types = nil) - axlsx_worksheet.add_row values, types: types || ([:string] * values.length), style: + axlsx_worksheet.add_row values, types: types || ([:string] * values.length), style: style end # Adds n empty rows diff --git a/app/uat_actions/uat_actions/generate_plate_concentrations.rb b/app/uat_actions/uat_actions/generate_plate_concentrations.rb index 918fe0772e..ac97aacb5a 100644 --- a/app/uat_actions/uat_actions/generate_plate_concentrations.rb +++ b/app/uat_actions/uat_actions/generate_plate_concentrations.rb @@ -103,12 +103,12 @@ def construct_qc_assay QcResult.create!( asset: well, - key:, + key: key, value: create_random_concentration, units: conc_units, assay_type: 'UAT_Testing', assay_version: 'Binning', - qc_assay: + qc_assay: qc_assay ) num_wells_written += 1 end diff --git a/app/uat_actions/uat_actions/generate_plates.rb b/app/uat_actions/uat_actions/generate_plates.rb index bde35373ab..cde3b44858 100644 --- a/app/uat_actions/uat_actions/generate_plates.rb +++ b/app/uat_actions/uat_actions/generate_plates.rb @@ -144,7 +144,7 @@ def save_sample(sample, well, sample_index) sample.save!(validate: false) if num_samples_per_well > 1 - well.aliquots.create!(sample:, study:, tag_depth: sample_index) + well.aliquots.create!(sample: sample, study: study, tag_depth: sample_index) else well.aliquots.create!(sample:, study:) end diff --git a/app/uat_actions/uat_actions/generate_primer_panel.rb b/app/uat_actions/uat_actions/generate_primer_panel.rb index 4cf95921f4..4b5a947cbb 100644 --- a/app/uat_actions/uat_actions/generate_primer_panel.rb +++ b/app/uat_actions/uat_actions/generate_primer_panel.rb @@ -71,8 +71,8 @@ def existing_primer_panel def primer_panel_params { - name:, - snp_count:, + name: name, + snp_count: snp_count, programs: { 'pcr 1' => { 'name' => pcr_1_name, diff --git a/app/uat_actions/uat_actions/generate_project.rb b/app/uat_actions/uat_actions/generate_project.rb index b601f23182..6bdd0565be 100644 --- a/app/uat_actions/uat_actions/generate_project.rb +++ b/app/uat_actions/uat_actions/generate_project.rb @@ -26,7 +26,7 @@ def create_project approved: true, state: 'active', project_metadata_attributes: { - project_cost_code:, + project_cost_code: project_cost_code, project_funding_model: 'Internal' } ).find_or_create_by!(name: project_name) diff --git a/app/uat_actions/uat_actions/generate_qc_results.rb b/app/uat_actions/uat_actions/generate_qc_results.rb index a5041e2028..9499ec8db2 100644 --- a/app/uat_actions/uat_actions/generate_qc_results.rb +++ b/app/uat_actions/uat_actions/generate_qc_results.rb @@ -114,7 +114,7 @@ def construct_qc_assay units: resolved_units, assay_type: 'UAT_Testing', assay_version: 'Binning', - qc_assay: + qc_assay: qc_assay ) end report['number_results_written'] = qc_assay.qc_results.length diff --git a/app/uat_actions/uat_actions/generate_sample_manifest.rb b/app/uat_actions/uat_actions/generate_sample_manifest.rb index eadb26db0c..593993d515 100644 --- a/app/uat_actions/uat_actions/generate_sample_manifest.rb +++ b/app/uat_actions/uat_actions/generate_sample_manifest.rb @@ -117,7 +117,7 @@ def create_sample(sample_name, sample_manifest) donor_id: "#{sample_name}_donor", sample_common_name: 'human' }, - sample_manifest: + sample_manifest: sample_manifest ) end diff --git a/app/uat_actions/uat_actions/generate_tag_group.rb b/app/uat_actions/uat_actions/generate_tag_group.rb index b884b9bc36..fc7790e751 100644 --- a/app/uat_actions/uat_actions/generate_tag_group.rb +++ b/app/uat_actions/uat_actions/generate_tag_group.rb @@ -70,13 +70,13 @@ def perform end def create_tag_group(name, adapter_type) - tag_group = TagGroup.create!(name:, adapter_type_id: adapter_type&.id) + tag_group = TagGroup.create!(name: name, adapter_type_id: adapter_type&.id) tag_group.tags.build( OligoEnumerator .new(size.to_i, tag_sequence_offset.to_i) .each_with_index - .map { |oligo, map_id| { oligo:, map_id: map_id + 1 } } + .map { |oligo, map_id| { oligo: oligo, map_id: map_id + 1 } } ) tag_group.save end diff --git a/app/uat_actions/uat_actions/generate_tag_layout_template.rb b/app/uat_actions/uat_actions/generate_tag_layout_template.rb index 318039a2c1..339ab66cd6 100644 --- a/app/uat_actions/uat_actions/generate_tag_layout_template.rb +++ b/app/uat_actions/uat_actions/generate_tag_layout_template.rb @@ -54,10 +54,10 @@ def perform walk_algorithm = walking_by_algorithm.presence || 'TagLayout::WalkWellsOfPlate' tlt_parameters = { - name:, + name: name, tag_group_id: tag_group.id, tag2_group_id: tag2_group&.id, - direction_algorithm:, + direction_algorithm: direction_algorithm, walking_algorithm: walk_algorithm } diff --git a/app/uat_actions/uat_actions/generate_tag_plates.rb b/app/uat_actions/uat_actions/generate_tag_plates.rb index 4442a8a02d..51efe3c91d 100644 --- a/app/uat_actions/uat_actions/generate_tag_plates.rb +++ b/app/uat_actions/uat_actions/generate_tag_plates.rb @@ -36,7 +36,7 @@ def self.default end def perform - qcc = QcableCreator.create!(lot:, user:, count: plate_count.to_i) + qcc = QcableCreator.create!(lot: lot, user: user, count: plate_count.to_i) qcc.qcables.each_with_index do |qcable, index| qcable.update!(state: 'available') report["tag_plate_#{index}"] = qcable.asset.machine_barcode @@ -54,7 +54,7 @@ def lot lot_type.lots.create!( lot_number: "UAT#{Time.current.to_f}", template: tag_layout_template, - user:, + user: user, received_at: Time.current ) end diff --git a/app/uat_actions/uat_actions/generate_tube_racks.rb b/app/uat_actions/uat_actions/generate_tube_racks.rb index 31e6518b46..7f8a8842d8 100644 --- a/app/uat_actions/uat_actions/generate_tube_racks.rb +++ b/app/uat_actions/uat_actions/generate_tube_racks.rb @@ -28,7 +28,7 @@ def perform # rubocop:todo Metrics/AbcSize, Metrics/MethodLength purpose = Purpose.find_by(name: 'TR Stock 96') rack_count.to_i.times do |i| TubeRack - .create!(size: 96, purpose:) + .create!(size: 96, purpose: purpose) .tap do |rack| Barcode.create!( asset: rack, @@ -58,7 +58,7 @@ def construct_tubes(rack) supplier_name: sample_name } ), - study: + study: study ) racked_tube = RackedTube.create!(tube_rack_id: rack.id, tube_id: tube.id, coordinate: i) diff --git a/app/uat_actions/uat_actions/generate_tubes.rb b/app/uat_actions/uat_actions/generate_tubes.rb index 6f8ee82d88..b5bc0e4ce6 100644 --- a/app/uat_actions/uat_actions/generate_tubes.rb +++ b/app/uat_actions/uat_actions/generate_tubes.rb @@ -49,7 +49,7 @@ def perform supplier_name: sample_name } ), - study: + study: study ) add_foreign_barcode_if_selected(tube) diff --git a/app/uat_actions/uat_actions/static_records.rb b/app/uat_actions/uat_actions/static_records.rb index 514c820c62..a5a4f63e62 100644 --- a/app/uat_actions/uat_actions/static_records.rb +++ b/app/uat_actions/uat_actions/static_records.rb @@ -26,14 +26,14 @@ def self.study state: 'active', study_metadata_attributes: { data_access_group: 'dag', - study_type:, - faculty_sponsor:, - data_release_study_type:, + study_type: study_type, + faculty_sponsor: faculty_sponsor, + data_release_study_type: data_release_study_type, study_description: 'A study generated for UAT', contaminated_human_dna: 'No', contains_human_dna: 'No', commercially_available: 'No', - program: + program: program } ).find_or_create_by!(name: 'UAT Study') end @@ -53,7 +53,7 @@ def self.project project_metadata_attributes: { project_cost_code: 'FAKE1', project_funding_model: 'Internal', - budget_division: + budget_division: budget_division } ).find_or_create_by!(name: 'UAT Project') end diff --git a/app/uat_actions/uat_actions/test_submission.rb b/app/uat_actions/uat_actions/test_submission.rb index 7f701ca6b5..d9fbece763 100644 --- a/app/uat_actions/uat_actions/test_submission.rb +++ b/app/uat_actions/uat_actions/test_submission.rb @@ -122,10 +122,10 @@ def self.compatible_submission_templates def perform # rubocop:todo Metrics/AbcSize order = submission_template.create_with_submission!( - study:, - project:, - user:, - assets:, + study: study, + project: project, + user: user, + assets: assets, request_options: order_request_options ) report['plate_barcode_0'] = labware.human_barcode diff --git a/app/uat_actions/uat_actions/tube_submission.rb b/app/uat_actions/uat_actions/tube_submission.rb index 7640b92b32..db35dce31c 100644 --- a/app/uat_actions/uat_actions/tube_submission.rb +++ b/app/uat_actions/uat_actions/tube_submission.rb @@ -80,10 +80,10 @@ def self.compatible_submission_templates def perform order = submission_template.create_with_submission!( - study:, - project:, - user:, - assets:, + study: study, + project: project, + user: user, + assets: assets, request_options: order_request_options ) fill_report(order) diff --git a/db/migrate/20180420144414_migrate_sanger_barcodes_to_new_tables.rb b/db/migrate/20180420144414_migrate_sanger_barcodes_to_new_tables.rb index 76be18f564..b8f4647492 100644 --- a/db/migrate/20180420144414_migrate_sanger_barcodes_to_new_tables.rb +++ b/db/migrate/20180420144414_migrate_sanger_barcodes_to_new_tables.rb @@ -18,8 +18,8 @@ def up # rubocop:disable Metrics/AbcSize barcodes_hash = barcodes.map do |asset_id, number, prefix_id| { - asset_id:, - barcode: SBCF::SangerBarcode.new(number:, prefix: @prefixes[prefix_id]).human_barcode, + asset_id: asset_id, + barcode: SBCF::SangerBarcode.new(number: number, prefix: @prefixes[prefix_id]).human_barcode, format: 0 } end diff --git a/db/migrate/20180420151252_migrate_other_barcodes_to_new_tables.rb b/db/migrate/20180420151252_migrate_other_barcodes_to_new_tables.rb index f723fc470e..efc891f356 100644 --- a/db/migrate/20180420151252_migrate_other_barcodes_to_new_tables.rb +++ b/db/migrate/20180420151252_migrate_other_barcodes_to_new_tables.rb @@ -14,7 +14,7 @@ def up # rubocop:disable Metrics/AbcSize barcodes = batch.pluck(:plate_id, :infinium_barcode) say "From #{barcodes.first.first} to #{barcodes.last.first}" say 'Building hashes' - barcodes_hash = barcodes.map { |asset_id, barcode| { asset_id:, barcode:, format: 1 } } + barcodes_hash = barcodes.map { |asset_id, barcode| { asset_id: asset_id, barcode: barcode, format: 1 } } say 'Importing' Barcode.import(barcodes_hash) say 'Imported' @@ -29,7 +29,7 @@ def up # rubocop:disable Metrics/AbcSize barcodes = batch.pluck(:plate_id, :fluidigm_barcode) say "From #{barcodes.first.first} to #{barcodes.last.first}" say 'Building hashes' - barcodes_hash = barcodes.map { |asset_id, barcode| { asset_id:, barcode:, format: 2 } } + barcodes_hash = barcodes.map { |asset_id, barcode| { asset_id: asset_id, barcode: barcode, format: 2 } } say 'Importing' Barcode.import(barcodes_hash) say 'Imported' diff --git a/db/migrate/20220428085815_remove_flexible_cherrypick_pipeline.rb b/db/migrate/20220428085815_remove_flexible_cherrypick_pipeline.rb index b03778f3c8..b597e44567 100644 --- a/db/migrate/20220428085815_remove_flexible_cherrypick_pipeline.rb +++ b/db/migrate/20220428085815_remove_flexible_cherrypick_pipeline.rb @@ -15,7 +15,7 @@ def down pipeline = Pipeline.find_by(name:) next if pipeline.nil? - pipeline.update!(sti_type:, active: true) + pipeline.update!(sti_type: sti_type, active: true) end end end diff --git a/db/migrate/20230512102847_add_missing_insdc_countries.rb b/db/migrate/20230512102847_add_missing_insdc_countries.rb index 9ac73c02ad..8d2f6ae50b 100644 --- a/db/migrate/20230512102847_add_missing_insdc_countries.rb +++ b/db/migrate/20230512102847_add_missing_insdc_countries.rb @@ -12,6 +12,6 @@ def change 'missing: data agreement established pre-2023', 'missing: endangered species', 'missing: human-identifiable' - ].each { |name| Insdc::Country.find_or_create_by(name:, sort_priority: -2, validation_state: 0) } + ].each { |name| Insdc::Country.find_or_create_by(name: name, sort_priority: -2, validation_state: 0) } end end diff --git a/db/seeds/0001_tube_purposes.rb b/db/seeds/0001_tube_purposes.rb index f9ec941a4c..cd647fc583 100644 --- a/db/seeds/0001_tube_purposes.rb +++ b/db/seeds/0001_tube_purposes.rb @@ -10,5 +10,7 @@ 'Stock MX' => %w[Tube::StockMx StockMultiplexedLibraryTube], 'Stock library' => %w[Tube::Purpose StockLibraryTube], 'Legacy MX tube' => %w[IlluminaHtp::MxTubePurpose MultiplexedLibraryTube] - }.each { |name, (type, asset_type)| type.constantize.create!(name:, barcode_printer_type:, target_type: asset_type) } + }.each do |name, (type, asset_type)| + type.constantize.create!(name: name, barcode_printer_type: barcode_printer_type, target_type: asset_type) + end end diff --git a/db/seeds/0001_workflows.rb b/db/seeds/0001_workflows.rb index 731e891c0f..e1a93b0d5b 100644 --- a/db/seeds/0001_workflows.rb +++ b/db/seeds/0001_workflows.rb @@ -31,7 +31,7 @@ REQUEST_INFORMATION_TYPES = RequestInformationType.all.index_by { |t| t.key }.freeze def create_request_information_types(pipeline, *keys) PipelineRequestInformationType.create!( - keys.map { |k| { pipeline:, request_information_type: REQUEST_INFORMATION_TYPES[k] } } + keys.map { |k| { pipeline: pipeline, request_information_type: REQUEST_INFORMATION_TYPES[k] } } ) end @@ -180,15 +180,15 @@ def create_request_information_types(pipeline, *keys) end .tap do |pipeline| PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(key: 'read_length') ) PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(key: 'library_type') ) PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -241,7 +241,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -294,7 +294,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -374,7 +374,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -430,7 +430,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -546,7 +546,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -640,7 +640,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -695,7 +695,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -747,7 +747,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -798,7 +798,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -844,7 +844,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -917,7 +917,7 @@ def create_request_information_types(pipeline, *keys) .tap do |pipeline| create_request_information_types(pipeline, 'read_length', 'library_type') PipelineRequestInformationType.create!( - pipeline:, + pipeline: pipeline, request_information_type: RequestInformationType.find_by(label: 'Vol.') ) end @@ -1006,9 +1006,9 @@ def create_request_information_types(pipeline, *keys) workflow.item_limit = 1 end .tap do |workflow| - t1 = SetDescriptorsTask.create!(name: 'Specify Dilution Volume', sorted: 0, workflow:) + t1 = SetDescriptorsTask.create!(name: 'Specify Dilution Volume', sorted: 0, workflow: workflow) Descriptor.create!(kind: 'Text', sorter: 1, name: 'Concentration', task: t1) - t2 = SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 0, workflow:) + t2 = SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 0, workflow: workflow) Descriptor.create!(kind: 'Text', sorter: 1, name: 'Chip barcode', task: t2) Descriptor.create!(kind: 'Text', sorter: 2, name: 'Cartridge barcode', task: t2) Descriptor.create!(kind: 'Text', sorter: 4, name: 'Machine name', task: t2) @@ -1364,8 +1364,8 @@ def create_request_information_types(pipeline, *keys) end def build_4000_tasks_for(workflow, paired_only = false) # rubocop:todo Metrics/MethodLength - AddSpikedInControlTask.create!(name: 'Add Spiked in control', sorted: 0, workflow:) - SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 1, workflow:) do |task| + AddSpikedInControlTask.create!(name: 'Add Spiked in control', sorted: 0, workflow: workflow) + SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 1, workflow: workflow) do |task| task.descriptors.build( [ { kind: 'Text', sorter: 1, name: 'Chip Barcode', required: true }, @@ -1379,7 +1379,7 @@ def build_4000_tasks_for(workflow, paired_only = false) # rubocop:todo Metrics/M ) end - SetDescriptorsTask.create!(name: 'Read 1 Lin/block/hyb/load', sorted: 2, workflow:) do |task| + SetDescriptorsTask.create!(name: 'Read 1 Lin/block/hyb/load', sorted: 2, workflow: workflow) do |task| task.descriptors.build( [ { kind: 'Text', sorter: 1, name: 'Chip Barcode', required: true }, @@ -1400,7 +1400,7 @@ def build_4000_tasks_for(workflow, paired_only = false) # rubocop:todo Metrics/M ) end - SetDescriptorsTask.create!(name: 'Read 2 Lin/block/hyb/load', sorted: 2, workflow:) do |task| + SetDescriptorsTask.create!(name: 'Read 2 Lin/block/hyb/load', sorted: 2, workflow: workflow) do |task| if paired_only task.descriptors.build( [ @@ -1478,6 +1478,10 @@ def add_4000_information_types_to(pipeline) ] if read_lengths.present? - RequestType::Validator.create!(request_type:, request_option: 'read_length', valid_options: read_lengths) + RequestType::Validator.create!( + request_type: request_type, + request_option: 'read_length', + valid_options: read_lengths + ) end end diff --git a/db/seeds/0015_tags.rb b/db/seeds/0015_tags.rb index 14eb659d01..7f6822ddb7 100644 --- a/db/seeds/0015_tags.rb +++ b/db/seeds/0015_tags.rb @@ -551,6 +551,6 @@ tag_options = tags.flat_map do |tag_group_name, tags_in_group| tag_group_id = groups[tag_group_name] - tags_in_group.map { |m, o| { map_id: m, oligo: o, tag_group_id: } } + tags_in_group.map { |m, o| { map_id: m, oligo: o, tag_group_id: tag_group_id } } end Tag.import(tag_options) diff --git a/db/seeds/0016_tag_layout_templates.rb b/db/seeds/0016_tag_layout_templates.rb index a1a2337959..e5d76e8cce 100644 --- a/db/seeds/0016_tag_layout_templates.rb +++ b/db/seeds/0016_tag_layout_templates.rb @@ -5,25 +5,25 @@ TagGroup.find_each do |tag_group| TagLayoutTemplate.create!( name: "#{tag_group.name} in column major order", - tag_group:, + tag_group: tag_group, direction_algorithm: 'TagLayout::InColumns', walking_algorithm: 'TagLayout::WalkWellsByPools' ) TagLayoutTemplate.create!( name: "#{tag_group.name} in row major order", - tag_group:, + tag_group: tag_group, direction_algorithm: 'TagLayout::InRows', walking_algorithm: 'TagLayout::WalkWellsByPools' ) TagLayoutTemplate.create!( name: "#{tag_group.name} in inverted column major order", - tag_group:, + tag_group: tag_group, direction_algorithm: 'TagLayout::InInverseColumns', walking_algorithm: 'TagLayout::WalkWellsByPools' ) TagLayoutTemplate.create!( name: "#{tag_group.name} in inverted row major order", - tag_group:, + tag_group: tag_group, direction_algorithm: 'TagLayout::InInverseRows', walking_algorithm: 'TagLayout::WalkWellsByPools' ) diff --git a/db/seeds/0019_plate_creators.rb b/db/seeds/0019_plate_creators.rb index a109b32346..098f126162 100644 --- a/db/seeds/0019_plate_creators.rb +++ b/db/seeds/0019_plate_creators.rb @@ -43,7 +43,7 @@ # Additional plate purposes required ['Pico dilution', 'Working dilution'].each do |name| plate_purpose = PlatePurpose.find_by!(name:) - Plate::Creator.create!(name:, plate_purposes: [plate_purpose]) + Plate::Creator.create!(name: name, plate_purposes: [plate_purpose]) end plate_purpose = PlatePurpose.find_by!(name: 'Pre-Extracted Plate') diff --git a/db/seeds/3000_library_types_setup.rb b/db/seeds/3000_library_types_setup.rb index b88e633444..fafed9948e 100644 --- a/db/seeds/3000_library_types_setup.rb +++ b/db/seeds/3000_library_types_setup.rb @@ -165,13 +165,13 @@ def self.existing_defaults_for(request_type) if library_types.present? library_types.each do |library_type| LibraryTypesRequestType.create!( - request_type:, - library_type:, + request_type: request_type, + library_type: library_type, is_default: library_type.name == SetupLibraryTypes.existing_defaults_for(request_type) ) end RequestType::Validator.create!( - request_type:, + request_type: request_type, request_option: 'library_type', valid_options: RequestType::Validator::LibraryTypeValidator.new(request_type.id) ) @@ -198,7 +198,11 @@ def self.existing_defaults_for(request_type) ] if read_lengths.present? - RequestType::Validator.create!(request_type:, request_option: 'read_length', valid_options: read_lengths) + RequestType::Validator.create!( + request_type: request_type, + request_option: 'read_length', + valid_options: read_lengths + ) end end @@ -229,7 +233,9 @@ def self.existing_defaults_for(request_type) %i[illumina_c_multiplexed_library_creation illumina_c_library_creation].each do |request_class_symbol| request_type = RequestType.find_by!(key: request_class_symbol.to_s) - library_types.each { |library_type| LibraryTypesRequestType.create!(request_type:, library_type:, is_default: false) } + library_types.each do |library_type| + LibraryTypesRequestType.create!(request_type: request_type, library_type: library_type, is_default: false) + end end libs_ribozero = @@ -238,7 +244,7 @@ def self.existing_defaults_for(request_type) libs_ribozero.each do |lib| %i[illumina_c_pcr illumina_c_pcr_no_pool].each do |request_class_symbol| request_type = RequestType.find_by(key: request_class_symbol.to_s) - LibraryTypesRequestType.create!(request_type:, library_type: lib, is_default: false) + LibraryTypesRequestType.create!(request_type: request_type, library_type: lib, is_default: false) end end diff --git a/db/seeds/9999_tag_qc_setup.rb b/db/seeds/9999_tag_qc_setup.rb index 583f6a87f5..db25d5e2e0 100644 --- a/db/seeds/9999_tag_qc_setup.rb +++ b/db/seeds/9999_tag_qc_setup.rb @@ -48,9 +48,9 @@ workflow.item_limit = 1 end .tap do |workflow| - t1 = SetDescriptorsTask.create!(name: 'Specify Dilution Volume', sorted: 0, workflow:) + t1 = SetDescriptorsTask.create!(name: 'Specify Dilution Volume', sorted: 0, workflow: workflow) Descriptor.create!(kind: 'Text', sorter: 1, name: 'Concentration', task: t1) - t2 = SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 0, workflow:) + t2 = SetDescriptorsTask.create!(name: 'Cluster Generation', sorted: 0, workflow: workflow) Descriptor.create!(kind: 'Text', sorter: 1, name: 'Chip barcode', task: t2) Descriptor.create!(kind: 'Text', sorter: 2, name: 'Cartridge barcode', task: t2) Descriptor.create!(kind: 'Text', sorter: 4, name: 'Machine name', task: t2) diff --git a/features/support/accession_service.rb b/features/support/accession_service.rb index b60b7f6786..086b6f2f20 100644 --- a/features/support/accession_service.rb +++ b/features/support/accession_service.rb @@ -38,7 +38,7 @@ def self.install_hooks(target, tags) # rubocop:todo Metrics/AbcSize .to_return do |_request| response = FakeAccessionService.instance.next! status = response.nil? ? 500 : 200 - { headers: { 'Content-Type' => 'text/xml' }, body: response, status: } + { headers: { 'Content-Type' => 'text/xml' }, body: response, status: status } end end end diff --git a/features/support/barcode_service.rb b/features/support/barcode_service.rb index 3d3bef0e23..c4666fbef0 100644 --- a/features/support/barcode_service.rb +++ b/features/support/barcode_service.rb @@ -64,7 +64,7 @@ def mock_child_barcodes(parent_barcode, count) end WebMock .stub_request(:post, "#{plate_barcode_url}/child-barcodes/#{configatron.plate_barcode_prefix}/new") - .with(body: { barcode: parent_barcode, count: }) + .with(body: { barcode: parent_barcode, count: count }) .to_return do { headers: { diff --git a/features/support/capybara.rb b/features/support/capybara.rb index 37d246acd6..2379940c1d 100644 --- a/features/support/capybara.rb +++ b/features/support/capybara.rb @@ -15,14 +15,14 @@ options.add_argument('--headless=old') options.add_argument('--disable-gpu') options.add_argument('--disable-search-engine-choice-screen') - Capybara::Selenium::Driver.new(app, browser: :chrome, options:) + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end Capybara.register_driver :chrome do |app| options = Selenium::WebDriver::Chrome::Options.new options.add_preference('download.default_directory', DownloadHelpers::PATH.to_s) - Capybara::Selenium::Driver.new(app, browser: :chrome, options:) + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end Capybara.default_max_wait_time = 10 diff --git a/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb b/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb index 701695b60a..d5a91ed9dc 100644 --- a/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb +++ b/features/support/step_definitions/10071597_change_request_type_on_request_steps.rb @@ -6,7 +6,14 @@ library_tube = FactoryBot.create :empty_library_tube request_type = RequestType.find_by(name: 'Illumina-B Paired end sequencing') request = - FactoryBot.create(:request, asset: library_tube, target_asset: lane, state: 'pending', project:, request_type:) + FactoryBot.create( + :request, + asset: library_tube, + target_asset: lane, + state: 'pending', + project: project, + request_type: request_type + ) project.update!(enforce_quotas: true) end diff --git a/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb b/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb index df3a12070c..593a57b44a 100644 --- a/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb +++ b/features/support/step_definitions/11438075_request_xml_exception_on_nil_study_steps.rb @@ -5,5 +5,12 @@ project = FactoryBot.create(:project) request_type = RequestType.find_by(key: 'library_creation') request = - FactoryBot.create(:request, id: request_id, study:, project:, request_type:, asset: FactoryBot.create(:sample_tube)) + FactoryBot.create( + :request, + id: request_id, + study: study, + project: project, + request_type: request_type, + asset: FactoryBot.create(:sample_tube) + ) end diff --git a/features/support/step_definitions/11803383_bug_NPG_batch_state_released_steps.rb b/features/support/step_definitions/11803383_bug_NPG_batch_state_released_steps.rb index 3696395990..b4c79bacb2 100644 --- a/features/support/step_definitions/11803383_bug_NPG_batch_state_released_steps.rb +++ b/features/support/step_definitions/11803383_bug_NPG_batch_state_released_steps.rb @@ -11,8 +11,8 @@ request_type: pipeline.request_types.last, state: 'started' - batch = FactoryBot.create(:batch, state: 'started', qc_state: 'qc_manual', pipeline:) - FactoryBot.create :batch_request, request:, batch:, position: 1 + batch = FactoryBot.create(:batch, state: 'started', qc_state: 'qc_manual', pipeline: pipeline) + FactoryBot.create :batch_request, request: request, batch: batch, position: 1 end When /^I (POST|PUT) following XML to pass QC state on the last asset:$/ do |action, xml| diff --git a/features/support/step_definitions/269135815_add_bait_library_editor_to_admin_view.rb b/features/support/step_definitions/269135815_add_bait_library_editor_to_admin_view.rb index ff322fbda0..fe0b2a8f9e 100644 --- a/features/support/step_definitions/269135815_add_bait_library_editor_to_admin_view.rb +++ b/features/support/step_definitions/269135815_add_bait_library_editor_to_admin_view.rb @@ -14,7 +14,7 @@ Given /^I have a bait library called "([^"]*)"$/ do |name| BaitLibrary.create!( - name:, + name: name, bait_library_type: BaitLibraryType.find_by(visible: true), bait_library_supplier: BaitLibrary::Supplier.find_by(visible: true), target_species: 'Dragon' @@ -26,7 +26,7 @@ end Given /^I have a bait library type called "([^"]*)"$/ do |name| - BaitLibraryType.create!(name:, category: 'standard') + BaitLibraryType.create!(name: name, category: 'standard') end Given /^I have a supplier called "([^"]*)"$/ do |name| @@ -39,7 +39,7 @@ end Given /^the last bait library has type "([^"]*)"$/ do |name| - BaitLibrary.last.update(bait_library_type: BaitLibraryType.create!(name:, category: 'standard')) + BaitLibrary.last.update(bait_library_type: BaitLibraryType.create!(name: name, category: 'standard')) end Given /^the last bait library has supplier "([^"]*)"$/ do |name| diff --git a/features/support/step_definitions/3871492_links_from_study_workflow_view_steps.rb b/features/support/step_definitions/3871492_links_from_study_workflow_view_steps.rb index 3cc83bf7f5..87afa5c725 100644 --- a/features/support/step_definitions/3871492_links_from_study_workflow_view_steps.rb +++ b/features/support/step_definitions/3871492_links_from_study_workflow_view_steps.rb @@ -5,5 +5,5 @@ sample = study.samples.create!(name: sample_name) st = SampleTube.create!.tap { |sample_tube| sample_tube.aliquots.create!(sample:, study:) } - FactoryHelp.submission(study:, assets: [st], state: 'ready') + FactoryHelp.submission(study: study, assets: [st], state: 'ready') end diff --git a/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb b/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb index e0e2f39994..a4b0c6a358 100644 --- a/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb +++ b/features/support/step_definitions/4560014_refactoring_properties_descriptors_etc_to_table_columns_steps.rb @@ -91,7 +91,7 @@ def create_request(request_type, study, project, asset, target_asset, additional tube_name = "#{group_name}, sample tube #{i}" FactoryBot.create(:sample_tube, name: tube_name, sample_attributes: { name: sample_name }) end - FactoryBot.create(:asset_group, name: group_name, study:, assets: assets.map(&:receptacle)) + FactoryBot.create(:asset_group, name: group_name, study: study, assets: assets.map(&:receptacle)) end Then /^I should see the following request information:$/ do |expected| diff --git a/features/support/step_definitions/4759010_bug_on_reset_batches_steps.rb b/features/support/step_definitions/4759010_bug_on_reset_batches_steps.rb index e73b8547b4..cb72340e4e 100644 --- a/features/support/step_definitions/4759010_bug_on_reset_batches_steps.rb +++ b/features/support/step_definitions/4759010_bug_on_reset_batches_steps.rb @@ -8,12 +8,12 @@ Given /^a batch in "Illumina-B MX Library Preparation" has been setup for feature 4759010$/ do pipeline = Pipeline.find_by(name: 'Illumina-B MX Library Preparation') or raise StandardError, "Cannot find pipeline 'Illumina-B MX Library Preparation'" - batch = FactoryBot.create :batch, pipeline:, state: 'pending' + batch = FactoryBot.create :batch, pipeline: pipeline, state: 'pending' asset_group = FactoryBot.create(:asset_group) submission = FactoryHelp.submission( - asset_group:, + asset_group: asset_group, request_options: { read_length: 76, fragment_size_required_from: 1, diff --git a/features/support/step_definitions/5070230_requesting_additional_hiseq_sequencing_steps.rb b/features/support/step_definitions/5070230_requesting_additional_hiseq_sequencing_steps.rb index cb152739ff..46f447046c 100644 --- a/features/support/step_definitions/5070230_requesting_additional_hiseq_sequencing_steps.rb +++ b/features/support/step_definitions/5070230_requesting_additional_hiseq_sequencing_steps.rb @@ -5,7 +5,7 @@ library_type = LibraryType.find_by(name: 'Standard') || FactoryBot.create(:library_type, name: 'Standard') FactoryBot.create(:library_creation_request_type, :with_library_types, library_type:).create!( asset: library_tube, - study:, + study: study, request_metadata_attributes: { fragment_size_required_from: 111, fragment_size_required_to: 222, diff --git a/features/support/step_definitions/5197615_external_release_flag_steps.rb b/features/support/step_definitions/5197615_external_release_flag_steps.rb index 4f1503ad48..5b0da6baf5 100644 --- a/features/support/step_definitions/5197615_external_release_flag_steps.rb +++ b/features/support/step_definitions/5197615_external_release_flag_steps.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true Given /^an unreleasable lane named "([^"]*)" exists$/ do |name| - FactoryBot.create(:lane, name:, external_release: false) + FactoryBot.create(:lane, name: name, external_release: false) end Given /^a releasable lane named "([^"]*)" exists$/ do |name| - FactoryBot.create(:lane, name:, external_release: true) + FactoryBot.create(:lane, name: name, external_release: true) end diff --git a/features/support/step_definitions/5397680_sequenome_plate_details_steps.rb b/features/support/step_definitions/5397680_sequenome_plate_details_steps.rb index ea0bd53f95..a67119482f 100644 --- a/features/support/step_definitions/5397680_sequenome_plate_details_steps.rb +++ b/features/support/step_definitions/5397680_sequenome_plate_details_steps.rb @@ -22,7 +22,7 @@ well.aliquots.clear well.aliquots.create!( sample: Sample.create!(name: "#{plate_barcode}_#{index}", empty_supplier_sample_name: true), - study: + study: study ) end end diff --git a/features/support/step_definitions/5781572_external_data_release_interactions_steps.rb b/features/support/step_definitions/5781572_external_data_release_interactions_steps.rb index 88d306a599..e144d8ca3c 100644 --- a/features/support/step_definitions/5781572_external_data_release_interactions_steps.rb +++ b/features/support/step_definitions/5781572_external_data_release_interactions_steps.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Given /^a state "([^"]*)" to lane named "([^"]*)"$/ do |status, name| - FactoryBot.create(:lane, name:, qc_state: status) + FactoryBot.create(:lane, name: name, qc_state: status) end Given /^an unreleasable lane named "([^"]*)"$/ do |name| diff --git a/features/support/step_definitions/6040471_truncate_sample_name_barcode_steps.rb b/features/support/step_definitions/6040471_truncate_sample_name_barcode_steps.rb index 5306109ce2..08b8f059fc 100644 --- a/features/support/step_definitions/6040471_truncate_sample_name_barcode_steps.rb +++ b/features/support/step_definitions/6040471_truncate_sample_name_barcode_steps.rb @@ -39,5 +39,5 @@ Given /^the asset "([^"]*)" has a sanger_sample_id of "([^"]*)"$/ do |asset_id, sanger_sample_id| asset = Labware.find(asset_id).receptacle asset.aliquots.clear - asset.aliquots.create!(sample: Sample.create!(name: 'Sample_123456', sanger_sample_id:)) + asset.aliquots.create!(sample: Sample.create!(name: 'Sample_123456', sanger_sample_id: sanger_sample_id)) end diff --git a/features/support/step_definitions/6218053_display_concentration_inbox_pipeline_steps.rb b/features/support/step_definitions/6218053_display_concentration_inbox_pipeline_steps.rb index a2cd1b41e0..fae396e947 100644 --- a/features/support/step_definitions/6218053_display_concentration_inbox_pipeline_steps.rb +++ b/features/support/step_definitions/6218053_display_concentration_inbox_pipeline_steps.rb @@ -7,7 +7,7 @@ metadata = FactoryBot.create :"request_metadata_for_#{request_type.key}" request = FactoryBot.create :request_with_submission, - request_type:, + request_type: request_type, asset: FactoryBot.create(asset_type), request_metadata: metadata request.asset.save! diff --git a/features/support/step_definitions/65192392_tag_qc_steps.rb b/features/support/step_definitions/65192392_tag_qc_steps.rb index 6c7a6d469f..51c84f9a5c 100644 --- a/features/support/step_definitions/65192392_tag_qc_steps.rb +++ b/features/support/step_definitions/65192392_tag_qc_steps.rb @@ -2,7 +2,7 @@ Given /^I have a lot type for testing called "(.*?)"$/ do |name| LotType.create!( - name:, + name: name, target_purpose: QcablePlatePurpose.find_by(name: 'Tag Plate'), template_class: 'TagLayoutTemplate' ) @@ -10,7 +10,7 @@ Given /^I have a reporter lot type for testing called "(.*?)"$/ do |name| LotType.create!( - name:, + name: name, target_purpose: QcablePlatePurpose.find_by(name: 'Reporter Plate'), template_class: 'PlateTemplate' ) @@ -38,7 +38,7 @@ Given /^lot "(.*?)" has (\d+) created qcables$/ do |lot_number, qcable_count| lot = Lot.find_by(lot_number:) - QcableCreator.create!(lot:, user: User.last, count: qcable_count.to_i) + QcableCreator.create!(lot: lot, user: User.last, count: qcable_count.to_i) end Then /^the qcables in lot "(.*?)" should be "(.*?)"$/ do |lot_number, target_state| @@ -54,19 +54,19 @@ user = User.last 9.times { |pos| step "the Baracoda barcode service returns \"SQPD-100000#{pos + 1}\"" } step 'a robot exists' - qccreate = QcableCreator.create!(lot:, user:, count: 6) + qccreate = QcableCreator.create!(lot: lot, user: user, count: 6) step 'all of this is happening at exactly "23-Oct-2010 23:00:00+01:00"' sqc_a = Stamp::StampQcable.new(bed: '1', order: 1, qcable: qccreate.qcables[0]) sqc_b = Stamp::StampQcable.new(bed: '2', order: 2, qcable: qccreate.qcables[4]) - stamp_a = Stamp.create!(user:, tip_lot: '1234556', stamp_qcables: [sqc_a, sqc_b], lot:, robot: Robot.last) + stamp_a = Stamp.create!(user: user, tip_lot: '1234556', stamp_qcables: [sqc_a, sqc_b], lot: lot, robot: Robot.last) step 'all of this is happening at exactly "23-Oct-2010 23:20:00+01:00"' sqc_c = Stamp::StampQcable.new(bed: '5', order: 1, qcable: qccreate.qcables[3]) sqc_d = Stamp::StampQcable.new(bed: '3', order: 2, qcable: qccreate.qcables[2]) - stamp_b = Stamp.create!(user:, tip_lot: '1234556', stamp_qcables: [sqc_c, sqc_d], lot:, robot: Robot.last) + stamp_b = Stamp.create!(user: user, tip_lot: '1234556', stamp_qcables: [sqc_c, sqc_d], lot: lot, robot: Robot.last) end Given /^I have a qcable$/ do @@ -74,7 +74,7 @@ user = User.last step 'the UUID of the next plate created will be "55555555-6666-7777-8888-000000000004"' step 'the Baracoda barcode service returns "SQPD-1000001"' - QcableCreator.create!(lot:, user:, count: 1) + QcableCreator.create!(lot: lot, user: user, count: 1) end Given /^I have two qcables$/ do @@ -82,11 +82,11 @@ user = User.last step 'the Baracoda barcode service returns "SQPD-1000001"' step 'the Baracoda barcode service returns "SQPD-1000002"' - QcableCreator.create!(lot:, user:, count: 2) + QcableCreator.create!(lot: lot, user: user, count: 2) end Given /^I have a robot for testing called "(.*?)"$/ do |name| - Robot.create!(name:, location: 'Somewhere', barcode: 123) do |robot| + Robot.create!(name: name, location: 'Somewhere', barcode: 123) do |robot| robot.robot_properties.build( [ { name: 'Max Number of plates', key: 'max_plates', value: '3' }, @@ -104,15 +104,23 @@ user = User.last step 'the Baracoda barcode service returns "SQPD-1000001"' step 'the Baracoda barcode service returns "SQPD-1000002"' - qca = QcableCreator.create!(lot:, user:, count: 1) - qcb = QcableCreator.create!(lot: lot_b, user:, count: 1) + qca = QcableCreator.create!(lot: lot, user: user, count: 1) + qcb = QcableCreator.create!(lot: lot_b, user: user, count: 1) tag_plate = qca.qcables.first.asset reporter_plate = qcb.qcables.first.asset tag_plate.update!(plate_purpose: PlatePurpose.find_by(name: 'Tag PCR')) - Transfer::BetweenPlates.create!(user:, source: reporter_plate, destination: tag_plate, transfers: { 'A1' => 'A1' }) - stc = SpecificTubeCreation.create!(parent: tag_plate, child_purposes: [Tube::Purpose.find_by(name: 'Tag MX')], user:) + Transfer::BetweenPlates.create!( + user: user, + source: reporter_plate, + destination: tag_plate, + transfers: { + 'A1' => 'A1' + } + ) + stc = + SpecificTubeCreation.create!(parent: tag_plate, child_purposes: [Tube::Purpose.find_by(name: 'Tag MX')], user: user) batch = Batch .new(pipeline: Pipeline.find_by(name: 'MiSeq sequencing')) @@ -120,7 +128,7 @@ batch.id = 12_345 batch.save! end - FactoryBot.create :request_without_submission, asset: stc.children.first, batch: + FactoryBot.create :request_without_submission, asset: stc.children.first, batch: batch # Batch.find(12345).batch_requests.create!(:request=>Request.create!(:asset=>stc.children.first),:position=>1) end Given /^the library is testing a reporter$/ do diff --git a/features/support/step_definitions/6679401_batch_request_recycling_broken_steps.rb b/features/support/step_definitions/6679401_batch_request_recycling_broken_steps.rb index a73887c64a..794cfdea02 100644 --- a/features/support/step_definitions/6679401_batch_request_recycling_broken_steps.rb +++ b/features/support/step_definitions/6679401_batch_request_recycling_broken_steps.rb @@ -9,7 +9,7 @@ .create!(name: group_name) .tap do |asset_group| asset_group.assets << (1..count.to_i).map do |index| - FactoryBot.create(:well, plate:, map: Map.map_96wells[index - 1]) + FactoryBot.create(:well, plate: plate, map: Map.map_96wells[index - 1]) end end end @@ -73,9 +73,9 @@ def build_batch_for(name, count) # rubocop:todo Metrics/AbcSize :linear_submission, study: FactoryBot.create(:study), project: FactoryBot.create(:project), - user:, + user: user, # Setup the assets so that they have samples and they are scanned into the correct lab. - assets:, + assets: assets, request_types: [rt_id], # Request parameter options request_options: submission_details[:request_options] diff --git a/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb b/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb index 178e658ef5..920df971a4 100644 --- a/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb +++ b/features/support/step_definitions/7119309_pulldown_cherrypick_pipeline_steps.rb @@ -38,7 +38,8 @@ Given(/^I have a plate "([^"]*)" with the following wells:$/) do |plate_barcode, well_details| plate = FactoryBot.create :plate, barcode: plate_barcode well_details.hashes.each do |well_detail| - well = Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate:) + well = + Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate: plate) well.well_attribute.update!( concentration: well_detail[:measured_concentration], measured_volume: well_detail[:measured_volume] diff --git a/features/support/step_definitions/api_steps.rb b/features/support/step_definitions/api_steps.rb index fd4c1e6a01..2a6ed03f95 100644 --- a/features/support/step_definitions/api_steps.rb +++ b/features/support/step_definitions/api_steps.rb @@ -119,7 +119,7 @@ def api_request(action, path, body) # rubocop:todo Metrics/AbcSize end Given /^I have a "(.*?)" authorised user with the key "(.*?)"$/ do |permission, key| - ApiApplication.new(name: 'test_api', key:, privilege: permission, contact: 'none').save(validate: false) + ApiApplication.new(name: 'test_api', key: key, privilege: permission, contact: 'none').save(validate: false) end When /^I retrieve the JSON for all (studies|samples|requests)$/ do |model| diff --git a/features/support/step_definitions/asset_steps.rb b/features/support/step_definitions/asset_steps.rb index 3592b5dad5..1b76b0a837 100644 --- a/features/support/step_definitions/asset_steps.rb +++ b/features/support/step_definitions/asset_steps.rb @@ -20,7 +20,7 @@ end Given /^(?:I have )?a phiX tube called "([^"]+)"$/ do |name| - FactoryBot.create(:sample_tube, name:, study: nil, project: nil) + FactoryBot.create(:sample_tube, name: name, study: nil, project: nil) end Given /^(?:I have )?a (sample|library) tube called "([^"]+)"$/ do |tube_type, name| @@ -41,6 +41,6 @@ AssetLink.create_edge(source_plate, target_plate) target_plate.wells.each do |target_well| source_well = source_plate.wells.located_at(target_well.map_description).first - Well::Link.create!(target_well:, source_well:, type: 'stock') + Well::Link.create!(target_well: target_well, source_well: source_well, type: 'stock') end end diff --git a/features/support/step_definitions/authentication_steps.rb b/features/support/step_definitions/authentication_steps.rb index c97a12f2ef..b5661ad03e 100644 --- a/features/support/step_definitions/authentication_steps.rb +++ b/features/support/step_definitions/authentication_steps.rb @@ -12,7 +12,7 @@ @current_user = FactoryBot.create( :user, - login:, + login: login, first_name: 'John', last_name: 'Doe', password: 'generic', diff --git a/features/support/step_definitions/barcode_steps.rb b/features/support/step_definitions/barcode_steps.rb index 9b7423207d..3ef23f0ee0 100644 --- a/features/support/step_definitions/barcode_steps.rb +++ b/features/support/step_definitions/barcode_steps.rb @@ -31,7 +31,7 @@ Given /^the "([^"]+)" barcode printer "([^"]+)" exists$/ do |type_name, name| printer_type = BarcodePrinterType.find_by!(name: type_name) - BarcodePrinter.create!(name:, barcode_printer_type: printer_type, active: true) + BarcodePrinter.create!(name: name, barcode_printer_type: printer_type, active: true) end Given '{asset_id} has a barcode of {string}' do |barcoded, barcode| diff --git a/features/support/step_definitions/custom_metadatum_collection_steps.rb b/features/support/step_definitions/custom_metadatum_collection_steps.rb index 6002a6b34d..e44fd42968 100644 --- a/features/support/step_definitions/custom_metadatum_collection_steps.rb +++ b/features/support/step_definitions/custom_metadatum_collection_steps.rb @@ -5,7 +5,7 @@ FactoryBot.build(:custom_metadatum, key: 'Key1', value: 'Value1'), FactoryBot.build(:custom_metadatum, key: 'Key2', value: 'Value2') ] - FactoryBot.create(:custom_metadatum_collection, id:, custom_metadata: metadata) + FactoryBot.create(:custom_metadatum_collection, id: id, custom_metadata: metadata) end Given(/^the UUID for the custom metadatum collection with ID (\d+) is "(.*?)"$/) do |id, uuid| diff --git a/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb b/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb index a40295ce45..1a0e999a2b 100644 --- a/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb +++ b/features/support/step_definitions/display_submitted_at_inbox_pipeline_steps.rb @@ -6,7 +6,8 @@ request_type = pipeline.request_types.detect { |rt| !rt.deprecated } metadata = FactoryBot.create :"request_metadata_for_#{request_type.key}" asset = FactoryBot.create(asset_type) - request = FactoryBot.create :request_with_submission, request_type:, asset:, request_metadata: metadata + request = + FactoryBot.create :request_with_submission, request_type: request_type, asset: asset, request_metadata: metadata request.asset.plate = FactoryBot.create(:plate) if request.asset.plate.nil? if request.asset.is_a?(Well) request.asset.save! diff --git a/features/support/step_definitions/genotyping_steps.rb b/features/support/step_definitions/genotyping_steps.rb index 6e30ec746c..aef87642e6 100644 --- a/features/support/step_definitions/genotyping_steps.rb +++ b/features/support/step_definitions/genotyping_steps.rb @@ -30,9 +30,12 @@ asset_group = study.asset_groups.find_by(name: asset_group_name) || study.asset_groups.create!(name: asset_group_name) asset_group.assets << (1..number_of_samples.to_i).map do |index| FactoryBot - .create(:well, plate:, map_id: index) + .create(:well, plate: plate, map_id: index) .tap do |well| - well.aliquots.create!(sample: FactoryBot.create(:sample, name: "Sample_#{plate_barcode}_#{index}"), study:) + well.aliquots.create!( + sample: FactoryBot.create(:sample, name: "Sample_#{plate_barcode}_#{index}"), + study: study + ) end end end @@ -98,7 +101,7 @@ wells = plate.wells.in_column_major_order.to_a submission_template = SubmissionTemplate.find_by(name: submission_template_name) - order = submission_template.create_with_submission!(study:, project:, user: User.last, assets: wells) + order = submission_template.create_with_submission!(study: study, project: project, user: User.last, assets: wells) order.submission.built! step('1 pending delayed jobs are processed') end @@ -109,7 +112,13 @@ asset_group = AssetGroup.find_by(name: asset_group_name) submission_template = SubmissionTemplate.find_by(name: 'Cherrypick') - order = submission_template.create_with_submission!(study:, project:, user: User.last, assets: asset_group.assets) + order = + submission_template.create_with_submission!( + study: study, + project: project, + user: User.last, + assets: asset_group.assets + ) order.submission.built! step('1 pending delayed jobs are processed') end diff --git a/features/support/step_definitions/pipeline_steps.rb b/features/support/step_definitions/pipeline_steps.rb index 3bbc666198..f72785a6e3 100644 --- a/features/support/step_definitions/pipeline_steps.rb +++ b/features/support/step_definitions/pipeline_steps.rb @@ -2,7 +2,7 @@ Given /^I have a pipeline called "([^"]*)"$/ do |name| request_type = FactoryBot.create :request_type - pipeline = FactoryBot.create :pipeline, name:, request_types: [request_type] + pipeline = FactoryBot.create :pipeline, name: name, request_types: [request_type] pipeline.workflow.update!(item_limit: 8) task = FactoryBot.create :task, name: 'Task1', workflow: pipeline.workflow end @@ -12,11 +12,11 @@ end Given /^I have a "([^"]*)" batch in "([^"]*)"$/ do |state, pipeline| - @batch = FactoryBot.create :batch, pipeline: Pipeline.find_by(name: pipeline), state:, production_state: nil + @batch = FactoryBot.create :batch, pipeline: Pipeline.find_by(name: pipeline), state: state, production_state: nil end Given /^I have a control called "([^"]*)" for "([^"]*)"$/ do |name, pipeline_name| - control = FactoryBot.create :control, name:, pipeline: Pipeline.find_by(name: pipeline_name) + control = FactoryBot.create :control, name: name, pipeline: Pipeline.find_by(name: pipeline_name) end def pipeline_name_to_asset_type(pipeline_name) @@ -34,7 +34,7 @@ def create_request_for_pipeline(pipeline_name, options = {}) # rubocop:todo Metr options.merge( request_type: pipeline.request_types.last, asset: FactoryBot.create(pipeline_name_to_asset_type(pipeline_name)), - request_metadata: + request_metadata: request_metadata ) FactoryBot .create(:request_with_submission, request_parameters) diff --git a/features/support/step_definitions/plate_steps.rb b/features/support/step_definitions/plate_steps.rb index 42f0ad14df..0c2e4d3bac 100644 --- a/features/support/step_definitions/plate_steps.rb +++ b/features/support/step_definitions/plate_steps.rb @@ -2,7 +2,7 @@ Given /^plate "([^"]*)" has "([^"]*)" wells$/ do |plate_barcode, number_of_wells| plate = Plate.find_from_barcode(plate_barcode) - 1.upto(number_of_wells.to_i) { |i| Well.create!(plate:, map_id: i) } + 1.upto(number_of_wells.to_i) { |i| Well.create!(plate: plate, map_id: i) } end Then /^plate with barcode "([^"]*)" should exist$/ do |plate_barcode| @@ -31,14 +31,15 @@ end Given 'a tube named {string} with barcode {string} exists' do |name, machine_barcode| - FactoryBot.create :tube, name:, sanger_barcode: { machine_barcode: } + FactoryBot.create :tube, name: name, sanger_barcode: { machine_barcode: } end Given /^a plate with barcode "([^"]*)" exists$/ do |machine_barcode| if machine_barcode.start_with?('SQPD') FactoryBot.create :plate, sanger_barcode: Barcode.build_sequencescape22({ barcode: machine_barcode }) else - FactoryBot.create :plate, sanger_barcode: Barcode.build_sanger_code39({ machine_barcode:, format: 'DN' }) + FactoryBot.create :plate, + sanger_barcode: Barcode.build_sanger_code39({ machine_barcode: machine_barcode, format: 'DN' }) end end @@ -46,7 +47,7 @@ Given /^a "([^"]*)" plate purpose and of type "([^"]*)" with barcode "([^"]*)" exists$/ do |plate_purpose_name, plate_type, machine_barcode| # rubocop:enable Layout/LineLength plate_type.constantize.create!( - sanger_barcode: Barcode.build_sanger_code39({ machine_barcode:, format: 'DN' }), + sanger_barcode: Barcode.build_sanger_code39({ machine_barcode: machine_barcode, format: 'DN' }), plate_purpose: PlatePurpose.find_by(name: plate_purpose_name), name: machine_barcode ) @@ -110,7 +111,7 @@ Given /^well "([^"]*)" is holded by plate "([^"]*)"$/ do |well_uuid, plate_uuid| well = Uuid.find_by(external_id: well_uuid).resource plate = Uuid.find_by(external_id: plate_uuid).resource - well.update!(plate:, map: Map.find_by(description: 'A1', asset_size: plate.size)) + well.update!(plate: plate, map: Map.find_by(description: 'A1', asset_size: plate.size)) Plate.find(plate_id).primary_barcode.update!(barcode: 'DN1S') end @@ -125,20 +126,27 @@ Given(/^a plate called "([^"]*)" exists with purpose "([^"]*)"$/) do |name, purpose_name| purpose = Purpose.find_by(name: purpose_name) || FactoryBot.create(:plate_purpose, name: purpose_name) - FactoryBot.create(:plate, name:, purpose:, well_count: 8) + FactoryBot.create(:plate, name: name, purpose: purpose, well_count: 8) end Given( /^a full plate called "([^"]*)" exists with purpose "([^"]*)" and barcode "([^"]*)"$/ ) do |name, purpose_name, barcode| purpose = Purpose.find_by(name: purpose_name) || FactoryBot.create(:plate_purpose, name: purpose_name) - FactoryBot.create(:full_plate, well_factory: :untagged_well, name:, purpose:, barcode:, well_count: 16) + FactoryBot.create( + :full_plate, + well_factory: :untagged_well, + name: name, + purpose: purpose, + barcode: barcode, + well_count: 16 + ) end Given /^a "([^"]+)" plate called "([^"]+)" exists with barcode "([^"]+)"$/ do |name, plate_name, barcode| plate_purpose = PlatePurpose.find_by!(name:) step("the Baracoda barcode service returns \"#{barcode}\"") - plate_purpose.create!(name: plate_name, barcode:) + plate_purpose.create!(name: plate_name, barcode: barcode) end Given /^a "([^"]+)" plate called "([^"]+)" exists as a child of "([^"]+)"$/ do |name, plate_name, parent_name| @@ -167,7 +175,7 @@ Given /^the plate "([^"]*)" is (passed|started|pending|failed) by "([^"]*)"$/ do |plate_name, state, user_name| plate = Plate.find_by(name: plate_name) user = User.find_by(login: user_name) - StateChange.create!(user:, target: plate, target_state: state) + StateChange.create!(user: user, target: plate, target_state: state) end # rubocop:todo Layout/LineLength @@ -180,7 +188,7 @@ :transfer_request, asset: source.wells.in_row_major_order[i], target_asset: destination.wells.in_row_major_order[i], - state: + state: state ) Well::Link.create!( source_well: source.wells.in_row_major_order[i], @@ -205,7 +213,8 @@ # plate = FactoryBot.create :plate, :barcode => plate_barcode plate = Uuid.find_by(external_id: uuid).resource well_details.hashes.each do |well_detail| - well = Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate:) + well = + Well.create!(map: Map.find_by(description: well_detail[:well_location], asset_size: plate.size), plate: plate) well.well_attribute.update!( concentration: well_detail[:measured_concentration], measured_volume: well_detail[:measured_volume] diff --git a/features/support/step_definitions/pulldown_steps.rb b/features/support/step_definitions/pulldown_steps.rb index 5e0954d8b8..9a653275a1 100644 --- a/features/support/step_definitions/pulldown_steps.rb +++ b/features/support/step_definitions/pulldown_steps.rb @@ -9,8 +9,8 @@ def create_submission_of_assets(template, assets, request_options = {}) user: FactoryBot.create(:user), study: FactoryBot.create(:study), project: FactoryBot.create(:project), - assets:, - request_options: + assets: assets, + request_options: request_options ).submission submission.built! Delayed::Worker.delay_jobs = true @@ -35,7 +35,7 @@ def create_submission_of_assets(template, assets, request_options = {}) plate .wells .select(&range.method(:include?)) - .each { |well| FactoryBot.create :transfer_request, submission:, target_asset: well } + .each { |well| FactoryBot.create :transfer_request, submission: submission, target_asset: well } end Given '{well_range} of {plate_name} have been failed' do |range, plate| @@ -119,7 +119,7 @@ def work_pipeline_for(submissions, name, template = nil) # rubocop:todo Metrics/ # rubocop:todo Layout/LineLength Given 'all of the wells on {plate_name} are in an asset group called {string} owned by {study_name}' do |plate, name, study| # rubocop:enable Layout/LineLength - AssetGroup.create!(study:, name:, assets: plate.wells) + AssetGroup.create!(study: study, name: name, assets: plate.wells) end Then /^all "([^"]+)" requests should have the following details:$/ do |name, table| @@ -168,8 +168,8 @@ def work_pipeline_for(submissions, name, template = nil) # rubocop:todo Metrics/ .readonly(false) .each_with_index do |well, i| stock_well = stock_wells[i] - FactoryBot.create(:library_creation_request, asset: stock_well, target_asset: well, submission:) - FactoryBot.create(:transfer_request, asset: stock_well, target_asset: well, submission:) + FactoryBot.create(:library_creation_request, asset: stock_well, target_asset: well, submission: submission) + FactoryBot.create(:transfer_request, asset: stock_well, target_asset: well, submission: submission) well.stock_wells.attach!([stock_well]) end end diff --git a/features/support/step_definitions/sample_manifest_steps.rb b/features/support/step_definitions/sample_manifest_steps.rb index 66ef3ce5e3..65a265df41 100644 --- a/features/support/step_definitions/sample_manifest_steps.rb +++ b/features/support/step_definitions/sample_manifest_steps.rb @@ -170,7 +170,8 @@ def instance.next! Given /^a manifest has been created for "([^"]*)"$/ do |study_name| study = Study.find_by!(name: study_name) supplier = Supplier.find_by!(name: 'Test supplier name') - sample_manifest = FactoryBot.create :sample_manifest, study:, supplier:, user: User.find_by(first_name: 'john') + sample_manifest = + FactoryBot.create :sample_manifest, study: study, supplier: supplier, user: User.find_by(first_name: 'john') sample_manifest.generate Delayed::Worker.new.work_off visit(url_for(sample_manifest)) diff --git a/features/support/step_definitions/study_report_steps.rb b/features/support/step_definitions/study_report_steps.rb index 5f1238b424..6494af4a57 100644 --- a/features/support/step_definitions/study_report_steps.rb +++ b/features/support/step_definitions/study_report_steps.rb @@ -6,12 +6,12 @@ Given /^there is (\d+) pending report for study "([^"]*)"$/ do |num_reports, study_name| study = Study.find_by(name: study_name) or raise StandardError, "Cannot find study #{study_name.inspect}" - 1.upto(num_reports.to_i) { FactoryBot.create :pending_study_report, study:, user: @current_user } + 1.upto(num_reports.to_i) { FactoryBot.create :pending_study_report, study: study, user: @current_user } end Given /^there is (\d+) completed report for study "([^"]*)"$/ do |num_reports, study_name| study = Study.find_by(name: study_name) or raise StandardError, "Cannot find study #{study_name.inspect}" - 1.upto(num_reports.to_i) { FactoryBot.create :completed_study_report, study:, user: @current_user } + 1.upto(num_reports.to_i) { FactoryBot.create :completed_study_report, study: study, user: @current_user } end Then /^I should see the report for "([^"]*)":$/ do |study_name, expected_results_table| diff --git a/features/support/step_definitions/study_steps.rb b/features/support/step_definitions/study_steps.rb index a580958910..e3bacbb72b 100644 --- a/features/support/step_definitions/study_steps.rb +++ b/features/support/step_definitions/study_steps.rb @@ -22,7 +22,7 @@ Given /^study "([^"]*)" has assets registered$/ do |study| proj = Study.find_by(name: study) user = User.find_by login: 'user' - new_sample_group = FactoryBot.create :asset_group, name: 'new_asset_group', user:, study: proj + new_sample_group = FactoryBot.create :asset_group, name: 'new_asset_group', user: user, study: proj end Given /^the following user records$/ do |table| @@ -176,7 +176,7 @@ def given_study_metadata(attribute, regexp) proj = Study.find_by(name: study) user = User.find_by login: 'user' - id_asset_group = FactoryBot.create :asset_group, user:, study: proj + id_asset_group = FactoryBot.create :asset_group, user: user, study: proj id_asset = FactoryBot.create :sample_tube, name: 'Cucumberirbattle', barcode: 'barcode', closed: '0' id_aga = FactoryBot.create :asset_group_asset, asset_id: id_asset.id, asset_group_id: id_asset_group.id end diff --git a/features/support/step_definitions/submission_steps.rb b/features/support/step_definitions/submission_steps.rb index 95fb6ed354..77ea087ab6 100644 --- a/features/support/step_definitions/submission_steps.rb +++ b/features/support/step_definitions/submission_steps.rb @@ -175,7 +175,7 @@ def with_request_type_scope(name, &) study: Study.find_by(name: params['Study']), asset_group: AssetGroup.find_by(name: params['Asset Group']), user: @current_user, - request_options: + request_options: request_options ) .submission .built! diff --git a/features/support/step_definitions/tag_layout_steps.rb b/features/support/step_definitions/tag_layout_steps.rb index 2b6df54a99..8a829ebedc 100644 --- a/features/support/step_definitions/tag_layout_steps.rb +++ b/features/support/step_definitions/tag_layout_steps.rb @@ -5,7 +5,7 @@ end Given /^the tag 2 layout template "([^"]+)" exists$/ do |name| - FactoryBot.create(:tag2_layout_template, name:, oligo: 'AAA') + FactoryBot.create(:tag2_layout_template, name: name, oligo: 'AAA') end TAG_LAYOUT_TEMPLATE_REGEXP = 'tag layout template "[^\"]+"' @@ -126,8 +126,11 @@ def pool_by_strategy(source, destination, pooling_strategy) # rubocop:todo Metri wells_for_source .zip(wells_for_destination) .each do |w| - TransferRequest.create!(asset: w.first, target_asset: w.last, submission_id:) - FactoryBot.create :request_without_submission, asset: w.first, target_asset: w.last, submission_id: + TransferRequest.create!(asset: w.first, target_asset: w.last, submission_id: submission_id) + FactoryBot.create :request_without_submission, + asset: w.first, + target_asset: w.last, + submission_id: submission_id end end end diff --git a/features/support/step_definitions/transfer_steps.rb b/features/support/step_definitions/transfer_steps.rb index b27533da51..8f70e44691 100644 --- a/features/support/step_definitions/transfer_steps.rb +++ b/features/support/step_definitions/transfer_steps.rb @@ -83,7 +83,7 @@ def transfer_model(name) source = Plate.find_by(name: source_name) or raise StandardError, "Could not find source plate #{source_name.inspect}" destination = Plate.find_by(name: destination_name) or raise StandardError, "Could not find destination plate #{destination_plate.inspect}" - template.create!(source:, destination:, user: FactoryBot.create(:user)) + template.create!(source: source, destination: destination, user: FactoryBot.create(:user)) end def assert_request_state(state, targets, direction, request_class) diff --git a/features/support/step_definitions/tube_steps.rb b/features/support/step_definitions/tube_steps.rb index 7ce48251df..6ee3304a57 100644 --- a/features/support/step_definitions/tube_steps.rb +++ b/features/support/step_definitions/tube_steps.rb @@ -2,5 +2,5 @@ Given /^a "([^"]*)" tube called "([^"]*)" exists$/ do |tube_purpose, tube_name| purpose = Tube::Purpose.find_by!(name: tube_purpose) - test = purpose.target_type.constantize.create!(name: tube_name, purpose:) + test = purpose.target_type.constantize.create!(name: tube_name, purpose: purpose) end diff --git a/features/support/step_definitions/user_steps.rb b/features/support/step_definitions/user_steps.rb index 8b3f9dbf07..d394c2ece0 100644 --- a/features/support/step_definitions/user_steps.rb +++ b/features/support/step_definitions/user_steps.rb @@ -26,7 +26,7 @@ if User.find_by(login: user_name) User.find_by(login: user_name).update!(barcode:) else - FactoryBot.create :user, barcode:, login: user_name + FactoryBot.create :user, barcode: barcode, login: user_name end end diff --git a/features/support/step_definitions/web_steps.rb b/features/support/step_definitions/web_steps.rb index 9988603faa..55f99dc732 100644 --- a/features/support/step_definitions/web_steps.rb +++ b/features/support/step_definitions/web_steps.rb @@ -161,15 +161,15 @@ def with_scope(locator) stub_request(:get, "#{LabelPrinter::PmbClient.label_templates_filter_url}sqsc_96plate_label_template").with( headers: LabelPrinter::PmbClient.headers - ).to_return(status: 200, body:) + ).to_return(status: 200, body: body) stub_request(:get, "#{LabelPrinter::PmbClient.label_templates_filter_url}tube_label_template_1d").with( headers: LabelPrinter::PmbClient.headers - ).to_return(status: 200, body:) + ).to_return(status: 200, body: body) stub_request(:get, "#{LabelPrinter::PmbClient.label_templates_filter_url}sqsc_384plate_label_template").with( headers: LabelPrinter::PmbClient.headers - ).to_return(status: 200, body:) + ).to_return(status: 200, body: body) end Then /^Pmb is up and running$/ do diff --git a/lib/accession/accession/contact.rb b/lib/accession/accession/contact.rb index 44109f1f23..107bad8e2c 100644 --- a/lib/accession/accession/contact.rb +++ b/lib/accession/accession/contact.rb @@ -19,7 +19,7 @@ def email end def to_h - { inform_on_error: email, inform_on_status: email, name: } + { inform_on_error: email, inform_on_status: email, name: name } end end end diff --git a/lib/acts_as_descriptable.rb b/lib/acts_as_descriptable.rb index 644b006e1a..2725d22901 100644 --- a/lib/acts_as_descriptable.rb +++ b/lib/acts_as_descriptable.rb @@ -34,7 +34,7 @@ def self.included(base) end def descriptors - descriptor_hash.map { |field, value| Descriptor.new(name: field, value:) } + descriptor_hash.map { |field, value| Descriptor.new(name: field, value: value) } end def descriptor_value(key) diff --git a/lib/event_factory.rb b/lib/event_factory.rb index aacb070694..4c443eccfe 100644 --- a/lib/event_factory.rb +++ b/lib/event_factory.rb @@ -16,7 +16,7 @@ def self.new_project(project, user) eventful_type: 'Project', message: 'Project registered', created_by: user.login, - content:, + content: content, of_interest_to: 'administrators' ) event.save @@ -33,7 +33,7 @@ def self.project_approved(project, user) eventful_type: 'Project', message: 'Project approved', created_by: user.login, - content:, + content: content, of_interest_to: 'administrators' ) event.save @@ -48,7 +48,7 @@ def self.project_refund_request(project, user, reference) eventful_type: 'Project', message: "Refund #{reference}", created_by: user.login, - content:, + content: content, of_interest_to: 'administrators' ) event.save @@ -73,7 +73,7 @@ def self.request_update_note_to_manager(request, user, message) # rubocop:todo M eventful_type: 'Request', message: 'Request update(s) failed', created_by: user.login, - content:, + content: content, of_interest_to: 'manager' ) diff --git a/lib/insdc/import_countries.rb b/lib/insdc/import_countries.rb index e218162f7d..db86dc4efe 100644 --- a/lib/insdc/import_countries.rb +++ b/lib/insdc/import_countries.rb @@ -35,7 +35,7 @@ def import private def generate_countries(pending_countries) - Insdc::Country.import(pending_countries.map { |name| { name:, sort_priority: priority_for(name) } }) + Insdc::Country.import(pending_countries.map { |name| { name: name, sort_priority: priority_for(name) } }) end def priority_for(name) diff --git a/lib/label_printer/label_printer/label/base_plate.rb b/lib/label_printer/label_printer/label/base_plate.rb index d97af71f3f..bc19fef959 100644 --- a/lib/label_printer/label_printer/label/base_plate.rb +++ b/lib/label_printer/label_printer/label/base_plate.rb @@ -6,7 +6,7 @@ class BasePlate def build_label(plate) { - top_left:, + top_left: top_left, bottom_left: bottom_left(plate), top_right: top_right(plate), bottom_right: bottom_right(plate), diff --git a/lib/label_printer/label_printer/pmb_client.rb b/lib/label_printer/label_printer/pmb_client.rb index 80f0a3215d..6f0032d0a3 100644 --- a/lib/label_printer/label_printer/pmb_client.rb +++ b/lib/label_printer/label_printer/pmb_client.rb @@ -92,7 +92,7 @@ def self.prettify_new_errors(errors) [].tap do |error_list| errors.each do |error| attribute = error['source']['pointer'].split('/').last.humanize - error_list << ('%{attribute} %{message}' % { attribute:, message: error['detail'] }) + error_list << ('%{attribute} %{message}' % { attribute: attribute, message: error['detail'] }) end end .join('; ') diff --git a/lib/label_printer/label_printer/print_job.rb b/lib/label_printer/label_printer/print_job.rb index 85e5215496..1f55858bd9 100644 --- a/lib/label_printer/label_printer/print_job.rb +++ b/lib/label_printer/label_printer/print_job.rb @@ -31,7 +31,11 @@ def execute # rubocop:todo Metrics/MethodLength end def build_attributes - @build_attributes ||= { printer_name:, label_template_name:, labels: labels_attribute } + @build_attributes ||= { + printer_name: printer_name, + label_template_name: label_template_name, + labels: labels_attribute + } end # returns: a list of labels diff --git a/lib/limber/helper.rb b/lib/limber/helper.rb index 51b8a20135..6b480ac345 100644 --- a/lib/limber/helper.rb +++ b/lib/limber/helper.rb @@ -175,8 +175,8 @@ def each_submission_template name: name_for(cherrypick, sequencing_request_type), submission_class_name: 'LinearSubmission', submission_parameters: submission_parameters(cherrypick, sequencing_request_type), - superceded_by_id:, - product_line_id:, + superceded_by_id: superceded_by_id, + product_line_id: product_line_id, product_catalogue: catalogue } ) diff --git a/lib/mbrave_tags_creator.rb b/lib/mbrave_tags_creator.rb index 32985c22b1..795340da3f 100644 --- a/lib/mbrave_tags_creator.rb +++ b/lib/mbrave_tags_creator.rb @@ -129,7 +129,7 @@ def _validate_reverse_row(row) def _create_tag_group(tag_group_name, tags) raise "TagGroup #{tag_group_name} already exists" if TagGroup.find_by(name: tag_group_name) - TagGroup.create(name: tag_group_name, tags:) + TagGroup.create(name: tag_group_name, tags: tags) end def _add_to_yaml(_yaml_filename, tag_group_name, mbrave_tags, version, num_plate) @@ -157,13 +157,13 @@ def create_tag_plates(tag_layout_templates, user) # rubocop:todo Metrics/MethodL lot_type.lots.create!( lot_number: "PSD_#{Time.current.to_f}", template: tag_layout_template, - user:, + user: user, received_at: Time.current ) text_code = text_code_for_tag_layout(tag_layout_template) plate_barcode = PlateBarcode.create_barcode_with_text(text_code) # barcode object - qcc = QcableCreator.create!(lot:, user:, supplied_barcode: plate_barcode) + qcc = QcableCreator.create!(lot: lot, user: user, supplied_barcode: plate_barcode) qcc.qcables.each_with_index do |qcable, _index| qcable.update!(state: 'available') log_line { "#{tag_layout_template.name}:" } @@ -190,10 +190,10 @@ def process_create_tag_groups(forward_filename, reverse_filename, version) ActiveRecord::Base.transaction do mbrave_tags_creator = MbraveTagsCreator.new( - forward_filename:, - reverse_filename:, + forward_filename: forward_filename, + reverse_filename: reverse_filename, tag_identifier: MbraveTagsCreator::TAG_IDENTIFIER, - version:, + version: version, yaml_filename: MbraveTagsCreator::YAML_FILENAME ) diff --git a/lib/object_space_profile.rb b/lib/object_space_profile.rb index ded7b8bda0..85ed2f7377 100644 --- a/lib/object_space_profile.rb +++ b/lib/object_space_profile.rb @@ -41,7 +41,7 @@ def measure(garbage_collect = true) # Export the collected information to the csv file named filename # @param [String] filename The csv file to generate (In the application base directory) def report(filename) - CSV.open(filename, 'wb', headers:, write_headers: true) do |csv| + CSV.open(filename, 'wb', headers: headers, write_headers: true) do |csv| @data.each_with_index { |data, index| csv << data.merge({ 'Iteration' => index }) } end end diff --git a/lib/product_helpers.rb b/lib/product_helpers.rb index 35188bc096..5c6be42db6 100644 --- a/lib/product_helpers.rb +++ b/lib/product_helpers.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true module ProductHelpers def self.single_template(name) - { name:, selection_behaviour: 'SingleProduct', products: { nil => name } } + { name: name, selection_behaviour: 'SingleProduct', products: { nil => name } } end end diff --git a/lib/record_loader/pipeline_loader.rb b/lib/record_loader/pipeline_loader.rb index a04859260e..4c027673ee 100644 --- a/lib/record_loader/pipeline_loader.rb +++ b/lib/record_loader/pipeline_loader.rb @@ -20,13 +20,13 @@ def add_spiked_in_control_event(workflow) name: 'Add Spiked in control', sorted: 0, lab_activity: true, - workflow: + workflow: workflow ).find_or_create_by!(pipeline_workflow_id: workflow.pipeline_id) end def add_loading_event(workflow) SetDescriptorsTask - .create_with(name: 'Loading', sorted: 1, lab_activity: true, workflow:) + .create_with(name: 'Loading', sorted: 1, lab_activity: true, workflow: workflow) .find_or_create_by!(pipeline_workflow_id: workflow.pipeline_id) do |task| task.descriptors.build( [ @@ -49,7 +49,7 @@ def create_or_update!(name, options) request_type_keys = obj.delete('request_type_keys') raise 'Request type keys not found' if request_type_keys.blank? request_types = RequestType.where(key: request_type_keys) - Pipeline.create_with(obj.merge(workflow: wf, request_types:)).find_or_create_by!(name:) + Pipeline.create_with(obj.merge(workflow: wf, request_types: request_types)).find_or_create_by!(name:) return unless name == 'NovaSeqX PE' diff --git a/lib/record_loader/pipeline_request_information_type_loader.rb b/lib/record_loader/pipeline_request_information_type_loader.rb index ed6deee940..a185e78825 100644 --- a/lib/record_loader/pipeline_request_information_type_loader.rb +++ b/lib/record_loader/pipeline_request_information_type_loader.rb @@ -12,10 +12,10 @@ class PipelineRequestInformationTypeLoader < ApplicationRecordLoader def create_or_update!(_name, options) pipeline = Pipeline.find_by!(name: options['pipeline_name']) - req_inf_type = RequestInformationType.find_by!(key: options['request_information_type_key']) - PipelineRequestInformationType.create_with(pipeline:, request_information_type: req_inf_type).find_or_create_by!( + request_information_type = RequestInformationType.find_by!(key: options['request_information_type_key']) + PipelineRequestInformationType.create_with(pipeline:, request_information_type:).find_or_create_by!( pipeline:, - request_information_type: req_inf_type + request_information_type: ) end end diff --git a/lib/record_loader/request_type_loader.rb b/lib/record_loader/request_type_loader.rb index 637b690bf0..2fe19c728a 100644 --- a/lib/record_loader/request_type_loader.rb +++ b/lib/record_loader/request_type_loader.rb @@ -45,7 +45,7 @@ def add_acceptable_purposes(request_type, purposes) def add_library_type_validator(request_type) RequestType::Validator.create!( - request_type:, + request_type: request_type, request_option: 'library_type', valid_options: RequestType::Validator::LibraryTypeValidator.new(request_type.id) ) diff --git a/lib/tasks/add_heron_product.rake b/lib/tasks/add_heron_product.rake index fa3e49a7e8..ab939c2620 100644 --- a/lib/tasks/add_heron_product.rake +++ b/lib/tasks/add_heron_product.rake @@ -22,7 +22,7 @@ namespace :product_heron do product = Product.create!(name: 'Heron') - ProductCriteria.create!(product:, stage: 'stock', configuration: ADDITIONAL_CRITERIA) + ProductCriteria.create!(product: product, stage: 'stock', configuration: ADDITIONAL_CRITERIA) end end diff --git a/lib/tasks/add_missing_asset_audit_records.rake b/lib/tasks/add_missing_asset_audit_records.rake index 62393c99ed..eef55f14c4 100644 --- a/lib/tasks/add_missing_asset_audit_records.rake +++ b/lib/tasks/add_missing_asset_audit_records.rake @@ -58,7 +58,7 @@ namespace :asset_audit do created_by: row['created_by'], created_at: row['created_at'], message: "Process '#{row['message']}' performed on instrument Destroying instrument", - key: + key: key } asset_audit_data << data end diff --git a/lib/tasks/add_traction_records.rake b/lib/tasks/add_traction_records.rake index ee7c0754fd..9f4f31ab89 100644 --- a/lib/tasks/add_traction_records.rake +++ b/lib/tasks/add_traction_records.rake @@ -70,7 +70,7 @@ namespace :traction do ActiveRecord::Base.transaction do (barcode_printer_type = BarcodePrinterType.find_by(name: '1D Tube')) || raise('Cannot find 1D printer') { 'saphyr' => %w[Tube::Purpose SampleTube] }.each do |name, (type, asset_type)| - type.constantize.create!(name:, barcode_printer_type:, target_type: asset_type) + type.constantize.create!(name: name, barcode_printer_type: barcode_printer_type, target_type: asset_type) end end end diff --git a/lib/tasks/benchmark_plate_transfer.rake b/lib/tasks/benchmark_plate_transfer.rake index 12c68ae99f..99225c1865 100644 --- a/lib/tasks/benchmark_plate_transfer.rake +++ b/lib/tasks/benchmark_plate_transfer.rake @@ -4,7 +4,9 @@ namespace :benchmark do $stdout.puts 'Preparing' stock = Purpose.find_by(name: 'Shear').create! sample = Sample.find_or_create_by(name: 'test_sample') - stock.wells.each { |w| w.aliquots.create!(sample:, study_id: Study.find_or_create_by(name: 'test_study').id) } + stock.wells.each do |w| + w.aliquots.create!(sample: sample, study_id: Study.find_or_create_by(name: 'test_study').id) + end user = User.find_or_create_by(login: 'test_user') targets = [] @@ -18,7 +20,7 @@ namespace :benchmark do $stdout.puts 'Warming up...' 15.times do - Transfer::BetweenPlates.create!(source: stock, destination: targets.pop, transfers: all_wells.clone, user:) + Transfer::BetweenPlates.create!(source: stock, destination: targets.pop, transfers: all_wells.clone, user: user) print '.' end puts '' @@ -26,7 +28,7 @@ namespace :benchmark do start = Time.zone.now $stdout.puts "Starting #{start}" 15.times do - Transfer::BetweenPlates.create!(source: stock, destination: targets.pop, transfers: all_wells.clone, user:) + Transfer::BetweenPlates.create!(source: stock, destination: targets.pop, transfers: all_wells.clone, user: user) $stdout.print '.' end $stdout.puts diff --git a/lib/tasks/devour.rake b/lib/tasks/devour.rake index 6b7ea430a0..56594d66b2 100644 --- a/lib/tasks/devour.rake +++ b/lib/tasks/devour.rake @@ -24,7 +24,7 @@ namespace :devour do attributes[attr] = { jsonApi: relation } attributes[attr][:type] = details.resource_klass._type.to_s.singularize unless details.polymorphic? end - { resource: resource._type.to_s.singularize, attributes:, options: {} } + { resource: resource._type.to_s.singularize, attributes: attributes, options: {} } end serialized_config = JSON.generate(config, json_formatting) diff --git a/lib/tasks/limber.rake b/lib/tasks/limber.rake index d0511d2f74..c20b04fcd1 100644 --- a/lib/tasks/limber.rake +++ b/lib/tasks/limber.rake @@ -141,7 +141,11 @@ namespace :limber do catalogue_name = params[:catalogue_name] || prefix catalogue = ProductCatalogue.create_with(selection_behaviour: 'SingleProduct').find_or_create_by!(name: catalogue_name) - Limber::Helper::TemplateConstructor.new(prefix:, catalogue:, sequencing_keys: params[:sequencing_list]).build! + Limber::Helper::TemplateConstructor.new( + prefix: prefix, + catalogue: catalogue, + sequencing_keys: params[:sequencing_list] + ).build! unless params[:omit_library_templates] Limber::Helper::LibraryOnlyTemplateConstructor.new(prefix:, catalogue:).build! Limber::Helper::LibraryAndMultiplexingTemplateConstructor.new(prefix:, catalogue:).build! @@ -233,7 +237,11 @@ namespace :limber do Limber::Helper::LibraryOnlyTemplateConstructor.new(prefix: 'GBS', catalogue: gbs_catalogue).build! catalogue = ProductCatalogue.create_with(selection_behaviour: 'SingleProduct').find_or_create_by!(name: 'Generic') - Limber::Helper::TemplateConstructor.new(prefix: 'Multiplexing', catalogue:, sequencing_keys: base_list).build! + Limber::Helper::TemplateConstructor.new( + prefix: 'Multiplexing', + catalogue: catalogue, + sequencing_keys: base_list + ).build! ## Bespoke Pipelines ## generic_pcr = diff --git a/lib/tasks/limber_dev.rake b/lib/tasks/limber_dev.rake index fc1571c0a6..6baec2ae3b 100644 --- a/lib/tasks/limber_dev.rake +++ b/lib/tasks/limber_dev.rake @@ -90,7 +90,7 @@ namespace :limber do OligoEnumerator .new(384, index * 384) .each_with_index - .map { |oligo, map_id| { oligo:, map_id: map_id + 1 } } + .map { |oligo, map_id| { oligo: oligo, map_id: map_id + 1 } } ) end TagLayoutTemplate.create!( @@ -110,7 +110,7 @@ namespace :limber do tg = TagGroup.create!(name: 'IDT for Illumina v1 - MOCK') do |group| group.tags.build( - OligoEnumerator.new(384).each_with_index.map { |oligo, map_id| { oligo:, map_id: map_id + 1 } } + OligoEnumerator.new(384).each_with_index.map { |oligo, map_id| { oligo: oligo, map_id: map_id + 1 } } ) end TagLayoutTemplate.create!( @@ -140,7 +140,7 @@ namespace :limber do OligoEnumerator .new(384, index * 384) .each_with_index - .map { |oligo, map_id| { oligo:, map_id: map_id + 1 } } + .map { |oligo, map_id| { oligo: oligo, map_id: map_id + 1 } } ) end TagLayoutTemplate.create!( diff --git a/lib/views_schema.rb b/lib/views_schema.rb index f8b0d87ff1..aeca2a23f4 100644 --- a/lib/views_schema.rb +++ b/lib/views_schema.rb @@ -72,7 +72,7 @@ def self.all_views # rubocop:todo Metrics/MethodLength # # @return [Void] def self.create_view(name, statement, algorithm: ALGORITHMS.first, security: SECURITIES.first) - execute(action: 'CREATE', name:, statement:, algorithm:, security:) + execute(action: 'CREATE', name: name, statement: statement, algorithm: algorithm, security: security) end # @@ -84,7 +84,7 @@ def self.create_view(name, statement, algorithm: ALGORITHMS.first, security: SEC # # @return [Void] def self.update_view(name, statement, algorithm: ALGORITHMS.first, security: SECURITIES.first) - execute(action: 'CREATE OR REPLACE', name:, statement:, algorithm:, security:) + execute(action: 'CREATE OR REPLACE', name: name, statement: statement, algorithm: algorithm, security: security) end # diff --git a/lib/working_setup/standard_seeder.rb b/lib/working_setup/standard_seeder.rb index d5bac2a34d..9966b65906 100644 --- a/lib/working_setup/standard_seeder.rb +++ b/lib/working_setup/standard_seeder.rb @@ -74,10 +74,10 @@ def tag_plates( # rubocop:todo Metrics/MethodLength .create!( lot_number: Time.current.to_i.to_s, template: TagLayoutTemplate.find_by!(name: template), - user:, + user: user, received_at: Time.current ) - qcc = QcableCreator.create!(lot:, user:, count: size) + qcc = QcableCreator.create!(lot: lot, user: user, count: size) qcc.qcables.each do |qcable| qcable.update!(state: 'available') puts "Tag Plate: #{qcable.asset.ean13_barcode}" @@ -114,7 +114,7 @@ def create_project(name) return existing if existing Project.create!( - name:, + name: name, enforce_quotas: false, approved: true, project_metadata_attributes: { @@ -130,11 +130,11 @@ def create_study(name) return existing if existing Study.create!( - name:, + name: name, study_metadata_attributes: { data_access_group: 'dag', study_type: StudyType.first, - faculty_sponsor:, + faculty_sponsor: faculty_sponsor, data_release_study_type: DataReleaseStudyType.first, study_description: 'A seeded test study', contaminated_human_dna: 'No', diff --git a/spec/api/dilution_plate_purpose_spec.rb b/spec/api/dilution_plate_purpose_spec.rb index 953a7d7f60..454550f03d 100644 --- a/spec/api/dilution_plate_purpose_spec.rb +++ b/spec/api/dilution_plate_purpose_spec.rb @@ -7,7 +7,7 @@ let(:authorised_app) { create(:api_application) } let(:uuid) { '00000000-1111-2222-3333-444444444444' } - before { create(:dilution_plate_purpose, :uuidable, uuid:, name: 'Example purpose') } + before { create(:dilution_plate_purpose, :uuidable, uuid: uuid, name: 'Example purpose') } describe '#get' do subject(:url) { '/api/1/' + uuid } diff --git a/spec/api/extraction_attributes_spec.rb b/spec/api/extraction_attributes_spec.rb index 1ce7611d9c..a63003cdb5 100644 --- a/spec/api/extraction_attributes_spec.rb +++ b/spec/api/extraction_attributes_spec.rb @@ -358,6 +358,6 @@ def authorized_api_request(action, path, body) headers['CONTENT_TYPE'] = 'application/json' unless body.nil? headers['HTTP_X_SEQUENCESCAPE_CLIENT_ID'] = authorised_app.key yield(headers) if block_given? - send(action.downcase, path, params: body, headers:) + send(action.downcase, path, params: body, headers: headers) end end diff --git a/spec/api/multiplexed_library_tube_spec.rb b/spec/api/multiplexed_library_tube_spec.rb index 05396c14d3..1dd25e53b3 100644 --- a/spec/api/multiplexed_library_tube_spec.rb +++ b/spec/api/multiplexed_library_tube_spec.rb @@ -10,7 +10,7 @@ let(:purpose_uuid) { '00000000-1111-2222-3333-666666666666' } let(:purpose) { create(:tube_purpose, :uuidable, uuid: purpose_uuid, name: 'Example purpose') } - let(:tube) { create(:multiplexed_library_tube, purpose:, volume: 8.76000000) } + let(:tube) { create(:multiplexed_library_tube, purpose: purpose, volume: 8.76000000) } let(:collection) { create(:custom_metadatum_collection, asset: tube) } before do diff --git a/spec/api/plate_purpose_spec.rb b/spec/api/plate_purpose_spec.rb index 16de8752a7..fc21cecd01 100644 --- a/spec/api/plate_purpose_spec.rb +++ b/spec/api/plate_purpose_spec.rb @@ -49,7 +49,7 @@ let(:authorised_app) { create(:api_application) } let(:uuid) { '00000000-1111-2222-3333-444444444444' } - before { create(:plate_purpose, :uuidable, uuid:, name: 'Example purpose') } + before { create(:plate_purpose, :uuidable, uuid: uuid, name: 'Example purpose') } describe '#get' do subject { '/api/1/' + uuid } diff --git a/spec/api/request_types_spec.rb b/spec/api/request_types_spec.rb index 8dde9e0540..7682f8b42b 100644 --- a/spec/api/request_types_spec.rb +++ b/spec/api/request_types_spec.rb @@ -7,7 +7,7 @@ let(:authorised_app) { create(:api_application) } let(:uuid) { '00000000-1111-2222-3333-444444444444' } - before { create(:request_type, :uuidable, uuid:, name: 'Sequencing by colour') } + before { create(:request_type, :uuidable, uuid: uuid, name: 'Sequencing by colour') } describe '#get' do subject(:url) { '/api/1/' + uuid } diff --git a/spec/api/specific_tube_creation_spec.rb b/spec/api/specific_tube_creation_spec.rb index fb9b4495c6..a60e675209 100644 --- a/spec/api/specific_tube_creation_spec.rb +++ b/spec/api/specific_tube_creation_spec.rb @@ -24,8 +24,8 @@ .readonly(false) .each_with_index do |well, i| stock_well = stock_plate.wells[i] - create(:library_creation_request, asset: stock_well, target_asset: well, submission:) - create(:transfer_request, asset: stock_well, target_asset: well, submission:) + create(:library_creation_request, asset: stock_well, target_asset: well, submission: submission) + create(:transfer_request, asset: stock_well, target_asset: well, submission: submission) well.stock_wells.attach!([stock_well]) end end @@ -82,7 +82,7 @@ def construct_expected_response_body(parent_plate, new_tube_creation) describe 'Retrieving a Tube Creation' do let!(:tube_creation) do - SpecificTubeCreation.create!(user:, parent: parent_plate, child_purposes: [child_purpose]) + SpecificTubeCreation.create!(user: user, parent: parent_plate, child_purposes: [child_purpose]) end let(:response_code) { 200 } diff --git a/spec/api/state_change_spec.rb b/spec/api/state_change_spec.rb index c565555f05..3d11fcee8b 100644 --- a/spec/api/state_change_spec.rb +++ b/spec/api/state_change_spec.rb @@ -20,10 +20,10 @@ state_change: { user: user.uuid, target: target_plate.uuid, - target_state:, - contents:, - customer_accepts_responsibility:, - reason: + target_state: target_state, + contents: contents, + customer_accepts_responsibility: customer_accepts_responsibility, + reason: reason } }.to_json end @@ -39,10 +39,10 @@ read: "http://www.example.com/api/1/#{target_plate.uuid}" } }, - target_state:, - previous_state:, - contents:, - reason: + target_state: target_state, + previous_state: previous_state, + contents: contents, + reason: reason } }.to_json end @@ -68,7 +68,16 @@ end shared_examples 'a failed state_change_endpoint' do - let(:payload) { { state_change: { user: user.uuid, target: target_plate.uuid, target_state:, reason: } }.to_json } + let(:payload) do + { + state_change: { + user: user.uuid, + target: target_plate.uuid, + target_state: target_state, + reason: reason + } + }.to_json + end before { api_request :post, subject, payload } diff --git a/spec/api/submission_pool_spec.rb b/spec/api/submission_pool_spec.rb index f6c509f063..ea177cf901 100644 --- a/spec/api/submission_pool_spec.rb +++ b/spec/api/submission_pool_spec.rb @@ -40,7 +40,9 @@ let(:plate) { create(:input_plate, well_count: 2) } before do - plate.wells.each { |well| create(:library_creation_request, asset: well, submission:, request_type:) } + plate.wells.each do |well| + create(:library_creation_request, asset: well, submission: submission, request_type: request_type) + end create(:tag2_layout_template_submission, submission:, tag2_layout_template:) end @@ -70,7 +72,13 @@ before do plate.wells.each do |well| - create(:library_creation_request, asset: well, submission:, request_type:, state: 'cancelled') + create( + :library_creation_request, + asset: well, + submission: submission, + request_type: request_type, + state: 'cancelled' + ) end end @@ -97,7 +105,9 @@ let(:plate) { create(:input_plate, well_count: 2) } before do - plate.wells.each { |well| create(:library_creation_request, asset: well, submission:, request_type:) } + plate.wells.each do |well| + create(:library_creation_request, asset: well, submission: submission, request_type: request_type) + end create(:tag_layout_template_submission, submission:, tag_layout_template:) end @@ -127,8 +137,12 @@ let(:plate_b) { create(:input_plate, well_count: 2) } before do - plate.wells.each { |well| create(:library_creation_request, asset: well, submission:, request_type:) } - plate_b.wells.each { |well| create(:library_creation_request, asset: well, submission:, request_type:) } + plate.wells.each do |well| + create(:library_creation_request, asset: well, submission: submission, request_type: request_type) + end + plate_b.wells.each do |well| + create(:library_creation_request, asset: well, submission: submission, request_type: request_type) + end end let(:response_body) do @@ -153,11 +167,13 @@ context 'a multi plate submission and a used template on children' do let(:plate_b) do plate = create(:input_plate, well_count: 2) - plate.wells.each { |well| create(:library_creation_request, asset: well, submission:, request_type:) } + plate.wells.each do |well| + create(:library_creation_request, asset: well, submission: submission, request_type: request_type) + end plate end - let(:plate) { create(:target_plate, well_count: 2, parent: plate_b, submission:) } + let(:plate) { create(:target_plate, well_count: 2, parent: plate_b, submission: submission) } before { create(:tag2_layout_template_submission, submission:, tag2_layout_template:) } diff --git a/spec/api/tube_creation_spec.rb b/spec/api/tube_creation_spec.rb index cca098f4da..a963636c5c 100644 --- a/spec/api/tube_creation_spec.rb +++ b/spec/api/tube_creation_spec.rb @@ -24,8 +24,8 @@ .readonly(false) .each_with_index do |well, i| stock_well = stock_plate.wells[i] - create(:library_creation_request, asset: stock_well, target_asset: well, submission:) - create(:transfer_request, asset: stock_well, target_asset: well, submission:) + create(:library_creation_request, asset: stock_well, target_asset: well, submission: submission) + create(:transfer_request, asset: stock_well, target_asset: well, submission: submission) well.stock_wells.attach!([stock_well]) end end @@ -79,7 +79,7 @@ def construct_expected_response_body(parent_plate, child_purpose, new_tube_creat end describe 'Retrieving a Tube Creation' do - let!(:tube_creation) { TubeCreation.create!(user:, parent: parent_plate, child_purpose:) } + let!(:tube_creation) { TubeCreation.create!(user: user, parent: parent_plate, child_purpose: child_purpose) } let(:response_code) { 200 } diff --git a/spec/bulk_submission_excel/data_worksheet_spec.rb b/spec/bulk_submission_excel/data_worksheet_spec.rb index dfda70aaca..bd22096467 100644 --- a/spec/bulk_submission_excel/data_worksheet_spec.rb +++ b/spec/bulk_submission_excel/data_worksheet_spec.rb @@ -27,9 +27,9 @@ context 'data worksheet' do let!(:worksheet) do described_class.new( - workbook:, + workbook: workbook, columns: configuration.columns.all.dup, - assets:, + assets: assets, ranges: configuration.ranges.dup, defaults: { user_login:, diff --git a/spec/bulk_submission_excel/download_spec.rb b/spec/bulk_submission_excel/download_spec.rb index b83ead3477..7c6b84f12d 100644 --- a/spec/bulk_submission_excel/download_spec.rb +++ b/spec/bulk_submission_excel/download_spec.rb @@ -16,7 +16,7 @@ let(:download) do described_class.new( - assets:, + assets: assets, column_list: columns, range_list: ranges, defaults: { diff --git a/spec/controllers/api/v2/heron/plates_controller_spec.rb b/spec/controllers/api/v2/heron/plates_controller_spec.rb index 12a54e4a90..ed3b1fe43a 100644 --- a/spec/controllers/api/v2/heron/plates_controller_spec.rb +++ b/spec/controllers/api/v2/heron/plates_controller_spec.rb @@ -20,7 +20,7 @@ data: { type: 'plates', attributes: { - barcode:, + barcode: barcode, wells: { A01: { content: { @@ -33,8 +33,8 @@ } } }, - purpose_uuid:, - study_uuid: + purpose_uuid: purpose_uuid, + study_uuid: study_uuid } } }.to_h.with_indifferent_access diff --git a/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb b/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb index e14eb5731e..eddbec6ce8 100644 --- a/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb +++ b/spec/controllers/api/v2/heron/tube_racks_controller_spec.rb @@ -35,7 +35,7 @@ } }, purpose_uuid: purpose_96_uuid, - study_uuid: + study_uuid: study_uuid } } }.to_h.with_indifferent_access diff --git a/spec/controllers/driver_files_controller_spec.rb b/spec/controllers/driver_files_controller_spec.rb index 9432118f91..308234ffb3 100644 --- a/spec/controllers/driver_files_controller_spec.rb +++ b/spec/controllers/driver_files_controller_spec.rb @@ -26,7 +26,7 @@ ) end - let(:batch) { create(:batch, requests:, pipeline:, user: current_user) } + let(:batch) { create(:batch, requests: requests, pipeline: pipeline, user: current_user) } before do get :show, params: { batch_id: batch.id, robot_id: robot.id, pick_number: 1 }, session: { user: current_user.id } diff --git a/spec/controllers/labwhere_receptions_controller_spec.rb b/spec/controllers/labwhere_receptions_controller_spec.rb index 160324a7da..e5aad0a045 100644 --- a/spec/controllers/labwhere_receptions_controller_spec.rb +++ b/spec/controllers/labwhere_receptions_controller_spec.rb @@ -12,7 +12,7 @@ shared_examples 'a reception' do before do expect(LabWhereClient::Scan).to receive(:create).with( - location_barcode:, + location_barcode: location_barcode, user_code: SBCF::SangerBarcode.from_human(user.barcode).machine_barcode.to_s, labware_barcodes: [plate.human_barcode, plate_2.machine_barcode, sample_tube.human_barcode] ).and_return(instance_double(LabWhereClient::Scan, valid?: true, errors: [])) @@ -22,7 +22,7 @@ labwhere_reception: { barcodes: [plate.human_barcode, plate_2.machine_barcode, sample_tube.human_barcode], user_code: SBCF::SangerBarcode.from_human(user.barcode).machine_barcode, - location_barcode: + location_barcode: location_barcode } } end diff --git a/spec/controllers/npg_actions/assets_controller_spec.rb b/spec/controllers/npg_actions/assets_controller_spec.rb index ecfb62f757..1095892357 100644 --- a/spec/controllers/npg_actions/assets_controller_spec.rb +++ b/spec/controllers/npg_actions/assets_controller_spec.rb @@ -12,9 +12,9 @@ let(:valid_seq_request) do create( :sequencing_request_with_assets, - batch:, + batch: batch, request_type: batch.pipeline.request_types.first, - study:, + study: study, target_asset: lane, state: 'passed' ) @@ -22,9 +22,9 @@ let(:cancelled_seq_request) do create( :sequencing_request_with_assets, - batch:, + batch: batch, request_type: batch.pipeline.request_types.first, - study:, + study: study, target_asset: lane, state: 'cancelled' ) @@ -32,9 +32,9 @@ let(:failed_seq_request) do create( :sequencing_request_with_assets, - batch:, + batch: batch, request_type: batch.pipeline.request_types.first, - study:, + study: study, target_asset: lane, state: 'failed' ) diff --git a/spec/controllers/receptacles_controller_spec.rb b/spec/controllers/receptacles_controller_spec.rb index 2062f406a3..422116877f 100644 --- a/spec/controllers/receptacles_controller_spec.rb +++ b/spec/controllers/receptacles_controller_spec.rb @@ -13,7 +13,7 @@ it_behaves_like 'it requires login' describe '#index' do - before { get :index, params:, session: { user: current_user.id } } + before { get :index, params: params, session: { user: current_user.id } } context 'when no parameters are specified' do let(:params) { {} } diff --git a/spec/controllers/report_fails_controller_spec.rb b/spec/controllers/report_fails_controller_spec.rb index a23aeb7fb0..868ae152d8 100644 --- a/spec/controllers/report_fails_controller_spec.rb +++ b/spec/controllers/report_fails_controller_spec.rb @@ -16,7 +16,7 @@ report_fail: { barcodes: [plate.human_barcode, plate_2.machine_barcode, sample_tube.human_barcode], user_code: SBCF::SangerBarcode.from_human(user.barcode).machine_barcode, - failure_id: + failure_id: failure_id } } end @@ -39,7 +39,7 @@ report_fail: { barcodes: [plate.human_barcode, plate_2.machine_barcode, sample_tube.human_barcode], user_code: SBCF::SangerBarcode.from_human(user.barcode).machine_barcode, - failure_id: + failure_id: failure_id } } end diff --git a/spec/controllers/robot_verifications_controller_spec.rb b/spec/controllers/robot_verifications_controller_spec.rb index f712bacae7..8e969afba7 100644 --- a/spec/controllers/robot_verifications_controller_spec.rb +++ b/spec/controllers/robot_verifications_controller_spec.rb @@ -53,12 +53,12 @@ user_id: user.id, batch_id: batch.id, robot_id: robot.id, - plate_types:, - barcodes:, - bed_barcodes:, - plate_barcodes:, - destination_bed_barcodes:, - destination_plate_barcodes:, + plate_types: plate_types, + barcodes: barcodes, + bed_barcodes: bed_barcodes, + plate_barcodes: plate_barcodes, + destination_bed_barcodes: destination_bed_barcodes, + destination_plate_barcodes: destination_plate_barcodes, pick_number: 1 } end @@ -68,7 +68,7 @@ source_plate = create(:plate, barcode:) position = Map.for_position_on_plate(index + 1, 96, source_plate.asset_shape).first well = create(:well, map: position, plate: source_plate) - target_well = create(:well, map: position, plate:) + target_well = create(:well, map: position, plate: plate) well_request = create(:request, state: 'passed', asset: well, target_asset: target_well) batch.requests << well_request end diff --git a/spec/controllers/searches_controller_spec.rb b/spec/controllers/searches_controller_spec.rb index be2b40d32f..bad973cf6a 100644 --- a/spec/controllers/searches_controller_spec.rb +++ b/spec/controllers/searches_controller_spec.rb @@ -13,7 +13,7 @@ let!(:sample) { create(:sample, name: 'FindMeSample') } let!(:asset) { create(:sample_tube, name: 'FindMeAsset') } let!(:other_asset) { create(:sample_tube) } - let!(:asset_group_to_find) { create(:asset_group, name: 'FindMeAssetGroup', study:) } + let!(:asset_group_to_find) { create(:asset_group, name: 'FindMeAssetGroup', study: study) } let!(:asset_group_to_not_find) { create(:asset_group, name: 'IgnoreAssetGroup') } let!(:submission) { create(:submission, name: 'FindMe') } diff --git a/spec/factories/barcode_factories.rb b/spec/factories/barcode_factories.rb index 099cdce5cf..f06347eef7 100644 --- a/spec/factories/barcode_factories.rb +++ b/spec/factories/barcode_factories.rb @@ -14,7 +14,7 @@ barcode_number end format { 'sanger_ean13' } - barcode { SBCF::SangerBarcode.new(prefix:, number: barcode_number).human_barcode } + barcode { SBCF::SangerBarcode.new(prefix: prefix, number: barcode_number).human_barcode } factory :sanger_ean13_tube do transient { prefix { 'NT' } } @@ -27,7 +27,7 @@ barcode_number end format { 'sanger_code39' } - barcode { SBCF::SangerBarcode.new(prefix:, number: barcode_number).human_barcode } + barcode { SBCF::SangerBarcode.new(prefix: prefix, number: barcode_number).human_barcode } factory :sanger_code39_tube do transient { prefix { 'NT' } } diff --git a/spec/factories/batch_factories.rb b/spec/factories/batch_factories.rb index 887e522a42..aef47324ce 100644 --- a/spec/factories/batch_factories.rb +++ b/spec/factories/batch_factories.rb @@ -59,10 +59,10 @@ evaluator.assets.each_with_index.each do |asset, index| create( :pac_bio_sequencing_request, - asset:, + asset: asset, target_asset: evaluator.target_plate.wells[index], request_type: batch.pipeline.request_types.first, - batch: + batch: batch ) end end diff --git a/spec/factories/lib_pcr_xp_factories.rb b/spec/factories/lib_pcr_xp_factories.rb index bb14f9f9c5..76d41aebd7 100644 --- a/spec/factories/lib_pcr_xp_factories.rb +++ b/spec/factories/lib_pcr_xp_factories.rb @@ -9,7 +9,7 @@ .where_description(%w[A1 B2 E6]) .where_plate_size(plate.size) .where_plate_shape(AssetShape.default) - .map { |map| build(:tagged_well, map:, requests: [create(:lib_pcr_xp_request)]) } + .map { |map| build(:tagged_well, map: map, requests: [create(:lib_pcr_xp_request)]) } plate.wells.each do |well| well.well_attribute.current_volume = 160 well.save diff --git a/spec/factories/pipelines_factories.rb b/spec/factories/pipelines_factories.rb index 4e64b55b5e..41ba15b9cb 100644 --- a/spec/factories/pipelines_factories.rb +++ b/spec/factories/pipelines_factories.rb @@ -64,7 +64,7 @@ name: pipeline.name, item_limit: evaluator.item_limit, locale: evaluator.locale, - pipeline: + pipeline: pipeline ) end end @@ -124,14 +124,14 @@ create( :set_descriptors_task, name: 'Specify Dilution Volume', - workflow:, + workflow: workflow, per_item: true, descriptor_attributes: [{ kind: 'Text', sorter: 0, name: 'Concentration' }] ) create(:add_spiked_in_control_task, workflow:) create( :set_descriptors_task, - workflow:, + workflow: workflow, descriptor_attributes: [ { kind: 'Selection', diff --git a/spec/factories/plate_factories.rb b/spec/factories/plate_factories.rb index a46a5afb24..a700925935 100644 --- a/spec/factories/plate_factories.rb +++ b/spec/factories/plate_factories.rb @@ -32,7 +32,7 @@ evaluator.well_locations.map do |map| build( evaluator.well_factory, - map:, + map: map, study: evaluator.studies_cycle.next, project: evaluator.projects_cycle.next ) @@ -92,7 +92,12 @@ outer_request = well_hash[well.map_description].requests.detect { |r| r.submission_id == evaluator.submission.id } - create(:transfer_request, asset: well_hash[well.map_description], target_asset: well, outer_request:) + create( + :transfer_request, + asset: well_hash[well.map_description], + target_asset: well, + outer_request: outer_request + ) end end end @@ -156,7 +161,7 @@ after(:create) do |plate, evaluator| plate.wells = evaluator.occupied_map_locations.map.with_index do |map, i| - create(:well_for_location_report, map:, study: evaluator.studies[i], project: nil) + create(:well_for_location_report, map: map, study: evaluator.studies[i], project: nil) end end end diff --git a/spec/factories/pulldown_factories.rb b/spec/factories/pulldown_factories.rb index 7ccadf1ff7..5991c3f25a 100644 --- a/spec/factories/pulldown_factories.rb +++ b/spec/factories/pulldown_factories.rb @@ -25,7 +25,7 @@ transient { tag_sequences { %w[ACGT TGCA] } } - tags { tag_sequences.each_with_index.map { |oligo, index| build(:tag, map_id: index + 1, oligo:) } } + tags { tag_sequences.each_with_index.map { |oligo, index| build(:tag, map_id: index + 1, oligo: oligo) } } end # Tag layouts and their templates @@ -92,11 +92,11 @@ .each_with_index do |pool, i| submission = create(:submission) pool.each do |well| - create(:transfer_request, asset: stock_wells[i], target_asset: well, submission:) + create(:transfer_request, asset: stock_wells[i], target_asset: well, submission: submission) mock_request_type.create!( asset: stock_wells[i], target_asset: well, - submission:, + submission: submission, request_metadata_attributes: create(:request_metadata_for_library_creation).attributes ) create(:stock_well_link, target_well: well, source_well: stock_wells[i]) @@ -130,7 +130,7 @@ { fragment_size_required_from: 100, fragment_size_required_to: 400, - bait_library:, + bait_library: bait_library, library_type: 'Agilent Pulldown' } end diff --git a/spec/factories/request_type_factories.rb b/spec/factories/request_type_factories.rb index fdb3dd7cc6..a50d83c244 100644 --- a/spec/factories/request_type_factories.rb +++ b/spec/factories/request_type_factories.rb @@ -15,7 +15,7 @@ request_type.library_types_request_types << create( :library_types_request_type, library_type: evaluator.library_type, - request_type: + request_type: request_type ) request_type.request_type_validators << create(:library_request_type_validator, request_type:) end @@ -90,13 +90,13 @@ request_type.request_type_validators = [ build( :request_type_validator, - request_type:, + request_type: request_type, request_option: 'insert_size', options: [500, 1000, 2000, 5000, 10_000, 20_000] ), build( :request_type_validator, - request_type:, + request_type: request_type, request_option: 'sequencing_type', options: ['Standard', 'MagBead', 'MagBead OneCellPerWell v1'] ) @@ -118,7 +118,13 @@ request_class { SequencingRequest } after(:build) do |request_type, ev| - srv = create(:sequencing_request_type_validator, request_type:, options: ev.read_lengths, default: ev.default) + srv = + create( + :sequencing_request_type_validator, + request_type: request_type, + options: ev.read_lengths, + default: ev.default + ) request_type.request_type_validators << srv end end @@ -128,7 +134,7 @@ asset_type { 'LibraryTube' } after(:build) do |request_type| - srv = create(:sequencing_request_type_validator, request_type:, options: [54, 150, 250]) + srv = create(:sequencing_request_type_validator, request_type: request_type, options: [54, 150, 250]) request_type.request_type_validators << srv end end diff --git a/spec/factories/sample_manifest_factories.rb b/spec/factories/sample_manifest_factories.rb index b8d88174e5..3a927f9da2 100644 --- a/spec/factories/sample_manifest_factories.rb +++ b/spec/factories/sample_manifest_factories.rb @@ -32,7 +32,7 @@ :sample_manifest_asset, sanger_sample_id: generate(:sanger_sample_id), asset: well, - sample_manifest: + sample_manifest: sample_manifest ) end end @@ -57,7 +57,7 @@ :sample_manifest_asset, sanger_sample_id: generate(:sanger_sample_id), asset: tube.receptacle, - sample_manifest: + sample_manifest: sample_manifest ) end sample_manifest.barcodes = sample_manifest.labware.map(&:human_barcode) @@ -91,7 +91,9 @@ .plates .flat_map(&:wells) .each do |well| - evaluator.num_rows_per_well.times { create(:sample_manifest_asset, asset: well, sample_manifest:) } + evaluator.num_rows_per_well.times do + create(:sample_manifest_asset, asset: well, sample_manifest: sample_manifest) + end end end end diff --git a/spec/factories/shared_traits.rb b/spec/factories/shared_traits.rb index 1c9dff6dc7..d793eb0268 100644 --- a/spec/factories/shared_traits.rb +++ b/spec/factories/shared_traits.rb @@ -26,7 +26,9 @@ transient { uuid { SecureRandom.uuid } } # Using an after build as I need access to both the transient and the resource. - after(:build) { |resource, context| resource.uuid_object = build(:uuid, external_id: context.uuid, resource:) } + after(:build) do |resource, context| + resource.uuid_object = build(:uuid, external_id: context.uuid, resource: resource) + end after(:create) { |resource, _context| resource.uuid_object.save! } end diff --git a/spec/factories/tag_group_factories.rb b/spec/factories/tag_group_factories.rb index d5a3ebae9c..11b023465c 100644 --- a/spec/factories/tag_group_factories.rb +++ b/spec/factories/tag_group_factories.rb @@ -24,7 +24,7 @@ adapter_type { build(:adapter_type, name: adapter_type_name) if adapter_type_name } after(:build) do |tag_group, evaluator| - evaluator.tag_count.times { |i| tag_group.tags << create(:tag, map_id: i + 1, tag_group:) } + evaluator.tag_count.times { |i| tag_group.tags << create(:tag, map_id: i + 1, tag_group: tag_group) } end factory :tag_group_with_tags do diff --git a/spec/factories/tube_factories.rb b/spec/factories/tube_factories.rb index 034c519889..7c2cdd653f 100644 --- a/spec/factories/tube_factories.rb +++ b/spec/factories/tube_factories.rb @@ -13,7 +13,7 @@ barcode { generate(:barcode_number) } prefix { 'NT' } end - sanger_barcode { { prefix:, number: barcode_number } } + sanger_barcode { { prefix: prefix, number: barcode_number } } end trait :in_a_rack do @@ -22,7 +22,7 @@ coordinate { nil } end after(:create) do |tube, evaluator| - create(:racked_tube, tube:, tube_rack: evaluator.tube_rack, coordinate: evaluator.coordinate) + create(:racked_tube, tube: tube, tube_rack: evaluator.tube_rack, coordinate: evaluator.coordinate) end end diff --git a/spec/factories/well_factories.rb b/spec/factories/well_factories.rb index f4d49cef89..2c8bf62d02 100644 --- a/spec/factories/well_factories.rb +++ b/spec/factories/well_factories.rb @@ -6,7 +6,7 @@ study { build(:study) } project { build(:project) } sample { build(:sample) } - aliquot_options { |_e, well| { study:, project:, receptacle: well, sample: } } + aliquot_options { |_e, well| { study: study, project: project, receptacle: well, sample: sample } } end association(:well_attribute, strategy: :build) @@ -37,7 +37,7 @@ factory :passed_well do transient do aliquot_options do |_e, well| - { study:, project:, receptacle: well, sample:, request: requests_as_target.first } + { study: study, project: project, receptacle: well, sample: sample, request: requests_as_target.first } end end stock_wells { [association(:well)] } diff --git a/spec/features/assets/asset_submission_spec.rb b/spec/features/assets/asset_submission_spec.rb index bdad5fae7d..637555bc85 100644 --- a/spec/features/assets/asset_submission_spec.rb +++ b/spec/features/assets/asset_submission_spec.rb @@ -11,7 +11,9 @@ let(:original_request_type) { request_types.first } let(:selected_request_type) { original_request_type } let(:selected_read_length) { '76' } - let!(:original_request) { create(request_factory, study:, project:, asset:, request_type: original_request_type) } + let!(:original_request) do + create(request_factory, study: study, project: project, asset: asset, request_type: original_request_type) + end shared_examples 'it allows additional sequencing' do it 'request additional sequencing' do @@ -128,7 +130,7 @@ let(:study) { asset.aliquots.first.study } let(:project) { asset.aliquots.first.project } let!(:original_request) do - create(request_factory, study: nil, project: nil, asset:, request_type: original_request_type) + create(request_factory, study: nil, project: nil, asset: asset, request_type: original_request_type) end let(:selected_read_length) { '108' } diff --git a/spec/features/batches/failing_requests_spec.rb b/spec/features/batches/failing_requests_spec.rb index 088527113d..b2afac1c82 100644 --- a/spec/features/batches/failing_requests_spec.rb +++ b/spec/features/batches/failing_requests_spec.rb @@ -6,7 +6,12 @@ describe 'Batches controller', :js do let(:request_count) { 3 } let(:batch) do - create(:cherrypick_batch, request_count:, state: 'released', request_factory: :passed_cherrypick_request) + create( + :cherrypick_batch, + request_count: request_count, + state: 'released', + request_factory: :passed_cherrypick_request + ) end let(:user) { create(:admin) } diff --git a/spec/features/batches/sort_requests_spec.rb b/spec/features/batches/sort_requests_spec.rb index ca4f72c147..af507a1440 100644 --- a/spec/features/batches/sort_requests_spec.rb +++ b/spec/features/batches/sort_requests_spec.rb @@ -5,7 +5,7 @@ describe 'Batches controller', :js, :warren do let(:request_count) { 3 } - let(:batch) { create(:sequencing_batch, request_count:, created_at: 1.day.ago, updated_at: 1.day.ago) } + let(:batch) { create(:sequencing_batch, request_count: request_count, created_at: 1.day.ago, updated_at: 1.day.ago) } let(:user) { create(:admin) } let!(:flowcell_message) { create(:flowcell_messenger, target: batch) } diff --git a/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb b/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb index e2ba91bd24..ad739a1e47 100644 --- a/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb +++ b/spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb @@ -34,7 +34,7 @@ def create_cherrypick_requests(plate, target_plate, transfers, submission_id) # :cherrypick_request, asset: plate.wells.located_at(source).first, target_asset: destination, - submission_id: + submission_id: submission_id ) end end diff --git a/spec/features/patient_consent_withdrawl_spec.rb b/spec/features/patient_consent_withdrawl_spec.rb index a53065485f..027e1eebf6 100644 --- a/spec/features/patient_consent_withdrawl_spec.rb +++ b/spec/features/patient_consent_withdrawl_spec.rb @@ -63,9 +63,9 @@ let(:order) do submission_template.new_order( project: create(:project), - study:, - asset_group:, - user:, + study: study, + asset_group: asset_group, + user: user, request_options: { 'fragment_size_required_from' => 300, 'fragment_size_required_to' => 400, @@ -81,9 +81,9 @@ let(:order) do submission_template.new_order( project: create(:project), - study:, + study: study, assets: [sample_tube], - user:, + user: user, request_options: { 'fragment_size_required_from' => 300, 'fragment_size_required_to' => 400, diff --git a/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb b/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb index 2e1ba039f5..d9a494b509 100644 --- a/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb +++ b/spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb @@ -28,12 +28,12 @@ assets.each do |asset| create( :cherrypick_for_fluidigm_request, - asset:, + asset: asset, request_type: pipeline.request_types.first, - submission:, - study:, - project:, - target_purpose: + submission: submission, + study: study, + project: project, + target_purpose: target_purpose ) end diff --git a/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb b/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb index bce0af8c0a..f464a1752c 100644 --- a/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb +++ b/spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb @@ -49,9 +49,9 @@ def initialize_plates(plates) :cherrypick_request, asset: well, request_type: pipeline.request_types.first, - submission:, - study:, - project: + submission: submission, + study: study, + project: project ) # create a concentration value on the wells if required diff --git a/spec/features/pipelines/creating_an_empty_batch_spec.rb b/spec/features/pipelines/creating_an_empty_batch_spec.rb index b17e0a3082..582e2764cc 100644 --- a/spec/features/pipelines/creating_an_empty_batch_spec.rb +++ b/spec/features/pipelines/creating_an_empty_batch_spec.rb @@ -14,7 +14,7 @@ plates.each do |plate| plate.wells.each do |well| # create the requests for cherrypicking - create(:cherrypick_request, asset: well, request_type:, submission:) + create(:cherrypick_request, asset: well, request_type: request_type, submission: submission) end end end diff --git a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb index 23ad3a3683..99025dcb20 100644 --- a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb +++ b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_spec.rb @@ -14,7 +14,7 @@ :sequencing_request_with_assets, 2, request_type: pipeline.request_types.first, - asset:, + asset: asset, target_asset: nil, submission: create(:submission) ) @@ -115,7 +115,9 @@ end context 'when a batch has been created' do - let(:batch) { create(:batch, pipeline:, requests: pipeline.requests, state: 'released', updated_at: 1.day.ago) } + let(:batch) do + create(:batch, pipeline: pipeline, requests: pipeline.requests, state: 'released', updated_at: 1.day.ago) + end let!(:flowcell_message) { Messenger.create!(target: batch, template: 'FlowcellIO', root: 'flowcell') } @@ -124,8 +126,8 @@ create( :lab_event, eventful: request, - batch:, - user:, + batch: batch, + user: user, description: 'Specify Dilution Volume', descriptors: { 'Concentration' => (1.2 + i).to_s @@ -134,8 +136,8 @@ create( :lab_event, eventful: request, - batch:, - user:, + batch: batch, + user: user, description: 'Set descriptors', descriptors: { 'Workflow (Standard or Xp)' => 'XP', diff --git a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb index 98ea80cbd1..db090a0458 100644 --- a/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb +++ b/spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb @@ -45,7 +45,7 @@ :sequencing_request_with_assets, 2, request_type: pipeline.request_types.first, - asset:, + asset: asset, target_asset: nil, submission: create(:submission) ) diff --git a/spec/features/pipelines/viewing_request_comments_spec.rb b/spec/features/pipelines/viewing_request_comments_spec.rb index 11f12c1407..bab01eb71a 100644 --- a/spec/features/pipelines/viewing_request_comments_spec.rb +++ b/spec/features/pipelines/viewing_request_comments_spec.rb @@ -8,7 +8,9 @@ let(:pipeline_name) { pipeline.name } let(:submission) { create(:submission) } let(:tube) { create(:multiplexed_library_tube) } - let(:request) { create(:sequencing_request, asset: tube, request_type: pipeline.request_types.first, submission:) } + let(:request) do + create(:sequencing_request, asset: tube, request_type: pipeline.request_types.first, submission: submission) + end before do create(:comment, commentable: tube, description: 'An excellent tube') diff --git a/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb b/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb index 7031946edc..ce916986ac 100644 --- a/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb +++ b/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb @@ -92,7 +92,7 @@ context 'invalid' do context 'upload' do - let(:download) { build(:test_download_tubes, columns:, validation_errors: [:library_type]) } + let(:download) { build(:test_download_tubes, columns: columns, validation_errors: [:library_type]) } it 'validation errors' do login_user(user) @@ -111,7 +111,7 @@ end context 'cgap foreign barcodes' do - let(:download) { build(:test_download_tubes_cgap, columns:, validation_errors: [:library_type]) } + let(:download) { build(:test_download_tubes_cgap, columns: columns, validation_errors: [:library_type]) } it 'validation errors' do login_user(user) @@ -123,7 +123,9 @@ end context 'duplicate cgap foreign barcodes' do - let(:download) { build(:test_download_tubes_cgap, columns:, validation_errors: [:sample_tube_id_duplicates]) } + let(:download) do + build(:test_download_tubes_cgap, columns: columns, validation_errors: [:sample_tube_id_duplicates]) + end it 'validation errors' do login_user(user) @@ -149,7 +151,7 @@ context 'valid' do context 'upload and reupload' do let(:download) do - build(:test_download_tubes, columns:, manifest_type: 'tube_multiplexed_library_with_tag_sequences') + build(:test_download_tubes, columns: columns, manifest_type: 'tube_multiplexed_library_with_tag_sequences') end it 'with override' do @@ -192,7 +194,11 @@ context 'cgap foreign barcodes' do let(:download) do - build(:test_download_tubes_cgap, columns:, manifest_type: 'tube_multiplexed_library_with_tag_sequences') + build( + :test_download_tubes_cgap, + columns: columns, + manifest_type: 'tube_multiplexed_library_with_tag_sequences' + ) end it 'upload' do @@ -210,7 +216,7 @@ let(:download) do build( :test_download_tubes, - columns:, + columns: columns, manifest_type: 'tube_multiplexed_library_with_tag_sequences', validation_errors: %i[library_type tags] ) @@ -237,7 +243,7 @@ let(:download) do build( :test_download_tubes_cgap, - columns:, + columns: columns, manifest_type: 'tube_multiplexed_library_with_tag_sequences', validation_errors: [:sanger_sample_id_invalid] ) @@ -256,7 +262,7 @@ let(:download) do build( :test_download_tubes_cgap, - columns:, + columns: columns, manifest_type: 'tube_multiplexed_library_with_tag_sequences', validation_errors: [:sample_tube_id_duplicates] ) @@ -285,7 +291,7 @@ context 'valid' do context 'upload and reupload' do - let(:download) { build(:test_download_tubes, columns:, manifest_type: 'tube_multiplexed_library') } + let(:download) { build(:test_download_tubes, columns: columns, manifest_type: 'tube_multiplexed_library') } it 'with override' do # upload @@ -326,7 +332,7 @@ end context 'cgap foreign barcodes' do - let(:download) { build(:test_download_tubes_cgap, columns:, manifest_type: 'tube_multiplexed_library') } + let(:download) { build(:test_download_tubes_cgap, columns: columns, manifest_type: 'tube_multiplexed_library') } it 'upload' do login_user(user) @@ -341,7 +347,12 @@ context 'invalid' do context 'upload' do let(:download) do - build(:test_download_tubes, columns:, manifest_type: 'tube_multiplexed_library', validation_errors: %i[tags]) + build( + :test_download_tubes, + columns: columns, + manifest_type: 'tube_multiplexed_library', + validation_errors: %i[tags] + ) end it 'validation errors' do @@ -365,7 +376,7 @@ let(:download) do build( :test_download_tubes_cgap, - columns:, + columns: columns, manifest_type: 'tube_multiplexed_library', validation_errors: [:sanger_sample_id_invalid] ) @@ -384,7 +395,7 @@ let(:download) do build( :test_download_tubes_cgap, - columns:, + columns: columns, manifest_type: 'tube_multiplexed_library', validation_errors: [:sample_tube_id_duplicates] ) @@ -475,7 +486,11 @@ context 'unrecognised cgap foreign barcodes' do let(:download) do - build(:test_download_plates_cgap, columns:, validation_errors: [:sample_plate_id_unrecognised_foreign]) + build( + :test_download_plates_cgap, + columns: columns, + validation_errors: [:sample_plate_id_unrecognised_foreign] + ) end it 'validation errors' do @@ -488,7 +503,9 @@ end context 'duplicate cgap foreign barcodes' do - let(:download) { build(:test_download_plates_cgap, columns:, validation_errors: [:sample_plate_id_duplicates]) } + let(:download) do + build(:test_download_plates_cgap, columns: columns, validation_errors: [:sample_plate_id_duplicates]) + end it 'validation errors' do login_user(user) diff --git a/spec/features/starting_transfers_on_repools_starts_repools_spec.rb b/spec/features/starting_transfers_on_repools_starts_repools_spec.rb index c224f11c95..1b78973926 100644 --- a/spec/features/starting_transfers_on_repools_starts_repools_spec.rb +++ b/spec/features/starting_transfers_on_repools_starts_repools_spec.rb @@ -20,13 +20,13 @@ describe 'Starting transfers on repools starts repools' do let(:original_input_plate) { create(:input_plate_for_pooling) } let(:secondary_input_plate) do - plate = PlateCreation.create!(user:, parent: original_input_plate, child_purpose: create(:plate_purpose)).child + plate = PlateCreation.create!(user: user, parent: original_input_plate, child_purpose: create(:plate_purpose)).child create(:transfer_between_plates, source: original_input_plate, destination: plate) plate end let(:target_plate) do - PlateCreation.create!(user:, parent: original_input_plate, child_purpose: create(:plate_purpose)).child + PlateCreation.create!(user: user, parent: original_input_plate, child_purpose: create(:plate_purpose)).child end let(:user) { create(:user) } @@ -42,7 +42,7 @@ before do allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode), build(:plate_barcode)) TransferRequestCollection.create!( - user:, + user: user, transfer_requests_attributes: [ { asset: source_a1, target_asset: target_a1, submission: library_creation_request_a1.submission }, { asset: source_b1, target_asset: target_b1, submission: library_creation_request_b1.submission } @@ -51,7 +51,7 @@ end it 'The target plate is started' do - StateChange.create(user:, target: target_plate, target_state: 'started') + StateChange.create(user: user, target: target_plate, target_state: 'started') expect(library_creation_request_a1.reload).to be_started expect(library_creation_request_b1.reload).to be_started end diff --git a/spec/features/studies/qc_reports_spec.rb b/spec/features/studies/qc_reports_spec.rb index 365fa04d2c..59ddcdd4e7 100644 --- a/spec/features/studies/qc_reports_spec.rb +++ b/spec/features/studies/qc_reports_spec.rb @@ -11,9 +11,9 @@ before do create(:plate_purpose) - create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[0])) - create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[1])) - create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[2])) + create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[0])) + create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[1])) + create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[2])) end it 'create a new report' do diff --git a/spec/features/studies/view_study_request_links_spec.rb b/spec/features/studies/view_study_request_links_spec.rb index 14b5507526..4134e1c15f 100644 --- a/spec/features/studies/view_study_request_links_spec.rb +++ b/spec/features/studies/view_study_request_links_spec.rb @@ -16,7 +16,7 @@ initial_study: study ) end - let(:library_tube) { create(:library_tube, samples: [sample], study:) } + let(:library_tube) { create(:library_tube, samples: [sample], study: study) } let(:sample_tube) { create(:sample_tube, sample:, study:) } before do diff --git a/spec/features/submissions/bulk_submissions_spec.rb b/spec/features/submissions/bulk_submissions_spec.rb index cbcfa205ca..debb336849 100644 --- a/spec/features/submissions/bulk_submissions_spec.rb +++ b/spec/features/submissions/bulk_submissions_spec.rb @@ -15,7 +15,7 @@ def process_submission(filename, encoding = nil) before do login_user user create(:project, name: 'Test project') - create(:asset_group, name: 'assetgroup123', study:, asset_count: 2) + create(:asset_group, name: 'assetgroup123', study: study, asset_count: 2) visit bulk_submissions_path expect(page).to have_content('Bulk Submission New') create(:library_type, name: 'Standard') diff --git a/spec/features/tag_set_spec.rb b/spec/features/tag_set_spec.rb index 4d838f6952..5554c2de5f 100644 --- a/spec/features/tag_set_spec.rb +++ b/spec/features/tag_set_spec.rb @@ -5,8 +5,8 @@ describe 'Create a new tag set' do let(:user) { create(:admin) } let(:adapter_type) { create(:adapter_type) } - let(:tag_group) { create(:tag_group, name: 'test-group-1', adapter_type:) } - let(:tag2_group) { create(:tag_group, name: 'test-group-2', adapter_type:) } + let(:tag_group) { create(:tag_group, name: 'test-group-1', adapter_type: adapter_type) } + let(:tag2_group) { create(:tag_group, name: 'test-group-2', adapter_type: adapter_type) } before do tag_group diff --git a/spec/helpers/batches_helper_spec.rb b/spec/helpers/batches_helper_spec.rb index 942b322e5f..519b6cade0 100644 --- a/spec/helpers/batches_helper_spec.rb +++ b/spec/helpers/batches_helper_spec.rb @@ -34,10 +34,10 @@ context 'with potential tasks' do def stage_link(id) - { action: :stage, batch_id: nil, controller: :workflows, id:, workflow_id: pipeline.workflow.id } + { action: :stage, batch_id: nil, controller: :workflows, id: id, workflow_id: pipeline.workflow.id } end let(:pipeline) { create(:sequencing_pipeline, :with_workflow) } - let(:batch) { build(:batch, state: 'pending', pipeline:) } + let(:batch) { build(:batch, state: 'pending', pipeline: pipeline) } let(:task1) { ['Specify Dilution Volume', stage_link(0), true, nil] } let(:task2) { ['Add Spiked in control', stage_link(1), true, nil] } diff --git a/spec/heron/factories/concerns/contents_spec.rb b/spec/heron/factories/concerns/contents_spec.rb index 3eba7fd0fc..64c4759bf0 100644 --- a/spec/heron/factories/concerns/contents_spec.rb +++ b/spec/heron/factories/concerns/contents_spec.rb @@ -233,7 +233,7 @@ def recipients_key context 'with a tube rack' do let(:purpose) { create(:plate_purpose, target_type: 'Plate', name: 'Stock Plate', size: '96') } - let(:tube_rack) { TubeRack.create!(size: '96', purpose:) } + let(:tube_rack) { TubeRack.create!(size: '96', purpose: purpose) } let(:plate) { tube_rack } let(:tubes) do %w[A1 B1 C1].map do |coordinate| diff --git a/spec/heron/factories/plate_spec.rb b/spec/heron/factories/plate_spec.rb index 005e7fcd75..b119a792cd 100644 --- a/spec/heron/factories/plate_spec.rb +++ b/spec/heron/factories/plate_spec.rb @@ -6,7 +6,7 @@ let(:purpose) { create(:plate_purpose, target_type: 'Plate', name: 'Stock Plate', size: '96') } let(:study) { create(:study) } let(:barcode) { '0000000001' } - let(:params) { { purpose_uuid: purpose.uuid, barcode: } } + let(:params) { { purpose_uuid: purpose.uuid, barcode: barcode } } include BarcodeHelper @@ -48,7 +48,7 @@ end context 'with a plate purpose uuid set to nil' do - let(:params) { { purpose_uuid: nil, barcode: } } + let(:params) { { purpose_uuid: nil, barcode: barcode } } let(:error_messages) { ['Plate purpose for uuid () do not exist'] } it_behaves_like 'an invalid parameter' @@ -56,7 +56,7 @@ context 'with a plate purpose uuid that do not exist' do let(:uuid) { SecureRandom.uuid } - let(:params) { { purpose_uuid: uuid, barcode: } } + let(:params) { { purpose_uuid: uuid, barcode: barcode } } let(:error_messages) { ["Plate purpose for uuid (#{uuid}) do not exist"] } it_behaves_like 'an invalid parameter' @@ -107,7 +107,7 @@ } } end - let(:params) { { barcode:, purpose_uuid: purpose.uuid, wells: } } + let(:params) { { barcode: barcode, purpose_uuid: purpose.uuid, wells: wells } } it 'persists the plate' do expect { plate_factory.save }.to change(Plate, :count).by(1) @@ -157,7 +157,7 @@ end context 'when declaring events' do - let(:params) { { barcode:, purpose_uuid: purpose.uuid, events: [event] } } + let(:params) { { barcode: barcode, purpose_uuid: purpose.uuid, events: [event] } } let(:subjects) do [ build( diff --git a/spec/heron/factories/sample_spec.rb b/spec/heron/factories/sample_spec.rb index bd087c5cb8..9ad572b0b9 100644 --- a/spec/heron/factories/sample_spec.rb +++ b/spec/heron/factories/sample_spec.rb @@ -16,7 +16,7 @@ end context 'when receiving a column that does not exist in sample or sample metadata' do - let(:params) { { study:, asdf: 'wrong' } } + let(:params) { { study: study, asdf: 'wrong' } } it 'is not valid' do factory = described_class.new(params) @@ -32,7 +32,7 @@ context 'when receiving other fields and sample_uuid' do let(:sample) { create(:sample) } - let(:params) { { study:, phenotype: 'A phenotype', sample_uuid: sample.uuid } } + let(:params) { { study: study, phenotype: 'A phenotype', sample_uuid: sample.uuid } } it 'is not valid' do factory = described_class.new(params) @@ -82,7 +82,7 @@ context 'when the factory is valid' do let(:well) { create(:well) } let(:tag_id) { 1 } - let(:factory) { described_class.new(study:, aliquot: { tag_id: }) } + let(:factory) { described_class.new(study: study, aliquot: { tag_id: }) } it 'can create an aliquot of the sample in the well' do expect { factory.create_aliquot_at(well) }.to change(Aliquot, :count).by(1).and(change(Sample, :count).by(1)) @@ -139,29 +139,29 @@ let(:sample) { create(:sample) } it 'wont create a new sample' do - factory = described_class.new(study:, sample_uuid: sample.uuid) + factory = described_class.new(study: study, sample_uuid: sample.uuid) expect { factory.create }.not_to change(Sample, :count) end it 'will return the sample with uuid specified' do - factory = described_class.new(study:, sample_uuid: sample.uuid) + factory = described_class.new(study: study, sample_uuid: sample.uuid) expect(factory.create).to eq(sample) end it 'will be invalid if providing any other extra attributes' do - factory = described_class.new(study:, sample_uuid: sample.uuid, sample_id: '1234') + factory = described_class.new(study: study, sample_uuid: sample.uuid, sample_id: '1234') expect(factory).not_to be_valid end it 'will be valid if providing any other attributes not sample related' do - factory = described_class.new(study:, sample_uuid: sample.uuid, aliquot: { tag_id: 1 }) + factory = described_class.new(study: study, sample_uuid: sample.uuid, aliquot: { tag_id: 1 }) expect(factory).to be_valid end end context 'when providing a sanger_sample_id' do let(:sample_id) { 'test' } - let(:factory) { described_class.new(study:, sanger_sample_id: sample_id) } + let(:factory) { described_class.new(study: study, sanger_sample_id: sample_id) } it 'sets the id provided as sanger_sample_id' do expect(factory.create.sanger_sample_id).to eq(sample_id) @@ -170,7 +170,7 @@ context 'when providing a name' do let(:sample_id) { 'test' } - let(:factory) { described_class.new(study:, name: sample_id) } + let(:factory) { described_class.new(study: study, name: sample_id) } it 'sets the id provided as name' do expect(factory.create.name).to eq(sample_id) @@ -180,7 +180,7 @@ context 'when providing both sanger_sample_id and name' do let(:sample_id) { 'test' } let(:name) { 'testingname' } - let(:factory) { described_class.new(study:, name:, sanger_sample_id: sample_id) } + let(:factory) { described_class.new(study: study, name: name, sanger_sample_id: sample_id) } it 'sets the id provided as sanger_sample_id' do expect(factory.create.sanger_sample_id).to eq(sample_id) @@ -215,13 +215,13 @@ context 'when the uuid does not exist already' do it 'creates a new sample using that uuid' do - factory = described_class.new(study:, uuid: replaced_uuid) + factory = described_class.new(study: study, uuid: replaced_uuid) sample = factory.create expect(sample.uuid).to eq(replaced_uuid) end it 'only creates one uuid' do - factory = described_class.new(study:, uuid: replaced_uuid) + factory = described_class.new(study: study, uuid: replaced_uuid) sample = factory.create expect(Uuid.where(resource: sample).count).to eq(1) end @@ -231,7 +231,7 @@ let(:sample) { create(:sample) } it 'will be invalid if providing any other extra attributes' do - factory = described_class.new(study:, uuid: sample.uuid) + factory = described_class.new(study: study, uuid: sample.uuid) expect { factory.create }.to raise_error(StandardError) end end @@ -239,13 +239,13 @@ context 'when providing other arguments' do it 'updates other sample attributes' do - factory = described_class.new(study:, control: true) + factory = described_class.new(study: study, control: true) sample = factory.create expect(sample.control).to be(true) end it 'updates other sample_metadata attributes' do - factory = described_class.new(study:, phenotype: 'A phenotype') + factory = described_class.new(study: study, phenotype: 'A phenotype') sample = factory.create expect(sample.sample_metadata.phenotype).to eq('A phenotype') end diff --git a/spec/heron/factories/tube_spec.rb b/spec/heron/factories/tube_spec.rb index f645af5795..b8f55f84d5 100644 --- a/spec/heron/factories/tube_spec.rb +++ b/spec/heron/factories/tube_spec.rb @@ -17,7 +17,7 @@ it 'is not valid unless the barcode is unique in database for that format' do barcode = 'FD00000001' - create(:barcode, barcode:, asset: create(:sample_tube), format: Barcode.matching_barcode_format(barcode)) + create(:barcode, barcode: barcode, asset: create(:sample_tube), format: Barcode.matching_barcode_format(barcode)) tube = described_class.new(params) expect(tube).not_to be_valid end diff --git a/spec/lib/label_printer/batch_plate_spec.rb b/spec/lib/label_printer/batch_plate_spec.rb index 879e34731e..9779791d45 100644 --- a/spec/lib/label_printer/batch_plate_spec.rb +++ b/spec/lib/label_printer/batch_plate_spec.rb @@ -65,27 +65,29 @@ let(:batch) { create(:batch) } let(:study) { create(:study) } let(:request1) do - order = create(:order, order_role: OrderRole.new(role: 'test_role'), study:, assets: [create(:empty_sample_tube)]) + order = + create(:order, order_role: OrderRole.new(role: 'test_role'), study: study, assets: [create(:empty_sample_tube)]) create( :well_request, asset: create(:well_with_sample_and_plate), target_asset: create(:well_with_sample_and_plate), - order: + order: order ) end let(:request2) do - order = create(:order, order_role: OrderRole.new(role: 'test_role'), study:, assets: [create(:empty_sample_tube)]) + order = + create(:order, order_role: OrderRole.new(role: 'test_role'), study: study, assets: [create(:empty_sample_tube)]) create( :well_request, asset: create(:well_with_sample_and_plate), target_asset: create(:well_with_sample_and_plate), - order: + order: order ) end let(:plate1) { request1.target_asset.plate } let(:plate2) { request2.target_asset.plate } let(:printables) { { plate1.human_barcode => 'on' } } - let(:options) { { count:, printable: printables, batch: } } + let(:options) { { count: count, printable: printables, batch: batch } } before do batch.requests << request1 @@ -94,7 +96,7 @@ describe LabelPrinter::Label::BatchPlateDouble do context 'printing double labels' do - let(:label_options) { { count:, printable: printables, batch: } } + let(:label_options) { { count: count, printable: printables, batch: batch } } let(:expected_count) { count.to_i * 2 } it_behaves_like 'a correct double label printer' diff --git a/spec/lib/label_printer/swipecard_spec.rb b/spec/lib/label_printer/swipecard_spec.rb index 466a15ffd6..cf225cb088 100644 --- a/spec/lib/label_printer/swipecard_spec.rb +++ b/spec/lib/label_printer/swipecard_spec.rb @@ -12,12 +12,14 @@ barcode_printer.name, label_class, user_login: user.login, - swipecard:, - label_template_name: + swipecard: swipecard, + label_template_name: label_template_name ) end let(:labels_attribute) { [{ left_text: user.login, barcode: swipecard, label_name: 'main' }] } - let(:build_attributes) { { printer_name: barcode_printer.name, label_template_name:, labels: labels_attribute } } + let(:build_attributes) do + { printer_name: barcode_printer.name, label_template_name: label_template_name, labels: labels_attribute } + end it 'builds correct attributes' do # This hash is sent to the printmybarcode service. diff --git a/spec/lib/limber/helper_spec.rb b/spec/lib/limber/helper_spec.rb index 2ad625178c..24f9988e34 100644 --- a/spec/lib/limber/helper_spec.rb +++ b/spec/lib/limber/helper_spec.rb @@ -5,7 +5,7 @@ subject(:template_constructor) do described_class::TemplateConstructor.new( prefix: 'WGS', - catalogue:, + catalogue: catalogue, sequencing_keys: [request_type.key], type: request_type.key ) @@ -53,7 +53,7 @@ hiseq_template_constructor = described_class::TemplateConstructor.new( prefix: 'WGS', - catalogue:, + catalogue: catalogue, sequencing_keys: [hiseq_request_type.key], type: request_type.key ) diff --git a/spec/lib/populate_numer_of_samples_per_pool_spec.rb b/spec/lib/populate_numer_of_samples_per_pool_spec.rb index 0f2cdf641e..3686ce8d97 100644 --- a/spec/lib/populate_numer_of_samples_per_pool_spec.rb +++ b/spec/lib/populate_numer_of_samples_per_pool_spec.rb @@ -21,7 +21,7 @@ def run_rake_task_with_args(task_name, *args) it 'populating number of samples per pool' do submission = create(:submission) tube = create(:tube) - request = create(:well_request, asset: tube, submission:) + request = create(:well_request, asset: tube, submission: submission) # Execute run_rake_task_with_args('number_of_samples_per_pool:populate', samples_per_pool, submission.reload.id) diff --git a/spec/lib/record_loader/request_type_loader_spec.rb b/spec/lib/record_loader/request_type_loader_spec.rb index 87378852cf..9bca18c10c 100644 --- a/spec/lib/record_loader/request_type_loader_spec.rb +++ b/spec/lib/record_loader/request_type_loader_spec.rb @@ -6,7 +6,7 @@ # This file was initially generated via `rails g record_loader` RSpec.describe RecordLoader::RequestTypeLoader, :loader, type: :model do def a_new_record_loader(files = selected_files) - described_class.new(directory: test_directory, files:) + described_class.new(directory: test_directory, files: files) end subject(:record_loader) { a_new_record_loader } diff --git a/spec/lib/record_loader/tag_layout_templates_loader_spec.rb b/spec/lib/record_loader/tag_layout_templates_loader_spec.rb index 2ed064cfa6..7596d212b5 100644 --- a/spec/lib/record_loader/tag_layout_templates_loader_spec.rb +++ b/spec/lib/record_loader/tag_layout_templates_loader_spec.rb @@ -17,7 +17,13 @@ def a_new_record_loader context 'with tag_layout_template_basic selected' do let(:selected_files) { 'tag_layout_template_basic' } let(:expected_attributes) do - { name: 'Tag Layout 1', tag_group:, tag2_group:, direction: 'column', walking_by: 'wells of plate' } + { + name: 'Tag Layout 1', + tag_group: tag_group, + tag2_group: tag2_group, + direction: 'column', + walking_by: 'wells of plate' + } end let!(:tag_group) { create(:tag_group, name: 'group 1') } diff --git a/spec/models/aliquot_spec.rb b/spec/models/aliquot_spec.rb index 903de59b55..32c2fb1dd6 100644 --- a/spec/models/aliquot_spec.rb +++ b/spec/models/aliquot_spec.rb @@ -25,7 +25,7 @@ context 'with different tag 2' do let(:aliquot1) { build(:aliquot, tag: tag1, tag2: tag1, sample: sample1) } - let(:aliquot2) { build(:aliquot, tag: tag1, tag2:, sample: sample1) } + let(:aliquot2) { build(:aliquot, tag: tag1, tag2: tag2, sample: sample1) } it { is_expected.to be false } end @@ -89,13 +89,13 @@ it 'allows mixing same tags with a different tag 2' do asset.aliquots << build(:aliquot, tag: tag1, tag2: tag1, sample: sample1) << - build(:aliquot, tag: tag1, tag2:, sample: sample2) + build(:aliquot, tag: tag1, tag2: tag2, sample: sample2) expect(asset.save).to be true end end describe '#set_library' do - subject { build(:aliquot, receptacle:, library_id: initial_library_id) } + subject { build(:aliquot, receptacle: receptacle, library_id: initial_library_id) } let(:receptacle) { create(:empty_well) } diff --git a/spec/models/api/aliquot_io_spec.rb b/spec/models/api/aliquot_io_spec.rb index 25d5c65947..38fa525df5 100644 --- a/spec/models/api/aliquot_io_spec.rb +++ b/spec/models/api/aliquot_io_spec.rb @@ -7,14 +7,14 @@ create( :aliquot, receptacle: well, - sample:, - study:, - project:, + sample: sample, + study: study, + project: project, library: well, - tag:, + tag: tag, insert_size_from: 100, insert_size_to: 200, - bait_library: + bait_library: bait_library ) end diff --git a/spec/models/api/batch_io_spec.rb b/spec/models/api/batch_io_spec.rb index 21aa02c591..015a8ffddc 100644 --- a/spec/models/api/batch_io_spec.rb +++ b/spec/models/api/batch_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::BatchIO do - subject { create(:batch, user:, assignee: user2, pipeline:) } + subject { create(:batch, user: user, assignee: user2, pipeline: pipeline) } let(:user) { create(:user) } let(:user2) { create(:user) } diff --git a/spec/models/api/library_tube_io_spec.rb b/spec/models/api/library_tube_io_spec.rb index bd32f72e56..a9a2c3d72c 100644 --- a/spec/models/api/library_tube_io_spec.rb +++ b/spec/models/api/library_tube_io_spec.rb @@ -4,12 +4,12 @@ RSpec.describe Api::LibraryTubeIO do subject do - create(:empty_library_tube, public_name: 'ABC', closed: false, aliquots:, volume: 12.0, concentration: 8.0) + create(:empty_library_tube, public_name: 'ABC', closed: false, aliquots: aliquots, volume: 12.0, concentration: 8.0) end let(:sample) { create(:sample) } let(:tag) { create(:tag) } - let(:aliquots) { [create(:aliquot, sample:, tag:, library_type: 'Standard')] } + let(:aliquots) { [create(:aliquot, sample: sample, tag: tag, library_type: 'Standard')] } let!(:library_request) { create(:library_creation_request, target_asset: subject) } diff --git a/spec/models/api/messages/flowcell_io_spec.rb b/spec/models/api/messages/flowcell_io_spec.rb index 574e240a47..b640c7c038 100644 --- a/spec/models/api/messages/flowcell_io_spec.rb +++ b/spec/models/api/messages/flowcell_io_spec.rb @@ -16,7 +16,7 @@ asset: mx_tube1, batch: sequencing_batch, target_asset: lane1, - request_type:, + request_type: request_type, event_descriptors: request_data ) end diff --git a/spec/models/api/messages/well_stock_resource_io_spec.rb b/spec/models/api/messages/well_stock_resource_io_spec.rb index d11ec77611..aa59645660 100644 --- a/spec/models/api/messages/well_stock_resource_io_spec.rb +++ b/spec/models/api/messages/well_stock_resource_io_spec.rb @@ -21,7 +21,7 @@ ) end let(:study) { create(:study) } - let(:aliquot) { create(:aliquot, study:, sample:, receptacle: well) } + let(:aliquot) { create(:aliquot, study: study, sample: sample, receptacle: well) } before { aliquot } # rubocop:todo RSpec/ScatteredSetup diff --git a/spec/models/api/order_io_spec.rb b/spec/models/api/order_io_spec.rb index 8b9089c4a9..de2090b395 100644 --- a/spec/models/api/order_io_spec.rb +++ b/spec/models/api/order_io_spec.rb @@ -6,10 +6,10 @@ subject do create( :order, - user:, + user: user, template_name: 'Cool template', - study:, - project:, + study: study, + project: project, comments: 'Good', request_options: { read_length: '200', diff --git a/spec/models/api/project_io_spec.rb b/spec/models/api/project_io_spec.rb index 2c5ce6ec9a..d22bcd815b 100644 --- a/spec/models/api/project_io_spec.rb +++ b/spec/models/api/project_io_spec.rb @@ -39,7 +39,7 @@ external_funding_source: 'Tooth fairy', sequencing_budget_cost_centre: '123', funding_comments: 'It is funded', - project_manager: + project_manager: project_manager } ) end diff --git a/spec/models/api/request_io_spec.rb b/spec/models/api/request_io_spec.rb index bc4eeabead..5a2e7cd414 100644 --- a/spec/models/api/request_io_spec.rb +++ b/spec/models/api/request_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::RequestIO do - subject { create(:request, asset: source_asset, target_asset:) } + subject { create(:request, asset: source_asset, target_asset: target_asset) } context 'between tubes' do let(:source_asset) { create(:sample_tube) } diff --git a/spec/models/api/sample_tube_io_spec.rb b/spec/models/api/sample_tube_io_spec.rb index 93ab11cb8e..0ec24d4ee6 100644 --- a/spec/models/api/sample_tube_io_spec.rb +++ b/spec/models/api/sample_tube_io_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Api::SampleTubeIO do - subject { create(:sample_tube, volume: 12.0, concentration: 8.0, sample:) } + subject { create(:sample_tube, volume: 12.0, concentration: 8.0, sample: sample) } let(:sample) { create(:sample) } diff --git a/spec/models/api/study_io_spec.rb b/spec/models/api/study_io_spec.rb index aafec9cbfd..b77ea8e5e4 100644 --- a/spec/models/api/study_io_spec.rb +++ b/spec/models/api/study_io_spec.rb @@ -11,7 +11,7 @@ faculty_sponsor: create(:faculty_sponsor, name: 'John Smith'), data_release_strategy: 'open', data_release_timing: 'standard', - reference_genome:, + reference_genome: reference_genome, array_express_accession_number: 'AE111', ega_policy_accession_number: 'EGA222', ega_dac_accession_number: 'DAC333', diff --git a/spec/models/api/well_io_spec.rb b/spec/models/api/well_io_spec.rb index e2278274db..e7a94624e7 100644 --- a/spec/models/api/well_io_spec.rb +++ b/spec/models/api/well_io_spec.rb @@ -6,7 +6,11 @@ context 'with one sample' do # As of the current records, the 'description' and 'asset_size' attributes can uniquely identify a map. subject do - create(:well_with_sample_and_without_plate, map: Map.find_by(description: 'A1', asset_size: plate.size), plate:) + create( + :well_with_sample_and_without_plate, + map: Map.find_by(description: 'A1', asset_size: plate.size), + plate: plate + ) end let(:plate) { create(:plate, barcode: 'SQPD-1') } @@ -44,7 +48,7 @@ create( :well_with_sample_and_without_plate, map: Map.find_by(description: 'A1', asset_size: plate.size), - plate:, + plate: plate, aliquot_count: 2 ) end diff --git a/spec/models/barcode/format_handlers_spec.rb b/spec/models/barcode/format_handlers_spec.rb index 20a9408560..b363388fe1 100644 --- a/spec/models/barcode/format_handlers_spec.rb +++ b/spec/models/barcode/format_handlers_spec.rb @@ -12,7 +12,7 @@ def self.it_has_a_valid_barcode(barcode, number: nil, prefix: nil, suffix: nil, it 'parses the barcode correctly', :aggregate_failures do expect(format_handler).to be_valid - expect(format_handler).to have_attributes(number:, barcode_prefix: prefix, suffix:, child:) + expect(format_handler).to have_attributes(number: number, barcode_prefix: prefix, suffix: suffix, child: child) end end end diff --git a/spec/models/broadcast_event/broadcast_event_spec.rb b/spec/models/broadcast_event/broadcast_event_spec.rb index 7b8a26dd87..e98ea36287 100644 --- a/spec/models/broadcast_event/broadcast_event_spec.rb +++ b/spec/models/broadcast_event/broadcast_event_spec.rb @@ -134,7 +134,7 @@ def accessible data_method_a: value_a ) end - let(:event) { ExampleEvent.new(seed:, user:, created_at: time) } + let(:event) { ExampleEvent.new(seed: seed, user: user, created_at: time) } it 'finds subjects with a 1 to 1 relationship' do expect(event.subjects).to be_present diff --git a/spec/models/broadcast_event/lab_event_spec.rb b/spec/models/broadcast_event/lab_event_spec.rb index ac7e9aa2ed..1f06d87ce6 100644 --- a/spec/models/broadcast_event/lab_event_spec.rb +++ b/spec/models/broadcast_event/lab_event_spec.rb @@ -5,14 +5,21 @@ require 'rails_helper' RSpec.describe BroadcastEvent::LabEvent, :broadcast_event do - subject { described_class.create!(seed: lab_event, user:, created_at: Time.zone.parse('2018-01-12T13:37:03+00:00')) } + subject do + described_class.create!(seed: lab_event, user: user, created_at: Time.zone.parse('2018-01-12T13:37:03+00:00')) + end let(:json) { JSON.parse(subject.to_json) } let(:eventful) { request } let(:batch) { create(:sequencing_batch) } let(:study) { create(:study) } let!(:request) do - create(:sequencing_request_with_assets, batch:, request_type: batch.pipeline.request_types.first, study:) + create( + :sequencing_request_with_assets, + batch: batch, + request_type: batch.pipeline.request_types.first, + study: study + ) end let(:sample) { request.asset.samples.first } let(:stock_asset) { request.asset.labware } @@ -25,7 +32,7 @@ 'key_a' => 'value a', 'key_b' => 'value b' }, - eventful: + eventful: eventful ) end let(:user) { create(:user) } diff --git a/spec/models/broadcast_event/library_complete_spec.rb b/spec/models/broadcast_event/library_complete_spec.rb index 5ff5af70f8..a0233be7fe 100644 --- a/spec/models/broadcast_event/library_complete_spec.rb +++ b/spec/models/broadcast_event/library_complete_spec.rb @@ -7,8 +7,8 @@ include_context 'a limber target plate with submissions' let(:user) { create(:user) } - let(:work_completion) { WorkCompletion.create!(user:, target: target_plate, submissions: [target_submission]) } - let(:event) { described_class.create!(seed: work_completion, user:, properties: { order_id: order.id }) } + let(:work_completion) { WorkCompletion.create!(user: user, target: target_plate, submissions: [target_submission]) } + let(:event) { described_class.create!(seed: work_completion, user: user, properties: { order_id: order.id }) } let(:subject_hash) { event.as_json['event'][:subjects].group_by(&:role_type) } let(:metadata) { event.as_json['event'][:metadata] } diff --git a/spec/models/broadcast_event/pool_released_spec.rb b/spec/models/broadcast_event/pool_released_spec.rb index 7cb404c035..d383e3aac4 100644 --- a/spec/models/broadcast_event/pool_released_spec.rb +++ b/spec/models/broadcast_event/pool_released_spec.rb @@ -15,10 +15,22 @@ let(:submission) { create(:library_submission) } let(:order) { submission.orders.first } let(:request1) do - create(:multiplex_request, asset: source_plate.wells.first, target_asset: tube.receptacle, state: 'passed', order:) + create( + :multiplex_request, + asset: source_plate.wells.first, + target_asset: tube.receptacle, + state: 'passed', + order: order + ) end let(:request2) do - create(:multiplex_request, asset: source_plate.wells.last, target_asset: tube.receptacle, state: 'passed', order:) + create( + :multiplex_request, + asset: source_plate.wells.last, + target_asset: tube.receptacle, + state: 'passed', + order: order + ) end let(:library_request) { create(:library_request, target_asset: source_plate.wells.first) } diff --git a/spec/models/broadcast_event/qc_assay_spec.rb b/spec/models/broadcast_event/qc_assay_spec.rb index 0fe996b778..0e053805f8 100644 --- a/spec/models/broadcast_event/qc_assay_spec.rb +++ b/spec/models/broadcast_event/qc_assay_spec.rb @@ -29,7 +29,7 @@ let(:qc_assay) do create( :qc_assay, - lot_number:, + lot_number: lot_number, qc_results: [ build(:qc_result_concentration, asset: well1, assay_type: 'Example Assay', assay_version: 'v0.0'), build(:qc_result_concentration, asset: well2, assay_type: 'Example Assay', assay_version: 'v0.0') @@ -104,7 +104,7 @@ let(:qc_assay) do create( :qc_assay, - lot_number:, + lot_number: lot_number, qc_results: [ build(:qc_result_concentration, asset: well1, assay_type: 'Example Assay', assay_version: 'v0.0'), build(:qc_result_concentration, asset: well2, assay_type: 'Other Assay', assay_version: 'v0.0') diff --git a/spec/models/broadcast_event/sequencing_complete_spec.rb b/spec/models/broadcast_event/sequencing_complete_spec.rb index d09ff2e859..83f1ae9db4 100644 --- a/spec/models/broadcast_event/sequencing_complete_spec.rb +++ b/spec/models/broadcast_event/sequencing_complete_spec.rb @@ -18,8 +18,8 @@ project: nil, study: nil, batch: create(:batch, pipeline:), - request_type:, - submission:, + request_type: request_type, + submission: submission, target_asset: lane, request_metadata_attributes: { fragment_size_required_from: 100, @@ -31,7 +31,7 @@ let(:event) do described_class.create!( seed: lane, - user:, + user: user, properties: { result: :passed }, diff --git a/spec/models/bulk_submission_spec.rb b/spec/models/bulk_submission_spec.rb index e1e254d17b..a1fdcb66c3 100644 --- a/spec/models/bulk_submission_spec.rb +++ b/spec/models/bulk_submission_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe BulkSubmission, with: :uploader do - subject { described_class.new(spreadsheet: submission_file, encoding:) } + subject { described_class.new(spreadsheet: submission_file, encoding: encoding) } let(:encoding) { 'Windows-1252' } let(:spreadsheet_path) { Rails.root.join('features', 'submission', 'csv', spreadsheet_filename) } @@ -19,7 +19,7 @@ after { submission_file.close } let!(:study) { create(:study, name: 'abc123_study') } - let!(:asset_group) { create(:asset_group, name: 'assetgroup123', study:, asset_count: 2) } + let!(:asset_group) { create(:asset_group, name: 'assetgroup123', study: study, asset_count: 2) } let!(:library_type) { create(:library_type, name: 'Standard') } before do diff --git a/spec/models/cherrypick_request_spec.rb b/spec/models/cherrypick_request_spec.rb index d25158a369..aec200cd8d 100644 --- a/spec/models/cherrypick_request_spec.rb +++ b/spec/models/cherrypick_request_spec.rb @@ -7,7 +7,7 @@ let(:source_asset) { create(:tagged_well) } let(:target_asset) { create(:empty_well) } - before { create(:cherrypick_request, asset: source_asset, target_asset:) } + before { create(:cherrypick_request, asset: source_asset, target_asset: target_asset) } it 'transfers the contents of the source asset to the target asset' do expect(target_asset.aliquots.length).to eq(source_asset.aliquots.length) diff --git a/spec/models/cherrypick_task/control_locator_spec.rb b/spec/models/cherrypick_task/control_locator_spec.rb index 30b980c99e..37cd0645f1 100644 --- a/spec/models/cherrypick_task/control_locator_spec.rb +++ b/spec/models/cherrypick_task/control_locator_spec.rb @@ -126,7 +126,7 @@ let(:range) { (1...1000) } let(:control_positions) do range.map do |batch_id| - described_class.new(batch_id:, total_wells: 96, num_control_wells: 1).control_positions(0).first + described_class.new(batch_id: batch_id, total_wells: 96, num_control_wells: 1).control_positions(0).first end end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index d429c8d0d1..922e4d6a37 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -53,17 +53,17 @@ let(:asset2) { create(:empty_sample_tube) } - let(:order1) { create(:order_with_submission, study:, assets: [asset], project:) } - let(:order2) { create(:order, study:, assets: [asset], project:) } - let(:order3) { create(:order, study:, assets: [asset2], project:) } - let(:order4) { create(:order_with_submission, study:, assets: [asset2], project:) } + let(:order1) { create(:order_with_submission, study: study, assets: [asset], project: project) } + let(:order2) { create(:order, study: study, assets: [asset], project: project) } + let(:order3) { create(:order, study: study, assets: [asset2], project: project) } + let(:order4) { create(:order_with_submission, study: study, assets: [asset2], project: project) } let(:submission) { order1.submission } let(:submission2) { order4.submission } let!(:sequencing_request) { create(:request_with_sequencing_request_type, submission:) } - let!(:request) { create(:request, order: order1, asset:, submission:) } - let!(:request2) { create(:request, order: order2, submission:) } + let!(:request) { create(:request, order: order1, asset: asset, submission: submission) } + let!(:request2) { create(:request, order: order2, submission: submission) } let!(:request3) { create(:request, order: order4, submission: order4.submission) } let!(:sequencing_request2) { create(:request_with_sequencing_request_type, submission: order4.submission) } @@ -127,7 +127,7 @@ context 'adding to a plate' do let(:plate) { create(:plate, well_count: 1) } let(:submission) { create(:submission) } - let!(:request) { create(:request, asset: plate.wells.first, submission:) } + let!(:request) { create(:request, asset: plate.wells.first, submission: submission) } it 'also adds to the request' do create(:comment, commentable: plate, description: 'Hello') diff --git a/spec/models/external_release_event_spec.rb b/spec/models/external_release_event_spec.rb index 011ad42104..8c40438f2a 100644 --- a/spec/models/external_release_event_spec.rb +++ b/spec/models/external_release_event_spec.rb @@ -6,7 +6,7 @@ describe '::create_for_asset!' do subject { described_class.create_for_asset!(asset, sendmail) } - let(:asset) { build(:lane, aliquots:, external_release: true) } + let(:asset) { build(:lane, aliquots: aliquots, external_release: true) } let(:aliquots) { [study_a, study_a, study_b].map { |s| build(:aliquot, study: s) } } let(:expected_recipients) { [user_on_multiple_studies.email, user_on_single_study.email] } let(:expected_message) { 'Data to be released externally set true' } diff --git a/spec/models/linear_submission_spec.rb b/spec/models/linear_submission_spec.rb index 94b281d9df..b5c62924bb 100644 --- a/spec/models/linear_submission_spec.rb +++ b/spec/models/linear_submission_spec.rb @@ -43,11 +43,11 @@ let(:mpx_submission) do create( :linear_submission, - study:, - project:, - user:, + study: study, + project: project, + user: user, request_types: [library_creation_request_type.id, sequencing_request_type.id], - request_options:, + request_options: request_options, product: product_criteria.product, assets: [request_well] ).submission @@ -79,12 +79,12 @@ let(:mpx_submission) do create( :linear_submission, - study:, - project:, - user:, + study: study, + project: project, + user: user, assets: mpx_assets, request_types: request_type_option, - request_options: + request_options: request_options ).submission end @@ -139,7 +139,16 @@ [library_creation_stage1.id, library_creation_stage2.id, mx_request_type.id, sequencing_request_type.id] end let(:assets) { create_list(:untagged_well, 2) } - let(:basic_options) { { study:, project:, user:, request_types: request_type_option, request_options:, assets: } } + let(:basic_options) do + { + study: study, + project: project, + user: user, + request_types: request_type_option, + request_options: request_options, + assets: assets + } + end let(:submission) { create(:linear_submission, basic_options).submission.tap(&:built!) } it 'builds the submission' do @@ -157,12 +166,12 @@ let(:submission) do create( :linear_submission, - study:, - project:, - user:, - assets:, + study: study, + project: project, + user: user, + assets: assets, request_types: request_type_option, - request_options:, + request_options: request_options, comments: 'This is a comment' ).submission end @@ -262,10 +271,10 @@ let(:submission) do create( :linear_submission, - study:, - project:, - user:, - assets:, + study: study, + project: project, + user: user, + assets: assets, request_types: [lib_request_type.id, sequencing_request_type.id], request_options: { :multiplier => { @@ -292,10 +301,10 @@ let(:submission) do create( :linear_submission, - study:, - project:, - user:, - assets:, + study: study, + project: project, + user: user, + assets: assets, request_types: [mx_request_type.id, sequencing_request_type.id], request_options: { :multiplier => { diff --git a/spec/models/location_report_spec.rb b/spec/models/location_report_spec.rb index 615be2d388..7b6a76b644 100644 --- a/spec/models/location_report_spec.rb +++ b/spec/models/location_report_spec.rb @@ -48,7 +48,7 @@ # add retention instruction metadata to plate 1 custom metadatum collection let(:retention_key) { 'retention_instruction' } let(:retention_value) { 'Long term storage' } - let(:plate_1_custom_metadatum_collection) { create(:custom_metadatum_collection, asset: plate_1, user:) } + let(:plate_1_custom_metadatum_collection) { create(:custom_metadatum_collection, asset: plate_1, user: user) } let(:plate_1_custom_metadatum) do create( :custom_metadatum, @@ -84,7 +84,7 @@ let(:plt_3_received_date) { 'Unknown' } # add retention instruction metadata to plate 3 custom metadatum collection - let(:plate_3_custom_metadatum_collection) { create(:custom_metadatum_collection, asset: plate_3, user:) } + let(:plate_3_custom_metadatum_collection) { create(:custom_metadatum_collection, asset: plate_3, user: user) } let(:plate_3_custom_metadatum) do create( :custom_metadatum, diff --git a/spec/models/lot_type_spec.rb b/spec/models/lot_type_spec.rb index f0ce865f51..cf144b5e69 100644 --- a/spec/models/lot_type_spec.rb +++ b/spec/models/lot_type_spec.rb @@ -21,7 +21,7 @@ let(:lot_type) { create(:lot_type) } let(:user) { create(:user) } let(:template) { PlateTemplate.new } - let(:lot) { lot_type.create!(template:, user:, lot_number: '123456789', received_at: '2014-02-01') } + let(:lot) { lot_type.create!(template: template, user: user, lot_number: '123456789', received_at: '2014-02-01') } context 'create' do it 'change Lot.count by 1' do diff --git a/spec/models/orders/order_spec.rb b/spec/models/orders/order_spec.rb index 96d257f110..91dca21504 100644 --- a/spec/models/orders/order_spec.rb +++ b/spec/models/orders/order_spec.rb @@ -15,7 +15,16 @@ # don't want to trigger this behaviour accidentally if someone forgets to # specify a study. - subject(:order) { build(:order, assets:, autodetect_studies:, autodetect_projects:, study: nil, project: nil) } + subject(:order) do + build( + :order, + assets: assets, + autodetect_studies: autodetect_studies, + autodetect_projects: autodetect_projects, + study: nil, + project: nil + ) + end let(:assets) { [tube] } let(:tube) { create(:sample_tube, aliquots:) } @@ -109,13 +118,13 @@ end it 'order should not be valid if study is not active' do - order = build(:order, study:, assets: [asset.receptacle], project:) + order = build(:order, study: study, assets: [asset.receptacle], project: project) expect(order).not_to be_valid end it 'order should be valid if study is active on create' do study.activate! - order = create(:order, study:, assets: [asset.receptacle], project:) + order = create(:order, study: study, assets: [asset.receptacle], project: project) assert order.valid? study.deactivate! new_asset = create(:empty_sample_tube) diff --git a/spec/models/phi_x/spiked_buffer_spec.rb b/spec/models/phi_x/spiked_buffer_spec.rb index 265c40ff27..2f52a80f50 100644 --- a/spec/models/phi_x/spiked_buffer_spec.rb +++ b/spec/models/phi_x/spiked_buffer_spec.rb @@ -70,7 +70,7 @@ concentration: '0.8', volume: '10', number: 2, - study_id: + study_id: study_id ) end diff --git a/spec/models/phi_x/stock_spec.rb b/spec/models/phi_x/stock_spec.rb index 4c9973a7c4..6628947698 100644 --- a/spec/models/phi_x/stock_spec.rb +++ b/spec/models/phi_x/stock_spec.rb @@ -49,7 +49,9 @@ context 'with valid data' do subject(:save) { phi_x_stock.save } - let(:phi_x_stock) { build(:phi_x_stock, number: 2, name: 'Example', concentration: '0.8', tags:, study_id:) } + let(:phi_x_stock) do + build(:phi_x_stock, number: 2, name: 'Example', concentration: '0.8', tags: tags, study_id: study_id) + end let(:tags) { 'Single' } let(:study_id) { build_stubbed(:study).id } diff --git a/spec/models/pick_list_spec.rb b/spec/models/pick_list_spec.rb index 026edb5948..36672297f4 100644 --- a/spec/models/pick_list_spec.rb +++ b/spec/models/pick_list_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' RSpec.describe PickList, :pick_list do - subject(:pick_list) { described_class.new(pick_attributes: picks, asynchronous:) } + subject(:pick_list) { described_class.new(pick_attributes: picks, asynchronous: asynchronous) } let(:wells) { create_list(:untagged_well, 2) } let(:asynchronous) { false } @@ -29,7 +29,7 @@ context 'when wells lack project information but the pick provides it' do let(:wells) { create_list(:untagged_well, 2, project: nil) } - let(:picks) { wells.map { |well| { source_receptacle: well, project: } } } + let(:picks) { wells.map { |well| { source_receptacle: well, project: project } } } it { is_expected.to be_valid } end diff --git a/spec/models/plate/quad_creator_spec.rb b/spec/models/plate/quad_creator_spec.rb index c983cbf66f..af9fd28052 100644 --- a/spec/models/plate/quad_creator_spec.rb +++ b/spec/models/plate/quad_creator_spec.rb @@ -9,7 +9,7 @@ let(:target_purpose) { create(:plate_purpose, size: 384) } let(:user) { create(:user) } - let(:creation_options) { { parent_barcodes: parent_barcodes_hash, target_purpose:, user: } } + let(:creation_options) { { parent_barcodes: parent_barcodes_hash, target_purpose: target_purpose, user: user } } before { allow(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode)) } @@ -31,7 +31,7 @@ end context 'when loading from barcodes' do - let(:creation_options) { { parent_barcodes: parent_barcodes_hash, target_purpose:, user: } } + let(:creation_options) { { parent_barcodes: parent_barcodes_hash, target_purpose: target_purpose, user: user } } context 'when a barcode is invalid' do let(:parent_barcodes_hash) { { 'quad_1' => 'INVALID' } } diff --git a/spec/models/plate_spec.rb b/spec/models/plate_spec.rb index 16d5ff2b7b..fa2c3e18e8 100644 --- a/spec/models/plate_spec.rb +++ b/spec/models/plate_spec.rb @@ -25,7 +25,7 @@ context 'with requests out of the wells' do before do submission = create(:submission) - request = create(:well_request, asset: plate.wells.first, submission:) + request = create(:well_request, asset: plate.wells.first, submission: submission) create(:comment, commentable: request, description: 'Comment on request') plate.reload end @@ -48,7 +48,7 @@ submission = create(:submission) request = create(:well_request, submission:) plate.wells.first.aliquots << create(:aliquot, request:) - create(:transfer_request, target_asset: plate.wells.first, submission:) + create(:transfer_request, target_asset: plate.wells.first, submission: submission) create(:comment, commentable: request, description: 'Comment on request') plate.reload end @@ -63,8 +63,8 @@ context 'with multiple identical comments' do before do submission = create(:submission) - request = create(:well_request, asset: plate.wells.first, submission:) - request2 = create(:well_request, asset: plate.wells.last, submission:) + request = create(:well_request, asset: plate.wells.first, submission: submission) + request2 = create(:well_request, asset: plate.wells.last, submission: submission) create(:comment, commentable: request, description: 'Duplicate comment') create(:comment, commentable: request2, description: 'Duplicate comment') create(:comment, commentable: plate, description: 'Duplicate comment') diff --git a/spec/models/pooling_spec.rb b/spec/models/pooling_spec.rb index 68b0f2ac40..75a51d1903 100644 --- a/spec/models/pooling_spec.rb +++ b/spec/models/pooling_spec.rb @@ -12,7 +12,12 @@ let(:stock_mx_tube_required) { false } let(:barcode_printer_option) { nil } let(:pooling) do - described_class.new(barcodes:, stock_mx_tube_required:, barcode_printer: barcode_printer_option, count: 1) + described_class.new( + barcodes: barcodes, + stock_mx_tube_required: stock_mx_tube_required, + barcode_printer: barcode_printer_option, + count: 1 + ) end context 'without source assets' do @@ -149,7 +154,7 @@ # set the tags in the second tube to be the same as the first, to create a tag clash tag1 = tagged_lb_tube1.aliquots.first.tag tag2 = tagged_lb_tube1.aliquots.first.tag2 - tagged_lb_tube2.aliquots.first.update!(tag: tag1, tag2:) + tagged_lb_tube2.aliquots.first.update!(tag: tag1, tag2: tag2) end it 'is not valid due to the tag clash' do diff --git a/spec/models/qc_report_spec.rb b/spec/models/qc_report_spec.rb index b1a438b27e..fdfd3e9803 100644 --- a/spec/models/qc_report_spec.rb +++ b/spec/models/qc_report_spec.rb @@ -84,12 +84,12 @@ @matching_report = create( :qc_report, - study:, + study: study, exclude_existing: true, product_criteria: current_criteria, report_identifier: 'Override' ) - @other_report = create(:qc_report, study:, exclude_existing: true, product_criteria: other_criteria) + @other_report = create(:qc_report, study: study, exclude_existing: true, product_criteria: other_criteria) @attribute = create(:well_attribute, current_volume: 500, concentration: 200) @@ -143,7 +143,7 @@ create(:qc_metric, asset: well, qc_report: matching_report) create(:qc_metric, asset: well, qc_report: other_report) - @qc_report = create(:qc_report, study:, exclude_existing: true, product_criteria: current_criteria) + @qc_report = create(:qc_report, study: study, exclude_existing: true, product_criteria: current_criteria) @qc_metric_count = QcMetric.count qc_report.generate! end @@ -180,14 +180,14 @@ let(:plate_purpose_names) { plate_purposes.map(&:name) } before do - create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[0])) - create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[1])) - create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: plate_purposes[2])) + create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[0])) + create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[1])) + create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: plate_purposes[2])) @qc_report = create( :qc_report, - study:, + study: study, exclude_existing: false, product_criteria: create(:product_criteria), plate_purposes: plate_purpose_names diff --git a/spec/models/qcable_creator_spec.rb b/spec/models/qcable_creator_spec.rb index 2babb48899..472ea1e315 100644 --- a/spec/models/qcable_creator_spec.rb +++ b/spec/models/qcable_creator_spec.rb @@ -7,7 +7,7 @@ let(:lot) { create(:tag2_lot) } it 'will create some qcables with a count' do - qcable_creator = described_class.create(count: 10, user:, lot:) + qcable_creator = described_class.create(count: 10, user: user, lot: lot) expect(qcable_creator.qcables.count).to eq(10) end @@ -24,7 +24,7 @@ let(:lot) { create(:tag_layout_lot) } it 'will create qcables with single barcode' do - qcable_creator = described_class.create(user:, lot:, supplied_barcode: plate_barcode) + qcable_creator = described_class.create(user: user, lot: lot, supplied_barcode: plate_barcode) expect(qcable_creator.qcables.count).to eq(1) expect(qcable_creator.qcables.first.barcodes.count).to eq(1) expect(qcable_creator.qcables.first.barcodes.first).to eq(plate_barcode) diff --git a/spec/models/qcable_spec.rb b/spec/models/qcable_spec.rb index b8ee3536b0..8057a1906f 100644 --- a/spec/models/qcable_spec.rb +++ b/spec/models/qcable_spec.rb @@ -7,7 +7,7 @@ let(:qcable_creator) { create(:qcable_creator) } it 'can create an asset with a barcode' do - qcable = described_class.create(qcable_creator:, lot:, barcode: 'CGAP-123456') + qcable = described_class.create(qcable_creator: qcable_creator, lot: lot, barcode: 'CGAP-123456') expect(qcable.asset.barcodes.first.barcode).to eq('CGAP-123456') end end diff --git a/spec/models/racked_tube_spec.rb b/spec/models/racked_tube_spec.rb index 2bfa4147a5..f917dc18d7 100644 --- a/spec/models/racked_tube_spec.rb +++ b/spec/models/racked_tube_spec.rb @@ -56,7 +56,7 @@ before do Array.new(num_tubes) do |i| - create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) + create(:sample_tube, :in_a_rack, tube_rack: tube_rack, coordinate: locations[i], barcodes: [barcodes[i]]) end end diff --git a/spec/models/receptacle_spec.rb b/spec/models/receptacle_spec.rb index 719ca56fa8..a4b733be15 100644 --- a/spec/models/receptacle_spec.rb +++ b/spec/models/receptacle_spec.rb @@ -27,7 +27,7 @@ end describe '#update_from_qc' do - let(:qc_result) { build(:qc_result, key:, value:, units:, assay_type: 'assay', assay_version: 1) } + let(:qc_result) { build(:qc_result, key: key, value: value, units: units, assay_type: 'assay', assay_version: 1) } before { receptacle.update_from_qc(qc_result) } diff --git a/spec/models/request/traction/grid_ion_spec.rb b/spec/models/request/traction/grid_ion_spec.rb index b297029646..2dccbd3fb4 100644 --- a/spec/models/request/traction/grid_ion_spec.rb +++ b/spec/models/request/traction/grid_ion_spec.rb @@ -9,14 +9,14 @@ :request_traction_grid_ion, asset: well, request_metadata_attributes: metadata, - order:, - submission:, - request_type:, - state: + order: order, + submission: submission, + request_type: request_type, + state: state ) end - let(:order) { build(:order, submission:, assets: [well], request_types: [request_type.id]) } + let(:order) { build(:order, submission: submission, assets: [well], request_types: [request_type.id]) } let(:request_type) { create(:well_request_type) } let(:submission) { build(:submission) } let(:well) { create(:well) } diff --git a/spec/models/request_information_type_spec.rb b/spec/models/request_information_type_spec.rb index 21759188d2..985044ce06 100644 --- a/spec/models/request_information_type_spec.rb +++ b/spec/models/request_information_type_spec.rb @@ -16,7 +16,7 @@ read_length: 76, created_at: Date.parse('2021-03-01') }, - batch: + batch: batch ) end @@ -38,8 +38,8 @@ context 'when key is an event' do before do - create(:lab_event, descriptors: { 'My event' => 'old value' }, eventful: request, batch:) - create(:lab_event, descriptors: { 'My event' => 'new value' }, eventful: request, batch:) + create(:lab_event, descriptors: { 'My event' => 'old value' }, eventful: request, batch: batch) + create(:lab_event, descriptors: { 'My event' => 'new value' }, eventful: request, batch: batch) end let(:name) { 'My event' } diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index e1f7cc7232..c97c7bafda 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -14,8 +14,8 @@ describe '#for_order_including_submission_based_requests' do before do @sequencing_request = create(:request_with_sequencing_request_type, submission:) - @request = create(:request, order: order1, submission:, asset: @asset) - @request2 = create(:request, order: order2, submission:) + @request = create(:request, order: order1, submission: submission, asset: @asset) + @request2 = create(:request, order: order2, submission: submission) @request3 = create(:request, order: order4, submission: order4.submission) @sequencing_request2 = create(:request_with_sequencing_request_type, submission: order4.submission) @@ -107,8 +107,8 @@ # themselves via FactoryBot until the two behaviours are uncoupled describe '#next_requests' do let(:submission) { create(:submission, orders: [order1, order2], state: 'pending') } - let(:order1) { create(:linear_submission, request_types: order1_request_types, request_options:) } - let(:order2) { create(:linear_submission, request_types: order2_request_types, request_options:) } + let(:order1) { create(:linear_submission, request_types: order1_request_types, request_options: request_options) } + let(:order2) { create(:linear_submission, request_types: order2_request_types, request_options: request_options) } let(:order1_request1) do submission.requests.detect { |r| r.order == order1 && r.request_type_id == order1_request_types.first } end @@ -233,7 +233,7 @@ describe '#copy' do before do @request_type = create(:request_type) - @request = create(:request, request_type: @request_type, study:, state: 'failed') + @request = create(:request, request_type: @request_type, study: study, state: 'failed') @new_request = @request.copy end @@ -389,7 +389,7 @@ describe '#eventful_studies' do let(:asset) { create(:untagged_well) } - let(:request) { create(:request, asset:, initial_study: study) } + let(:request) { create(:request, asset: asset, initial_study: study) } context 'with no study itself' do let(:study) { nil } diff --git a/spec/models/request_type/validator/library_type_validator_spec.rb b/spec/models/request_type/validator/library_type_validator_spec.rb index a44214f92f..b4588e434e 100644 --- a/spec/models/request_type/validator/library_type_validator_spec.rb +++ b/spec/models/request_type/validator/library_type_validator_spec.rb @@ -41,14 +41,14 @@ before do request_type.library_types_request_types << create( :library_types_request_type, - library_type:, - request_type:, + library_type: library_type, + request_type: request_type, is_default: false ) request_type.library_types_request_types << create( :library_types_request_type, library_type: library_type2, - request_type:, + request_type: request_type, is_default: true ) end @@ -62,14 +62,14 @@ before do request_type.library_types_request_types << create( :library_types_request_type, - library_type:, - request_type:, + library_type: library_type, + request_type: request_type, is_default: false ) request_type.library_types_request_types << create( :library_types_request_type, library_type: library_type2, - request_type:, + request_type: request_type, is_default: false ) end diff --git a/spec/models/robot/generator/tecan_spec.rb b/spec/models/robot/generator/tecan_spec.rb index c07789b3b8..3fae3deba7 100644 --- a/spec/models/robot/generator/tecan_spec.rb +++ b/spec/models/robot/generator/tecan_spec.rb @@ -7,7 +7,7 @@ describe '.as_text' do let(:batch) { instance_double(Batch, total_volume_to_cherrypick: 13) } let(:layout) { Robot::Verification::SourceDestBeds.new.layout_data_object(data_object) } - let(:generator) { described_class.new(picking_data: data_object, batch:, layout:) } + let(:generator) { described_class.new(picking_data: data_object, batch: batch, layout: layout) } context 'when mapping wells from 1 96 well source plate to 1 96 well destination plate' do it 'returns a String object' do diff --git a/spec/models/sample_manifest/generator_spec.rb b/spec/models/sample_manifest/generator_spec.rb index 4e434b28cd..32d6a976f0 100644 --- a/spec/models/sample_manifest/generator_spec.rb +++ b/spec/models/sample_manifest/generator_spec.rb @@ -26,7 +26,9 @@ let(:configuration) { SampleManifestExcel.configuration } let(:template) { 'plate_full' } - let(:attributes) { { template:, study_id: study.id, supplier_id: supplier.id, count: '4' }.with_indifferent_access } + let(:attributes) do + { template: template, study_id: study.id, supplier_id: supplier.id, count: '4' }.with_indifferent_access + end after(:all) { SampleManifestExcel.reset! } diff --git a/spec/models/sample_manifest_spec.rb b/spec/models/sample_manifest_spec.rb index 0338c603e4..866ee304d4 100644 --- a/spec/models/sample_manifest_spec.rb +++ b/spec/models/sample_manifest_spec.rb @@ -11,7 +11,7 @@ describe '#default_filename' do let(:date) { Date.parse('25/10/2018') } - let(:manifest) { create(:sample_manifest, study:, created_at: date) } + let(:manifest) { create(:sample_manifest, study: study, created_at: date) } it 'includes the information requested' do expect(manifest.default_filename).to eq("#{study.id}stdy_manifest_#{manifest.id}_251018") @@ -358,7 +358,12 @@ describe '#pools' do let(:manifest) do - create(:plate_sample_manifest_with_manifest_assets, study:, asset_type: 'plate', num_samples_per_well:) + create( + :plate_sample_manifest_with_manifest_assets, + study: study, + asset_type: 'plate', + num_samples_per_well: num_samples_per_well + ) end context 'when there is only one sample per well' do diff --git a/spec/models/sequencing_request_spec.rb b/spec/models/sequencing_request_spec.rb index 5d9b8a4fd2..ef9906818c 100644 --- a/spec/models/sequencing_request_spec.rb +++ b/spec/models/sequencing_request_spec.rb @@ -159,8 +159,8 @@ let(:tags) { create_list(:tag, 4) } context 'when compound samples are not necessary because each aliquot has a unique tag combination' do - let(:aliquot1) { create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, study:) } - let(:aliquot2) { create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[2].id, study:) } + let(:aliquot1) { create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, study: study) } + let(:aliquot2) { create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[2].id, study: study) } it 'performs a normal transfer of aliquots' do expect(sequencing_request.target_asset.aliquots.count).to eq(0) @@ -173,10 +173,26 @@ context 'when compound samples are necessary because each aliquot does not have a unique tag combination' do context 'when there is one tag combination' do let(:aliquot1) do - create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, study:, project:) + create( + :aliquot, + sample: samples[0], + tag_id: tags[0].id, + tag2_id: tags[1].id, + tag_depth: 1, + study: study, + project: project + ) end let(:aliquot2) do - create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, study:, project:) + create( + :aliquot, + sample: samples[1], + tag_id: tags[0].id, + tag2_id: tags[1].id, + tag_depth: 2, + study: study, + project: project + ) end it 'creates a compound sample and transfers an aliquot of it' do @@ -190,16 +206,16 @@ context 'when there are two tag combinations' do let(:samples) { create_list(:sample, 4) } let(:aliquot1) do - create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, study:) + create(:aliquot, sample: samples[0], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 1, study: study) end let(:aliquot2) do - create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, study:) + create(:aliquot, sample: samples[1], tag_id: tags[0].id, tag2_id: tags[1].id, tag_depth: 2, study: study) end let(:aliquot3) do - create(:aliquot, sample: samples[2], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 1, study:) + create(:aliquot, sample: samples[2], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 1, study: study) end let(:aliquot4) do - create(:aliquot, sample: samples[3], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 2, study:) + create(:aliquot, sample: samples[3], tag_id: tags[2].id, tag2_id: tags[3].id, tag_depth: 2, study: study) end let(:aliquots) { [aliquot1, aliquot2, aliquot3, aliquot4] } diff --git a/spec/models/specific_tube_creations_spec.rb b/spec/models/specific_tube_creations_spec.rb index 3eb2cd3f63..3bc2b5c45b 100644 --- a/spec/models/specific_tube_creations_spec.rb +++ b/spec/models/specific_tube_creations_spec.rb @@ -53,7 +53,7 @@ context 'with no custom names' do let(:names) { [nil] * purpose_count } - let(:creation_parameters) { { user:, child_purposes: [child_purpose] * purpose_count, parent: } } + let(:creation_parameters) { { user: user, child_purposes: [child_purpose] * purpose_count, parent: parent } } context 'with one child purpose' do let(:purpose_count) { 1 } @@ -72,7 +72,9 @@ let(:names) { %w[example_1 example_2] } let(:purpose_count) { 2 } let(:tube_attributes) { names.map { |name| { name: } } } - let(:creation_parameters) { { user:, child_purposes: [child_purpose] * purpose_count, parent:, tube_attributes: } } + let(:creation_parameters) do + { user: user, child_purposes: [child_purpose] * purpose_count, parent: parent, tube_attributes: tube_attributes } + end it_behaves_like 'a specific tube creator' end @@ -83,8 +85,10 @@ let(:names) { ['example_1'] } let(:purpose_count) { 1 } let(:foreign_barcode) { 'FD00000001' } - let(:tube_attributes) { [{ name: names[0], foreign_barcode: }] } - let(:creation_parameters) { { user:, child_purposes: [child_purpose], parent:, tube_attributes: } } + let(:tube_attributes) { [{ name: names[0], foreign_barcode: foreign_barcode }] } + let(:creation_parameters) do + { user: user, child_purposes: [child_purpose], parent: parent, tube_attributes: tube_attributes } + end describe '#save' do include_context 'with common test setup' diff --git a/spec/models/state_changer/initial_stock_tube_spec.rb b/spec/models/state_changer/initial_stock_tube_spec.rb index cbcfe7c5c0..7a853061e6 100644 --- a/spec/models/state_changer/initial_stock_tube_spec.rb +++ b/spec/models/state_changer/initial_stock_tube_spec.rb @@ -20,7 +20,7 @@ outer_request: request ) end - let!(:request) { create(:customer_request, asset: well, state: request_state, submission:) } + let!(:request) { create(:customer_request, asset: well, state: request_state, submission: submission) } before do well.stock_wells << well diff --git a/spec/models/state_changer/input_plate_spec.rb b/spec/models/state_changer/input_plate_spec.rb index 1571d6353c..6973a9a682 100644 --- a/spec/models/state_changer/input_plate_spec.rb +++ b/spec/models/state_changer/input_plate_spec.rb @@ -6,7 +6,13 @@ RSpec.describe StateChanger::InputPlate do let(:state_changer) do - described_class.new(labware: input_plate, target_state:, user:, contents:, customer_accepts_responsibility:) + described_class.new( + labware: input_plate, + target_state: target_state, + user: user, + contents: contents, + customer_accepts_responsibility: customer_accepts_responsibility + ) end let(:user) { build_stubbed(:user) } let(:contents) { [] } diff --git a/spec/models/state_changer/mx_tube_spec.rb b/spec/models/state_changer/mx_tube_spec.rb index 2dcbedb85c..5f4d07d3a4 100644 --- a/spec/models/state_changer/mx_tube_spec.rb +++ b/spec/models/state_changer/mx_tube_spec.rb @@ -10,7 +10,7 @@ let(:customer_accepts_responsibility) { false } let(:labware) { create(:multiplexed_library_tube) } let(:transfer_request) { create(:transfer_request, target_asset: labware.receptacle, state: transfer_request_state) } - let(:request) { create(:request, target_asset: labware.receptacle, state: request_state, order:) } + let(:request) { create(:request, target_asset: labware.receptacle, state: request_state, order: order) } let(:requests) { [request] } let(:order) { create(:order) } diff --git a/spec/models/state_changer/qcable_labware_spec.rb b/spec/models/state_changer/qcable_labware_spec.rb index faf8ce086e..cbd7ff1acc 100644 --- a/spec/models/state_changer/qcable_labware_spec.rb +++ b/spec/models/state_changer/qcable_labware_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe StateChanger::QcableLabware do - let(:state_changer) { described_class.new(labware:, target_state: 'exhausted', user:) } + let(:state_changer) { described_class.new(labware: labware, target_state: 'exhausted', user: user) } let!(:qcable) { create(:qcable, asset: labware, state: 'available') } let(:labware) { create(:plate) } let(:user) { build_stubbed(:user) } diff --git a/spec/models/state_changer/qcable_library_plate_spec.rb b/spec/models/state_changer/qcable_library_plate_spec.rb index 93001600f9..0cc3bb6777 100644 --- a/spec/models/state_changer/qcable_library_plate_spec.rb +++ b/spec/models/state_changer/qcable_library_plate_spec.rb @@ -5,7 +5,13 @@ RSpec.describe StateChanger::QcableLibraryPlate do let(:state_changer) do - described_class.new(labware:, target_state: 'passed', user:, contents:, customer_accepts_responsibility:) + described_class.new( + labware: labware, + target_state: 'passed', + user: user, + contents: contents, + customer_accepts_responsibility: customer_accepts_responsibility + ) end let(:labware) { instance_double('Plate', wells: [well]) } # rubocop:todo RSpec/VerifiedDoubleReference let(:well) { instance_double('Well', aliquots: [aliquot]) } # rubocop:todo RSpec/VerifiedDoubleReference diff --git a/spec/models/state_changer/standard_plate_spec.rb b/spec/models/state_changer/standard_plate_spec.rb index 912d0e1aa9..59e44f42fc 100644 --- a/spec/models/state_changer/standard_plate_spec.rb +++ b/spec/models/state_changer/standard_plate_spec.rb @@ -5,7 +5,13 @@ RSpec.describe StateChanger::StandardPlate do let(:state_changer) do - described_class.new(labware: target_plate, target_state:, user:, contents:, customer_accepts_responsibility:) + described_class.new( + labware: target_plate, + target_state: target_state, + user: user, + contents: contents, + customer_accepts_responsibility: customer_accepts_responsibility + ) end let(:user) { build_stubbed(:user) } let(:contents) { [] } diff --git a/spec/models/std_library_request_spec.rb b/spec/models/std_library_request_spec.rb index 8bfc9ab8db..cdf547dbd3 100644 --- a/spec/models/std_library_request_spec.rb +++ b/spec/models/std_library_request_spec.rb @@ -6,7 +6,7 @@ let(:tagged_well) { create(:tagged_well) } describe '#pass' do - subject { create(:library_request, target_asset: tagged_well, state:) } + subject { create(:library_request, target_asset: tagged_well, state: state) } let(:state) { 'started' } @@ -40,7 +40,7 @@ name: library_type }, request_type: subject.request_type.key, - pcr_cycles:, + pcr_cycles: pcr_cycles, for_multiplexing: false } end diff --git a/spec/models/study_spec.rb b/spec/models/study_spec.rb index db255ad928..d2e512b929 100644 --- a/spec/models/study_spec.rb +++ b/spec/models/study_spec.rb @@ -20,13 +20,13 @@ # Passed 3.times { r << (create(:passed_request, study:, request_type:)) } - r << (create(:passed_request, study:, request_type: request_type_2)) - r << (create(:passed_request, study:, request_type: request_type_3)) - r << (create(:passed_request, study:, request_type: request_type_3)) + r << (create(:passed_request, study: study, request_type: request_type_2)) + r << (create(:passed_request, study: study, request_type: request_type_3)) + r << (create(:passed_request, study: study, request_type: request_type_3)) # Pending r << (create(:pending_request, study:, request_type:)) - r << (create(:pending_request, study:, request_type: request_type_3)) + r << (create(:pending_request, study: study, request_type: request_type_3)) end # we have to hack t @@ -208,9 +208,9 @@ context 'with submissions still unprocessed' do before do - FactoryHelp.submission study:, state: 'building', assets: [asset] - FactoryHelp.submission study:, state: 'pending', assets: [asset] - FactoryHelp.submission study:, state: 'processing', assets: [asset] + FactoryHelp.submission study: study, state: 'building', assets: [asset] + FactoryHelp.submission study: study, state: 'pending', assets: [asset] + FactoryHelp.submission study: study, state: 'processing', assets: [asset] end it 'returns true' do @@ -220,8 +220,8 @@ context 'with no submissions unprocessed' do before do - FactoryHelp.submission study:, state: 'ready', assets: [asset] - FactoryHelp.submission study:, state: 'failed', assets: [asset] + FactoryHelp.submission study: study, state: 'ready', assets: [asset] + FactoryHelp.submission study: study, state: 'failed', assets: [asset] end it 'returns false' do @@ -242,7 +242,7 @@ before do 2.times do - r = create(:passed_request, request_type:, initial_study_id: study.id) + r = create(:passed_request, request_type: request_type, initial_study_id: study.id) r.asset.aliquots.each do |al| al.study = study al.save! @@ -380,10 +380,10 @@ let(:purpose_2) { create(:plate_purpose) } let(:purpose_3) { create(:plate_purpose) } let(:purpose_4) { create(:plate_purpose) } - let!(:well_1) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_1)) } - let!(:well_2) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_2)) } - let!(:well_3) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_3)) } - let!(:well_4) { create(:well_for_qc_report, study:, plate: create(:plate, plate_purpose: purpose_4)) } + let!(:well_1) { create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: purpose_1)) } + let!(:well_2) { create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: purpose_2)) } + let!(:well_3) { create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: purpose_3)) } + let!(:well_4) { create(:well_for_qc_report, study: study, plate: create(:plate, plate_purpose: purpose_4)) } it 'will limit by stock plate purposes if there are no plate purposes' do wells_count = 0 diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index bc9d0e147a..844f660113 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -39,9 +39,9 @@ request_type_3.id, request_type_4.id ] - order1 = create(:order, request_types:, request_options: { read_length: 100 }) - order2 = create(:order, request_types:, request_options: { read_length: 100 }) - order3 = create(:order, request_types:, request_options: { read_length: 100 }) + order1 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order2 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order3 = create(:order, request_types: request_types, request_options: { read_length: 100 }) order4 = create(:order, request_types: [request_type_1.id] + request_types, request_options: { read_length: 100 }) expect(build(:submission, orders: [order1, order2, order3, order4])).to be_valid end @@ -65,30 +65,30 @@ it 'are not compatible with different request types after a multiplexed request types' do request_types = [request_type_1.id, request_type_2.id, request_type_for_multiplexing.id, request_type_3.id] - order1 = create(:order, request_types:, request_options: { read_length: 100 }) - order2 = create(:order, request_types:, request_options: { read_length: 100 }) - order3 = create(:order, request_types:, request_options: { read_length: 100 }) + order1 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order2 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order3 = create(:order, request_types: request_types, request_options: { read_length: 100 }) request_types[3] = request_type_4.id - order4 = create(:order, request_types:, request_options: { read_length: 100 }) + order4 = create(:order, request_types: request_types, request_options: { read_length: 100 }) expect(build(:submission, orders: [order1, order2, order3, order4])).not_to be_valid end it 'are not compatible if any of the read lengths are different' do request_types = [request_type_1.id, request_type_2.id, request_type_for_multiplexing.id, request_type_3.id] - order1 = create(:order, request_types:, request_options: { read_length: 100 }) - order2 = create(:order, request_types:, request_options: { read_length: 100 }) - order3 = create(:order, request_types:, request_options: { read_length: 200 }) - order4 = create(:order, request_types:, request_options: { read_length: 100 }) + order1 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order2 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order3 = create(:order, request_types: request_types, request_options: { read_length: 200 }) + order4 = create(:order, request_types: request_types, request_options: { read_length: 100 }) expect(build(:submission, orders: [order1, order2, order3, order4])).not_to be_valid end it 'are not compatible if at least one of the request types are not for multiplexing' do request_types = [request_type_1.id, request_type_2.id, request_type_for_multiplexing.id, request_type_3.id] - order1 = create(:order, request_types:, request_options: { read_length: 100 }) - order2 = create(:order, request_types:, request_options: { read_length: 100 }) - order3 = create(:order, request_types:, request_options: { read_length: 100 }) + order1 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order2 = create(:order, request_types: request_types, request_options: { read_length: 100 }) + order3 = create(:order, request_types: request_types, request_options: { read_length: 100 }) request_types = [request_type_1.id, request_type_2.id, request_type_3.id, request_type_4.id] - order4 = create(:order, request_types:, request_options: { read_length: 100 }) + order4 = create(:order, request_types: request_types, request_options: { read_length: 100 }) expect(build(:submission, orders: [order1, order2, order3, order4])).not_to be_valid end end diff --git a/spec/models/tag_layout_template_spec.rb b/spec/models/tag_layout_template_spec.rb index b7f48db02d..609301233f 100644 --- a/spec/models/tag_layout_template_spec.rb +++ b/spec/models/tag_layout_template_spec.rb @@ -7,7 +7,15 @@ # templates. The actual layout of tags is carried out by the tag layouts themselves, # and is tested there. describe TagLayoutTemplate do - let(:template) { build(:tag_layout_template, direction_algorithm:, walking_algorithm:, tag2_group:, tags: ['AAA']) } + let(:template) do + build( + :tag_layout_template, + direction_algorithm: direction_algorithm, + walking_algorithm: walking_algorithm, + tag2_group: tag2_group, + tags: ['AAA'] + ) + end describe '#create!' do subject { template.create!(plate:, user:) } diff --git a/spec/models/tag_set_spec.rb b/spec/models/tag_set_spec.rb index 6e0b60d4ad..336c169d16 100644 --- a/spec/models/tag_set_spec.rb +++ b/spec/models/tag_set_spec.rb @@ -18,7 +18,7 @@ adapter_type = build(:adapter_type) tag_group = create(:tag_group, adapter_type:) tag_group2 = create(:tag_group, adapter_type:) - tag_set = build(:tag_set, tag_group:, tag2_group: tag_group2) + tag_set = build(:tag_set, tag_group: tag_group, tag2_group: tag_group2) expect(tag_set).to be_valid end @@ -93,13 +93,13 @@ describe '#visible' do it 'returns true if it only has one tag_group and it is set to visible' do tag_group = create(:tag_group, visible: true) - tag_set = create(:tag_set, tag_group:, tag2_group: nil) + tag_set = create(:tag_set, tag_group: tag_group, tag2_group: nil) expect(tag_set.visible).to be(true) end it 'returns false if it only has one tag_group and it is not set to visible' do tag_group = create(:tag_group, visible: false) - tag_set = create(:tag_set, tag_group:, tag2_group: nil) + tag_set = create(:tag_set, tag_group: tag_group, tag2_group: nil) expect(tag_set.visible).to be(false) end @@ -112,7 +112,7 @@ it 'returns false if one of the tag_groups is not set to visible' do tag_group = create(:tag_group, visible: true) tag_group2 = create(:tag_group, visible: false) - tag_set = create(:tag_set, tag_group:, tag2_group: tag_group2) + tag_set = create(:tag_set, tag_group: tag_group, tag2_group: tag_group2) expect(tag_set.visible).to be(false) end end @@ -120,7 +120,7 @@ describe '#adapter_type' do it 'delegates to tag_group' do tag_group = create(:tag_group) - tag_set = create(:tag_set, tag_group:, tag2_group: nil) + tag_set = create(:tag_set, tag_group: tag_group, tag2_group: nil) expect(tag_set.adapter_type).to eq(tag_group.adapter_type) end end diff --git a/spec/models/tasks/cherrypick_task_spec.rb b/spec/models/tasks/cherrypick_task_spec.rb index b076f84ddf..887de3e81f 100644 --- a/spec/models/tasks/cherrypick_task_spec.rb +++ b/spec/models/tasks/cherrypick_task_spec.rb @@ -7,11 +7,13 @@ RSpec.describe CherrypickTask do let!(:plate) { create(:plate_with_untagged_wells, sample_count: 4) } let(:control_plate) { create(:control_plate, sample_count: 2) } - let(:requests) { plate.wells.in_column_major_order.map { |w| create(:cherrypick_request, asset: w, submission:) } } + let(:requests) do + plate.wells.in_column_major_order.map { |w| create(:cherrypick_request, asset: w, submission: submission) } + end let(:template) { create(:plate_template, size: 6) } let(:robot) { instance_double('Robot', max_beds: 2) } # rubocop:todo RSpec/VerifiedDoubleReference let(:purpose) { create(:purpose) } - let(:batch) { instance_double('Batch', id: 1235, requests:) } # rubocop:todo RSpec/VerifiedDoubleReference + let(:batch) { instance_double('Batch', id: 1235, requests: requests) } # rubocop:todo RSpec/VerifiedDoubleReference let(:submission) { create(:submission) } let(:wells_to_leave_free) { Rails.application.config.plate_default_control_wells_to_leave_free } @@ -34,7 +36,7 @@ def requests_for_plate(plate) batch_id: 1235, total_wells: 6, num_control_wells: 2, - wells_to_leave_free: + wells_to_leave_free: wells_to_leave_free ).and_return(locator) end @@ -61,7 +63,7 @@ def requests_for_plate(plate) context 'when control positions clashes with templates' do let(:instance) { described_class.new } let(:wells) { build_stubbed_list(:well, 1, map_id: 6) } - let(:template) { build_stubbed(:plate_template, size: 6, wells:) } + let(:template) { build_stubbed(:plate_template, size: 6, wells: wells) } let(:destinations) do [ [ diff --git a/spec/models/tasks/plate_template_task_spec.rb b/spec/models/tasks/plate_template_task_spec.rb index cf15bc55cf..7d18042cb0 100644 --- a/spec/models/tasks/plate_template_task_spec.rb +++ b/spec/models/tasks/plate_template_task_spec.rb @@ -77,7 +77,11 @@ describe '#do_task' do let(:params) do - ActionController::Parameters.new(workflow_id: workflow.id, file:, plate_purpose_id: create(:plate_purpose).id) + ActionController::Parameters.new( + workflow_id: workflow.id, + file: file, + plate_purpose_id: create(:plate_purpose).id + ) end it 'does stuff' do diff --git a/spec/models/tasks/set_descriptors_handler/handler_spec.rb b/spec/models/tasks/set_descriptors_handler/handler_spec.rb index b3410c6714..816d97a1ec 100644 --- a/spec/models/tasks/set_descriptors_handler/handler_spec.rb +++ b/spec/models/tasks/set_descriptors_handler/handler_spec.rb @@ -30,7 +30,7 @@ it 'sets attributes on the lab event' do handler.perform event = request.reload.lab_events.first - expect(event).to have_attributes(description: 'Step 1', descriptor_hash: { 'key' => 'value ' }, user:) + expect(event).to have_attributes(description: 'Step 1', descriptor_hash: { 'key' => 'value ' }, user: user) end it 'sets attributes on the batch event' do @@ -42,7 +42,7 @@ 'task' => 'Step 1', 'task_id' => '1' }, - user: + user: user ) end end diff --git a/spec/models/transfer/between_plates_spec.rb b/spec/models/transfer/between_plates_spec.rb index fac5959b16..b4c100911f 100644 --- a/spec/models/transfer/between_plates_spec.rb +++ b/spec/models/transfer/between_plates_spec.rb @@ -9,9 +9,9 @@ before do described_class.create!( - source:, - destination:, - user:, + source: source, + destination: destination, + user: user, transfers: { 'A1' => 'A1', 'B1' => 'B1', diff --git a/spec/models/transfer_request_collection_spec.rb b/spec/models/transfer_request_collection_spec.rb index ed8de275f0..2c08e6b35b 100644 --- a/spec/models/transfer_request_collection_spec.rb +++ b/spec/models/transfer_request_collection_spec.rb @@ -10,7 +10,7 @@ let(:target_asset) { create(:empty_library_tube) } context 'with a single transfer' do - let(:creation_attributes) { { user:, transfer_requests_attributes: [{ asset:, target_asset: }] } } + let(:creation_attributes) { { user: user, transfer_requests_attributes: [{ asset:, target_asset: }] } } context 'and no outer requests' do describe '#save' do @@ -58,15 +58,20 @@ context 'and two outer requests' do let(:submission_a) { create(:submission) } let(:submission_b) { create(:submission) } - let!(:outer_request) { create(:request, asset:, submission: submission_a) } - let!(:other_outer_request) { create(:request, asset:, submission: submission_b) } + let!(:outer_request) { create(:request, asset: asset, submission: submission_a) } + let!(:other_outer_request) { create(:request, asset: asset, submission: submission_b) } describe '#save' do let(:transfer_request) { subject.transfer_requests.first } context 'specifying submission' do let(:creation_attributes) do - { user:, transfer_requests_attributes: [{ asset:, target_asset:, submission: outer_request.submission }] } + { + user: user, + transfer_requests_attributes: [ + { asset: asset, target_asset: target_asset, submission: outer_request.submission } + ] + } end before { expect(subject.save).to be true } @@ -104,7 +109,12 @@ context 'specifying submission' do let(:creation_attributes) do - { user:, transfer_requests_attributes: [{ asset:, target_asset:, submission: outer_request.submission }] } + { + user: user, + transfer_requests_attributes: [ + { asset: asset, target_asset: target_asset, submission: outer_request.submission } + ] + } end it 'is invalid' do @@ -114,7 +124,7 @@ context 'specifying outer_request' do let(:creation_attributes) do - { user:, transfer_requests_attributes: [{ asset:, target_asset:, outer_request: }] } + { user: user, transfer_requests_attributes: [{ asset:, target_asset:, outer_request: }] } end before { expect(subject.save).to be true } diff --git a/spec/models/transfer_request_spec.rb b/spec/models/transfer_request_spec.rb index 4359fb9935..452b9d5167 100644 --- a/spec/models/transfer_request_spec.rb +++ b/spec/models/transfer_request_spec.rb @@ -251,14 +251,14 @@ it 'does not permit transfers to the same asset' do asset = create(:sample_tube) - expect { described_class.create!(asset:, target_asset: asset) }.to raise_error(ActiveRecord::RecordInvalid) + expect { described_class.create!(asset: asset, target_asset: asset) }.to raise_error(ActiveRecord::RecordInvalid) end context 'with a tag clash' do let!(:tag) { create(:tag) } let!(:tag2) { create(:tag) } let!(:aliquot_1) { create(:aliquot, tag:, tag2:) } - let!(:aliquot_2) { create(:aliquot, tag:, tag2:, receptacle: create(:well)) } + let!(:aliquot_2) { create(:aliquot, tag: tag, tag2: tag2, receptacle: create(:well)) } let!(:target_asset) { create(:well, aliquots: [aliquot_1]) } it 'raises an exception' do @@ -459,7 +459,7 @@ let(:order) do create( :library_order, - submission:, + submission: submission, request_types: [library_request_type.id, multiplex_request_type.id], assets: [source_well_a, source_well_b] ) @@ -470,8 +470,8 @@ :library_request, asset: source_well_a, target_asset: target_well, - submission:, - order:, + submission: submission, + order: order, state: 'passed', request_type: library_request_type ) @@ -481,8 +481,8 @@ :library_request, asset: source_well_b, target_asset: target_well, - submission:, - order:, + submission: submission, + order: order, state: 'passed', request_type: library_request_type ) @@ -494,8 +494,8 @@ :multiplex_request, asset: target_well, target_asset: multiplexed_library_tube, - submission:, - order:, + submission: submission, + order: order, request_type: multiplex_request_type ) end @@ -504,8 +504,8 @@ :multiplex_request, asset: target_well, target_asset: multiplexed_library_tube, - submission:, - order:, + submission: submission, + order: order, request_type: multiplex_request_type ) end @@ -517,12 +517,12 @@ library_request_b multiplex_request_a multiplex_request_b - create(:transfer_request, asset: source_well_a, target_asset: target_well, submission:) - create(:transfer_request, asset: source_well_b, target_asset: target_well, submission:) + create(:transfer_request, asset: source_well_a, target_asset: target_well, submission: submission) + create(:transfer_request, asset: source_well_b, target_asset: target_well, submission: submission) end it 'associated each aliquot with a different library request' do - create(:transfer_request, asset: target_well, target_asset: multiplexed_library_tube, submission:) + create(:transfer_request, asset: target_well, target_asset: multiplexed_library_tube, submission: submission) expect(multiplexed_library_tube.reload.aliquots.map(&:request_id)).to eq( [multiplex_request_a.id, multiplex_request_a.id, multiplex_request_b.id] ) diff --git a/spec/models/tube_purpose_spec.rb b/spec/models/tube_purpose_spec.rb index b5acfb940a..f6b322fac7 100644 --- a/spec/models/tube_purpose_spec.rb +++ b/spec/models/tube_purpose_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Tube::Purpose do - let(:tube_purpose) { create(:tube_purpose, prefix: barcode_prefix, target_type:) } + let(:tube_purpose) { create(:tube_purpose, prefix: barcode_prefix, target_type: target_type) } shared_examples 'a tube factory' do describe '#create!' do diff --git a/spec/models/tube_rack_spec.rb b/spec/models/tube_rack_spec.rb index 1bf07e9ce7..f89b4b5238 100644 --- a/spec/models/tube_rack_spec.rb +++ b/spec/models/tube_rack_spec.rb @@ -62,7 +62,7 @@ let(:barcodes) { Array.new(num_tubes) { create(:fluidx) } } let!(:tubes) do Array.new(num_tubes) do |i| - create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) + create(:sample_tube, :in_a_rack, tube_rack: tube_rack, coordinate: locations[i], barcodes: [barcodes[i]]) end end @@ -73,10 +73,10 @@ context 'with a rack with tubes and requests' do let(:tube_rack) { create(:tube_rack) } - let(:tube_a) { create(:tube, :in_a_rack, tube_rack:, coordinate: 'A1') } - let(:tube_b) { create(:tube, :in_a_rack, tube_rack:, coordinate: 'H12') } + let(:tube_a) { create(:tube, :in_a_rack, tube_rack: tube_rack, coordinate: 'A1') } + let(:tube_b) { create(:tube, :in_a_rack, tube_rack: tube_rack, coordinate: 'H12') } let(:aliquot) { create(:aliquot, receptacle: tube_a.receptacle, request: create(:request, submission:)) } - let(:outer_request) { create(:request, asset: tube_b.receptacle, submission:) } + let(:outer_request) { create(:request, asset: tube_b.receptacle, submission: submission) } let(:submission) { create(:submission) } # The comments scope should also retrieve comments associated with tubes, and diff --git a/spec/models/tube_spec.rb b/spec/models/tube_spec.rb index 5a14236d10..c00baca3f6 100644 --- a/spec/models/tube_spec.rb +++ b/spec/models/tube_spec.rb @@ -12,7 +12,7 @@ before do Array.new(num_tubes) do |i| - create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) + create(:sample_tube, :in_a_rack, tube_rack: tube_rack, coordinate: locations[i], barcodes: [barcodes[i]]) end end @@ -87,7 +87,7 @@ context 'with requests' do let(:submission) { create(:submission) } - let!(:request) { create(:well_request, asset: tube, submission:) } + let!(:request) { create(:well_request, asset: tube, submission: submission) } before do create(:comment, commentable: request, description: 'Comment on request') @@ -113,7 +113,7 @@ submission = create(:submission) request = create(:well_request, submission:) tube.receptacle.aliquots << create(:aliquot, request:) - create(:transfer_request, target_asset: tube, submission:) + create(:transfer_request, target_asset: tube, submission: submission) create(:comment, commentable: request, description: 'Comment on request') tube.reload end @@ -128,8 +128,8 @@ context 'with multiple identical comments' do before do submission = create(:submission) - request = create(:well_request, asset: tube, submission:) - request2 = create(:well_request, asset: tube, submission:) + request = create(:well_request, asset: tube, submission: submission) + request2 = create(:well_request, asset: tube, submission: submission) create(:comment, commentable: request, description: 'Duplicate comment') create(:comment, commentable: request2, description: 'Duplicate comment') create(:comment, commentable: tube, description: 'Duplicate comment') diff --git a/spec/models/user_query_spec.rb b/spec/models/user_query_spec.rb index b785a71729..af3005ce6f 100644 --- a/spec/models/user_query_spec.rb +++ b/spec/models/user_query_spec.rb @@ -8,7 +8,7 @@ let!(:user_query_attributes) do { user_email: 'another_email@example.com', - user:, + user: user, url: 'url', what_was_trying_to_do: 'create', what_happened: 'it did not work', diff --git a/spec/models/well_spec.rb b/spec/models/well_spec.rb index b5ee955be0..826afa93be 100644 --- a/spec/models/well_spec.rb +++ b/spec/models/well_spec.rb @@ -73,7 +73,7 @@ describe '#update_from_qc' do let(:well_attributes) { { concentration: nil } } - let(:qc_result) { build(:qc_result, key:, value:, units:, assay_type: 'assay', assay_version: 1) } + let(:qc_result) { build(:qc_result, key: key, value: value, units: units, assay_type: 'assay', assay_version: 1) } before { well.update_from_qc(qc_result) } @@ -162,7 +162,7 @@ purposes = create_list(:plate_purpose, 4) stock_plate = create(:plate_with_untagged_wells, sample_count: 3) - norm_plates = purposes.map { |purpose| create(:plate_with_untagged_wells, purpose:, sample_count: 3) } + norm_plates = purposes.map { |purpose| create(:plate_with_untagged_wells, purpose: purpose, sample_count: 3) } well_plate_concentrations = [ # Plate 1, Plate 2, Plate 3 @@ -282,7 +282,11 @@ minimum_volume = 10 maximum_volume = 50 robot_minimum_picking_volume = 1.0 - @source_well.well_attribute.update!(concentration: measured_concentration, measured_volume:, current_volume:) + @source_well.well_attribute.update!( + concentration: measured_concentration, + measured_volume: measured_volume, + current_volume: current_volume + ) @target_well.volume_to_cherrypick_by_nano_grams( minimum_volume, maximum_volume, diff --git a/spec/models/work_order_spec.rb b/spec/models/work_order_spec.rb index e387e67124..d349924266 100644 --- a/spec/models/work_order_spec.rb +++ b/spec/models/work_order_spec.rb @@ -36,11 +36,11 @@ let(:submission) { create(:submission, requests:) } let(:request_type) { create(:request_type) } - let(:requests_set_a) { create_list(:request, 3, asset: create(:well), request_type:) } + let(:requests_set_a) { create_list(:request, 3, asset: create(:well), request_type: request_type) } let(:requests) { requests_set_a + requests_set_b } context 'where request types match' do - let(:requests_set_b) { create_list(:request, 3, asset: create(:well), request_type:) } + let(:requests_set_b) { create_list(:request, 3, asset: create(:well), request_type: request_type) } it { is_expected.to be_valid } diff --git a/spec/requests/api/v2/heron/plates_spec.rb b/spec/requests/api/v2/heron/plates_spec.rb index 9e41c5d208..d10ce771c4 100644 --- a/spec/requests/api/v2/heron/plates_spec.rb +++ b/spec/requests/api/v2/heron/plates_spec.rb @@ -231,7 +231,7 @@ build(:event_subject, role_type: BroadcastEvent::PlateCherrypicked::ROBOT_ROLE_TYPE, subject_type: 'robot') ] end - let(:events) { [{ event: { event_type: BroadcastEvent::PlateCherrypicked::EVENT_TYPE, subjects: } }] } + let(:events) { [{ event: { event_type: BroadcastEvent::PlateCherrypicked::EVENT_TYPE, subjects: subjects } }] } it_behaves_like 'a successful plate creation' diff --git a/spec/requests/api/v2/heron/tube_racks_spec.rb b/spec/requests/api/v2/heron/tube_racks_spec.rb index bb75f6eae5..4df9dd827d 100644 --- a/spec/requests/api/v2/heron/tube_racks_spec.rb +++ b/spec/requests/api/v2/heron/tube_racks_spec.rb @@ -43,10 +43,10 @@ data: { 'type' => 'tube_rack', :attributes => { - purpose_uuid:, + purpose_uuid: purpose_uuid, study_uuid: study.uuid, barcode: tube_rack_barcode, - tubes: + tubes: tubes } } } diff --git a/spec/requests/qc_files_spec.rb b/spec/requests/qc_files_spec.rb index 6d3ac9e947..58d2c25dfb 100644 --- a/spec/requests/qc_files_spec.rb +++ b/spec/requests/qc_files_spec.rb @@ -18,7 +18,7 @@ 'HTTP_COOKIE' => '' } - post("/api/1/#{plate.uuid}/qc_files", params: file.read, headers:) + post("/api/1/#{plate.uuid}/qc_files", params: file.read, headers: headers) expect(response).to have_http_status(:success) diff --git a/spec/resources/api/v2/plate_purpose_resource_spec.rb b/spec/resources/api/v2/plate_purpose_resource_spec.rb index 0cd64b879b..5bec47000d 100644 --- a/spec/resources/api/v2/plate_purpose_resource_spec.rb +++ b/spec/resources/api/v2/plate_purpose_resource_spec.rb @@ -10,7 +10,7 @@ let(:purpose) { PlatePurpose.new } # New instance of PlatePurpose model let(:resource) { described_class.new(purpose, {}) } # Resource wrapping the instance let(:receive) { resource.replace_fields(payload[:data]) } # Simulate receiving payload - let(:payload) { { data: { type: 'plate_purposes', attributes: } } } # Payload to be received + let(:payload) { { data: { type: 'plate_purposes', attributes: attributes } } } # Payload to be received let(:purpose_name) { 'Example Purpose' } let(:plate_size) { 16 } let(:asset_shape_name) { 'Shape4x1' } diff --git a/spec/resources/api/v2/well_resource_spec.rb b/spec/resources/api/v2/well_resource_spec.rb index 44175ee6cd..29525ee0d3 100644 --- a/spec/resources/api/v2/well_resource_spec.rb +++ b/spec/resources/api/v2/well_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::WellResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed(:well, plate:, map: position) } + let(:resource_model) { build_stubbed(:well, plate: plate, map: position) } shared_examples 'a well resource' do # Test attributes diff --git a/spec/sample_manifest_excel/upload/processor_spec.rb b/spec/sample_manifest_excel/upload/processor_spec.rb index de2b8bcfe4..0d5e2332b2 100644 --- a/spec/sample_manifest_excel/upload/processor_spec.rb +++ b/spec/sample_manifest_excel/upload/processor_spec.rb @@ -28,7 +28,7 @@ def cell(row, column) end let(:column_list) { configuration.columns.send(manifest_type) } - let(:upload) { SampleManifestExcel::Upload::Base.new(file: test_file, column_list:, start_row: 9) } + let(:upload) { SampleManifestExcel::Upload::Base.new(file: test_file, column_list: column_list, start_row: 9) } let(:processor) { described_class.new(upload) } let(:test_file_name) { 'test_file.xlsx' } let(:new_test_file_name) { 'new_test_file.xlsx' } @@ -48,7 +48,12 @@ def cell(row, column) cell(rows.last, columns[:insert_size_to]).value = '1000' download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) expect(processor.substitutions[0]).to include('insert_size_from' => 100) @@ -63,7 +68,12 @@ def cell(row, column) cell(rows.last, columns[:i7]).value = i7_tag1 download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) expect(processor).to be_downstream_aliquots_updated @@ -77,7 +87,12 @@ def cell(row, column) cell(rows.last, columns[:i7]).value = 'ATAGATAGATAG' download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) expect(processor).to be_aliquots_updated @@ -87,7 +102,12 @@ def cell(row, column) it 'will not update the aliquots downstream if there is nothing to update' do download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) expect(processor.substitutions.compact).to be_empty @@ -101,7 +121,12 @@ def cell(row, column) cell(rows.last, columns[:insert_size_to]).value = '1000' download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) @@ -117,7 +142,12 @@ def cell(row, column) cell(rows.last, columns[:chromium_tag_well]).value = chromium_tag1 download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) expect(processor.substitutions.compact.length).to eq(8) @@ -135,7 +165,12 @@ def cell(row, column) cell(rows.last, columns[:chromium_tag_well]).value = chromium_tag1 download.save(new_test_file_name) reupload2 = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload2) processor.update_samples_and_aliquots(tag_group) @@ -150,7 +185,7 @@ def cell(row, column) describe SampleManifestExcel::Upload::Processor::OneDTube do let(:manifest_type) { 'tube_library_with_tag_sequences' } - let(:download) { build(:test_download_tubes, columns: column_list, manifest_type:) } + let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } context 'when valid' do it 'will not generate samples on initialisation' do @@ -195,7 +230,12 @@ def cell(row, column) context 'when updating sample data' do let(:reupload) do - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override:) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: override + ) end let(:processor) { described_class.new(reupload) } @@ -219,7 +259,12 @@ def cell(row, column) context 'when override is false' do let(:override) { false } let(:reupload) do - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override:) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: override + ) end let(:processor) { described_class.new(reupload) } @@ -243,7 +288,7 @@ def cell(row, column) context 'with mandatory fields' do let(:column_list) { configuration.columns.tube_extraction.dup } let(:manifest_type) { 'tube_extraction' } - let(:download) { build(:test_download_tubes, columns: column_list, manifest_type:) } + let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } let(:new_test_file) { Rack::Test::UploadedFile.new(Rails.root.join(new_test_file_name), '') } after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } @@ -255,7 +300,7 @@ def cell(row, column) column_no = column.number cell(row_no - 1, column_no - 1).value = nil # zero-based index download.save(new_test_file_name) - upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:) + upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list) processor = described_class.new(upload) processor.run(nil) expect(processor.errors.full_messages).to include(expected_message) @@ -280,7 +325,7 @@ def cell(row, column) context 'when using extraction tube' do let(:column_list) { configuration.columns.tube_extraction.dup } let(:manifest_type) { 'tube_extraction' } - let(:download) { build(:test_download_tubes, columns: column_list, manifest_type:) } + let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } let(:new_test_file) { Rack::Test::UploadedFile.new(Rails.root.join(new_test_file_name), '') } after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } @@ -291,7 +336,7 @@ def cell(row, column) column_no = column.number cell(row_no - 1, column_no - 1).value = nil # zero-based index download.save(new_test_file_name) - upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:) + upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list) processor = described_class.new(upload) processor.run(nil) expected = "Retention instruction checks failed at row: #{row_no}. Value cannot be blank." @@ -305,7 +350,7 @@ def cell(row, column) (row1..rown).each { |x| cell(x, col1).value = 'Destroy after 2 years' } # Set all the same cell(rown, col1).value = 'Long term storage' # Set one of them different download.save(new_test_file_name) - upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:) + upload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list) processor = described_class.new(upload) processor.run(nil) col1 = download.worksheet.columns.find_by(:name, :sanger_tube_id).number - 1 @@ -320,7 +365,7 @@ def cell(row, column) end describe SampleManifestExcel::Upload::Processor::LibraryTube do - let(:download) { build(:test_download_tubes, columns: column_list, manifest_type:) } + let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } context 'with chromium tag-columns' do let(:manifest_type) { 'tube_chromium_library' } @@ -346,7 +391,7 @@ def cell(row, column) describe SampleManifestExcel::Upload::Processor::MultiplexedLibraryTube do let(:manifest_type) { 'tube_multiplexed_library_with_tag_sequences' } - let(:download) { build(:test_download_tubes, columns: column_list, manifest_type:) } + let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } context 'when using tag sequences' do context 'when valid' do @@ -382,7 +427,7 @@ def cell(row, column) end context 'with a partial manifest' do - let(:download) { build(:test_download_tubes_partial, manifest_type:, columns: column_list) } + let(:download) { build(:test_download_tubes_partial, manifest_type: manifest_type, columns: column_list) } it 'will process partial upload and cancel unprocessed requests' do expect(upload.sample_manifest.pending_external_library_creation_requests.count).to eq 6 @@ -410,7 +455,7 @@ def cell(row, column) context 'with mismatched tags' do let(:download) do - build(:test_download_tubes, manifest_type:, columns: column_list, validation_errors: [:tags]) + build(:test_download_tubes, manifest_type: manifest_type, columns: column_list, validation_errors: [:tags]) end it 'will not be valid' do @@ -425,7 +470,7 @@ def cell(row, column) let(:manifest_type) { 'tube_multiplexed_library' } context 'when valid' do - let(:download) { build(:test_download_tubes, manifest_type:, columns: column_list) } + let(:download) { build(:test_download_tubes, manifest_type: manifest_type, columns: column_list) } it 'will process', :aggregate_failures do processor.run(nil) @@ -451,7 +496,7 @@ def cell(row, column) end context 'when partially filled in' do - let(:download) { build(:test_download_tubes_partial, manifest_type:, columns: column_list) } + let(:download) { build(:test_download_tubes_partial, manifest_type: manifest_type, columns: column_list) } it 'will process partial upload and cancel unprocessed requests' do processor = described_class.new(upload) @@ -466,7 +511,7 @@ def cell(row, column) end context 'when manifest is reuploaded and overriden' do - let(:download) { build(:test_download_tubes, manifest_type:, columns: column_list) } + let(:download) { build(:test_download_tubes, manifest_type: manifest_type, columns: column_list) } let(:new_test_file) { Rack::Test::UploadedFile.new(Rails.root.join(new_test_file_name), '') } @@ -482,7 +527,12 @@ def cell(row, column) cell(11, 8).value = '1000' download.save(new_test_file_name) reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor.substitutions[0]).to include('insert_size_from' => 100) @@ -501,7 +551,12 @@ def cell(row, column) cell(11, 3).value = tag_index1 download.save(new_test_file_name) reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).to be_downstream_aliquots_updated @@ -510,7 +565,12 @@ def cell(row, column) it 'will not update the aliquots downstream if there is nothing to update' do download.save(new_test_file_name) reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor.substitutions.compact).to be_empty @@ -520,7 +580,7 @@ def cell(row, column) context 'when tags are mismatched' do let(:download) do - build(:test_download_tubes, manifest_type:, columns: column_list, validation_errors: [:tags]) + build(:test_download_tubes, manifest_type: manifest_type, columns: column_list, validation_errors: [:tags]) end it 'will not be valid' do @@ -640,7 +700,12 @@ def cell(row, column) it 'will update the samples if samples data has changed and override is set true' do reupload = - SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9, override: true) + SampleManifestExcel::Upload::Base.new( + file: new_test_file, + column_list: column_list, + start_row: 9, + override: true + ) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(reupload.rows).to be_all(&:sample_updated?) @@ -652,7 +717,8 @@ def cell(row, column) end it 'will not update the samples if samples data has changed and override is set false' do - reupload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) + reupload = + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(reupload.rows).not_to be_all(&:sample_updated?) @@ -683,7 +749,8 @@ def cell(row, column) cell(10, 0).value = 'CGAP-00000' cell(11, 0).value = 'CGAP-00000' download.save(new_test_file_name) - reupload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) + reupload = + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -693,7 +760,8 @@ def cell(row, column) cell(9, 0).value = 'CGAP-00000' cell(10, 0).value = 'CGAP-11111' download.save(new_test_file_name) - reupload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) + reupload = + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -717,7 +785,8 @@ def cell(row, column) row1 = download.worksheet.first_row - 1 cell(row1, col1).value = nil download.save(new_test_file_name) - reupload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) + reupload = + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -733,7 +802,8 @@ def cell(row, column) cell(row1, col1).value = 'Destroy after 2 years' cell(row2, col1).value = 'Long term storage' download.save(new_test_file_name) - reupload = SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list:, start_row: 9) + reupload = + SampleManifestExcel::Upload::Base.new(file: new_test_file, column_list: column_list, start_row: 9) processor = described_class.new(reupload) processor.update_samples_and_aliquots(nil) expect(processor).not_to be_valid @@ -935,8 +1005,8 @@ def cell(row, column) tube_barcode = mock_microservice_responses[tube_rack_barcode]['layout'].keys[counter] Barcode.create(asset: tube, barcode: tube_barcode, format: 'fluidx_barcode') RackedTube.create( - tube:, - tube_rack:, + tube: tube, + tube_rack: tube_rack, coordinate: mock_microservice_responses[tube_rack_barcode]['layout'].values[counter] ) counter += 1 diff --git a/spec/sample_manifest_excel/upload/row_spec.rb b/spec/sample_manifest_excel/upload/row_spec.rb index 1b01424401..0c4f8b25c7 100644 --- a/spec/sample_manifest_excel/upload/row_spec.rb +++ b/spec/sample_manifest_excel/upload/row_spec.rb @@ -103,30 +103,30 @@ end it 'is not valid without row number' do - expect(described_class.new(number: 'one', data:, columns:)).not_to be_valid + expect(described_class.new(number: 'one', data: data, columns: columns)).not_to be_valid expect(described_class.new(data:, columns:)).not_to be_valid end it 'is not valid without some data' do - expect(described_class.new(number: 1, columns:)).not_to be_valid + expect(described_class.new(number: 1, columns: columns)).not_to be_valid end it 'is not valid without some columns' do - expect(described_class.new(number: 1, data:)).not_to be_valid + expect(described_class.new(number: 1, data: data)).not_to be_valid end it '#value returns value for specified key' do - expect(described_class.new(number: 1, data:, columns:).value(:sanger_sample_id)).to eq( + expect(described_class.new(number: 1, data: data, columns: columns).value(:sanger_sample_id)).to eq( sample_manifest.labware.first.sample_manifest_assets.first.sanger_sample_id ) end it '#at returns value at specified index (offset by 1)' do - expect(described_class.new(number: 1, data:, columns:).at(3)).to eq('AA') + expect(described_class.new(number: 1, data: data, columns: columns).at(3)).to eq('AA') end it '#at strips down spaces including non-breaking ones (\u00A0)' do - row = described_class.new(number: 1, data: data_with_spaces, columns:) + row = described_class.new(number: 1, data: data_with_spaces, columns: columns) tag_cell_content = data_with_spaces[2] tag_cell_content_retrieved = row.at(3) expect(tag_cell_content.bytes[0]).to eq(32) @@ -135,7 +135,7 @@ end it '#at strips down spaces' do - row = described_class.new(number: 1, data: data_with_spaces, columns:) + row = described_class.new(number: 1, data: data_with_spaces, columns: columns) reference_genome_cell_content = data_with_spaces[4] reference_genome_cell_content_retrieved = row.at(5) volume_cell_content = data_with_spaces[6] @@ -148,37 +148,37 @@ end it '#first? is true if this is the first row' do - expect(described_class.new(number: 1, data:, columns:)).to be_first + expect(described_class.new(number: 1, data: data, columns: columns)).to be_first end it 'is not valid without a primary receptacle or sample' do data[1] = 2 - expect(described_class.new(number: 1, data:, columns:).validate_sample).to be false + expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be false data[1] = 999_999 - row = described_class.new(number: 1, data:, columns:) + row = described_class.new(number: 1, data: data, columns: columns) expect(row.validate_sample).to be false expect(row.errors.full_messages).to include('Row 1 - Sample can\'t be blank.') end it 'is not valid unless all specialised fields are valid' do - expect(described_class.new(number: 1, data:, columns:).validate_sample).to be true + expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be true data[5] = 'Dodgy library type' - expect(described_class.new(number: 1, data:, columns:).validate_sample).to be false + expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be false data[5] = 'My New Library Type' data[6] = 'one' - expect(described_class.new(number: 1, data:, columns:).validate_sample).to be false + expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be false end it 'is not valid unless metadata is valid' do - described_class.new(number: 1, data:, columns:) - expect(described_class.new(number: 1, data:, columns:).validate_sample).to be true + described_class.new(number: 1, data: data, columns: columns) + expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be true data[16] = 'Cell-line' - expect(described_class.new(number: 1, data:, columns:).validate_sample).to be false + expect(described_class.new(number: 1, data: data, columns: columns).validate_sample).to be false end it 'updates the aliquot with the specialised fields' do sample_count = Sample.count - row = described_class.new(number: 1, data:, columns:) + row = described_class.new(number: 1, data: data, columns: columns) row.sample row.update_specialised_fields(tag_group) aliquot = row.aliquots.first @@ -190,7 +190,7 @@ end it 'updates the sample metadata' do - row = described_class.new(number: 1, data:, columns:) + row = described_class.new(number: 1, data: data, columns: columns) row.update_metadata_fields expect(row.metadata).to have_attributes( concentration: '1', @@ -209,7 +209,7 @@ end it 'updates the sample' do - row = described_class.new(number: 1, data:, columns:) + row = described_class.new(number: 1, data: data, columns: columns) row.update_sample(tag_group, false) row.metadata expect(row).to be_sample_updated @@ -257,8 +257,8 @@ sample_manifest.labware.first.sample_manifest_assets.first.sanger_sample_id, '' ] - row = described_class.new(number: 1, data:, columns:) - empty_row = described_class.new(number: 1, data: empty_data, columns:) + row = described_class.new(number: 1, data: data, columns: columns) + empty_row = described_class.new(number: 1, data: empty_data, columns: columns) expect(row.empty?).to be false expect(empty_row.empty?).to be true end @@ -267,7 +267,7 @@ let(:columns) { configuration.columns.tube_multiplexed_library.dup } it 'links up specialised fields' do - row = described_class.new(number: 1, data:, columns:) + row = described_class.new(number: 1, data: data, columns: columns) tag_index = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::TagIndex) } tag_group = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::TagGroup) } tag2_index = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::Tag2Index) } @@ -281,7 +281,7 @@ let(:columns) { configuration.columns.plate_chromium_library.dup } it 'links up specialised fields' do - row = described_class.new(number: 1, data:, columns:) + row = described_class.new(number: 1, data: data, columns: columns) tag_well = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::ChromiumTagWell) } tag_group = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::ChromiumTagGroup) } expect(tag_well.sf_tag_group).to eq tag_group @@ -294,7 +294,7 @@ it 'links up specialised fields' do data[4] = 'Tag Set 1' data[5] = 'B1' - row = described_class.new(number: 1, data:, columns:) + row = described_class.new(number: 1, data: data, columns: columns) dual_index_tag_set = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::DualIndexTagSet) } dual_index_tag_well = @@ -347,7 +347,7 @@ end it 'links up specialised fields' do - row = described_class.new(number: 1, data:, columns:) + row = described_class.new(number: 1, data: data, columns: columns) bs_well = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::Well) } bioscan_supplier_name = row.specialised_fields.detect { |f| f.is_a?(SequencescapeExcel::SpecialisedField::BioscanSupplierName) } @@ -380,7 +380,7 @@ row_data[1] = sma.sanger_sample_id row_data[2] = tags[i][:i7] row_data[3] = tags[i][:i5] - rows << described_class.new(number: i + 1, data: row_data, columns:) + rows << described_class.new(number: i + 1, data: row_data, columns: columns) end end @@ -424,7 +424,7 @@ row_data[1] = tube.samples.first.sanger_sample_id row_data[2] = tags[i][:i7] row_data[3] = tags[i][:i5] - rows << described_class.new(number: i + 1, data: row_data, columns:) + rows << described_class.new(number: i + 1, data: row_data, columns: columns) end end diff --git a/spec/sample_manifest_excel/upload/rows_spec.rb b/spec/sample_manifest_excel/upload/rows_spec.rb index ddc2256a07..928638f15e 100644 --- a/spec/sample_manifest_excel/upload/rows_spec.rb +++ b/spec/sample_manifest_excel/upload/rows_spec.rb @@ -29,7 +29,7 @@ end it 'is not valid unless all of the rows are valid' do - download = build(:test_download_tubes, columns:, validation_errors: [:sanger_sample_id_invalid]) + download = build(:test_download_tubes, columns: columns, validation_errors: [:sanger_sample_id_invalid]) download.save(test_file_name) expect(described_class.new(SampleManifestExcel::Upload::Data.new(test_file), columns)).not_to be_valid end @@ -41,14 +41,14 @@ end it 'creates the row number relative to the start row' do - download = build(:test_download_tubes, columns:, validation_errors: [:insert_size_from]) + download = build(:test_download_tubes, columns: columns, validation_errors: [:insert_size_from]) download.save(test_file_name) rows = described_class.new(SampleManifestExcel::Upload::Data.new(test_file), columns) expect(rows.first.number).to eq(10) end it 'knows values for all rows at particular column' do - download = build(:test_download_tubes, columns:, validation_errors: [:insert_size_from]) + download = build(:test_download_tubes, columns: columns, validation_errors: [:insert_size_from]) download.save(test_file_name) rows = described_class.new(SampleManifestExcel::Upload::Data.new(test_file), columns) diff --git a/spec/sample_manifest_excel/upload/upload_spec.rb b/spec/sample_manifest_excel/upload/upload_spec.rb index 3d6d2d7a52..d2c9adb177 100644 --- a/spec/sample_manifest_excel/upload/upload_spec.rb +++ b/spec/sample_manifest_excel/upload/upload_spec.rb @@ -150,7 +150,9 @@ context 'library tube with tag sequences' do let!(:columns) { SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup } - let!(:download) { build(:test_download_tubes, columns:, manifest_type: 'tube_library_with_tag_sequences') } + let!(:download) do + build(:test_download_tubes, columns: columns, manifest_type: 'tube_library_with_tag_sequences') + end before { download.save(test_file_name) } @@ -309,7 +311,7 @@ context 'plate' do let!(:plate_columns) { SampleManifestExcel.configuration.columns.plate_full.dup } - let(:download) { build(:test_download_plates, columns: plate_columns, study:) } + let(:download) { build(:test_download_plates, columns: plate_columns, study: study) } let(:study) { create(:open_study, accession_number: 'acc') } let(:upload) { SampleManifestExcel::Upload::Base.new(file: test_file, column_list: plate_columns, start_row: 9) } diff --git a/spec/sample_manifest_excel/worksheet_spec.rb b/spec/sample_manifest_excel/worksheet_spec.rb index 6b9c3c219b..b77883e4d1 100644 --- a/spec/sample_manifest_excel/worksheet_spec.rb +++ b/spec/sample_manifest_excel/worksheet_spec.rb @@ -33,12 +33,14 @@ def save_file after { File.delete(test_file) if File.exist?(test_file) } context 'type' do - let(:options) { { workbook:, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' } } + let(:options) { { workbook: workbook, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' } } it 'be Plates for any plate based manifest' do column_list = SampleManifestExcel.configuration.columns.plate_full.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) + SampleManifestExcel::Worksheet::DataWorksheet.new( + options.merge(columns: column_list, sample_manifest: sample_manifest) + ) expect(worksheet.type).to eq('Plates') end @@ -46,7 +48,9 @@ def save_file sample_manifest = create(:tube_sample_manifest, asset_type: '1dtube') column_list = SampleManifestExcel.configuration.columns.tube_full.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) + SampleManifestExcel::Worksheet::DataWorksheet.new( + options.merge(columns: column_list, sample_manifest: sample_manifest) + ) expect(worksheet.type).to eq('Tubes') end @@ -54,7 +58,9 @@ def save_file sample_manifest = create(:tube_sample_manifest, asset_type: '1dtube') column_list = SampleManifestExcel.configuration.columns.tube_extraction.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) + SampleManifestExcel::Worksheet::DataWorksheet.new( + options.merge(columns: column_list, sample_manifest: sample_manifest) + ) expect(worksheet.type).to eq('Tubes') end @@ -62,7 +68,9 @@ def save_file sample_manifest = create(:tube_sample_manifest, asset_type: 'library') column_list = SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) + SampleManifestExcel::Worksheet::DataWorksheet.new( + options.merge(columns: column_list, sample_manifest: sample_manifest) + ) expect(worksheet.type).to eq('Tubes') end @@ -70,7 +78,9 @@ def save_file sample_manifest = create(:tube_sample_manifest_with_tubes_and_manifest_assets, asset_type: 'multiplexed_library') column_list = SampleManifestExcel.configuration.columns.tube_multiplexed_library_with_tag_sequences.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) + SampleManifestExcel::Worksheet::DataWorksheet.new( + options.merge(columns: column_list, sample_manifest: sample_manifest) + ) expect(worksheet.type).to eq('Tubes') end @@ -78,7 +88,9 @@ def save_file sample_manifest = create(:tube_rack_manifest) column_list = SampleManifestExcel.configuration.columns.tube_rack_default.dup worksheet = - SampleManifestExcel::Worksheet::DataWorksheet.new(options.merge(columns: column_list, sample_manifest:)) + SampleManifestExcel::Worksheet::DataWorksheet.new( + options.merge(columns: column_list, sample_manifest: sample_manifest) + ) expect(worksheet.type).to eq('Tube Racks') end end @@ -86,9 +98,9 @@ def save_file context 'data worksheet' do let!(:worksheet) do SampleManifestExcel::Worksheet::DataWorksheet.new( - workbook:, + workbook: workbook, columns: SampleManifestExcel.configuration.columns.plate_full.dup, - sample_manifest:, + sample_manifest: sample_manifest, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' ) @@ -173,9 +185,9 @@ def save_file context 'tube rack worksheet' do let!(:worksheet) do SampleManifestExcel::Worksheet::DataWorksheet.new( - workbook:, + workbook: workbook, columns: SampleManifestExcel.configuration.columns.tube_rack_default.dup, - sample_manifest:, + sample_manifest: sample_manifest, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' ) @@ -243,9 +255,9 @@ def save_file asset_type: 'multiplexed_library' ) SampleManifestExcel::Worksheet::DataWorksheet.new( - workbook:, + workbook: workbook, columns: SampleManifestExcel.configuration.columns.tube_multiplexed_library_with_tag_sequences.dup, - sample_manifest:, + sample_manifest: sample_manifest, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' ) @@ -280,9 +292,9 @@ def save_file let(:attributes) do { - workbook:, + workbook: workbook, columns: SampleManifestExcel.configuration.columns.tube_library_with_tag_sequences.dup, - data:, + data: data, no_of_rows: 5, study: 'WTCCC', supplier: 'Test supplier', @@ -529,9 +541,9 @@ def save_file end let(:attributes) do { - workbook:, + workbook: workbook, columns: SampleManifestExcel.configuration.columns.tube_extraction.dup, - data:, + data: data, no_of_rows: 5, study: 'WTCCC', supplier: 'Test supplier', @@ -577,9 +589,9 @@ def save_file let(:attributes) do { - workbook:, + workbook: workbook, columns: SampleManifestExcel.configuration.columns.plate_default.dup, - data:, + data: data, no_of_rows: 5, study: 'WTCCC', supplier: 'Test supplier', diff --git a/spec/sequencescape_excel/range_spec.rb b/spec/sequencescape_excel/range_spec.rb index 2117a663d7..aa0a3d55dd 100644 --- a/spec/sequencescape_excel/range_spec.rb +++ b/spec/sequencescape_excel/range_spec.rb @@ -6,7 +6,14 @@ let(:options) { %w[option1 option2 option3] } it 'is comparable' do - attributes = { options:, first_column: 4, first_row: 5, last_column: 8, last_row: 10, worksheet_name: 'Sheet1' } + attributes = { + options: options, + first_column: 4, + first_row: 5, + last_column: 8, + last_row: 10, + worksheet_name: 'Sheet1' + } # rubocop:todo RSpec/IdenticalEqualityAssertion expect(described_class.new(attributes)).to eq(described_class.new(attributes)) @@ -16,7 +23,7 @@ end context 'with static options' do - let(:range) { described_class.new(options:, first_row: 4) } + let(:range) { described_class.new(options: options, first_row: 4) } it 'has some options' do expect(range.options).to eq(options) @@ -32,7 +39,7 @@ it 'sets the last column' do expect(range.last_column).to eq(3) - expect(described_class.new(options:, first_column: 4, first_row: 4).last_column).to eq(6) + expect(described_class.new(options: options, first_column: 4, first_row: 4).last_column).to eq(6) end it 'has a first_cell' do diff --git a/spec/sequencescape_excel/specialised_field_spec.rb b/spec/sequencescape_excel/specialised_field_spec.rb index a9b011a427..bf8eb0d63e 100644 --- a/spec/sequencescape_excel/specialised_field_spec.rb +++ b/spec/sequencescape_excel/specialised_field_spec.rb @@ -8,10 +8,20 @@ let(:asset2) { create(:untagged_well, map:) } let(:sample_manifest) { create(:sample_manifest) } let(:sample_manifest_asset) do - create(:sample_manifest_asset, asset:, sanger_sample_id: sample.sanger_sample_id, sample_manifest:) + create( + :sample_manifest_asset, + asset: asset, + sanger_sample_id: sample.sanger_sample_id, + sample_manifest: sample_manifest + ) end let(:sample_manifest_asset2) do - create(:sample_manifest_asset, asset: asset2, sanger_sample_id: sample2.sanger_sample_id, sample_manifest:) + create( + :sample_manifest_asset, + asset: asset2, + sanger_sample_id: sample2.sanger_sample_id, + sample_manifest: sample_manifest + ) end let!(:library_type) { create(:library_type) } let!(:reference_genome) { create(:reference_genome, name: 'new one') } @@ -25,7 +35,7 @@ let(:class_with_base) { Class.new { include SequencescapeExcel::SpecialisedField::Base } } it 'can be initialized with a value and a sample_manifest_asset' do - thing = class_with_base.new(value: 'value', sample_manifest_asset:) + thing = class_with_base.new(value: 'value', sample_manifest_asset: sample_manifest_asset) expect(thing.value).to eq 'value' expect(thing.sample).to eq sample end @@ -61,21 +71,23 @@ def self.name describe SequencescapeExcel::SpecialisedField::LibraryType do it 'will not be valid without a persisted library type' do - expect(described_class.new(value: library_type.name, sample_manifest_asset:)).to be_valid - expect(described_class.new(value: 'A new library type', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: library_type.name, sample_manifest_asset: sample_manifest_asset)).to be_valid + expect( + described_class.new(value: 'A new library type', sample_manifest_asset: sample_manifest_asset) + ).not_to be_valid end it 'will add the the value to the aliquot' do - specialised_field = described_class.new(value: library_type.name, sample_manifest_asset:) + specialised_field = described_class.new(value: library_type.name, sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) expect(aliquot.library_type).to eq(library_type.name) end context 'with multiple aliquots' do - let(:asset) { create(:tagged_well, map:, aliquot_count: 2) } + let(:asset) { create(:tagged_well, map: map, aliquot_count: 2) } it 'will add the the value to all aliquots' do - specialised_field = described_class.new(value: library_type.name, sample_manifest_asset:) + specialised_field = described_class.new(value: library_type.name, sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) expect(asset.aliquots).to all(have_attributes(library_type: library_type.name)) end @@ -88,12 +100,17 @@ def self.name end it 'will not be valid without a persisted reference genome if a value is provided' do - expect(described_class.new(value: reference_genome.name, sample_manifest_asset:)).to be_valid - expect(described_class.new(value: 'A new reference genome', sample_manifest_asset:)).not_to be_valid + expect( + described_class.new(value: reference_genome.name, sample_manifest_asset: sample_manifest_asset) + ).to be_valid + expect( + described_class.new(value: 'A new reference genome', sample_manifest_asset: sample_manifest_asset) + ).not_to be_valid end it 'will add reference genome to sample_metadata' do - specialised_field = described_class.new(value: reference_genome.name, sample_manifest_asset:) + specialised_field = + described_class.new(value: reference_genome.name, sample_manifest_asset: sample_manifest_asset) specialised_field.update expect(sample_manifest_asset.sample.sample_metadata.reference_genome).to eq(reference_genome) end @@ -132,14 +149,14 @@ def self.name end it 'will not create QC results for the asset if the value is blank' do - specialised_field = described_class.new(value: nil, sample_manifest_asset:) + specialised_field = described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset) specialised_field.update qc_result = sample_manifest_asset.asset.qc_results.first expect(qc_result).to be_nil end it 'will not create QC assays for the asset if the value is blank' do - specialised_field = described_class.new(value: nil, sample_manifest_asset:) + specialised_field = described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset) specialised_field.update qc_assay = QcAssay.find_by(lot_number: "sample_manifest_id:#{sample_manifest.id}") expect(qc_assay).to be_nil @@ -148,21 +165,21 @@ def self.name describe SequencescapeExcel::SpecialisedField::InsertSizeFrom do it 'value must be a valid number greater than 0' do - expect(described_class.new(value: 'zero', sample_manifest_asset:)).not_to be_valid - expect(described_class.new(value: -1, sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: 'zero', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: -1, sample_manifest_asset: sample_manifest_asset)).not_to be_valid end it 'will add the value to the aliquot' do - specialised_field = described_class.new(value: 100, sample_manifest_asset:) + specialised_field = described_class.new(value: 100, sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) expect(aliquot.insert_size_from).to eq(100) end context 'with multiple aliquots' do - let(:asset) { create(:tagged_well, map:, aliquot_count: 2) } + let(:asset) { create(:tagged_well, map: map, aliquot_count: 2) } it 'will add the the value to all aliquots' do - specialised_field = described_class.new(value: 100, sample_manifest_asset:) + specialised_field = described_class.new(value: 100, sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) expect(asset.aliquots).to all(have_attributes(insert_size_from: 100)) end @@ -171,21 +188,21 @@ def self.name describe SequencescapeExcel::SpecialisedField::InsertSizeTo do it 'value must be a valid number greater than 0' do - expect(described_class.new(value: 'zero', sample_manifest_asset:)).not_to be_valid - expect(described_class.new(value: -1, sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: 'zero', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: -1, sample_manifest_asset: sample_manifest_asset)).not_to be_valid end it 'will add the value to the aliquot' do - specialised_field = described_class.new(value: 100, sample_manifest_asset:) + specialised_field = described_class.new(value: 100, sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) expect(aliquot.insert_size_to).to eq(100) end context 'with multiple aliquots' do - let(:asset) { create(:tagged_well, map:, aliquot_count: 2) } + let(:asset) { create(:tagged_well, map: map, aliquot_count: 2) } it 'will add the the value to all aliquots' do - specialised_field = described_class.new(value: 100, sample_manifest_asset:) + specialised_field = described_class.new(value: 100, sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) expect(asset.aliquots).to all(have_attributes(insert_size_to: 100)) end @@ -233,7 +250,7 @@ def self.name describe SequencescapeExcel::SpecialisedField::SangerSampleId do it 'will set the sanger sample id from the sample' do - expect(described_class.new(value: '1234', sample_manifest_asset:).value).to eq('1234') + expect(described_class.new(value: '1234', sample_manifest_asset: sample_manifest_asset).value).to eq('1234') end end @@ -278,21 +295,24 @@ def self.name describe SequencescapeExcel::SpecialisedField::Well do it 'will not be valid unless the value matches the well description' do - expect(described_class.new(value: 'well', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: 'well', sample_manifest_asset: sample_manifest_asset)).not_to be_valid expect( - described_class.new(value: sample_manifest_asset.asset.map_description, sample_manifest_asset:) + described_class.new( + value: sample_manifest_asset.asset.map_description, + sample_manifest_asset: sample_manifest_asset + ) ).to be_valid end end describe SequencescapeExcel::SpecialisedField::SampleEbiAccessionNumber do it 'will not be valid if the value is different to the sample accession number' do - expect(described_class.new(value: '', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: 'EB123', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: 'EB123', sample_manifest_asset: sample_manifest_asset)).to be_valid sample_manifest_asset.sample.sample_metadata.sample_ebi_accession_number = 'EB123' - expect(described_class.new(value: '', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: 'EB1234', sample_manifest_asset:)).not_to be_valid - expect(described_class.new(value: 'EB123', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: 'EB1234', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: 'EB123', sample_manifest_asset: sample_manifest_asset)).to be_valid end end @@ -301,20 +321,20 @@ def self.name let(:oligo) { 'AA' } describe SequencescapeExcel::SpecialisedField::I7 do - let(:i7) { described_class.new(value: oligo, sample_manifest_asset:) } + let(:i7) { described_class.new(value: oligo, sample_manifest_asset: sample_manifest_asset) } it 'will be valid if the tag contains just A, C, G or T' do - expect(described_class.new(value: 'ACGT', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: 'acgt', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: 'acgt', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: 'aatc', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: 'ACGT', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: 'acgt', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: 'acgt', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: 'aatc', sample_manifest_asset: sample_manifest_asset)).to be_valid end it 'will not be valid if the tag does not contain A, C, G or T' do - expect(described_class.new(value: 'ACGT ACGT', sample_manifest_asset:)).not_to be_valid - expect(described_class.new(value: 'BCGT', sample_manifest_asset:)).not_to be_valid - expect(described_class.new(value: '-CGT', sample_manifest_asset:)).not_to be_valid - expect(described_class.new(value: 'xCGT', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: 'ACGT ACGT', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: 'BCGT', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: '-CGT', sample_manifest_asset: sample_manifest_asset)).not_to be_valid + expect(described_class.new(value: 'xCGT', sample_manifest_asset: sample_manifest_asset)).not_to be_valid end it 'will add the value' do @@ -331,25 +351,25 @@ def self.name end it 'if oligo is not present aliquot tag should be -1' do - i7 = described_class.new(value: nil, sample_manifest_asset:) + i7 = described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset) i7.update(aliquot:, tag_group:) aliquot.save expect(aliquot.tag_id).to eq(-1) end it 'will find the tag if it already exists' do - tag = tag_group.tags.create(oligo:, map_id: 10) + tag = tag_group.tags.create(oligo: oligo, map_id: 10) i7.update(aliquot:, tag_group:) expect(aliquot.tag).to eq(tag) end end describe SequencescapeExcel::SpecialisedField::I5 do - let(:i5) { described_class.new(value: oligo, sample_manifest_asset:) } + let(:i5) { described_class.new(value: oligo, sample_manifest_asset: sample_manifest_asset) } it 'will not be valid if the tag does not contain A, C, G or T' do - expect(described_class.new(value: 'ACGT', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: 'BCGT', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: 'ACGT', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: 'BCGT', sample_manifest_asset: sample_manifest_asset)).not_to be_valid end it 'will add the value' do @@ -374,21 +394,21 @@ def self.name describe 'tag group' do it 'will add the value' do - sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset:) + sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset) expect(sf_tag_group.value).to eq(tag_group_name) end it 'will be valid with an existing tag group name' do - expect(described_class.new(value: tag_group_name, sample_manifest_asset:)).to be_valid + expect(described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset)).to be_valid end it 'will not be valid without an existing tag group name' do - expect(described_class.new(value: 'unknown', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: 'unknown', sample_manifest_asset: sample_manifest_asset)).not_to be_valid end it 'responds to update method but does nothing to tag on aliquot' do - sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset:) - expect(sf_tag_group.update(aliquot:, tag_group: nil)).to be_nil + sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset) + expect(sf_tag_group.update(aliquot: aliquot, tag_group: nil)).to be_nil aliquot.save expect(aliquot.tag).to be_nil end @@ -396,19 +416,22 @@ def self.name describe SequencescapeExcel::SpecialisedField::TagIndex do it 'will add the value' do - sf_tag_index = described_class.new(value: tag_index, sample_manifest_asset:) + sf_tag_index = described_class.new(value: tag_index, sample_manifest_asset: sample_manifest_asset) expect(sf_tag_index.value).to eq(tag_index) end it 'will not have a valid tag index when unlinked from a tag group' do - expect(described_class.new(value: tag_index, sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: tag_index, sample_manifest_asset: sample_manifest_asset)).not_to be_valid end describe 'linking' do let!(:sf_tag_group) do - SequencescapeExcel::SpecialisedField::TagGroup.new(value: tag_group_name, sample_manifest_asset:) + SequencescapeExcel::SpecialisedField::TagGroup.new( + value: tag_group_name, + sample_manifest_asset: sample_manifest_asset + ) end - let!(:sf_tag_index) { described_class.new(value: tag_index, sample_manifest_asset:) } + let!(:sf_tag_index) { described_class.new(value: tag_index, sample_manifest_asset: sample_manifest_asset) } before { sf_tag_index.sf_tag_group = sf_tag_group } @@ -417,13 +440,13 @@ def self.name end it 'will not have a valid tag index when index does not match to a map_id in the tag group' do - sf_tag_index2 = described_class.new(value: 10, sample_manifest_asset:) + sf_tag_index2 = described_class.new(value: 10, sample_manifest_asset: sample_manifest_asset) sf_tag_index2.sf_tag_group = sf_tag_group expect(sf_tag_index2).not_to be_valid end it 'will update the aliquot with tag if its oligo is present' do - sf_tag_index.update(aliquot:, tag_group: nil) + sf_tag_index.update(aliquot: aliquot, tag_group: nil) tag = tag_group.tags.find_by(map_id: tag_index) expect(tag).to be_present expect(tag.oligo).to eq(tag_group.tags[0].oligo) @@ -438,7 +461,7 @@ def self.name tag.oligo = nil tag.save expect(tag.oligo).to be_nil - sf_tag_index.update(aliquot:, tag_group: nil) + sf_tag_index.update(aliquot: aliquot, tag_group: nil) aliquot.save expect(aliquot.tag_id).to eq(-1) end @@ -447,21 +470,21 @@ def self.name describe SequencescapeExcel::SpecialisedField::Tag2Group do it 'will add the value' do - sf_tag2_group = described_class.new(value: tag2_group_name, sample_manifest_asset:) + sf_tag2_group = described_class.new(value: tag2_group_name, sample_manifest_asset: sample_manifest_asset) expect(sf_tag2_group.value).to eq(tag2_group_name) end it 'will be valid with an existing tag2 group name' do - expect(described_class.new(value: tag2_group_name, sample_manifest_asset:)).to be_valid + expect(described_class.new(value: tag2_group_name, sample_manifest_asset: sample_manifest_asset)).to be_valid end it 'will not be valid without an existing tag2 group name' do - expect(described_class.new(value: 'unknown', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: 'unknown', sample_manifest_asset: sample_manifest_asset)).not_to be_valid end it 'responds to update method but does nothing to tag2 on aliquot' do - sf_tag2_group = described_class.new(value: tag2_group_name, sample_manifest_asset:) - expect(sf_tag2_group.update(aliquot:, tag_group: nil)).to be_nil + sf_tag2_group = described_class.new(value: tag2_group_name, sample_manifest_asset: sample_manifest_asset) + expect(sf_tag2_group.update(aliquot: aliquot, tag_group: nil)).to be_nil aliquot.save expect(aliquot.tag2).to be_nil end @@ -469,12 +492,12 @@ def self.name describe SequencescapeExcel::SpecialisedField::Tag2Index do it 'will add the value' do - sf_tag2_index = described_class.new(value: tag2_index, sample_manifest_asset:) + sf_tag2_index = described_class.new(value: tag2_index, sample_manifest_asset: sample_manifest_asset) expect(sf_tag2_index.value).to eq(tag2_index) end it 'will not have a valid tag index when unlinked from a tag group' do - expect(described_class.new(value: tag2_index, sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: tag2_index, sample_manifest_asset: sample_manifest_asset)).not_to be_valid end context 'when value and index are nil and tag exists that matches based on nil values' do @@ -495,9 +518,12 @@ def self.name describe 'linking' do let!(:sf_tag2_group) do - SequencescapeExcel::SpecialisedField::Tag2Group.new(value: tag2_group_name, sample_manifest_asset:) + SequencescapeExcel::SpecialisedField::Tag2Group.new( + value: tag2_group_name, + sample_manifest_asset: sample_manifest_asset + ) end - let!(:sf_tag2_index) { described_class.new(value: tag2_index, sample_manifest_asset:) } + let!(:sf_tag2_index) { described_class.new(value: tag2_index, sample_manifest_asset: sample_manifest_asset) } before { sf_tag2_index.sf_tag2_group = sf_tag2_group } @@ -506,13 +532,13 @@ def self.name end it 'will not have a valid tag index when index does not match to a map_id in the tag group' do - sf_tag2_index2 = described_class.new(value: 10, sample_manifest_asset:) + sf_tag2_index2 = described_class.new(value: 10, sample_manifest_asset: sample_manifest_asset) sf_tag2_index2.sf_tag2_group = sf_tag2_group expect(sf_tag2_index2).not_to be_valid end it 'will update the aliquot with tag2 if its oligo is present' do - sf_tag2_index.update(aliquot:, tag_group: nil) + sf_tag2_index.update(aliquot: aliquot, tag_group: nil) tag2 = tag2_group.tags.find_by(map_id: tag2_index) expect(tag2).to be_present expect(tag2.oligo).to eq(tag2_group.tags[0].oligo) @@ -527,7 +553,7 @@ def self.name tag2.oligo = nil tag2.save expect(tag2.oligo).to be_nil - sf_tag2_index.update(aliquot:, tag_group: nil) + sf_tag2_index.update(aliquot: aliquot, tag_group: nil) aliquot.save expect(aliquot.tag2_id).to eq(-1) end @@ -543,25 +569,27 @@ def self.name describe 'tag group' do it 'will add the value' do - sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset:) + sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset) expect(sf_tag_group.value).to eq(tag_group_name) end it 'will be valid with an existing tag group name' do - expect(described_class.new(value: tag_group_name, sample_manifest_asset:)).to be_valid + expect(described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset)).to be_valid end context 'when the tag group is not Chromium' do let(:adapter_type) { create(:adapter_type, name: 'Other') } it 'will not be valid' do - expect(described_class.new(value: tag_group_name, sample_manifest_asset:)).not_to be_valid + expect( + described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset) + ).not_to be_valid end end it 'responds to update method but does nothing to tag on aliquot' do - sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset:) - expect(sf_tag_group.update(aliquot:, tag_group: nil)).to be_nil + sf_tag_group = described_class.new(value: tag_group_name, sample_manifest_asset: sample_manifest_asset) + expect(sf_tag_group.update(aliquot: aliquot, tag_group: nil)).to be_nil aliquot.save expect(aliquot.tag).to be_nil end @@ -569,19 +597,22 @@ def self.name describe SequencescapeExcel::SpecialisedField::ChromiumTagWell do it 'will add the value' do - sf_tag_well = described_class.new(value: tag_well, sample_manifest_asset:) + sf_tag_well = described_class.new(value: tag_well, sample_manifest_asset: sample_manifest_asset) expect(sf_tag_well.value).to eq(tag_well) end it 'will not have a valid tag index when unlinked from a tag group' do - expect(described_class.new(value: tag_well, sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: tag_well, sample_manifest_asset: sample_manifest_asset)).not_to be_valid end describe 'linking' do let(:sf_tag_group) do - SequencescapeExcel::SpecialisedField::ChromiumTagGroup.new(value: tag_group_name, sample_manifest_asset:) + SequencescapeExcel::SpecialisedField::ChromiumTagGroup.new( + value: tag_group_name, + sample_manifest_asset: sample_manifest_asset + ) end - let(:sf_tag_well) { described_class.new(value: tag_well, sample_manifest_asset:) } + let(:sf_tag_well) { described_class.new(value: tag_well, sample_manifest_asset: sample_manifest_asset) } before { sf_tag_well.sf_tag_group = sf_tag_group } @@ -598,15 +629,15 @@ def self.name end it 'will apply the four tags associated with the map_id' do - sf_tag_well.update(aliquot:, tag_group: nil) + sf_tag_well.update(aliquot: aliquot, tag_group: nil) expect(asset.reload.aliquots.map { |a| a.tag.map_id }).to contain_exactly(1, 2, 3, 4) end context 'when applied to a re-upload' do - let(:asset) { create(:tagged_well, map:, aliquot_count: 4) } + let(:asset) { create(:tagged_well, map: map, aliquot_count: 4) } it 'will apply the four tags associated with the map_id' do - sf_tag_well.update(aliquot:, tag_group: nil) + sf_tag_well.update(aliquot: aliquot, tag_group: nil) expect(asset.aliquots.map { |a| a.tag.map_id }).to contain_exactly(1, 2, 3, 4) end end @@ -621,7 +652,9 @@ def self.name let(:dual_index_tag_well) { 'A1' } describe 'dual index tag set' do - let(:sf_dual_index_tag_set) { described_class.new(value: dual_index_tag_set.name, sample_manifest_asset:) } + let(:sf_dual_index_tag_set) do + described_class.new(value: dual_index_tag_set.name, sample_manifest_asset: sample_manifest_asset) + end it 'will add the value' do expect(sf_dual_index_tag_set.value).to eq(dual_index_tag_set.name) @@ -632,7 +665,7 @@ def self.name end context 'when no tag set name is provided' do - let(:sf_dual_index_tag_set) { described_class.new(value: '', sample_manifest_asset:) } + let(:sf_dual_index_tag_set) { described_class.new(value: '', sample_manifest_asset: sample_manifest_asset) } it 'will be not be valid' do expect(sf_dual_index_tag_set).not_to be_valid @@ -641,7 +674,9 @@ def self.name end context 'when the tag set name is unknown' do - let(:sf_dual_index_tag_set) { described_class.new(value: 'bananas', sample_manifest_asset:) } + let(:sf_dual_index_tag_set) do + described_class.new(value: 'bananas', sample_manifest_asset: sample_manifest_asset) + end it 'will be not be valid' do expect(sf_dual_index_tag_set).not_to be_valid @@ -664,11 +699,13 @@ def self.name end describe SequencescapeExcel::SpecialisedField::DualIndexTagWell do - let(:sf_dual_index_tag_well) { described_class.new(value: dual_index_tag_well, sample_manifest_asset:) } + let(:sf_dual_index_tag_well) do + described_class.new(value: dual_index_tag_well, sample_manifest_asset: sample_manifest_asset) + end let(:sf_dual_index_tag_set) do SequencescapeExcel::SpecialisedField::DualIndexTagSet.new( value: dual_index_tag_set.name, - sample_manifest_asset: + sample_manifest_asset: sample_manifest_asset ) end @@ -686,7 +723,7 @@ def self.name end it 'will apply the two tags associated with the map_id' do - sf_dual_index_tag_well.update(aliquot:, tag_group: nil) + sf_dual_index_tag_well.update(aliquot: aliquot, tag_group: nil) # well location 'A1' => map_id '1' expect(asset.aliquots.first.tag.map_id).to eq 1 expect(asset.aliquots.first.tag.tag_group).to eq tag_group1 @@ -703,11 +740,11 @@ def self.name end context 'when applied to a re-upload' do - let(:asset) { create(:tagged_well, map:, aliquot_count: 1) } + let(:asset) { create(:tagged_well, map: map, aliquot_count: 1) } let(:dual_index_tag_well) { 'd1' } it 'will apply the 2 tags associated with the updated map_id' do - sf_dual_index_tag_well.update(aliquot:, tag_group: nil) + sf_dual_index_tag_well.update(aliquot: aliquot, tag_group: nil) # well location 'D1' => map_id '4' expect(asset.reload.aliquots.first.tag.map_id).to eq 4 expect(asset.reload.aliquots.first.tag2.map_id).to eq 4 @@ -743,25 +780,27 @@ def self.name let(:primer_panel) { create(:primer_panel) } it 'will not be valid without a persisted primer panel' do - expect(described_class.new(value: primer_panel.name, sample_manifest_asset:)).to be_valid - expect(described_class.new(value: 'A new primer panel', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: primer_panel.name, sample_manifest_asset: sample_manifest_asset)).to be_valid + expect( + described_class.new(value: 'A new primer panel', sample_manifest_asset: sample_manifest_asset) + ).not_to be_valid end it 'will be valid if blank' do - expect(described_class.new(value: '', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).to be_valid end it 'will add the the value to the aliquot' do - specialised_field = described_class.new(value: primer_panel.name, sample_manifest_asset:) + specialised_field = described_class.new(value: primer_panel.name, sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) expect(aliquot.primer_panel).to eq(primer_panel) end context 'with multiple aliquots' do - let(:asset) { create(:tagged_well, map:, aliquot_count: 2) } + let(:asset) { create(:tagged_well, map: map, aliquot_count: 2) } it 'will add the the value to all aliquots' do - specialised_field = described_class.new(value: primer_panel.name, sample_manifest_asset:) + specialised_field = described_class.new(value: primer_panel.name, sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) expect(asset.aliquots).to all(have_attributes(primer_panel:)) end @@ -770,25 +809,25 @@ def self.name describe SequencescapeExcel::SpecialisedField::Priority do it 'will be valid if value blank string or nil' do - expect(described_class.new(value: '', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: nil, sample_manifest_asset:)).to be_valid + expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset)).to be_valid end it 'will be valid if value matches enum' do - expect(described_class.new(value: '0', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: '1', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: '2', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: '3', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: '0', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: '1', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: '2', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: '3', sample_manifest_asset: sample_manifest_asset)).to be_valid end it 'will not be valid if value does not match enum' do - sf = described_class.new(value: '5', sample_manifest_asset:) + sf = described_class.new(value: '5', sample_manifest_asset: sample_manifest_asset) expect(sf).not_to be_valid expect(sf.errors.full_messages.join).to include('the priority 5 was not recognised.') end it 'will update the priority on the sample when present' do - specialised_field = described_class.new(value: '1', sample_manifest_asset:) + specialised_field = described_class.new(value: '1', sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) aliquot.save expect(sample_manifest_asset.sample.priority).to eq('backlog') @@ -797,23 +836,23 @@ def self.name describe SequencescapeExcel::SpecialisedField::ControlType do it 'will be valid if value blank string or nil' do - expect(described_class.new(value: '', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: nil, sample_manifest_asset:)).to be_valid + expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset)).to be_valid end it 'will be valid if value matches enum' do - expect(described_class.new(value: 'positive', sample_manifest_asset:)).to be_valid - expect(described_class.new(value: 'negative', sample_manifest_asset:)).to be_valid + expect(described_class.new(value: 'positive', sample_manifest_asset: sample_manifest_asset)).to be_valid + expect(described_class.new(value: 'negative', sample_manifest_asset: sample_manifest_asset)).to be_valid end it 'will not be valid if value does not match enum' do - sf = described_class.new(value: 'rubbish', sample_manifest_asset:) + sf = described_class.new(value: 'rubbish', sample_manifest_asset: sample_manifest_asset) expect(sf).not_to be_valid expect(sf.errors.full_messages).to include('the control type rubbish was not recognised.') end it 'will update the control and control type on the sample when present' do - specialised_field = described_class.new(value: 'positive', sample_manifest_asset:) + specialised_field = described_class.new(value: 'positive', sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) aliquot.save expect(sample_manifest_asset.sample.control).to be(true) @@ -825,7 +864,7 @@ def self.name sample_manifest_asset.sample.control = true sample_manifest_asset.sample.control_type = 'positive' sample_manifest_asset.sample.save - specialised_field = described_class.new(value: '', sample_manifest_asset:) + specialised_field = described_class.new(value: '', sample_manifest_asset: sample_manifest_asset) specialised_field.update(aliquot:) aliquot.save expect(sample_manifest_asset.sample.control).to be(false) @@ -837,22 +876,27 @@ def self.name describe SequencescapeExcel::SpecialisedField::BioscanControlType do let(:sample_supplier_name) { 'CONTROL_test_01' } let!(:bs_supplier_name) do - SequencescapeExcel::SpecialisedField::BioscanSupplierName.new(value: sample_supplier_name, sample_manifest_asset:) + SequencescapeExcel::SpecialisedField::BioscanSupplierName.new( + value: sample_supplier_name, + sample_manifest_asset: sample_manifest_asset + ) + end + let!(:sf_well) do + SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset: sample_manifest_asset) end - let!(:sf_well) { SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) } # test value matches to the enum in the sample model # for Bioscan we have three types of control it 'will be valid if value matches enum' do - sf_pcr_pos = described_class.new(value: 'pcr positive', sample_manifest_asset:) + sf_pcr_pos = described_class.new(value: 'pcr positive', sample_manifest_asset: sample_manifest_asset) sf_pcr_pos.supplier_name = bs_supplier_name expect(sf_pcr_pos).to be_valid - sf_pcr_neg = described_class.new(value: 'pcr negative', sample_manifest_asset:) + sf_pcr_neg = described_class.new(value: 'pcr negative', sample_manifest_asset: sample_manifest_asset) sf_pcr_neg.supplier_name = bs_supplier_name expect(sf_pcr_neg).to be_valid - sf_lysate_neg = described_class.new(value: 'lysate negative', sample_manifest_asset:) + sf_lysate_neg = described_class.new(value: 'lysate negative', sample_manifest_asset: sample_manifest_asset) sf_lysate_neg.supplier_name = bs_supplier_name sf_lysate_neg.well = sf_well expect(sf_lysate_neg).to be_valid @@ -860,7 +904,7 @@ def self.name # test field is not valid if value does not match to the enum in the sample model it 'will not be valid if value does not match enum' do - sf = described_class.new(value: 'rubbish', sample_manifest_asset:) + sf = described_class.new(value: 'rubbish', sample_manifest_asset: sample_manifest_asset) sf.supplier_name = bs_supplier_name expect(sf).not_to be_valid @@ -869,7 +913,7 @@ def self.name # test control flag and type are set on sample it 'will update the control and control type on the sample when present' do - sf = described_class.new(value: 'pcr positive', sample_manifest_asset:) + sf = described_class.new(value: 'pcr positive', sample_manifest_asset: sample_manifest_asset) sf.supplier_name = bs_supplier_name sf.update(aliquot:) aliquot.save @@ -882,7 +926,7 @@ def self.name sample_manifest_asset.sample.control = true sample_manifest_asset.sample.control_type = 'pcr positive' sample_manifest_asset.sample.save - sf = described_class.new(value: '', sample_manifest_asset:) + sf = described_class.new(value: '', sample_manifest_asset: sample_manifest_asset) sf.supplier_name = bs_supplier_name sf.update(aliquot:) aliquot.save @@ -891,10 +935,12 @@ def self.name end context 'when pcr positive in H12' do - let!(:bs_well) { SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) } + let!(:bs_well) do + SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset: sample_manifest_asset) + end it 'will be invalid' do - control_type_sf = described_class.new(value: 'pcr positive', sample_manifest_asset:) + control_type_sf = described_class.new(value: 'pcr positive', sample_manifest_asset: sample_manifest_asset) control_type_sf.supplier_name = bs_supplier_name control_type_sf.well = bs_well expect(control_type_sf).not_to be_valid @@ -902,10 +948,12 @@ def self.name end context 'when pcr positive not in H12' do - let!(:bs_well) { SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset:) } + let!(:bs_well) do + SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset: sample_manifest_asset) + end it 'will be valid' do - control_type_sf = described_class.new(value: 'pcr positive', sample_manifest_asset:) + control_type_sf = described_class.new(value: 'pcr positive', sample_manifest_asset: sample_manifest_asset) control_type_sf.supplier_name = bs_supplier_name control_type_sf.well = bs_well expect(control_type_sf).to be_valid @@ -913,10 +961,12 @@ def self.name end context 'when lysate negative in H12' do - let!(:bs_well) { SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset:) } + let!(:bs_well) do + SequencescapeExcel::SpecialisedField::Well.new(value: 'H12', sample_manifest_asset: sample_manifest_asset) + end it 'will be valid' do - control_type_sf = described_class.new(value: 'lysate negative', sample_manifest_asset:) + control_type_sf = described_class.new(value: 'lysate negative', sample_manifest_asset: sample_manifest_asset) control_type_sf.supplier_name = bs_supplier_name control_type_sf.well = bs_well expect(control_type_sf).to be_valid @@ -924,10 +974,12 @@ def self.name end context 'when lysate negative not in H12' do - let!(:bs_well) { SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset:) } + let!(:bs_well) do + SequencescapeExcel::SpecialisedField::Well.new(value: 'A1', sample_manifest_asset: sample_manifest_asset) + end it 'will be invalid' do - control_type_sf = described_class.new(value: 'lysate negative', sample_manifest_asset:) + control_type_sf = described_class.new(value: 'lysate negative', sample_manifest_asset: sample_manifest_asset) control_type_sf.supplier_name = bs_supplier_name control_type_sf.well = bs_well expect(control_type_sf).not_to be_valid @@ -944,12 +996,12 @@ def self.name # supplier name is a primary field and must be present in the manifest rows it 'will not be valid if blank' do - expect(described_class.new(value: '', sample_manifest_asset:)).not_to be_valid + expect(described_class.new(value: '', sample_manifest_asset: sample_manifest_asset)).not_to be_valid end # test supplier name is stored in the sample metadata on update it 'will add supplier name to sample_metadata' do - sf = described_class.new(value: sample_supplier_name, sample_manifest_asset:) + sf = described_class.new(value: sample_supplier_name, sample_manifest_asset: sample_manifest_asset) sf.update expect(sample_manifest_asset.sample.sample_metadata.supplier_name).to eq(sample_supplier_name) end @@ -961,18 +1013,20 @@ def self.name shared_examples 'a retention instruction labware' do it 'will be invalid if the value is not set' do - sf = described_class.new(value: nil, sample_manifest_asset:) + sf = described_class.new(value: nil, sample_manifest_asset: sample_manifest_asset) expect(sf).not_to be_valid expect(sf.errors.full_messages.join).to include('Retention instruction can\'t be blank') end it 'will be valid if the value matches one of the expected values' do - expect(described_class.new(value: 'Long term storage', sample_manifest_asset:)).to be_valid + expect( + described_class.new(value: 'Long term storage', sample_manifest_asset: sample_manifest_asset) + ).to be_valid end it 'will create labware custom metadata on the labware and set the retention instruction choice' do - sf = described_class.new(value: 'Long term storage', sample_manifest_asset:) + sf = described_class.new(value: 'Long term storage', sample_manifest_asset: sample_manifest_asset) sf.update expect(sf.asset.labware.retention_instruction.to_sym).to eq(:long_term_storage) @@ -984,7 +1038,7 @@ def self.name asset.labware.save # Update the retention instruction value - sf = described_class.new(value: 'Long term storage', sample_manifest_asset:) + sf = described_class.new(value: 'Long term storage', sample_manifest_asset: sample_manifest_asset) sf.update expect(sf.asset.labware.retention_instruction.to_sym).to eq(:long_term_storage) @@ -994,7 +1048,7 @@ def self.name # As long as the validation on the manifest re-upload passes (and for a plate that all wells for a labware # have the same retention instruction value, it is valid to update. it 'will be valid to update if the labware already contains a retention instruction metadata' do - sf = described_class.new(value: 'Destroy after 2 years', sample_manifest_asset:) + sf = described_class.new(value: 'Destroy after 2 years', sample_manifest_asset: sample_manifest_asset) expect(sf).to be_valid sf.update @@ -1032,7 +1086,7 @@ def self.name custom_metadatum_collection.save! custom_metadatum.save! - sf = described_class.new(value: 'Long term storage', sample_manifest_asset:) + sf = described_class.new(value: 'Long term storage', sample_manifest_asset: sample_manifest_asset) sf.update end diff --git a/spec/sequencescape_excel/validation_spec.rb b/spec/sequencescape_excel/validation_spec.rb index ee347c3798..2ea3f491bc 100644 --- a/spec/sequencescape_excel/validation_spec.rb +++ b/spec/sequencescape_excel/validation_spec.rb @@ -34,12 +34,12 @@ it '#does not add a range' do expect(worksheet).to receive(:add_data_validation).with('N10:N30', **options) - validation.update(range:, worksheet:, reference: 'N10:N30') + validation.update(range: range, worksheet: worksheet, reference: 'N10:N30') end end context 'with range name' do - let(:validation) { described_class.new(options:, range_name: :a_range) } + let(:validation) { described_class.new(options: options, range_name: :a_range) } it 'will have a range name' do expect(validation.range_name).to eq(:a_range) @@ -47,7 +47,7 @@ it '#update will set formula1' do expect(worksheet).to receive(:add_data_validation).with('N10:N30', **options, formula1: range.absolute_reference) - validation.update(range:, worksheet:, reference: 'N10:N30') + validation.update(range: range, worksheet: worksheet, reference: 'N10:N30') end end @@ -61,7 +61,7 @@ type: :custom, formula1: 'AND(N10>5,N10<10)' ) - validation.update(reference: 'N10:N30', worksheet:) + validation.update(reference: 'N10:N30', worksheet: worksheet) end end @@ -75,7 +75,7 @@ end it 'adds validation to the worksheet' do - validation.update(reference: range.reference, worksheet:) + validation.update(reference: range.reference, worksheet: worksheet) validations = worksheet.data_validation_rules expect(validation).to be_saved expect(validations.count).to eq(1) @@ -83,13 +83,13 @@ end it 'is comparable' do - validation.update(reference: range.reference, worksheet:) + validation.update(reference: range.reference, worksheet: worksheet) other_validation = described_class.new(options:) - other_validation.update(reference: range.reference, worksheet:) + other_validation.update(reference: range.reference, worksheet: worksheet) expect(other_validation).to eq(validation) other_validation = described_class.new(options: options.merge(option3: 'value3')) - other_validation.update(reference: range.reference, worksheet:) + other_validation.update(reference: range.reference, worksheet: worksheet) expect(other_validation).not_to eq(validation) end end diff --git a/spec/sequencescape_excel/worksheet_spec.rb b/spec/sequencescape_excel/worksheet_spec.rb index 7a4a3c90e2..118cb6cf58 100644 --- a/spec/sequencescape_excel/worksheet_spec.rb +++ b/spec/sequencescape_excel/worksheet_spec.rb @@ -38,7 +38,7 @@ def save_file describe 'validations ranges worksheet' do let!(:range_list) { SampleManifestExcel.configuration.ranges.dup } - let!(:worksheet) { SequencescapeExcel::Worksheet::RangesWorksheet.new(workbook:, ranges: range_list) } + let!(:worksheet) { SequencescapeExcel::Worksheet::RangesWorksheet.new(workbook: workbook, ranges: range_list) } before { save_file } diff --git a/spec/shared_contexts/limber_shared_context.rb b/spec/shared_contexts/limber_shared_context.rb index 2d270880a9..2427fb9b77 100644 --- a/spec/shared_contexts/limber_shared_context.rb +++ b/spec/shared_contexts/limber_shared_context.rb @@ -45,7 +45,7 @@ asset: well, submission: target_submission, state: library_state, - order: + order: order ) create( :library_request, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a080a1c64a..39210c9b0e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -55,7 +55,7 @@ options.add_argument('--headless=old') options.add_argument('--disable-gpu') options.add_argument('--disable-search-engine-choice-screen') - Capybara::Selenium::Driver.new(app, browser: :chrome, options:) + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end Capybara.register_driver :selenium_chrome do |app| @@ -64,7 +64,7 @@ options.add_preference('download.default_directory', DownloadHelpers::PATH.to_s) options.add_argument('--disable-gpu') options.add_argument('--disable-search-engine-choice-screen') - Capybara::Selenium::Driver.new(app, browser: :chrome, options:) + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end Capybara.javascript_driver = ENV.fetch('JS_DRIVER', 'headless_chrome').to_sym diff --git a/spec/support/api_helper.rb b/spec/support/api_helper.rb index 8ee320fc2c..dc907ed53e 100644 --- a/spec/support/api_helper.rb +++ b/spec/support/api_helper.rb @@ -6,14 +6,14 @@ def api_request(action, path, body = nil) headers['CONTENT_TYPE'] = 'application/json' unless body.nil? headers['HTTP_X_SEQUENCESCAPE_CLIENT_ID'] = authorised_app.key yield(headers) if block_given? - send(action.downcase, path, params: body, headers:) + send(action.downcase, path, params: body, headers: headers) end def unauthorized_api_request(action, path, body = nil) headers = { 'HTTP_ACCEPT' => 'application/json' } headers['CONTENT_TYPE'] = 'application/json' unless body.nil? yield(headers) if block_given? - send(action.downcase, path, params: body, headers:) + send(action.downcase, path, params: body, headers: headers) end def user_api_request(user, action, path, body = nil) @@ -21,6 +21,6 @@ def user_api_request(user, action, path, body = nil) cookies['api_key'] = user.api_key headers['CONTENT_TYPE'] = 'application/json' unless body.nil? yield(headers) if block_given? - send(action.downcase, path, params: body, headers:) + send(action.downcase, path, params: body, headers: headers) end end diff --git a/spec/support/api_v2_helper.rb b/spec/support/api_v2_helper.rb index 26e61c9ed4..14aeb5a776 100644 --- a/spec/support/api_v2_helper.rb +++ b/spec/support/api_v2_helper.rb @@ -10,12 +10,12 @@ def api_get(path, headers: {}) def api_patch(path, payload, headers: {}) headers.merge!(DEFAULT_HEADERS) - patch(path, params: payload.to_json, headers:) + patch(path, params: payload.to_json, headers: headers) end def api_post(path, payload, headers: {}) headers.merge!(DEFAULT_HEADERS) - post(path, params: payload.to_json, headers:) + post(path, params: payload.to_json, headers: headers) end def json diff --git a/spec/uat_actions/generate_sample_manifest_spec.rb b/spec/uat_actions/generate_sample_manifest_spec.rb index 322d4a86cb..44f5be3144 100644 --- a/spec/uat_actions/generate_sample_manifest_spec.rb +++ b/spec/uat_actions/generate_sample_manifest_spec.rb @@ -15,10 +15,10 @@ { study_name: study.name, supplier_name: supplier.name, - asset_type:, - count:, + asset_type: asset_type, + count: count, tube_purpose_name: purpose.name, - with_samples: + with_samples: with_samples } end diff --git a/spec/uat_actions/plate_information_spec.rb b/spec/uat_actions/plate_information_spec.rb index a05d144f66..8cf2656bfd 100644 --- a/spec/uat_actions/plate_information_spec.rb +++ b/spec/uat_actions/plate_information_spec.rb @@ -10,7 +10,7 @@ let(:report) do # A report is a hash of key value pairs which get returned to the user. # It should include information such as barcodes and identifiers - { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } + { plate_barcode: plate_barcode, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } end before { create(:plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode) } @@ -28,7 +28,7 @@ let(:report) do # A report is a hash of key value pairs which get returned to the user. # It should include information such as barcodes and identifiers - { plate_barcode:, wells_with_aliquots: '', wells_with_active_requests_as_source: '' } + { plate_barcode: plate_barcode, wells_with_aliquots: '', wells_with_active_requests_as_source: '' } end before { create(:plate_with_empty_wells, well_count: 3, barcode: plate_barcode) } @@ -63,7 +63,11 @@ let(:submission) { create(:submission) } let(:request_type) { create(:library_creation_request_type) } let(:report) do - { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: 'A1, C1' } + { + plate_barcode: plate_barcode, + wells_with_aliquots: 'A1, B1, C1', + wells_with_active_requests_as_source: 'A1, C1' + } end before do @@ -71,10 +75,24 @@ plate_wells = plate.wells.with_contents - req1 = create(:library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'started') + req1 = + create( + :library_creation_request, + asset: plate_wells.first, + submission: submission, + request_type: request_type, + state: 'started' + ) plate_wells.first.requests_as_source << req1 - req2 = create(:library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'started') + req2 = + create( + :library_creation_request, + asset: plate_wells.last, + submission: submission, + request_type: request_type, + state: 'started' + ) plate_wells.last.requests_as_source << req2 end @@ -92,17 +110,33 @@ let(:uat_action) { described_class.new(parameters) } let(:submission) { create(:submission) } let(:request_type) { create(:library_creation_request_type) } - let(:report) { { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } } + let(:report) do + { plate_barcode: plate_barcode, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: '' } + end before do plate = create(:plate_with_untagged_wells, sample_count: 3, barcode: plate_barcode) plate_wells = plate.wells.with_contents - req1 = create(:library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'passed') + req1 = + create( + :library_creation_request, + asset: plate_wells.first, + submission: submission, + request_type: request_type, + state: 'passed' + ) plate_wells.first.requests_as_source << req1 - req2 = create(:library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'passed') + req2 = + create( + :library_creation_request, + asset: plate_wells.last, + submission: submission, + request_type: request_type, + state: 'passed' + ) plate_wells.last.requests_as_source << req2 end @@ -122,7 +156,11 @@ let(:submission2) { create(:submission) } let(:request_type) { create(:library_creation_request_type) } let(:report) do - { plate_barcode:, wells_with_aliquots: 'A1, B1, C1', wells_with_active_requests_as_source: 'A1, C1' } + { + plate_barcode: plate_barcode, + wells_with_aliquots: 'A1, B1, C1', + wells_with_active_requests_as_source: 'A1, C1' + } end before do @@ -130,13 +168,34 @@ plate_wells = plate.wells.with_contents - req1 = create(:library_creation_request, asset: plate_wells.first, submission:, request_type:, state: 'passed') + req1 = + create( + :library_creation_request, + asset: plate_wells.first, + submission: submission, + request_type: request_type, + state: 'passed' + ) plate_wells.first.requests_as_source << req1 - req2 = create(:library_creation_request, asset: plate_wells.second, submission:, request_type:, state: 'passed') + req2 = + create( + :library_creation_request, + asset: plate_wells.second, + submission: submission, + request_type: request_type, + state: 'passed' + ) plate_wells.second.requests_as_source << req2 - req3 = create(:library_creation_request, asset: plate_wells.last, submission:, request_type:, state: 'passed') + req3 = + create( + :library_creation_request, + asset: plate_wells.last, + submission: submission, + request_type: request_type, + state: 'passed' + ) plate_wells.last.requests_as_source << req3 req4 = @@ -144,7 +203,7 @@ :library_creation_request, asset: plate_wells.first, submission: submission2, - request_type:, + request_type: request_type, state: 'started' ) plate_wells.first.requests_as_source << req4 @@ -154,7 +213,7 @@ :library_creation_request, asset: plate_wells.last, submission: submission2, - request_type:, + request_type: request_type, state: 'started' ) plate_wells.last.requests_as_source << req5 diff --git a/spec/views/labware/show_chromium_chip_spec.rb b/spec/views/labware/show_chromium_chip_spec.rb index 70fe68f26d..c4dc02ee57 100644 --- a/spec/views/labware/show_chromium_chip_spec.rb +++ b/spec/views/labware/show_chromium_chip_spec.rb @@ -14,7 +14,7 @@ let(:current_user) { user } let(:purpose_name) { 'chromium-chip-purpose' } let(:purpose) { create(:shape4x1_purpose, name: purpose_name) } # AssetShape Shape4x1, size 16 - let(:plate) { create(:child_plate, well_factory: :passed_well, purpose:, size: 16, sample_count: 16) } + let(:plate) { create(:child_plate, well_factory: :passed_well, purpose: purpose, size: 16, sample_count: 16) } let(:doc) { Nokogiri.HTML(rendered) } before do diff --git a/spec/views/labware/show_html_erb_spec.rb b/spec/views/labware/show_html_erb_spec.rb index cf451915f4..cda9966ed2 100644 --- a/spec/views/labware/show_html_erb_spec.rb +++ b/spec/views/labware/show_html_erb_spec.rb @@ -71,7 +71,7 @@ let(:barcodes) { Array.new(num_tubes) { create(:fluidx) } } let!(:tubes) do Array.new(num_tubes) do |i| - create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) + create(:sample_tube, :in_a_rack, tube_rack: tube_rack, coordinate: locations[i], barcodes: [barcodes[i]]) end end diff --git a/spec/views/tube_rack_summaries/show_html_erb_spec.rb b/spec/views/tube_rack_summaries/show_html_erb_spec.rb index 329cdf1de2..4f9b07a53e 100644 --- a/spec/views/tube_rack_summaries/show_html_erb_spec.rb +++ b/spec/views/tube_rack_summaries/show_html_erb_spec.rb @@ -16,7 +16,7 @@ before do Array.new(num_tubes) do |i| - create(:sample_tube, :in_a_rack, tube_rack:, coordinate: locations[i], barcodes: [barcodes[i]]) + create(:sample_tube, :in_a_rack, tube_rack: tube_rack, coordinate: locations[i], barcodes: [barcodes[i]]) end assign(:tube_rack, tube_rack) # sets @widget = Widget.new in the view template diff --git a/test/controllers/batches_controller_test.rb b/test/controllers/batches_controller_test.rb index 2c3c84c1c0..ca11a5e558 100644 --- a/test/controllers/batches_controller_test.rb +++ b/test/controllers/batches_controller_test.rb @@ -552,13 +552,13 @@ class BatchesControllerTest < ActionController::TestCase asset = create(:empty_sample_tube) order_role = OrderRole.new role: 'test' - order = create(:order, order_role:, study:, assets: [asset], project:) + order = create(:order, order_role: order_role, study: study, assets: [asset], project: project) request = create( :well_request, asset: create(:well_with_sample_and_plate), target_asset: create(:well_with_sample_and_plate), - order: + order: order ) @batch = create(:batch) @batch.requests << request @@ -588,7 +588,7 @@ class BatchesControllerTest < ActionController::TestCase params: { printer: barcode_printer.name, count: '3', - printable:, + printable: printable, batch_id: @batch.id.to_s } end diff --git a/test/controllers/requests_comments_controller_test.rb b/test/controllers/requests_comments_controller_test.rb index c29977b468..d2600029a0 100644 --- a/test/controllers/requests_comments_controller_test.rb +++ b/test/controllers/requests_comments_controller_test.rb @@ -26,7 +26,7 @@ class CommentsControllerTest < ActionController::TestCase setup do @rq = create(:request) - %w[this is a test].each { |description| create(:comment, description:, commentable: @rq) } + %w[this is a test].each { |description| create(:comment, description: description, commentable: @rq) } end should 'return a ul of comments' do diff --git a/test/functional/pre_cap_groups_test.rb b/test/functional/pre_cap_groups_test.rb index ae1f0cbd27..8b8d29d852 100644 --- a/test/functional/pre_cap_groups_test.rb +++ b/test/functional/pre_cap_groups_test.rb @@ -119,7 +119,7 @@ def with_pools(*pools) @pools = create_list(:pre_capture_pool, 3) with_pools(%w[A1 B1 C1], %w[D1 E1 F1]) transfers = @test_plate.wells.each_with_object({}) { |w, hash| hash[w.map_description] = w.map_description } - create(:transfer_between_plates, transfers:, source: @plate, destination: @test_plate) + create(:transfer_between_plates, transfers: transfers, source: @plate, destination: @test_plate) end should 'report the pools from the stock plate' do diff --git a/test/lib/label_printer/batch_tube_test.rb b/test/lib/label_printer/batch_tube_test.rb index e4ed73a183..c735772fe6 100644 --- a/test/lib/label_printer/batch_tube_test.rb +++ b/test/lib/label_printer/batch_tube_test.rb @@ -16,7 +16,7 @@ class BatchTubeTest < ActiveSupport::TestCase @batch.requests << request printable = { request.id => 'on' } - options = { count: '1', printable:, batch:, stock: true } + options = { count: '1', printable: printable, batch: batch, stock: true } @tube_label = LabelPrinter::Label::BatchTube.new(options) assert_equal 1, tube_label.tubes.count @@ -32,7 +32,7 @@ class BatchTubeTest < ActiveSupport::TestCase @batch.requests << request printable = { request.id => 'on' } - options = { count: '1', printable:, batch:, stock: false } + options = { count: '1', printable: printable, batch: batch, stock: false } @tube_label = LabelPrinter::Label::BatchTube.new(options) assert_equal 1, tube_label.tubes.count diff --git a/test/lib/label_printer/plate_creator_test.rb b/test/lib/label_printer/plate_creator_test.rb index f680a2a430..a22e4c4934 100644 --- a/test/lib/label_printer/plate_creator_test.rb +++ b/test/lib/label_printer/plate_creator_test.rb @@ -28,9 +28,9 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength @plate1 = create( :child_plate, - parent:, + parent: parent, barcode: barcode1, - plate_purpose:, + plate_purpose: plate_purpose, well_count: 1, well_factory: :untagged_well, studies: @studies @@ -38,7 +38,7 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength @plates = [plate1] @user = 'user' @study_abbreviation = 'WTCCC' - options = { plate_purpose:, plates:, user_login: user } + options = { plate_purpose: plate_purpose, plates: plates, user_login: user } @plate_label = LabelPrinter::Label::PlateCreator.new(options) @label = { top_left: Date.today.strftime('%e-%^b-%Y').to_s, diff --git a/test/lib/label_printer/print_job_test.rb b/test/lib/label_printer/print_job_test.rb index 97696bca94..14c32637c6 100644 --- a/test/lib/label_printer/print_job_test.rb +++ b/test/lib/label_printer/print_job_test.rb @@ -29,13 +29,17 @@ def setup # rubocop:todo Metrics/AbcSize, Metrics/MethodLength label_name: 'main_label' } ] - @attributes = { printer_name: barcode_printer.name, label_template_name:, labels: labels_attributes } + @attributes = { + printer_name: barcode_printer.name, + label_template_name: label_template_name, + labels: labels_attributes + } @print_job = LabelPrinter::PrintJob.new( barcode_printer.name, LabelPrinter::Label::PlateCreator, - plates:, - plate_purpose:, + plates: plates, + plate_purpose: plate_purpose, user_login: 'user' ) end diff --git a/test/performance/state_change_test.rb b/test/performance/state_change_test.rb index 77bfb10988..5a53f07119 100644 --- a/test/performance/state_change_test.rb +++ b/test/performance/state_change_test.rb @@ -13,7 +13,7 @@ def setup @source = create(:transfer_plate, well_count: 96) @destination = create(:plate, well_count: 96) transfers = @source.wells.each_with_object({}) { |w, h| h[w.map_description] = w.map_description } - @transfer = create(:transfer_between_plates, source: @source, destination: @destination, transfers:) + @transfer = create(:transfer_between_plates, source: @source, destination: @destination, transfers: transfers) @user = create(:user) end diff --git a/test/unit/accession_service_test.rb b/test/unit/accession_service_test.rb index e67a45ce3e..aaacd0963b 100644 --- a/test/unit/accession_service_test.rb +++ b/test/unit/accession_service_test.rb @@ -8,7 +8,7 @@ def assert_tag(tag_label, value) tag = acc.tags.detect { |tag| tag.label == tag_label } assert tag, "Could not find #{tag} in #{acc.tags.map(&:label).join(',')}" subject_tag = { tag: tag.label, value: tag.value } - assert_equal({ tag: tag_label, value: }, subject_tag) + assert_equal({ tag: tag_label, value: value }, subject_tag) end # temporary test for hotfix diff --git a/test/unit/import_fluidigm_data_test.rb b/test/unit/import_fluidigm_data_test.rb index 694bf2bbb3..b0aa88ffb2 100644 --- a/test/unit/import_fluidigm_data_test.rb +++ b/test/unit/import_fluidigm_data_test.rb @@ -35,13 +35,21 @@ def create_stock_plate(barcode) well_count: 1, well_factory: :untagged_well, purpose: PlatePurpose.stock_plate_purpose, - barcode: + barcode: barcode ) end def create_plate_with_fluidigm(_barcode, fluidigm_barcode, stock_plate) fgp = create(:fluidigm_96_purpose) - plate_target = create(:plate, size: 96, purpose: fgp, well_count: 1, well_factory: :empty_well, fluidigm_barcode:) + plate_target = + create( + :plate, + size: 96, + purpose: fgp, + well_count: 1, + well_factory: :empty_well, + fluidigm_barcode: fluidigm_barcode + ) well_target = plate_target.wells.first diff --git a/test/unit/lab_interface/workflow_test.rb b/test/unit/lab_interface/workflow_test.rb index 42f299e0ae..641706a9eb 100644 --- a/test/unit/lab_interface/workflow_test.rb +++ b/test/unit/lab_interface/workflow_test.rb @@ -13,8 +13,8 @@ class WorkflowTest < ActiveSupport::TestCase @workflow.update!(name: 'Workflow for WorkflowTest') task = create(:task, workflow: @workflow) - create(:descriptor, task:, name: 'prop', value: 'something', key: 'something') - create(:descriptor, task:, name: 'prop_2', value: 'upstairs', key: 'upstairs') + create(:descriptor, task: task, name: 'prop', value: 'something', key: 'something') + create(:descriptor, task: task, name: 'prop_2', value: 'upstairs', key: 'upstairs') end subject { @workflow } diff --git a/test/unit/lib_pool_norm_tube_generator_test.rb b/test/unit/lib_pool_norm_tube_generator_test.rb index a7a02e266c..f96db20da6 100644 --- a/test/unit/lib_pool_norm_tube_generator_test.rb +++ b/test/unit/lib_pool_norm_tube_generator_test.rb @@ -22,7 +22,7 @@ def mock_transfer(generator) generator.lib_pool_tubes.each do |source| transfer = mock('transfer') transfer.stubs(:destination).returns(create(:lib_pool_norm_tube, parent_tube: source)) - generator.transfer_template.stubs(:create!).with(user: @user, source:).returns(transfer) + generator.transfer_template.stubs(:create!).with(user: @user, source: source).returns(transfer) end end diff --git a/test/unit/plate_test.rb b/test/unit/plate_test.rb index 74907fb83f..0f41e4fa5f 100644 --- a/test/unit/plate_test.rb +++ b/test/unit/plate_test.rb @@ -11,7 +11,7 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) name: "Cherrypicked #{plate_barcode}", size: 192, barcode: plate_barcode, - fluidigm_barcode: + fluidigm_barcode: fluidigm_barcode ) end @@ -116,7 +116,7 @@ def create_plate_with_fluidigm(plate_barcode, fluidigm_barcode) @plate = create(:transfer_plate) user = create(:user) @plate.wells.each_with_index do |well, index| - create(:request, asset: well, submission: Submission.create!(priority: index + 1, user:)) + create(:request, asset: well, submission: Submission.create!(priority: index + 1, user: user)) end end diff --git a/test/unit/product_catalogue/library_driven_test.rb b/test/unit/product_catalogue/library_driven_test.rb index acb170d4be..a9fd6d6d9a 100644 --- a/test/unit/product_catalogue/library_driven_test.rb +++ b/test/unit/product_catalogue/library_driven_test.rb @@ -8,8 +8,8 @@ class LibraryDrivenTest < ActiveSupport::TestCase def link_product_with_pc(product, product_catalogue, library_type_name) FactoryBot.create( :product_product_catalogue, - product:, - product_catalogue:, + product: product, + product_catalogue: product_catalogue, selection_criterion: library_type_name ) end From ce2d06f0d8780eb92f367009fa4da9ca8c06498a Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 26 Sep 2024 15:05:32 +0100 Subject: [PATCH 142/158] style: add reason comment --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index cb9b1cdbab..6556c8a223 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -57,6 +57,7 @@ Lint/AmbiguousRegexpLiteral: Exclude: - features/support/step_definitions/**/* +# Only use shorthand hash syntax when all keys match the variables for better readability Style/HashSyntax: EnforcedShorthandSyntax: consistent From 5afce29d0c687a8090455132a6f609aaa221d47b Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Thu, 26 Sep 2024 15:20:33 +0100 Subject: [PATCH 143/158] style: rubocop and prettier merged code bundle exec rubocop -a yarn prettier --write . rubocop --auto-gen-config --no-exclude-limit --- .rubocop_todo.yml | 26 ++++++++++++++----- .../api/v2/bait_library_layouts_controller.rb | 4 +-- .../api/v2/bait_library_layouts_spec.rb | 4 +-- .../api/v2/pooled_plate_creations_spec.rb | 12 ++++----- .../api/v2/specific_tube_creations_spec.rb | 12 ++++----- spec/requests/api/v2/state_changes_spec.rb | 4 +-- spec/requests/api/v2/tag_layouts_spec.rb | 4 +-- .../v2/bait_library_layout_resource_spec.rb | 2 +- .../v2/pooled_plate_creation_resource_spec.rb | 2 +- .../specific_tube_creation_resource_spec.rb | 2 +- .../api/v2/tag_layout_resource_spec.rb | 2 +- 11 files changed, 43 insertions(+), 31 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 93ce4d036c..ae552edda7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-26 13:53:59 UTC using RuboCop version 1.66.1. +# on 2024-09-26 14:20:02 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -327,10 +327,11 @@ Metrics/CyclomaticComplexity: Exclude: - 'lib/limber/helper.rb' -# Offense count: 8 +# Offense count: 9 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Exclude: + - 'app/controllers/api/v2/bait_library_layouts_controller.rb' - 'app/controllers/tag_layout_templates_controller.rb' - 'app/jobs/export_pool_xp_to_traction_job.rb' - 'app/models/plate/quad_creator.rb' @@ -731,8 +732,8 @@ RSpec/ExampleLength: - 'spec/requests/api/v2/qc_results_spec.rb' - 'spec/requests/api/v2/sample_metadata_spec.rb' - 'spec/requests/api/v2/shared_examples/api_key_authenticatable.rb' - - 'spec/requests/api/v2/state_changes_spec.rb' - 'spec/requests/api/v2/tag_layout_templates_spec.rb' + - 'spec/requests/api/v2/tag_layouts_spec.rb' - 'spec/requests/api/v2/transfers/transfers_spec.rb' - 'spec/requests/api/v2/tube_purposes_spec.rb' - 'spec/requests/api/v2/users_spec.rb' @@ -750,7 +751,6 @@ RSpec/ExampleLength: - 'spec/resources/api/v2/request_resource_spec.rb' - 'spec/resources/api/v2/request_type_resource_spec.rb' - 'spec/resources/api/v2/sample_metadata_resource_spec.rb' - - 'spec/resources/api/v2/state_change_resource_spec.rb' - 'spec/resources/api/v2/submission_resource_spec.rb' - 'spec/resources/api/v2/tag_group_resource_spec.rb' - 'spec/resources/api/v2/transfers/transfer_resource_spec.rb' @@ -915,7 +915,7 @@ RSpec/MultipleDescribes: - 'spec/lib/label_printer/asset_labels_spec.rb' - 'spec/models/qc_result/qc_result_spec.rb' -# Offense count: 915 +# Offense count: 946 # Configuration parameters: Max. RSpec/MultipleExpectations: Exclude: @@ -1063,6 +1063,7 @@ RSpec/MultipleExpectations: - 'spec/models/work_order_spec.rb' - 'spec/requests/api/v2/aliquots_spec.rb' - 'spec/requests/api/v2/asset_audits_spec.rb' + - 'spec/requests/api/v2/bait_library_layouts_spec.rb' - 'spec/requests/api/v2/barcode_printers_spec.rb' - 'spec/requests/api/v2/comments_spec.rb' - 'spec/requests/api/v2/custom_metadatum_collections_spec.rb' @@ -1077,6 +1078,7 @@ RSpec/MultipleExpectations: - 'spec/requests/api/v2/plate_templates_spec.rb' - 'spec/requests/api/v2/plates_spec.rb' - 'spec/requests/api/v2/poly_metadata_spec.rb' + - 'spec/requests/api/v2/pooled_plate_creations_spec.rb' - 'spec/requests/api/v2/pre_capture_pools_spec.rb' - 'spec/requests/api/v2/primer_panels_spec.rb' - 'spec/requests/api/v2/purposes_spec.rb' @@ -1088,12 +1090,14 @@ RSpec/MultipleExpectations: - 'spec/requests/api/v2/requests_spec.rb' - 'spec/requests/api/v2/sample_metadata_spec.rb' - 'spec/requests/api/v2/shared_examples/api_key_authenticatable.rb' + - 'spec/requests/api/v2/specific_tube_creations_spec.rb' - 'spec/requests/api/v2/state_changes_spec.rb' - 'spec/requests/api/v2/studies_spec.rb' - 'spec/requests/api/v2/submission_templates_spec.rb' - 'spec/requests/api/v2/submissions_spec.rb' - 'spec/requests/api/v2/tag_groups_spec.rb' - 'spec/requests/api/v2/tag_layout_templates_spec.rb' + - 'spec/requests/api/v2/tag_layouts_spec.rb' - 'spec/requests/api/v2/transfer_requests_spec.rb' - 'spec/requests/api/v2/transfer_templates_spec.rb' - 'spec/requests/api/v2/transfers/transfers_spec.rb' @@ -1154,7 +1158,7 @@ RSpec/MultipleExpectations: - 'spec/views/labware/show_chromium_chip_spec.rb' - 'spec/views/samples/index_html_erb_spec.rb' -# Offense count: 1041 +# Offense count: 1114 # Configuration parameters: AllowSubject, Max. RSpec/MultipleMemoizedHelpers: Exclude: @@ -1270,12 +1274,16 @@ RSpec/MultipleMemoizedHelpers: - 'spec/models/transfer_request_spec.rb' - 'spec/models/tube_rack_spec.rb' - 'spec/models/work_completion_spec.rb' + - 'spec/requests/api/v2/bait_library_layouts_spec.rb' - 'spec/requests/api/v2/custom_metadatum_collections_spec.rb' - 'spec/requests/api/v2/heron/plates_spec.rb' - 'spec/requests/api/v2/heron/tube_racks_spec.rb' - 'spec/requests/api/v2/plates_spec.rb' + - 'spec/requests/api/v2/pooled_plate_creations_spec.rb' - 'spec/requests/api/v2/receptacles_spec.rb' + - 'spec/requests/api/v2/specific_tube_creations_spec.rb' - 'spec/requests/api/v2/state_changes_spec.rb' + - 'spec/requests/api/v2/tag_layouts_spec.rb' - 'spec/requests/api/v2/transfers/transfers_spec.rb' - 'spec/requests/api/v2/wells_spec.rb' - 'spec/requests/plate_picks_request_spec.rb' @@ -1367,7 +1375,7 @@ RSpec/NamedSubject: - 'spec/resources/api/v2/tag_group_resource_spec.rb' - 'spec/resources/api/v2/tube_resource_spec.rb' -# Offense count: 454 +# Offense count: 523 # Configuration parameters: Max, AllowedGroups. RSpec/NestedGroups: Exclude: @@ -1427,11 +1435,15 @@ RSpec/NestedGroups: - 'spec/models/transfer_request_spec.rb' - 'spec/models/tube_rack_spec.rb' - 'spec/models/well_spec.rb' + - 'spec/requests/api/v2/bait_library_layouts_spec.rb' - 'spec/requests/api/v2/custom_metadatum_collections_spec.rb' - 'spec/requests/api/v2/heron/plates_spec.rb' - 'spec/requests/api/v2/heron/tube_racks_spec.rb' + - 'spec/requests/api/v2/pooled_plate_creations_spec.rb' - 'spec/requests/api/v2/sample_metadata_spec.rb' + - 'spec/requests/api/v2/specific_tube_creations_spec.rb' - 'spec/requests/api/v2/state_changes_spec.rb' + - 'spec/requests/api/v2/tag_layouts_spec.rb' - 'spec/requests/api/v2/transfers/transfers_spec.rb' - 'spec/requests/api/v2/users_spec.rb' - 'spec/sample_manifest_excel/upload/processor_spec.rb' diff --git a/app/controllers/api/v2/bait_library_layouts_controller.rb b/app/controllers/api/v2/bait_library_layouts_controller.rb index fbdafbf478..f518fdb834 100644 --- a/app/controllers/api/v2/bait_library_layouts_controller.rb +++ b/app/controllers/api/v2/bait_library_layouts_controller.rb @@ -44,7 +44,7 @@ def respond_with_errors(title, details, status) errors = details.map { |detail| { title: title, detail: detail, code: status_code, status: status_code } } - render json: { errors: errors }, status: status + render json: { errors: }, status: status end # This should only be called once per request, as it will render an exception every time it's called when any one @@ -72,7 +72,7 @@ def preview_records respond_with_errors('Record not found', record_errors, :bad_request) and return if record_errors.any? - { user: user, plate: plate } + { user:, plate: } end end end diff --git a/spec/requests/api/v2/bait_library_layouts_spec.rb b/spec/requests/api/v2/bait_library_layouts_spec.rb index 209cd30c3f..8ff389389a 100644 --- a/spec/requests/api/v2/bait_library_layouts_spec.rb +++ b/spec/requests/api/v2/bait_library_layouts_spec.rb @@ -32,7 +32,7 @@ context 'with a single resource' do describe '#GET the resource by ID' do - let(:resource) { create :bait_library_layout } + let(:resource) { create(:bait_library_layout) } context 'without included relationships' do before { api_get "#{base_endpoint}/#{resource.id}" } @@ -83,7 +83,7 @@ end describe '#PATCH a resource' do - let(:resource) { create :bait_library_layout } + let(:resource) { create(:bait_library_layout) } let(:payload) do { 'data' => { diff --git a/spec/requests/api/v2/pooled_plate_creations_spec.rb b/spec/requests/api/v2/pooled_plate_creations_spec.rb index e029379ed4..8436b20c0f 100644 --- a/spec/requests/api/v2/pooled_plate_creations_spec.rb +++ b/spec/requests/api/v2/pooled_plate_creations_spec.rb @@ -31,7 +31,7 @@ context 'with a single resource' do describe '#GET resource by ID' do - let(:resource) { create :pooled_plate_creation } + let(:resource) { create(:pooled_plate_creation) } context 'without included relationships' do before { api_get "#{base_endpoint}/#{resource.id}" } @@ -89,8 +89,8 @@ end describe '#PATCH a resource' do - let(:resource_model) { create :pooled_plate_creation } - let(:purpose) { create :plate_purpose } + let(:resource_model) { create(:pooled_plate_creation) } + let(:purpose) { create(:plate_purpose) } let(:payload) do { data: { id: resource_model.id, type: resource_type, attributes: { child_purpose_uuid: [purpose.uuid] } } } end @@ -103,7 +103,7 @@ end describe '#POST a create request' do - let(:purpose) { create :plate_purpose } + let(:purpose) { create(:plate_purpose) } let(:parents) { [create(:plate), create(:tube, prefix: 'PT')] } let(:user) { create(:user) } @@ -194,8 +194,8 @@ end context 'with conflicting relationships' do - let(:other_parents) { create_list :plate, 2 } - let(:other_user) { create :user } + let(:other_parents) { create_list(:plate, 2) } + let(:other_user) { create(:user) } let(:payload) do { data: { diff --git a/spec/requests/api/v2/specific_tube_creations_spec.rb b/spec/requests/api/v2/specific_tube_creations_spec.rb index 83338967a7..160be165a1 100644 --- a/spec/requests/api/v2/specific_tube_creations_spec.rb +++ b/spec/requests/api/v2/specific_tube_creations_spec.rb @@ -31,7 +31,7 @@ context 'with a single resource' do describe '#GET resource by ID' do - let(:resource) { create :specific_tube_creation } + let(:resource) { create(:specific_tube_creation) } context 'without included relationships' do before { api_get "#{base_endpoint}/#{resource.id}" } @@ -89,8 +89,8 @@ end describe '#PATCH a resource' do - let(:resource_model) { create :specific_tube_creation } - let(:purpose) { create :tube_purpose } + let(:resource_model) { create(:specific_tube_creation) } + let(:purpose) { create(:tube_purpose) } let(:payload) do { data: { id: resource_model.id, type: resource_type, attributes: { child_purpose_uuids: [purpose.uuid] } } } end @@ -103,7 +103,7 @@ end describe '#POST a create request' do - let(:child_purposes) { create_list :tube_purpose, 2 } + let(:child_purposes) { create_list(:tube_purpose, 2) } let(:parents) { [create(:plate), create(:tube, prefix: 'PT')] } let(:user) { create(:user) } @@ -208,8 +208,8 @@ end context 'with conflicting relationships' do - let(:other_parents) { create_list :plate, 2 } - let(:other_user) { create :user } + let(:other_parents) { create_list(:plate, 2) } + let(:other_user) { create(:user) } let(:payload) do { data: { diff --git a/spec/requests/api/v2/state_changes_spec.rb b/spec/requests/api/v2/state_changes_spec.rb index a8a2e7e3c6..e0fee7fa14 100644 --- a/spec/requests/api/v2/state_changes_spec.rb +++ b/spec/requests/api/v2/state_changes_spec.rb @@ -31,7 +31,7 @@ context 'with a single resource' do describe '#GET resource by ID' do - let(:resource) { create :state_change } + let(:resource) { create(:state_change) } context 'without included relationships' do before { api_get "#{base_endpoint}/#{resource.id}" } @@ -86,7 +86,7 @@ end describe '#PATCH a resource' do - let(:resource_model) { create :state_change } + let(:resource_model) { create(:state_change) } let(:payload) do { 'data' => { diff --git a/spec/requests/api/v2/tag_layouts_spec.rb b/spec/requests/api/v2/tag_layouts_spec.rb index aa995ae7bb..f0da50b14a 100644 --- a/spec/requests/api/v2/tag_layouts_spec.rb +++ b/spec/requests/api/v2/tag_layouts_spec.rb @@ -31,7 +31,7 @@ context 'with a single resource' do describe '#GET resource by ID' do - let(:resource) { create :tag_layout } + let(:resource) { create(:tag_layout) } context 'without included relationships' do before { api_get "#{base_endpoint}/#{resource.id}" } @@ -90,7 +90,7 @@ end describe '#PATCH a resource' do - let(:resource_model) { create :tag_layout } + let(:resource_model) { create(:tag_layout) } let(:payload) { { data: { id: resource_model.id, type: resource_type, attributes: { direction: 'columns' } } } } it 'finds no route for the method' do diff --git a/spec/resources/api/v2/bait_library_layout_resource_spec.rb b/spec/resources/api/v2/bait_library_layout_resource_spec.rb index cf7a349492..28a8fc8d68 100644 --- a/spec/resources/api/v2/bait_library_layout_resource_spec.rb +++ b/spec/resources/api/v2/bait_library_layout_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::BaitLibraryLayoutResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :bait_library_layout } + let(:resource_model) { build_stubbed(:bait_library_layout) } # Attributes it { is_expected.to have_readonly_attribute :uuid } diff --git a/spec/resources/api/v2/pooled_plate_creation_resource_spec.rb b/spec/resources/api/v2/pooled_plate_creation_resource_spec.rb index 0f076f663f..478c5e4d06 100644 --- a/spec/resources/api/v2/pooled_plate_creation_resource_spec.rb +++ b/spec/resources/api/v2/pooled_plate_creation_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::PooledPlateCreationResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :pooled_plate_creation } + let(:resource_model) { build_stubbed(:pooled_plate_creation) } # Attributes it { is_expected.to have_readonly_attribute :uuid } diff --git a/spec/resources/api/v2/specific_tube_creation_resource_spec.rb b/spec/resources/api/v2/specific_tube_creation_resource_spec.rb index 13f9fd33ab..91b73e4f6c 100644 --- a/spec/resources/api/v2/specific_tube_creation_resource_spec.rb +++ b/spec/resources/api/v2/specific_tube_creation_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::SpecificTubeCreationResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :specific_tube_creation } + let(:resource_model) { build_stubbed(:specific_tube_creation) } # Attributes it { is_expected.to have_readonly_attribute :uuid } diff --git a/spec/resources/api/v2/tag_layout_resource_spec.rb b/spec/resources/api/v2/tag_layout_resource_spec.rb index 2c46b31bef..87a0cafc66 100644 --- a/spec/resources/api/v2/tag_layout_resource_spec.rb +++ b/spec/resources/api/v2/tag_layout_resource_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Api::V2::TagLayoutResource, type: :resource do subject(:resource) { described_class.new(resource_model, {}) } - let(:resource_model) { build_stubbed :tag_layout } + let(:resource_model) { build_stubbed(:tag_layout) } # Attributes it { is_expected.to have_readonly_attribute :uuid } From 9c20660c8aed6deeed2ce4bbad1206f76242c848 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 27 Sep 2024 10:17:28 +0100 Subject: [PATCH 144/158] added validation for study level based on template name --- app/models/bulk_submission.rb | 22 +++---- .../validations_by_template_name.rb | 63 +++++++++++++++++++ 2 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 app/models/submission/validations_by_template_name.rb diff --git a/app/models/bulk_submission.rb b/app/models/bulk_submission.rb index 0a23364032..3c8c5fa313 100644 --- a/app/models/bulk_submission.rb +++ b/app/models/bulk_submission.rb @@ -32,6 +32,7 @@ class BulkSubmission # rubocop:todo Metrics/ClassLength extend ActiveModel::Naming include Submission::AssetSubmissionFinder + include Submission::ValidationsByTemplateName attr_accessor :spreadsheet, :encoding @@ -116,11 +117,9 @@ def valid_header? return false if headers.nil? return true if headers.include? 'submission name' - # rubocop:todo Layout/LineLength errors.add :spreadsheet, - "You submitted an incompatible spreadsheet. Please ensure your spreadsheet contains the 'submission name' column" - - # rubocop:enable Layout/LineLength + 'You submitted an incompatible spreadsheet. Please ensure your spreadsheet contains ' \ + "the 'submission name' column" false end @@ -150,6 +149,9 @@ def process # rubocop:todo Metrics/CyclomaticComplexity if spreadsheet_valid? submission_details = submission_structure + # Apply any additional validations based on the submission template name + apply_additional_validations_by_template_name unless errors.count > 0 + raise ActiveRecord::RecordInvalid, self if errors.count > 0 # Within a single transaction process each of the rows of the CSV file as a separate submission. Any name @@ -291,16 +293,15 @@ def submission_structure # rubocop:todo Metrics/CyclomaticComplexity # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity def shared_options!(rows) # rubocop:todo Metrics/MethodLength - # Builds an array of the common fields. Raises and exception if the fields are inconsistent + # Builds an array of the common fields. Raises an exception if the fields are inconsistent COMMON_FIELDS.map do |field| option = rows.pluck(field).uniq if option.count > 1 provided_values = option.map { |o| "'#{o}'" }.to_sentence errors.add( :spreadsheet, - # rubocop:todo Layout/LineLength - "#{field} should be identical for all requests in asset group '#{rows.first['asset group name']}'. Given values were: #{provided_values}." - # rubocop:enable Layout/LineLength + "#{field} should be identical for all requests in asset group '#{rows.first['asset group name']}'. " \ + "Given values were: #{provided_values}." ) end [field, option.first] @@ -413,10 +414,9 @@ def prepare_order(details) # rubocop:todo Metrics/CyclomaticComplexity if attributes[:asset_group].nil? attributes[:assets] = found_assets elsif found_assets.present? && found_assets != attributes[:asset_group].assets - # rubocop:todo Layout/LineLength raise StandardError, - "Asset Group '#{attributes[:asset_group].name}' contains different assets to those you specified. You may be reusing an asset group name" - # rubocop:enable Layout/LineLength + "Asset Group '#{attributes[:asset_group].name}' contains different assets to those you specified. " \ + 'You may be reusing an asset group name' end add_study_to_assets(found_assets, study) diff --git a/app/models/submission/validations_by_template_name.rb b/app/models/submission/validations_by_template_name.rb new file mode 100644 index 0000000000..cbdc1675e0 --- /dev/null +++ b/app/models/submission/validations_by_template_name.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +module Submission::ValidationsByTemplateName + # Template names + SCRNA_CORE_CDNA_PREP_GEM_X_5P = 'Limber-Htp - scRNA Core cDNA Prep GEM-X 5p' + + # Column headers + HEADER_TEMPLATE_NAME = 'template name' + HEADER_STUDY_NAME = 'study name' + HEADER_NUM_SAMPLES = 'scrna core number of samples per pool' + + # Applies additional validations based on the submission template type. + # + # This method determines the submission template type from the CSV data and calls the appropriate + # validation methods based on the template type. It assumes that all rows in the CSV have the same + # submission template name. + # If no match is found for the submission template name, no additional validations are performed. + # + # @return [void] + def apply_additional_validations_by_template_name + # depending on the submission template type, call additional validations + # NB. assumption that all rows in the csv have the same submission template name + index_of_template_name = headers.index(HEADER_TEMPLATE_NAME) + submission_template_name = csv_data_rows.first[index_of_template_name] + + case submission_template_name + # this validation is for the scRNA pipeline cDNA submission + when SCRNA_CORE_CDNA_PREP_GEM_X_5P + validate_scrna_core_samples_per_pool + end + end + + # Validates that the scrna core number of samples per pool is consistent for all rows with the same study name. + # + # This method groups the rows in the CSV data by the study name and checks if the scrna core number of samples per pool + # is the same for all rows within each study group. If inconsistencies are found, an error is added to the errors collection. + # + # @param csv_data_rows [Array>] The CSV data rows, where each row is an array of strings. + # @param headers [Array] The headers of the CSV file, used to find the index of specific columns. + # @param errors [ActiveModel::Errors] The errors object to which validation errors are added. + # + # @return [void] + def validate_scrna_core_samples_per_pool + # Group rows by study name + index_of_study_name = headers.index(HEADER_STUDY_NAME) + grouped_rows = csv_data_rows.group_by { |row| row[index_of_study_name] } + + # Iterate through each study group + grouped_rows.each do |study_name, rows| + # Get the unique values of scrna core number of samples per pool for the group + index_of_num_samples = headers.index(HEADER_NUM_SAMPLES) + list_of_uniq_number_of_samples_per_pool = rows.map { |row| row[index_of_num_samples] }.uniq + + # Check if there is more than one unique value + if list_of_uniq_number_of_samples_per_pool.size > 1 + errors.add( + :spreadsheet, + "Inconsistent values for column 'scRNA Core Number of Samples per Pool' for Study #{study_name}, " \ + 'all rows for a specific study must have the same value' + ) + end + end + end +end From 32e1214468a0146ce4efda8d2ad8ba13f8e07d58 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 27 Sep 2024 11:23:34 +0100 Subject: [PATCH 145/158] build: update action versions --- .github/workflows/update-rubocop.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-rubocop.yml b/.github/workflows/update-rubocop.yml index 80952c40d4..fb1ca03cfa 100644 --- a/.github/workflows/update-rubocop.yml +++ b/.github/workflows/update-rubocop.yml @@ -29,9 +29,9 @@ jobs: if: (github.repository_owner == 'sanger') # On the sanger fork only runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" cache: "yarn" From 11a7ee25673cb0ef96aa4243c2a8be12f4298b14 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 27 Sep 2024 11:23:43 +0100 Subject: [PATCH 146/158] build: add Techinical Debt label --- .github/workflows/update-rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update-rubocop.yml b/.github/workflows/update-rubocop.yml index fb1ca03cfa..a4a0046622 100644 --- a/.github/workflows/update-rubocop.yml +++ b/.github/workflows/update-rubocop.yml @@ -54,6 +54,7 @@ jobs: with: title: Automatic Rubocop update branch: gh_action/update_rubocop + labels: Technical Debt delete-branch: true body: | Automatic update via https://github.com/sanger/sequencescape/blob/develop/.github/workflows/update_rubocop.yml From 20bd2883d312fa8b8e3b2f721cc5aa70d6ac4a93 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 27 Sep 2024 11:38:43 +0100 Subject: [PATCH 147/158] build: try update to peter-evans/create-pull-request@v7 --- .github/workflows/update-rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-rubocop.yml b/.github/workflows/update-rubocop.yml index a4a0046622..6d5537fd15 100644 --- a/.github/workflows/update-rubocop.yml +++ b/.github/workflows/update-rubocop.yml @@ -50,7 +50,7 @@ jobs: run: bundle exec rubocop --auto-correct --disable-uncorrectable # https://github.com/marketplace/actions/create-pull-request - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v7 with: title: Automatic Rubocop update branch: gh_action/update_rubocop From 5993c5682ade869a92cc95c23b071676485c73e0 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 27 Sep 2024 12:09:23 +0100 Subject: [PATCH 148/158] moved csv files from features to spec directory --- .../validations_by_template_name.rb | 2 +- .../data/submission}/1_valid_rows.csv | 0 .../submission}/2_valid_sc_submissions.csv | 0 .../data/submission}/pcr_cycles.csv | 0 .../data/submission}/primer_panels.csv | 0 .../scrna_additional_validations_invalid.csv | 3 + .../scrna_additional_validations_valid.csv | 3 + .../template_for_bulk_submission.csv | 0 .../with_lowercase_library_type.csv | 0 .../submission}/with_unknown_library_type.csv | 0 spec/models/bulk_submission_spec.rb | 62 ++++++++++++++++++- 11 files changed, 68 insertions(+), 2 deletions(-) rename {features/submission/csv => spec/data/submission}/1_valid_rows.csv (100%) rename {features/submission/csv => spec/data/submission}/2_valid_sc_submissions.csv (100%) rename {features/submission/csv => spec/data/submission}/pcr_cycles.csv (100%) rename {features/submission/csv => spec/data/submission}/primer_panels.csv (100%) create mode 100644 spec/data/submission/scrna_additional_validations_invalid.csv create mode 100644 spec/data/submission/scrna_additional_validations_valid.csv rename {features/submission/csv => spec/data/submission}/template_for_bulk_submission.csv (100%) rename {features/submission/csv => spec/data/submission}/with_lowercase_library_type.csv (100%) rename {features/submission/csv => spec/data/submission}/with_unknown_library_type.csv (100%) diff --git a/app/models/submission/validations_by_template_name.rb b/app/models/submission/validations_by_template_name.rb index cbdc1675e0..6b41a52b9b 100644 --- a/app/models/submission/validations_by_template_name.rb +++ b/app/models/submission/validations_by_template_name.rb @@ -54,7 +54,7 @@ def validate_scrna_core_samples_per_pool if list_of_uniq_number_of_samples_per_pool.size > 1 errors.add( :spreadsheet, - "Inconsistent values for column 'scRNA Core Number of Samples per Pool' for Study #{study_name}, " \ + "Inconsistent values for column 'scRNA Core Number of Samples per Pool' for Study name '#{study_name}', " \ 'all rows for a specific study must have the same value' ) end diff --git a/features/submission/csv/1_valid_rows.csv b/spec/data/submission/1_valid_rows.csv similarity index 100% rename from features/submission/csv/1_valid_rows.csv rename to spec/data/submission/1_valid_rows.csv diff --git a/features/submission/csv/2_valid_sc_submissions.csv b/spec/data/submission/2_valid_sc_submissions.csv similarity index 100% rename from features/submission/csv/2_valid_sc_submissions.csv rename to spec/data/submission/2_valid_sc_submissions.csv diff --git a/features/submission/csv/pcr_cycles.csv b/spec/data/submission/pcr_cycles.csv similarity index 100% rename from features/submission/csv/pcr_cycles.csv rename to spec/data/submission/pcr_cycles.csv diff --git a/features/submission/csv/primer_panels.csv b/spec/data/submission/primer_panels.csv similarity index 100% rename from features/submission/csv/primer_panels.csv rename to spec/data/submission/primer_panels.csv diff --git a/spec/data/submission/scrna_additional_validations_invalid.csv b/spec/data/submission/scrna_additional_validations_invalid.csv new file mode 100644 index 0000000000..6af3f0c985 --- /dev/null +++ b/spec/data/submission/scrna_additional_validations_invalid.csv @@ -0,0 +1,3 @@ +User Login,template name,study name,project name,submission name,asset names,asset group name,read length,fragment size from,fragment size to,library type,comments,pre-capture plex level,pre-capture group,gigabases expected,scrna core number of samples per pool,scrna core cells per chip well +user,Limber-Htp - scRNA Core cDNA Prep GEM-X 5p,abc123_study,Test project,sub1,,assetgroup123,100,,,Standard,hello there,,,1.35,15, +user,Limber-Htp - scRNA Core cDNA Prep GEM-X 5p,abc123_study,Test project,sub2,,assetgroup123,100,,,Standard,hello there,,,1.35,10, diff --git a/spec/data/submission/scrna_additional_validations_valid.csv b/spec/data/submission/scrna_additional_validations_valid.csv new file mode 100644 index 0000000000..46da271f46 --- /dev/null +++ b/spec/data/submission/scrna_additional_validations_valid.csv @@ -0,0 +1,3 @@ +User Login,template name,study name,project name,submission name,asset names,asset group name,read length,fragment size from,fragment size to,library type,comments,pre-capture plex level,pre-capture group,gigabases expected,scrna core number of samples per pool,scrna core cells per chip well +user,Limber-Htp - scRNA Core cDNA Prep GEM-X 5p,abc123_study,Test project,sub1,,assetgroup123,100,,,Standard,hello there,,,1.35,15, +user,Limber-Htp - scRNA Core cDNA Prep GEM-X 5p,abc123_study,Test project,sub2,,assetgroup123,100,,,Standard,hello there,,,1.35,15, diff --git a/features/submission/csv/template_for_bulk_submission.csv b/spec/data/submission/template_for_bulk_submission.csv similarity index 100% rename from features/submission/csv/template_for_bulk_submission.csv rename to spec/data/submission/template_for_bulk_submission.csv diff --git a/features/submission/csv/with_lowercase_library_type.csv b/spec/data/submission/with_lowercase_library_type.csv similarity index 100% rename from features/submission/csv/with_lowercase_library_type.csv rename to spec/data/submission/with_lowercase_library_type.csv diff --git a/features/submission/csv/with_unknown_library_type.csv b/spec/data/submission/with_unknown_library_type.csv similarity index 100% rename from features/submission/csv/with_unknown_library_type.csv rename to spec/data/submission/with_unknown_library_type.csv diff --git a/spec/models/bulk_submission_spec.rb b/spec/models/bulk_submission_spec.rb index 6871bd386c..8d29d96378 100644 --- a/spec/models/bulk_submission_spec.rb +++ b/spec/models/bulk_submission_spec.rb @@ -6,7 +6,7 @@ subject { described_class.new(spreadsheet: submission_file, encoding: encoding) } let(:encoding) { 'Windows-1252' } - let(:spreadsheet_path) { Rails.root.join('features', 'submission', 'csv', spreadsheet_filename) } + let(:spreadsheet_path) { Rails.root.join('spec', 'data', 'submission', spreadsheet_filename) } # NB. fixture_file_upload is a Rails method on ActionDispatch::TestProcess::FixtureFile let(:submission_file) { fixture_file_upload(spreadsheet_path) } @@ -243,4 +243,64 @@ ) end end + + context 'a submission with additional template name validations' do + context 'when valid for scRNA template' do + let(:submission_template_hash) do + { + name: 'Limber-Htp - scRNA Core cDNA Prep GEM-X 5p', + submission_class_name: 'LinearSubmission', + product_catalogue: 'Generic', + submission_parameters: { + request_options: { + }, + request_types: request_types.map(&:key) + } + } + end + let(:spreadsheet_filename) { 'scrna_additional_validations_valid.csv' } + + before { SubmissionSerializer.construct!(submission_template_hash) } + + it 'is valid' do + expect(subject).to be_valid + end + + it 'generates submissions when processed' do + subject.process + expect(number_submissions_created).to eq(2) + end + + it 'generates submissions with one order' do + subject.process + expect(generated_submission.orders.count).to eq(1) + end + end + + context 'when invalid for scRNA template' do + let(:submission_template_hash) do + { + name: 'Limber-Htp - scRNA Core cDNA Prep GEM-X 5p', + submission_class_name: 'LinearSubmission', + product_catalogue: 'Generic', + submission_parameters: { + request_options: { + }, + request_types: request_types.map(&:key) + } + } + end + let(:spreadsheet_filename) { 'scrna_additional_validations_invalid.csv' } + + before { SubmissionSerializer.construct!(submission_template_hash) } + + it 'raises an error and sets an error message' do + expect { subject.process }.to raise_error(ActiveRecord::RecordInvalid) + expect(subject.errors.messages[:spreadsheet][0]).to eq( + "Inconsistent values for column 'scRNA Core Number of Samples per Pool' for " \ + "Study name 'abc123_study', all rows for a specific study must have the same value" + ) + end + end + end end From d1b8eea02825b97c14661abffaa284cb98a8e35f Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 27 Sep 2024 12:42:42 +0100 Subject: [PATCH 149/158] build: run linting tests for thr update-rubocop workflow --- .github/workflows/lint.yml | 11 +++++++++-- .github/workflows/lint_yard_docs.yml | 11 +++++++++-- .github/workflows/ruby_test.yml | 11 +++++++++-- .github/workflows/update-rubocop.yml | 3 +++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4c46e241de..4410fcd05f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,7 +1,14 @@ name: Linting on: - - push - - pull_request + push: + pull_request: + types: + # defaults + - opened + - synchronize + - reopened + # custom + - ready_for_review # required for Github-created PRs jobs: rubocop: diff --git a/.github/workflows/lint_yard_docs.yml b/.github/workflows/lint_yard_docs.yml index a4a3685061..d93fb8b1b6 100644 --- a/.github/workflows/lint_yard_docs.yml +++ b/.github/workflows/lint_yard_docs.yml @@ -1,7 +1,14 @@ name: Lint documentation on: - - push - - pull_request + push: + pull_request: + types: + # defaults + - opened + - synchronize + - reopened + # custom + - ready_for_review # required for Github-created PRs jobs: yard-junk: diff --git a/.github/workflows/ruby_test.yml b/.github/workflows/ruby_test.yml index d8da15e6b5..34f98ead59 100644 --- a/.github/workflows/ruby_test.yml +++ b/.github/workflows/ruby_test.yml @@ -16,8 +16,15 @@ env: ######## on: - - push - - pull_request + push: + pull_request: + types: + # defaults + - opened + - synchronize + - reopened + # custom + - ready_for_review # required for Github-created PRs jobs: rake_tests: diff --git a/.github/workflows/update-rubocop.yml b/.github/workflows/update-rubocop.yml index 6d5537fd15..fae2dbfa1b 100644 --- a/.github/workflows/update-rubocop.yml +++ b/.github/workflows/update-rubocop.yml @@ -55,10 +55,13 @@ jobs: title: Automatic Rubocop update branch: gh_action/update_rubocop labels: Technical Debt + draft: always-true # https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#workarounds-to-trigger-further-workflow-runs delete-branch: true body: | Automatic update via https://github.com/sanger/sequencescape/blob/develop/.github/workflows/update_rubocop.yml + Click `Ready for review` to trigger the CI checks. + This cop will trigger safe-autocorrect for new cops, and will add inline rubocop:todo for other cops. Please sanity check any changes before merging in. From c59b94a5be21d894337bf6fadb6775740ac1b0c8 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 27 Sep 2024 12:51:10 +0100 Subject: [PATCH 150/158] build: reorder PR text --- .github/workflows/update-rubocop.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-rubocop.yml b/.github/workflows/update-rubocop.yml index fae2dbfa1b..513b9bc067 100644 --- a/.github/workflows/update-rubocop.yml +++ b/.github/workflows/update-rubocop.yml @@ -60,8 +60,8 @@ jobs: body: | Automatic update via https://github.com/sanger/sequencescape/blob/develop/.github/workflows/update_rubocop.yml - Click `Ready for review` to trigger the CI checks. - This cop will trigger safe-autocorrect for new cops, and will add inline rubocop:todo for other cops. Please sanity check any changes before merging in. + + Click `Ready for review` to trigger the CI checks. From 0f05e26e34fa45522d622840dfc9df97cace4944 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 27 Sep 2024 13:03:53 +0100 Subject: [PATCH 151/158] style: add rubocop errors that snuck in due to a race-condition to todo --- .rubocop_todo.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ae552edda7..f0100b6877 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2024-09-26 14:20:02 UTC using RuboCop version 1.66.1. +# on 2024-09-27 12:02:58 UTC using RuboCop version 1.66.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -653,7 +653,7 @@ RSpec/EmptyExampleGroup: - 'spec/models/pulldown/requests_spec.rb' - 'spec/models/tag_substitutions_spec.rb' -# Offense count: 389 +# Offense count: 390 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: @@ -775,6 +775,7 @@ RSpec/ExampleLength: - 'spec/sequencescape_excel/specialised_field_spec.rb' - 'spec/sequencescape_excel/validation_spec.rb' - 'spec/tasks/support/disable_hiseq_submission_templates_spec.rb' + - 'spec/tasks/support/remove_duplicate_asset_links_spec.rb' - 'spec/views/labware/show_chromium_chip_spec.rb' - 'spec/views/samples/index_html_erb_spec.rb' - 'spec/views/samples/show_html_erb_spec.rb' @@ -915,7 +916,7 @@ RSpec/MultipleDescribes: - 'spec/lib/label_printer/asset_labels_spec.rb' - 'spec/models/qc_result/qc_result_spec.rb' -# Offense count: 946 +# Offense count: 948 # Configuration parameters: Max. RSpec/MultipleExpectations: Exclude: @@ -1138,6 +1139,7 @@ RSpec/MultipleExpectations: - 'spec/sequencescape_excel/worksheet_spec.rb' - 'spec/tasks/support/add_stock_rna_plate_to_working_dilution_parents_spec.rb' - 'spec/tasks/support/disable_hiseq_submission_templates_spec.rb' + - 'spec/tasks/support/remove_duplicate_asset_links_spec.rb' - 'spec/uat_actions/generate_plate_concentrations_spec.rb' - 'spec/uat_actions/generate_plates_spec.rb' - 'spec/uat_actions/generate_primer_panel_spec.rb' @@ -1158,7 +1160,7 @@ RSpec/MultipleExpectations: - 'spec/views/labware/show_chromium_chip_spec.rb' - 'spec/views/samples/index_html_erb_spec.rb' -# Offense count: 1114 +# Offense count: 1115 # Configuration parameters: AllowSubject, Max. RSpec/MultipleMemoizedHelpers: Exclude: @@ -1296,6 +1298,7 @@ RSpec/MultipleMemoizedHelpers: - 'spec/sequencescape_excel/specialised_field_spec.rb' - 'spec/shared_contexts/limber_shared_context.rb' - 'spec/tasks/support/add_stock_rna_plate_to_working_dilution_parents_spec.rb' + - 'spec/tasks/support/remove_duplicate_asset_links_spec.rb' - 'spec/uat_actions/generate_plates_spec.rb' - 'spec/uat_actions/generate_sample_manifest_spec.rb' - 'spec/uat_actions/generate_tag_layout_template_spec.rb' From 01994e0cceb2f7d8d4ad4c77a43e467ba9fc7169 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 27 Sep 2024 13:53:36 +0100 Subject: [PATCH 152/158] linted --- .../validations_by_template_name.rb | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/submission/validations_by_template_name.rb b/app/models/submission/validations_by_template_name.rb index 6b41a52b9b..f1834f3764 100644 --- a/app/models/submission/validations_by_template_name.rb +++ b/app/models/submission/validations_by_template_name.rb @@ -31,8 +31,9 @@ def apply_additional_validations_by_template_name # Validates that the scrna core number of samples per pool is consistent for all rows with the same study name. # - # This method groups the rows in the CSV data by the study name and checks if the scrna core number of samples per pool - # is the same for all rows within each study group. If inconsistencies are found, an error is added to the errors collection. + # This method groups the rows in the CSV data by the study name and checks if the scrna core number of samples + # per pool is the same for all rows within each study group. If inconsistencies are found, an error is added to + # the errors collection. # # @param csv_data_rows [Array>] The CSV data rows, where each row is an array of strings. # @param headers [Array] The headers of the CSV file, used to find the index of specific columns. @@ -48,16 +49,15 @@ def validate_scrna_core_samples_per_pool grouped_rows.each do |study_name, rows| # Get the unique values of scrna core number of samples per pool for the group index_of_num_samples = headers.index(HEADER_NUM_SAMPLES) - list_of_uniq_number_of_samples_per_pool = rows.map { |row| row[index_of_num_samples] }.uniq + list_of_uniq_number_of_samples_per_pool = rows.pluck(index_of_num_samples).uniq # Check if there is more than one unique value - if list_of_uniq_number_of_samples_per_pool.size > 1 - errors.add( - :spreadsheet, - "Inconsistent values for column 'scRNA Core Number of Samples per Pool' for Study name '#{study_name}', " \ - 'all rows for a specific study must have the same value' - ) - end + next unless list_of_uniq_number_of_samples_per_pool.size > 1 + errors.add( + :spreadsheet, + "Inconsistent values for column 'scRNA Core Number of Samples per Pool' for Study name '#{study_name}', " \ + 'all rows for a specific study must have the same value' + ) end end end From 2048e7356f6b4e35bd407e276c3f53fa5a701b51 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 27 Sep 2024 13:59:34 +0100 Subject: [PATCH 153/158] fixed comments --- app/models/submission/validations_by_template_name.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/submission/validations_by_template_name.rb b/app/models/submission/validations_by_template_name.rb index f1834f3764..74e858f27f 100644 --- a/app/models/submission/validations_by_template_name.rb +++ b/app/models/submission/validations_by_template_name.rb @@ -15,6 +15,11 @@ module Submission::ValidationsByTemplateName # submission template name. # If no match is found for the submission template name, no additional validations are performed. # + # Uses the following instance variables: + # csv_data_rows [Array>] The CSV data rows, where each row is an array of strings. + # headers [Array] The headers of the CSV file, used to find the index of specific columns. + # errors [ActiveModel::Errors] The errors object to which validation errors are added. + # # @return [void] def apply_additional_validations_by_template_name # depending on the submission template type, call additional validations @@ -35,10 +40,6 @@ def apply_additional_validations_by_template_name # per pool is the same for all rows within each study group. If inconsistencies are found, an error is added to # the errors collection. # - # @param csv_data_rows [Array>] The CSV data rows, where each row is an array of strings. - # @param headers [Array] The headers of the CSV file, used to find the index of specific columns. - # @param errors [ActiveModel::Errors] The errors object to which validation errors are added. - # # @return [void] def validate_scrna_core_samples_per_pool # Group rows by study name From e76022e40078decbd4234fdd692e13d6fea2ed60 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 27 Sep 2024 14:10:17 +0100 Subject: [PATCH 154/158] re-added csv file for feature test --- features/submission/csv/1_valid_rows.csv | 1 + 1 file changed, 1 insertion(+) create mode 100644 features/submission/csv/1_valid_rows.csv diff --git a/features/submission/csv/1_valid_rows.csv b/features/submission/csv/1_valid_rows.csv new file mode 100644 index 0000000000..4935dcc02d --- /dev/null +++ b/features/submission/csv/1_valid_rows.csv @@ -0,0 +1 @@ +User Login,template name,study name,project name,submission name,asset names,asset group name,read length,fragment size from,fragment size to,library type,comments user,Illumina-A - Cherrypick for pulldown - Pulldown WGS - HiSeq Paired end sequencing,abc123_study,Test project,sub,,assetgroup123,100,,,Standard,hello there \ No newline at end of file From 75c5ee4e8cd7500df4b851468a6ad080c8d6c0e9 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Fri, 27 Sep 2024 14:18:38 +0100 Subject: [PATCH 155/158] linted --- app/models/submission/validations_by_template_name.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/submission/validations_by_template_name.rb b/app/models/submission/validations_by_template_name.rb index 74e858f27f..e3ed8e1517 100644 --- a/app/models/submission/validations_by_template_name.rb +++ b/app/models/submission/validations_by_template_name.rb @@ -41,6 +41,7 @@ def apply_additional_validations_by_template_name # the errors collection. # # @return [void] + # rubocop:disable Metrics/MethodLength def validate_scrna_core_samples_per_pool # Group rows by study name index_of_study_name = headers.index(HEADER_STUDY_NAME) @@ -61,4 +62,6 @@ def validate_scrna_core_samples_per_pool ) end end + + # rubocop:enable Metrics/MethodLength end From 2b0e2da2a66c7e8615a550520127dd4ff3f3dc3f Mon Sep 17 00:00:00 2001 From: yoldas Date: Fri, 27 Sep 2024 14:30:59 +0100 Subject: [PATCH 156/158] Ignore linting errors in rake task --- spec/tasks/support/remove_duplicate_asset_links_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/tasks/support/remove_duplicate_asset_links_spec.rb b/spec/tasks/support/remove_duplicate_asset_links_spec.rb index f071dc0534..b34eebdc98 100644 --- a/spec/tasks/support/remove_duplicate_asset_links_spec.rb +++ b/spec/tasks/support/remove_duplicate_asset_links_spec.rb @@ -2,6 +2,7 @@ require 'rails_helper' +# rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations,RSpec/MultipleMemoizedHelpers RSpec.describe 'support:remove_duplicate_asset_links', type: :task do let(:clear_tasks) { Rake.application.clear } let(:load_tasks) { Rails.application.load_tasks } @@ -47,3 +48,4 @@ end end end +# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations,RSpec/MultipleMemoizedHelpers From 5017f5a7f3aeea5a9ab94e9d2ff0c13e0af3b1d8 Mon Sep 17 00:00:00 2001 From: JamesGlover <1283620+JamesGlover@users.noreply.github.com> Date: Sun, 29 Sep 2024 10:06:46 +0000 Subject: [PATCH 157/158] [create-pull-request] automated change --- Gemfile.lock | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2e589310b4..9dd2a685e4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -305,6 +305,7 @@ GEM racc (~> 1.4) nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) + ostruct (0.6.0) parallel (1.26.3) parser (3.3.5.0) ast (~> 2.4.1) @@ -380,7 +381,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rbs (3.5.1) + rbs (3.5.3) logger rbtree (0.4.6) regexp_parser (2.9.2) @@ -440,10 +441,10 @@ GEM rubocop (~> 1.41) rubocop-factory_bot (2.26.1) rubocop (~> 1.61) - rubocop-performance (1.20.2) + rubocop-performance (1.22.1) rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rails (2.26.1) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.26.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.52.0, < 2.0) @@ -519,9 +520,9 @@ GEM sys-uname (1.2.3) ffi (~> 1.1) temple (0.10.3) - test-prof (1.3.3.1) - thor (1.3.1) - tilt (2.3.0) + test-prof (1.4.2) + thor (1.3.2) + tilt (2.4.0) timecop (0.9.10) timeout (0.4.1) traceroute (0.8.1) @@ -553,11 +554,12 @@ GEM will_paginate (>= 3.0.3) xpath (3.2.0) nokogiri (~> 1.8) - yard (0.9.36) + yard (0.9.37) yard-activerecord (0.0.16) yard (>= 0.8.3) - yard-junk (0.0.9) + yard-junk (0.0.10) backports (>= 3.18) + ostruct rainbow yard zeitwerk (2.6.18) From 57413e2de73aa8e243715d73144ccd0b03f9fd0c Mon Sep 17 00:00:00 2001 From: yoldas Date: Mon, 30 Sep 2024 15:00:51 +0100 Subject: [PATCH 158/158] Update .release-version to 14.42.2 Incremented to one patch version higher than master for release prep. --- .release-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-version b/.release-version index 68779e98d9..b08f99bfbe 100644 --- a/.release-version +++ b/.release-version @@ -1 +1 @@ -14.42.0 +14.42.2