diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2dddd94ac8..3c07524d38 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,9 +27,6 @@ jobs: - name: Setup Ruby uses: sanger/.github/.github/actions/setup/ruby@master - - name: Set up yarn - run: yarn install - - name: Cache Rubocop uses: sanger/.github/.github/actions/setup/cache@master with: @@ -44,6 +41,9 @@ jobs: - name: Run rubocop run: bundle exec rubocop --extra-details --display-style-guide --parallel --format github --format progress + - name: Verify rubocop config + run: bundle exec ruboclean --preserve-comments --preserve-paths --verify + prettier: name: Prettier runs-on: ubuntu-latest diff --git a/.prettierignore b/.prettierignore index 4a84a2e34a..430d204f7f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,6 +4,7 @@ .history/* .Rakelist .rubocop_todo.yml +.rubocop.yml .ruby-lsp/vendor .yardoc .yardoc/* diff --git a/.rubocop.yml b/.rubocop.yml index 60a06423bf..0b54779d0b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,47 +1,59 @@ -inherit_from: - - .rubocop_todo.yml -plugins: - - rubocop-capybara - - rubocop-factory_bot - - rubocop-minitest - - rubocop-performance - - rubocop-rails - - rubocop-rspec - - rubocop-rspec_rails - - test-prof +--- -inherit_mode: - merge: - - Exclude +# To order the config, run: bundle exec ruboclean --preserve-comments + +inherit_from: +- ".rubocop_todo.yml" inherit_gem: test-prof: config/rubocop-rspec.yml +inherit_mode: + merge: + - Exclude + +plugins: +- rubocop-capybara +- rubocop-factory_bot +- rubocop-minitest +- rubocop-performance +- rubocop-rails +- rubocop-rspec +- rubocop-rspec_rails +- test-prof + +# env.rb and cucumber.rake are generated by cucumber-rails AllCops: NewCops: enable Exclude: - - db/schema.rb - - db/views_schema.rb - - db/archived_migrations/* - - features/support/env.rb # generated by cucumber-rails - - lib/tasks/cucumber.rake # generated by cucumber-rails - # CI installs gems in the vendor directory, which causes rubocop to try - # and cop our gems. We don't want it to. - - vendor/**/* - - bin/* - - sbin/* - - node_modules/**/* - - tmp/**/* + - db/schema.rb + - db/views_schema.rb + - features/support/env.rb + - lib/tasks/cucumber.rake + - bin/* + - node_modules/**/* + - tmp/**/* -Layout/EmptyLineAfterMagicComment: +Rails: + Enabled: true + +# Capybara +Capybara/ClickLinkOrButtonStyle: Enabled: false -Layout/EndAlignment: - EnforcedStyleAlignWith: start_of_line +# Factory Bot +FactoryBot/FactoryAssociationWithStrategy: + Enabled: false Layout/DefEndAlignment: EnforcedStyleAlignWith: def +Layout/EmptyLineAfterMagicComment: + Enabled: false + +Layout/EndAlignment: + EnforcedStyleAlignWith: start_of_line + Layout/LeadingCommentSpace: AllowRBSInlineAnnotation: true @@ -51,55 +63,16 @@ Layout/MultilineMethodCallIndentation: Layout/MultilineOperationIndentation: EnforcedStyle: indented -# There is so much existing inconsistent code that it is not worth enforcing this cop -Naming/PredicateMethod: - Enabled: false - # Step definitions are defined with Given /regex/ do ... # There is little ambiguity here, and brackets just break convention Lint/AmbiguousRegexpLiteral: Exclude: - - features/support/step_definitions/**/* - -Rails: - Enabled: true + - features/support/step_definitions/**/* -Rails/SkipsModelValidations: - Exclude: - - "db/migrate/*.rb" - - "db/migrate_asset_refactor/*.rb" - - "features/support/step_definitions/*.rb" - -# This cop doesn't always increase clarity -Style/CollectionQuerying: - Enabled: false - -Style/Documentation: - Enabled: false - -# The single-line syntax can be clearer than the multi-line version for multiple definitions -Style/EmptyClassDefinition: - Enabled: false - -Style/EmptyMethod: - EnforcedStyle: expanded - -# Only use shorthand hash syntax when all keys match the variables for better readability -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: - Enabled: false - -Style/QuotedSymbols: - Exclude: - - "bin/*" # these are generally generated files and don't need excessive linting - -Style/StringLiterals: - Exclude: - - "bin/*" # these are generally generated files and don't need excessive linting +# Unused keyword arguments are good for maintaining API compatibility, and +# applying an underscore before the keyword name breaks that API. +Lint/UnusedMethodArgument: + AllowUnusedKeywordArguments: true # Blocks are used to structure tests and are part of the shoulda dsl. # The standard BlockLength limits are too stringent for this purpose. @@ -109,192 +82,194 @@ Style/StringLiterals: # We exclude builders, as they are concerned with rendering xml Metrics/BlockLength: Exclude: - - Gemfile - - "db/seeds/**/*" - - "**/*.builder" + - Gemfile + - db/seeds/**/* + - "**/*.builder" CountAsOne: - - array - - hash - - heredoc + - array + - hash + - heredoc AllowedMethods: - - describe - - context - - background - - scenario - - namespace - - task - - included - - shared_context - - shared_examples - - shared_examples_for - - state_machine - - configure - - draw - - feature - - subject - - let - - let! - - factory - - define - - guard - - transient - - with_nested_has_many_association - - with_association - - it - - class_eval - - has_metadata - - resources - - aasm - - redefine_aasm - - model - - step - -# We have a few custom find_by methods which we maintain. -# At least for now. find_by_id_or_name is a bit clunky. -Rails/DynamicFindBy: + - describe + - context + - background + - scenario + - namespace + - task + - included + - shared_context + - shared_examples + - shared_examples_for + - state_machine + - configure + - draw + - feature + - subject + - let + - let! + - factory + - define + - guard + - transient + - with_nested_has_many_association + - with_association + - it + - class_eval + - has_metadata + - resources + - aasm + - redefine_aasm + - model + - step + +# Disable for features and tests, we want lots of tests +Metrics/ClassLength: + inherit_mode: + merge: + - Exclude + CountAsOne: + - array + - hash + - heredoc Exclude: - - "app/sample_manifest_excel/**/*" - - "test/app/sample_manifest_excel/**/*" - AllowedMethods: - - find_by_sql - - find_by_id_or_name - - find_by_id_or_name! - - find_by_barcode - -# Explicit if statements are clearer than chaining with the safe navigation operator -# particularly where there is a behavioural impact -Rails/Presence: - Enabled: false + - spec/**/* + - test/**/* -# Method length limits make little sense when you are describing a table schema -# or a view. +# Method length limits make little sense when you are describing a table schema or a view. Metrics/MethodLength: Exclude: - - "db/migrate/*" + - db/migrate/* CountAsOne: - - array - - hash - - heredoc + - array + - hash + - heredoc -Style/ClassAndModuleChildren: +# There is so much existing inconsistent code that it is not worth enforcing this cop +Naming/PredicateMethod: Enabled: false -Rails/UnknownEnv: - Environments: - - production - - development - - test - - cucumber - - profile - - staging - +# 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. 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" + - spec/requests/**/*.rb + - spec/api/**/*.rb + - spec/features/**/*.rb + - spec/views/**/*.rb +# Disable for features, as we might want to step through long processes RSpec/ExampleLength: inherit_mode: merge: - - Exclude + - Exclude CountAsOne: - - array - - hash - - heredoc - # Disable for features, as we might want to step through long processes + - array + - hash + - heredoc Exclude: - - "spec/features/**/*" + - spec/features/**/* -Metrics/ClassLength: - inherit_mode: - merge: - - Exclude - CountAsOne: - - array - - hash - - heredoc - # Disable for features and tests, we want lots of tests - Exclude: - - "spec/**/*" - - "test/**/*" -RSpecRails/AvoidSetupHook: - Exclude: - - "test/**/*" +# We want to be able to use `it do ... end` as well as `it { is_expected.to ... }` +RSpec/ImplicitSubject: + EnforcedStyle: single_statement_only + +# Due to the nature of our application, this doesn't add value to our tests +RSpec/IndexedLet: + Enabled: false RSpec/MultipleExpectations: Exclude: - - "spec/features/**/*" - -Lint/UnusedMethodArgument: - # Unused keyword arguments are good for maintaining API compatibility, and - # applying an underscore before the keyword name breaks that API. - AllowUnusedKeywordArguments: true + - spec/features/**/* -# This seems to be causing all sorts of issues with failing tests -Rails/RedundantPresenceValidationOnBelongsTo: +# We don't see a benefit to limiting the number of memoized helpers. +RSpec/MultipleMemoizedHelpers: Enabled: false -Rails/UniqueValidationWithoutIndex: - Enabled: false +# Set a more reasonable max. We've been happy with our existing nesting. +RSpec/NestedGroups: + Max: 6 -# Factory Bot -FactoryBot/FactoryAssociationWithStrategy: - Enabled: false +RSpecRails/AvoidSetupHook: + Exclude: + - test/**/* -# Capybara -Capybara/ClickLinkOrButtonStyle: - Enabled: false +# We have a few custom find_by methods which we maintain. +# At least for now. find_by_id_or_name is a bit clunky. +Rails/DynamicFindBy: + Exclude: + - app/sample_manifest_excel/**/* + AllowedMethods: + - find_by_sql + - find_by_id_or_name + - find_by_id_or_name! + - find_by_barcode -# Disabling newly introduced cops until we have time to sort out the offenses -Rails/I18nLocaleTexts: # new in 2.14 +# Not planning to internationalise the app, so this is not relevant +Rails/I18nLocaleTexts: Enabled: false -RSpecRails/InferredSpecType: # new in 2.14 +# Explicit if statements are clearer than chaining with the safe navigation operator +# particularly where there is a behavioural impact +Rails/Presence: Enabled: false -Lint/NonAtomicFileOperation: # new in 1.31 +# This seems to be causing all sorts of issues with failing tests +Rails/RedundantPresenceValidationOnBelongsTo: Enabled: false -Rails/ActionControllerTestCase: # new in 2.14 - Enabled: false +Rails/SkipsModelValidations: + Exclude: + - db/migrate/*.rb + - features/support/step_definitions/*.rb -RSpec/NoExpectationExample: # new in 2.13 +Rails/UniqueValidationWithoutIndex: Enabled: false -# New in ruby 3 upgrade -RSpec/IndexedLet: - Enabled: false +Rails/UnknownEnv: + Environments: + - production + - development + - test + - cucumber + - profile + - staging -RSpec/SpecFilePathFormat: +Style/ClassAndModuleChildren: Enabled: false -RSpec/PendingWithoutReason: +# This cop doesn't always increase clarity +Style/CollectionQuerying: Enabled: false -Performance/MapMethodChain: +Style/Documentation: Enabled: false -Rails/ThreeStateBooleanColumn: +# The single-line syntax can be clearer than the multi-line version for multiple definitions +Style/EmptyClassDefinition: Enabled: false -RSpec/ExpectInHook: - Enabled: false -# New in Ruby 3.2 upgrade -# Added to Rubocop Todo and handling from there +Style/EmptyMethod: + EnforcedStyle: expanded -RSpec/MultipleMemoizedHelpers: # new in 1.43 - Enabled: false # We don't see a benefit to limiting the number of memoized helpers. +# Only use shorthand hash syntax when all keys match the variables for better readability +Style/HashSyntax: + EnforcedShorthandSyntax: consistent -RSpec/NestedGroups: # new in 1.7 - Max: 6 # Set a more reasonable max. We've been happy with our existing nesting. +# 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: + Enabled: false -RSpec/ImplicitSubject: # new in 1.29 - EnforcedStyle: single_statement_only # We want to be able to use `it do ... end` as well as `it { is_expected.to ... }` +# these are generally generated files and don't need excessive linting +Style/QuotedSymbols: + Exclude: + - bin/* + +# these are generally generated files and don't need excessive linting +Style/StringLiterals: + Exclude: + - bin/* diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 88182357af..d85ada56a9 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 2026-02-06 14:12:50 UTC using RuboCop version 1.84.1. +# on 2026-03-06 15:42:00 UTC using RuboCop version 1.85.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 @@ -49,6 +49,14 @@ Layout/HeredocIndentation: Exclude: - 'db/seeds.rb' +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns. +# SupportedStylesAlignWith: start_of_line, relative_to_receiver +Layout/IndentationWidth: + Exclude: + - 'lib/record_loader/plate_creator_loader.rb' + # Offense count: 12 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment, AllowRBSInlineAnnotation, AllowSteepAnnotation. @@ -65,7 +73,7 @@ Layout/LeadingCommentSpace: - 'spec/models/sample_manifest/uploader_spec.rb' - 'spec/views/labware/show_html_erb_spec.rb' -# Offense count: 18 +# Offense count: 17 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedMethods, AllowedPatterns. Lint/AmbiguousBlockAssociation: @@ -73,7 +81,6 @@ Lint/AmbiguousBlockAssociation: - 'features/support/step_definitions/bulk_submission_steps.rb' - 'spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb' - 'spec/features/studies/accession_all_samples_spec.rb' - - 'spec/lib/accession/study_spec.rb' - 'spec/sample_manifest_excel/worksheet_spec.rb' - 'spec/sequencescape_excel/column_list_spec.rb' - 'spec/sequencescape_excel/column_spec.rb' @@ -504,6 +511,8 @@ Naming/VariableNumber: - 'db/seeds/0015_transfer_templates.rb' - 'spec/api/asset_audit_spec.rb' - 'spec/controllers/api/v2/heron/tube_racks_controller_spec.rb' + - 'spec/controllers/api/v2/qc_assays_controller_spec.rb' + - 'spec/controllers/api/v2/qc_results_controller_spec.rb' - 'spec/controllers/labwhere_receptions_controller_spec.rb' - 'spec/controllers/report_fails_controller_spec.rb' - 'spec/factories/accession/tags.rb' @@ -539,8 +548,6 @@ Naming/VariableNumber: - 'spec/models/transfer_request_spec.rb' - 'spec/models/well_spec.rb' - 'spec/requests/api/v2/pick_lists_spec.rb' - - 'spec/requests/api/v2/qc_assays_spec.rb' - - 'spec/requests/api/v2/qc_results_spec.rb' - 'spec/sequencescape_excel/conditional_formatting_list_spec.rb' - 'spec/uat_actions/generate_plates_spec.rb' - 'spec/uat_actions/generate_tagged_plates_spec.rb' @@ -559,6 +566,20 @@ Performance/CollectionLiteralInLoop: - 'features/support/step_definitions/sample_manifest_steps.rb' - 'spec/models/transfer_request_spec.rb' +# Offense count: 10 +Performance/MapMethodChain: + Exclude: + - 'app/api/core/service.rb' + - 'app/helpers/compound_sample_helper.rb' + - 'app/helpers/submissions_helper.rb' + - 'app/models/bait_library_layout.rb' + - 'app/models/lane.rb' + - 'app/models/submission/asset_submission_finder.rb' + - 'features/support/step_definitions/multiplexed_inbox_steps.rb' + - 'features/support/step_definitions/project_steps.rb' + - 'lib/tasks/support/update_library_types.rake' + - 'test/unit/tag_qc/qcable_statemachine_checks.rb' + # Offense count: 25 Performance/MethodObjectAsBlock: Exclude: @@ -599,7 +620,7 @@ RSpec/BeforeAfterAll: - 'spec/sample_manifest_excel/worksheet_spec.rb' - 'spec/sequencescape_excel/worksheet_spec.rb' -# Offense count: 342 +# Offense count: 341 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -607,7 +628,7 @@ RSpec/ContextWording: - 'spec/api/extraction_attributes_spec.rb' - 'spec/api/plate_purpose_spec.rb' - 'spec/api/submission_pool_spec.rb' - - 'spec/bulk_submission_excel/data_worksheet_spec.rb' + - 'spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb' - 'spec/bulk_submission_excel/download_spec.rb' - 'spec/controllers/admin/primer_panels_controller_spec.rb' - 'spec/controllers/lab_searches_controller_spec.rb' @@ -619,11 +640,10 @@ RSpec/ContextWording: - '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/lib/accession/study_spec.rb' - 'spec/lib/label_printer/asset_labels_spec.rb' - 'spec/lib/label_printer/asset_redirect_spec.rb' - 'spec/lib/label_printer/batch_plate_spec.rb' - - 'spec/lib/label_printer/sample_manifest_plate_double_spec.rb' + - 'spec/lib/label_printer/label/sample_manifest_plate_double_spec.rb' - 'spec/lib/record_loader/plate_purpose_loader_spec.rb' - 'spec/models/aliquot_spec.rb' - 'spec/models/api/messages/qc_result_io_spec.rb' @@ -685,8 +705,10 @@ RSpec/EmptyExampleGroup: RSpec/ExampleLength: Exclude: - 'spec/api/extraction_attributes_spec.rb' + - 'spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb' - 'spec/bulk_submission_excel/configuration_spec.rb' - - 'spec/bulk_submission_excel/data_worksheet_spec.rb' + - 'spec/controllers/api/v2/qc_assays_controller_spec.rb' + - 'spec/controllers/api/v2/qc_results_controller_spec.rb' - 'spec/controllers/npg_actions/assets_controller_spec.rb' - 'spec/controllers/submissions_controller_spec.rb' - 'spec/lib/accession/accessionable_spec.rb' @@ -750,8 +772,6 @@ RSpec/ExampleLength: - '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/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/tag_layout_templates_spec.rb' @@ -794,14 +814,13 @@ RSpec/ExampleLength: - 'spec/views/samples/index_html_erb_spec.rb' - 'spec/views/samples/show_html_erb_spec.rb' -# Offense count: 276 +# Offense count: 275 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. # DisallowedExamples: works RSpec/ExampleWording: Exclude: - 'spec/bulk_submission_excel/configuration_spec.rb' - - 'spec/bulk_submission_excel/data_worksheet_spec.rb' - 'spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb' - 'spec/models/heron/factories/sample_spec.rb' - 'spec/models/heron/factories/tube_rack_spec.rb' @@ -824,7 +843,28 @@ RSpec/ExampleWording: - 'spec/sequencescape_excel/validation_spec.rb' - 'spec/sequencescape_excel/worksheet_spec.rb' -# Offense count: 257 +# Offense count: 26 +RSpec/ExpectInHook: + Exclude: + - 'spec/controllers/labwhere_receptions_controller_spec.rb' + - 'spec/features/admin/changing_user_roles_spec.rb' + - 'spec/features/asset_information_spec.rb' + - 'spec/features/labware/retention_instruction_spec.rb' + - 'spec/features/retrospective_failure_spec.rb' + - 'spec/features/submissions/bulk_submissions_spec.rb' + - 'spec/jobs/sample_accessioning_job_spec.rb' + - 'spec/lib/accession/sample_spec.rb' + - 'spec/lib/accession/submission_spec.rb' + - 'spec/models/batch_spec.rb' + - 'spec/models/external_release_event_spec.rb' + - 'spec/models/plate_purpose_spec.rb' + - 'spec/models/request_spec.rb' + - 'spec/models/specific_tube_creations_spec.rb' + - 'spec/models/specific_tube_rack_creation_spec.rb' + - 'spec/models/transfer_request_collection_spec.rb' + - 'spec/uat_actions/test_submission_spec.rb' + +# Offense count: 268 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: @@ -872,7 +912,7 @@ RSpec/LeakyLocalVariable: - 'spec/models/well_spec.rb' - 'spec/shared_contexts/it_requires_login.rb' -# Offense count: 39 +# Offense count: 40 RSpec/LetSetup: Exclude: - 'spec/controllers/searches_controller_spec.rb' @@ -892,7 +932,7 @@ RSpec/LetSetup: - 'spec/models/transfer_request_collection_spec.rb' - 'spec/requests/api/v2/comments_spec.rb' -# Offense count: 39 +# Offense count: 38 # Configuration parameters: EnforcedStyle. # SupportedStyles: have_received, receive RSpec/MessageSpies: @@ -905,7 +945,6 @@ RSpec/MessageSpies: - 'spec/features/sample_manifests/create_manifest_spec.rb' - 'spec/features/sample_manifests/track_sample_manifest_updates_spec.rb' - 'spec/insdc/import_countries_spec.rb' - - 'spec/lib/accession/study_spec.rb' - 'spec/lib/method_benchmarking_spec.rb' - 'spec/lib/migration_extensions/encoding_changes_spec.rb' - 'spec/models/external_release_event_spec.rb' @@ -956,12 +995,14 @@ RSpec/MultipleExpectations: - 'spec/api/tube_purpose_spec.rb' - 'spec/api/well_spec.rb' - 'spec/api/work_completion_spec.rb' + - 'spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_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/api/v2/qc_assays_controller_spec.rb' + - 'spec/controllers/api/v2/qc_results_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' @@ -974,7 +1015,6 @@ RSpec/MultipleExpectations: - 'spec/helpers/compound_sample_helper_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/sample_spec.rb' - 'spec/lib/accession/service_spec.rb' - 'spec/lib/accession/submission_spec.rb' @@ -1090,8 +1130,6 @@ RSpec/MultipleExpectations: - '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/receptacles_spec.rb' - 'spec/requests/api/v2/request_types_spec.rb' - 'spec/requests/api/v2/requests_spec.rb' @@ -1162,7 +1200,7 @@ RSpec/MultipleExpectations: - 'spec/views/labware/show_chromium_chip_spec.rb' - 'spec/views/samples/index_html_erb_spec.rb' -# Offense count: 246 +# Offense count: 243 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: @@ -1180,7 +1218,7 @@ RSpec/NamedSubject: - 'spec/api/work_completion_spec.rb' - 'spec/controllers/studies/information_controller_spec.rb' - 'spec/controllers/studies_controller_spec.rb' - - 'spec/lib/label_printer/sample_manifest_plate_double_spec.rb' + - 'spec/lib/label_printer/label/sample_manifest_plate_double_spec.rb' - 'spec/models/aliquot_spec.rb' - 'spec/models/api/library_tube_io_spec.rb' - 'spec/models/api/messages/flowcell_io_spec.rb' @@ -1209,15 +1247,26 @@ RSpec/NamedSubject: - 'spec/models/well_spec.rb' - 'spec/models/work_order_spec.rb' -# Offense count: 2 -RSpec/RepeatedDescription: +# Offense count: 18 +# Configuration parameters: AllowedPatterns. +# AllowedPatterns: ^expect_, ^assert_ +RSpec/NoExpectationExample: Exclude: - - 'spec/sequencescape_excel/conditional_formatting_spec.rb' + - 'spec/api/work_completion_spec.rb' + - 'spec/features/admin/add_a_printer_spec.rb' + - 'spec/features/submissions/bulk_submissions_spec.rb' + - 'spec/models/lane_spec.rb' + - 'spec/models/orders/order_spec.rb' + - 'spec/models/receptacle_spec.rb' + - 'spec/models/request_spec.rb' + - 'spec/models/request_type_spec.rb' + - 'spec/models/tasks/plate_template_task_spec.rb' + - 'spec/sequencescape_excel/range_spec.rb' # Offense count: 2 -RSpec/RepeatedExample: +RSpec/RepeatedDescription: Exclude: - - 'spec/models/sample_manifest/uploader_spec.rb' + - 'spec/sequencescape_excel/conditional_formatting_spec.rb' # Offense count: 2 RSpec/RepeatedExampleGroupBody: @@ -1245,6 +1294,22 @@ RSpec/ScatteredLet: - 'spec/models/work_completion_spec.rb' - 'spec/requests/api/v2/work_orders_spec.rb' +# Offense count: 10 +# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector. +# SupportedInflectors: default, active_support +RSpec/SpecFilePathFormat: + Exclude: + - 'spec/models/library_assets_stocks_spec.rb' + - 'spec/models/location_report_form_spec.rb' + - 'spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb' + - 'spec/models/scrna_core_cdna_prep_feasibility_validator_spec.rb' + - 'spec/models/std_library_request_spec.rb' + - 'spec/models/submission/scrna_core_cdna_prep_feasibility_calcuator_spec.rb' + - 'spec/sample_manifest_excel/retention_instruction_verification_spec.rb' + - 'spec/sample_manifest_excel/upload/upload_spec.rb' + - 'spec/sequencescape_excel/configuration_spec.rb' + - 'spec/validators/novaseqx_read_length_validator_spec.rb' + # Offense count: 9 RSpec/StubbedMock: Exclude: @@ -1282,6 +1347,48 @@ Rails/ActionControllerFlashBeforeRender: - 'app/controllers/projects_controller.rb' - 'app/controllers/requests_controller.rb' +# Offense count: 37 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/ActionControllerTestCase: + Exclude: + - 'test/controllers/admin_controller_test.rb' + - 'test/controllers/admin_programs_controller_test.rb' + - 'test/controllers/admin_projects_controller_test.rb' + - 'test/controllers/admin_roles_controller_test.rb' + - 'test/controllers/admin_studies_controller_test.rb' + - 'test/controllers/admin_users_controller_test.rb' + - 'test/controllers/api/submissions_controller.rb' + - 'test/controllers/authentication_controller_test.rb' + - 'test/controllers/batches_controller_test.rb' + - 'test/controllers/events_controller_test.rb' + - 'test/controllers/get_your_qc_completed_tubes_here_controller_test.rb' + - 'test/controllers/labware_controller_test.rb' + - 'test/controllers/pipelines_controller_test.rb' + - 'test/controllers/plate_summaries_controller_test.rb' + - 'test/controllers/plate_template_controller_test.rb' + - 'test/controllers/plates_controller_test.rb' + - 'test/controllers/plates_from_tubes_controller_test.rb' + - 'test/controllers/projects_controller_test.rb' + - 'test/controllers/qc_files_controller_test.rb' + - 'test/controllers/qc_reports_controller_test.rb' + - 'test/controllers/receptacles_controller_test.rb' + - 'test/controllers/requests_comments_controller_test.rb' + - 'test/controllers/requests_controller_test.rb' + - 'test/controllers/robots_controller_test.rb' + - 'test/controllers/roles_users_controller_test.rb' + - 'test/controllers/sample_manifests_controller_test.rb' + - 'test/controllers/samples_comments_controller_test.rb' + - 'test/controllers/samples_controller_test.rb' + - 'test/controllers/sessions_controller_test.rb' + - 'test/controllers/studies_asset_groups_controller_test.rb' + - 'test/controllers/studies_comments_controller_test.rb' + - 'test/controllers/studies_controller_test.rb' + - 'test/controllers/studies_events_controller_test.rb' + - 'test/controllers/studies_sample_controller_test.rb' + - 'test/controllers/users_controller_test.rb' + - 'test/controllers/workflows_controller_test.rb' + - 'test/unit/plate_owner_test.rb' + # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/ApplicationMailer: @@ -1495,6 +1602,12 @@ Rails/RootPathnameMethods: Exclude: - 'spec/rails_helper.rb' +# Offense count: 2 +Rails/ThreeStateBooleanColumn: + Exclude: + - 'db/migrate/20250326144346_add_element_aviti_pipeline_to_request_metadata.rb' + - 'db/migrate/20250818125034_add_active_to_lot_types.rb' + # Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/WhereEquals: @@ -1876,7 +1989,7 @@ Style/NestedParenthesizedCalls: - 'app/controllers/uuids_controller.rb' - 'app/models/parsers/bioanalysis_csv_parser.rb' -# Offense count: 18 +# Offense count: 15 # This cop supports safe autocorrection (--autocorrect). Style/Not: Exclude: @@ -1885,7 +1998,6 @@ Style/Not: - 'app/controllers/studies_controller.rb' - 'app/models/pipeline/batch_validation.rb' - 'app/models/request/change_decision.rb' - - 'app/models/submission/accession_behaviour.rb' - 'app/models/submission/asset_group_behaviour.rb' - 'app/models/submission/project_validation.rb' - 'app/models/user.rb' @@ -1913,6 +2025,28 @@ Style/NumericPredicate: - 'lib/deployed.rb' - 'lib/submission_serializer.rb' +# Offense count: 32 +# Configuration parameters: AllowedClasses. +Style/OneClassPerFile: + Exclude: + - 'app/api/core/service/error_handling.rb' + - 'app/models/bulk_submission.rb' + - 'app/uploaders/polymorphic_uploader.rb' + - 'config/initializers/active_record_validations.rb' + - 'config/initializers/api_routing.rb' + - 'features/support/api.rb' + - 'lib/api_tools.rb' + - 'lib/authenticated_test_helper.rb' + - 'lib/informatics/test/helpers/authentication_helper.rb' + - 'spec/models/broadcast_event/broadcast_event_spec.rb' + - 'spec/support/api_v2_resource_matchers.rb' + - 'spec/uat_actions/uat_actions_spec.rb' + - 'test/controllers/authentication_controller_test.rb' + - 'test/lib/label_printer/labels_multiplication_test.rb' + - 'test/test_helper.rb' + - 'test/unit/eventful_entry_test.rb' + - 'test/unit/tasks/plate_transfer_task_test.rb' + # Offense count: 18 # Configuration parameters: AllowedMethods. # AllowedMethods: respond_to_missing? @@ -2027,6 +2161,31 @@ Style/Proc: - 'app/models/lib_pool_norm_tube_generator.rb' - 'app/models/qcable/statemachine.rb' +# Offense count: 20 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ReduceToHash: + Exclude: + - 'app/api/core/io/base/json_formatting_behaviour/input.rb' + - 'app/models/accession_service/base_service.rb' + - 'app/models/attributable.rb' + - 'app/models/heron/factories/concerns/contents.rb' + - 'app/models/heron/factories/concerns/recipients.rb' + - 'app/models/heron/factories/tube_rack.rb' + - 'app/models/labware.rb' + - 'app/models/robot/verification/base.rb' + - 'app/models/transfer/between_plate_and_tubes.rb' + - 'app/models/transfer_request.rb' + - 'app/models/transfer_request_collection.rb' + - 'app/uat_actions/uat_actions/test_submission.rb' + - 'app/uat_actions/uat_actions/tube_submission.rb' + - 'spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb' + - 'spec/models/robot/pick_hash_tester_helper.rb' + - 'spec/models/tag_layout_spec.rb' + - 'test/controllers/workflows_controller_test.rb' + - 'test/functional/pre_cap_groups_test.rb' + - 'test/performance/state_change_test.rb' + - 'test/unit/batch_test.rb' + # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Methods. diff --git a/Gemfile b/Gemfile index 19a37133e1..8cf19d6709 100644 --- a/Gemfile +++ b/Gemfile @@ -151,6 +151,7 @@ end group :development, :linting do # Enforces coding styles and detects some bad practices + gem 'ruboclean', require: false gem 'rubocop', require: false gem 'rubocop-capybara', require: false gem 'rubocop-factory_bot', require: false diff --git a/Gemfile.lock b/Gemfile.lock index c8ad9a573e..555ff66b94 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -283,7 +283,10 @@ GEM prism (>= 1.3.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.18.1) + json (2.19.0) + json-schema (6.2.0) + addressable (~> 2.8) + bigdecimal (>= 3.1, < 5) jsonapi-resources (0.9.0) activerecord (>= 4.1) concurrent-ruby @@ -314,6 +317,8 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.3) + mcp (0.8.0) + json-schema (>= 4.1) memoist3 (1.0.0) method_source (1.1.0) mime-types (3.7.0) @@ -363,7 +368,7 @@ GEM racc (~> 1.4) ostruct (0.6.3) parallel (1.27.0) - parser (3.3.10.1) + parser (3.3.10.2) ast (~> 2.4.1) racc pp (0.6.3) @@ -500,10 +505,12 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.7) - rubocop (1.84.1) + ruboclean (0.7.1) + rubocop (1.85.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) + mcp (~> 0.6) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) @@ -736,6 +743,7 @@ DEPENDENCIES rspec-json_expectations rspec-longrun rspec-rails (~> 8.0.0) + ruboclean rubocop rubocop-capybara rubocop-factory_bot diff --git a/app/controllers/studies/asset_groups_controller.rb b/app/controllers/studies/asset_groups_controller.rb index 8765aee307..7d640c6c8b 100644 --- a/app/controllers/studies/asset_groups_controller.rb +++ b/app/controllers/studies/asset_groups_controller.rb @@ -133,7 +133,7 @@ def print @asset_group = AssetGroup.find(params[:id]) @study = Study.find(params[:study_id]) - @labware = @asset_group.labware.select { |asset| asset.is_a?(Barcode::Barcodeable) } + @labware = @asset_group.labware.grep(Barcode::Barcodeable) end def print_labels # rubocop:todo Metrics/AbcSize, Metrics/MethodLength diff --git a/app/models/broadcast_event/order_made.rb b/app/models/broadcast_event/order_made.rb index cfe70e4176..c0f3137155 100644 --- a/app/models/broadcast_event/order_made.rb +++ b/app/models/broadcast_event/order_made.rb @@ -53,7 +53,7 @@ class BroadcastEvent::OrderMade < BroadcastEvent def plates return @plates if @plates - wells = seed.assets.select { |a| a.is_a?(Well) } + wells = seed.assets.grep(Well) return [] if wells.empty? @plates = Plate.with_wells(wells) diff --git a/app/models/lib_pool_norm_tube_generator.rb b/app/models/lib_pool_norm_tube_generator.rb index b33383681a..948b567906 100644 --- a/app/models/lib_pool_norm_tube_generator.rb +++ b/app/models/lib_pool_norm_tube_generator.rb @@ -33,7 +33,7 @@ def lib_pool_tubes @lib_pool_tubes ||= plate .children - .select { |c| c.is_a?(StockMultiplexedLibraryTube) } + .grep(StockMultiplexedLibraryTube) .reject { |tube| ignore_states.include?(tube.state) } end diff --git a/app/models/presenters/batch_submenu_presenter.rb b/app/models/presenters/batch_submenu_presenter.rb index 7b0db72aeb..ab61700e1b 100644 --- a/app/models/presenters/batch_submenu_presenter.rb +++ b/app/models/presenters/batch_submenu_presenter.rb @@ -86,11 +86,11 @@ def aviti_run_manifest? end # rubocop is suggesting changes that returns false positive - # rubocop: disable Performance/RedundantEqualityComparisonBlock + # rubocop: disable Performance/RedundantEqualityComparisonBlock, Style/PredicateWithKind def aviti_requests? @batch.requests.any? { |request| request.is_a?(ElementAvitiSequencingRequest) } end - # rubocop: enable Performance/RedundantEqualityComparisonBlock + # rubocop: enable Performance/RedundantEqualityComparisonBlock, Style/PredicateWithKind def ultima_run_manifest? @batch.released? && ultima_requests? diff --git a/features/support/step_definitions/transfer_steps.rb b/features/support/step_definitions/transfer_steps.rb index 8f70e44691..9e89e3fbcb 100644 --- a/features/support/step_definitions/transfer_steps.rb +++ b/features/support/step_definitions/transfer_steps.rb @@ -98,7 +98,7 @@ def assert_request_state(state, targets, direction, request_class) 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) + id: Array(targets).map(&association).flatten.grep(request_class).map(&:id) ).update_all(state:) end diff --git a/lib/tasks/views_schema.rake b/lib/tasks/views_schema.rake index 3dadecf438..a87ec233a8 100644 --- a/lib/tasks/views_schema.rake +++ b/lib/tasks/views_schema.rake @@ -14,7 +14,7 @@ namespace :db do schema.puts ')' end end - File.delete('./db/views_schema.old') if File.exist?('./db/views_schema.old') + FileUtils.rm_f('./db/views_schema.old') File.rename('./db/views_schema.rb', './db/views_schema.old') File.rename('./db/views_schema.tmp', './db/views_schema.rb') end diff --git a/package.json b/package.json index eead6a30fa..dcc6c990d7 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "jsbarcode": "^3.12.3", "jszip": "^3.10.1", "popper.js": "^1.16.1", - "postcss": "^8.5.6", + "postcss": "^8.5.8", "postcss-flexbugs-fixes": "^5.0.2", "postcss-import": "^14.1.0", "postcss-preset-env": "^7.8.3", diff --git a/script/support/sample_move.rb b/script/support/sample_move.rb index 83a3e856bd..4663ac1793 100644 --- a/script/support/sample_move.rb +++ b/script/support/sample_move.rb @@ -4,11 +4,11 @@ class StudySample < ApplicationRecord end # added sample class as comments are not commentable at present 21/3/2019 -class Sample +class Sample # rubocop:disable Style/OneClassPerFile include Commentable end -class Asset +class Asset # rubocop:disable Style/OneClassPerFile has_many :submitted_assets has_many :orders, through: :submitted_assets, as: :asset end diff --git a/spec/bulk_submission_excel/data_worksheet_spec.rb b/spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb similarity index 98% rename from spec/bulk_submission_excel/data_worksheet_spec.rb rename to spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb index bd22096467..ebde8e8b6f 100644 --- a/spec/bulk_submission_excel/data_worksheet_spec.rb +++ b/spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb @@ -22,7 +22,7 @@ let(:spreadsheet) { Roo::Spreadsheet.open(test_file) } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } context 'data worksheet' do let!(:worksheet) do @@ -43,7 +43,7 @@ @spreadsheet = Roo::Spreadsheet.open(test_file) end - it 'will have a axlsx worksheet' do + it 'has a axlsx worksheet' do expect(worksheet.axlsx_worksheet).to be_present end diff --git a/spec/bulk_submission_excel/download_spec.rb b/spec/bulk_submission_excel/download_spec.rb index 7c6b84f12d..fe55a38ae5 100644 --- a/spec/bulk_submission_excel/download_spec.rb +++ b/spec/bulk_submission_excel/download_spec.rb @@ -32,7 +32,7 @@ let(:assets) { create(:plate_with_untagged_wells).wells } let(:submission_template) { create(:library_and_sequencing_template) } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } context 'without columns' do let(:columns) { nil } diff --git a/spec/controllers/concerns/api/v2/disable_destroy_action_spec.rb b/spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb similarity index 94% rename from spec/controllers/concerns/api/v2/disable_destroy_action_spec.rb rename to spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb index d4614b3c97..6c2a2f8ef8 100644 --- a/spec/controllers/concerns/api/v2/disable_destroy_action_spec.rb +++ b/spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb @@ -7,7 +7,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe Api::V2::Concerns::DisableDestroyAction, type: :controller do +RSpec.describe Api::V2::Concerns::DisableDestroyAction do # We explicitly use the constant `Api::V2::DisableDestroyAction` here instead of `described_class` # because `described_class` is not accessible at the top level of the spec file where the # anonymous controller is being defined. Attempting to use `described_class` in this context diff --git a/spec/requests/api/v2/plate_controller_spec.rb b/spec/controllers/api/v2/plates_controller_spec.rb similarity index 100% rename from spec/requests/api/v2/plate_controller_spec.rb rename to spec/controllers/api/v2/plates_controller_spec.rb diff --git a/spec/requests/api/v2/qc_assays_spec.rb b/spec/controllers/api/v2/qc_assays_controller_spec.rb similarity index 94% rename from spec/requests/api/v2/qc_assays_spec.rb rename to spec/controllers/api/v2/qc_assays_controller_spec.rb index a52268b506..5c3c3d3b9f 100644 --- a/spec/requests/api/v2/qc_assays_spec.rb +++ b/spec/controllers/api/v2/qc_assays_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require './spec/requests/api/v2/shared_examples/api_key_authenticatable' -RSpec.describe Api::V2::QcAssaysController, :qc_result, with: :api_v2 do +RSpec.describe Api::V2::QcAssaysController, :qc_result, type: :request, with: :api_v2 do let(:asset_1) { attributes_for(:qc_result).merge(uuid: create(:receptacle).uuid) } let(:asset_2) { attributes_for(:qc_result).merge(uuid: create(:receptacle).uuid) } let(:asset_3) { attributes_for(:qc_result).merge(uuid: create(:receptacle).uuid) } diff --git a/spec/requests/api/v2/qc_results_spec.rb b/spec/controllers/api/v2/qc_results_controller_spec.rb similarity index 97% rename from spec/requests/api/v2/qc_results_spec.rb rename to spec/controllers/api/v2/qc_results_controller_spec.rb index 7936893685..0a63440678 100644 --- a/spec/requests/api/v2/qc_results_spec.rb +++ b/spec/controllers/api/v2/qc_results_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require './spec/requests/api/v2/shared_examples/api_key_authenticatable' -RSpec.describe Api::V2::QcResultsController, :qc_result, with: :api_v2 do +RSpec.describe Api::V2::QcResultsController, :qc_result, type: :request, with: :api_v2 do let(:asset_invalid) { attributes_for(:qc_result) } let(:base_endpoint) { '/api/v2/qc_results' } diff --git a/spec/controllers/batches_controller_spec.rb b/spec/controllers/batches_controller_spec.rb index 7855875d86..9dae4f9a15 100644 --- a/spec/controllers/batches_controller_spec.rb +++ b/spec/controllers/batches_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe BatchesController, type: :controller do +RSpec.describe BatchesController do describe '#generate_ultima_sample_sheet' do let(:current_user) { create(:user) } let(:pipeline) { create(:ultima_sequencing_pipeline) } diff --git a/spec/controllers/bioscan_control_locations_controller_spec.rb b/spec/controllers/bioscan_control_locations_controller_spec.rb index 7726208fd1..42fabd4b2f 100644 --- a/spec/controllers/bioscan_control_locations_controller_spec.rb +++ b/spec/controllers/bioscan_control_locations_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe BioscanControlLocationsController, type: :controller do +RSpec.describe BioscanControlLocationsController do describe 'POST #create' do # Plate with samples and controls let!(:plate) do diff --git a/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb b/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb index 71eef6edae..82aab0a41c 100644 --- a/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb +++ b/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe BulkSubmissionExcel::DownloadsController, type: :controller do +RSpec.describe BulkSubmissionExcel::DownloadsController do subject(:downloads_controller) { described_class.new } let(:submission) { create(:submission) } diff --git a/spec/controllers/errors_controller_spec.rb b/spec/controllers/errors_controller_spec.rb index 8997a3faeb..077ee27701 100644 --- a/spec/controllers/errors_controller_spec.rb +++ b/spec/controllers/errors_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe ErrorsController, type: :controller do +RSpec.describe ErrorsController do errors = %i[not_found internal_server_error service_unavailable] formats = [nil, :html, :json, :png, :unknown] diff --git a/spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb b/spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb index c4815f3947..c23ebb82d6 100644 --- a/spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb +++ b/spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb @@ -3,7 +3,7 @@ # For more complete tests, see spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb -RSpec.describe SampleManifestUploadWithTagSequencesController, type: :controller do +RSpec.describe SampleManifestUploadWithTagSequencesController do let(:user) { create(:user) } let(:upload_file) { 'pretend-this-is-an-actual-file' } let(:uploader) { instance_double(SampleManifest::Uploader, study: nil) } diff --git a/spec/controllers/sample_manifest_controller_spec.rb b/spec/controllers/sdb/sample_manifests_controller_spec.rb similarity index 100% rename from spec/controllers/sample_manifest_controller_spec.rb rename to spec/controllers/sdb/sample_manifests_controller_spec.rb diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 8431b94628..0742ca632e 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -4,7 +4,7 @@ # Related authentication tests are in test/controllers/authentication_controller_test.rb -RSpec.describe SessionsController, type: :controller do +RSpec.describe SessionsController do describe 'POST #login' do let(:user) { instance_double(User, id: 1) } diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index 304c9a9faf..6ae700ca4e 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe SubmissionsController, type: :controller do +RSpec.describe SubmissionsController do render_views let(:request_type) { create(:well_request_type) } diff --git a/spec/controllers/taxa_controller_spec.rb b/spec/controllers/taxa_controller_spec.rb index 700035b106..3de95ffe95 100644 --- a/spec/controllers/taxa_controller_spec.rb +++ b/spec/controllers/taxa_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe TaxaController, type: :controller do +RSpec.describe TaxaController do let(:taxa_client) { instance_double(HTTPClients::ENATaxaClient) } before do diff --git a/spec/features/migrated/move_samples_from_plates_to_tubes_spec.rb b/spec/features/migrated/move_samples_from_plates_to_tubes_spec.rb index 5e4749cf7a..8466974665 100644 --- a/spec/features/migrated/move_samples_from_plates_to_tubes_spec.rb +++ b/spec/features/migrated/move_samples_from_plates_to_tubes_spec.rb @@ -4,7 +4,7 @@ # This test verifies moving samples from plates to tubes via /plates/to_sample_tubes . -RSpec.feature 'Creating sample tubes from a plate, add to asset group, and print barcodes', type: :feature do +RSpec.feature 'Creating sample tubes from a plate, add to asset group, and print barcodes' do let(:user) { create(:user, login: 'user') } let(:sanger_barcode) { Barcode.build_sanger_code39({ machine_barcode: '1220128459804', format: 'DN' }) } let!(:study) { create(:study, name: 'Study 4696931') } 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 4000cb56b4..ad33e62f2f 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 @@ -12,7 +12,7 @@ end after do - File.delete(test_file) if File.exist?(test_file) + FileUtils.rm_f(test_file) Delayed::Worker.delay_jobs = true end diff --git a/spec/features/samples/sample_accession_errors_spec.rb b/spec/features/samples/sample_accession_errors_spec.rb index b1b954b252..faec7b13e6 100644 --- a/spec/features/samples/sample_accession_errors_spec.rb +++ b/spec/features/samples/sample_accession_errors_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Sample accession errors', :js, type: :feature do +RSpec.describe 'Sample accession errors', :js do let(:user) { create(:admin) } let(:study) { create(:managed_study, accession_number: 'ENA123') } diff --git a/spec/features/samples/sample_edit_spec.rb b/spec/features/samples/sample_edit_spec.rb index 0f099a66e1..4601462db7 100644 --- a/spec/features/samples/sample_edit_spec.rb +++ b/spec/features/samples/sample_edit_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Sample accession errors', :js, type: :feature do +RSpec.describe 'Sample accession errors', :js do let(:user) { create(:admin) } let(:sample) { create(:sample) } diff --git a/spec/features/samples/sample_spec.rb b/spec/features/samples/sample_spec.rb index eefca2e2cc..56d551489a 100644 --- a/spec/features/samples/sample_spec.rb +++ b/spec/features/samples/sample_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Sample', :js, type: :feature do +RSpec.describe 'Sample', :js do describe 'Sample study association' do let(:user) { create(:admin) } let!(:study) { create(:study, name: 'Study_PT_7125863') } diff --git a/spec/features/studies/accession_study_dac_policy_spec.rb b/spec/features/studies/accession_study_dac_policy_spec.rb index 9bdff44778..db2f238948 100644 --- a/spec/features/studies/accession_study_dac_policy_spec.rb +++ b/spec/features/studies/accession_study_dac_policy_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'EGA DAC and Policy accessioning', :accessioning_enabled, :js, type: :feature do +RSpec.describe 'EGA DAC and Policy accessioning', :accessioning_enabled, :js do include MockAccession let(:user) { create(:admin) } diff --git a/spec/features/studies/accession_study_spec.rb b/spec/features/studies/accession_study_spec.rb index eb36b8b768..dd1d457e75 100644 --- a/spec/features/studies/accession_study_spec.rb +++ b/spec/features/studies/accession_study_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Study accession number', :accessioning_enabled, :js, type: :feature do +RSpec.describe 'Study accession number', :accessioning_enabled, :js do include MockAccession let(:user) { create(:admin, first_name: 'John', last_name: 'Smith') } diff --git a/spec/helpers/delayed_jobs_helper_spec.rb b/spec/helpers/delayed_jobs_helper_spec.rb index 93f8b5cac4..e7e09a882b 100644 --- a/spec/helpers/delayed_jobs_helper_spec.rb +++ b/spec/helpers/delayed_jobs_helper_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe DelayedJobsHelper, type: :helper do +RSpec.describe DelayedJobsHelper do let(:last_error) { nil } let(:job_name) { 'DefaultJob' } let(:locked_by) { nil } diff --git a/spec/helpers/samples_helper_spec.rb b/spec/helpers/samples_helper_spec.rb index fd74b15655..90e79e1ec6 100644 --- a/spec/helpers/samples_helper_spec.rb +++ b/spec/helpers/samples_helper_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe SamplesHelper, type: :helper do +RSpec.describe SamplesHelper do describe '#save_text' do subject { helper.save_text(sample) } 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 715effe24d..77d4f42dc3 100644 --- a/spec/jobs/export_pool_xp_to_traction_job_spec.rb +++ b/spec/jobs/export_pool_xp_to_traction_job_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe ExportPoolXpToTractionJob, type: :job do +RSpec.describe ExportPoolXpToTractionJob do let(:export_job) { described_class.new(tube.human_barcode) } let(:tube) { create(:multiplexed_library_tube, sample_count: 3) } @@ -96,7 +96,7 @@ before do # Remove any cached schema file - File.delete(cache_file_path) if File.exist?(cache_file_path) + FileUtils.rm_f(cache_file_path) end context 'when the schema is cached' do diff --git a/spec/jobs/sample_accessioning_job_spec.rb b/spec/jobs/sample_accessioning_job_spec.rb index 1935b08c54..f00edb5f84 100644 --- a/spec/jobs/sample_accessioning_job_spec.rb +++ b/spec/jobs/sample_accessioning_job_spec.rb @@ -3,7 +3,7 @@ # See additional related tests in spec/models/sample_spec.rb -RSpec.describe SampleAccessioningJob, type: :job do +RSpec.describe SampleAccessioningJob do include AccessionV1ClientHelper let(:sample_metadata) { create(:sample_metadata_for_accessioning) } diff --git a/spec/lib/accession/accessionable_spec.rb b/spec/lib/accession/accessionable_spec.rb index 18061acfb9..9afb95a133 100644 --- a/spec/lib/accession/accessionable_spec.rb +++ b/spec/lib/accession/accessionable_spec.rb @@ -3,46 +3,91 @@ require 'rails_helper' RSpec.describe Accession::Accessionable, :accession, type: :model do - class Accessionobubble - include Accession::Accessionable + context 'with a class that includes Accessionable' do + class Accessionobubble + include Accession::Accessionable - def ebi_alias - 'ALIAS' + def ebi_alias + 'ALIAS' + end + + def build_xml(xml) + xml.ACCESSIONOBUBBLE 'Pop!' + end end - def build_xml(xml) - xml.ACCESSIONOBUBBLE 'Pop!' + before { allow(Time).to receive(:now).and_return(Time.zone.parse('2016-12-08T13:29:59Z')) } + + it 'has a date stamped alias' do + expect(Accessionobubble.new.ebi_alias_datestamped).to eq('ALIAS-2016-12-08T13:29:59Z') end - end - before { allow(Time).to receive(:now).and_return(Time.zone.parse('2016-12-08T13:29:59Z')) } + it 'has a file name' do + expect(Accessionobubble.new.filename).to eq('ALIAS-2016-12-08T132959Z.accessionobubble.xml') + end - it 'has a date stamped alias' do - expect(Accessionobubble.new.ebi_alias_datestamped).to eq('ALIAS-2016-12-08T13:29:59Z') - end + it 'has some xml' do + expect(Accessionobubble.new.to_xml).to be_present + end - it 'has a file name' do - expect(Accessionobubble.new.filename).to eq('ALIAS-2016-12-08T132959Z.accessionobubble.xml') - end + it 'has create a file with some text' do + accessionable = Accessionobubble.new + file = accessionable.to_file + file.open + text = file.read + expect(text).to include(accessionable.to_xml) + expect(text.last).to eq("\n") + file.close! + end - it 'has some xml' do - expect(Accessionobubble.new.to_xml).to be_present + it 'creates a file with the correct filename' do + accessionable = Accessionobubble.new + file = accessionable.to_file + expect(file.path).to end_with("_#{accessionable.filename}") + file.close! + end end - it 'has create a file with some text' do - accessionable = Accessionobubble.new - file = accessionable.to_file - file.open - text = file.read - expect(text).to include(accessionable.to_xml) - expect(text.last).to eq("\n") - file.close! - end + context 'when loading configuration' do + let(:configuration) { Accession::Configuration.new } - it 'creates a file with the correct filename' do - accessionable = Accessionobubble.new - file = accessionable.to_file - expect(file.path).to end_with("_#{accessionable.filename}") - file.close! + it 'is comparable' do + expect(Accession::Configuration.new).to eq(configuration) + end + + it 'is able to add a new file' do + configuration.add_file 'a_new_file' + expect(Accession::Configuration::FILES.length + 1).to eq(configuration.files.length) + expect(configuration.files).to include(:a_new_file) + expect(configuration).to respond_to('a_new_file=') + end + + context 'without a folder' do + it 'is not loaded' do + configuration.load! + expect(configuration).not_to be_loaded + end + end + + context 'with a valid folder' do + let(:folder) { File.join('spec', 'data', 'accession') } + + before do + configuration.folder = folder + configuration.load! + end + + it 'is loaded' do + expect(configuration).to be_loaded + end + + it 'loads the tag list' do + expect(configuration.tags).to eq(Accession::TagList.new(configuration.load_file(folder, 'tags'))) + end + + it 'freezes all of the configuration options' do + expect(configuration.tags).to be_frozen + end + end end end diff --git a/spec/lib/accession/configuration_spec.rb b/spec/lib/accession/configuration_spec.rb deleted file mode 100644 index aad3d618df..0000000000 --- a/spec/lib/accession/configuration_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe Accession::Accessionable, :accession, type: :model do - let(:configuration) { Accession::Configuration.new } - - it 'is comparable' do - expect(Accession::Configuration.new).to eq(configuration) - end - - it 'is able to add a new file' do - configuration.add_file 'a_new_file' - expect(Accession::Configuration::FILES.length + 1).to eq(configuration.files.length) - expect(configuration.files).to include(:a_new_file) - expect(configuration).to respond_to('a_new_file=') - end - - context 'without a folder' do - it 'is not loaded' do - configuration.load! - expect(configuration).not_to be_loaded - end - end - - context 'with a valid folder' do - let(:folder) { File.join('spec', 'data', 'accession') } - - before do - configuration.folder = folder - configuration.load! - end - - it 'is loaded' do - expect(configuration).to be_loaded - end - - it 'loads the tag list' do - expect(configuration.tags).to eq(Accession::TagList.new(configuration.load_file(folder, 'tags'))) - end - - it 'freezes all of the configuration options' do - expect(configuration.tags).to be_frozen - end - end -end diff --git a/spec/lib/accession/sample_spec.rb b/spec/lib/accession/sample_spec.rb index 6c96fb590b..07bcf9fa17 100644 --- a/spec/lib/accession/sample_spec.rb +++ b/spec/lib/accession/sample_spec.rb @@ -394,15 +394,13 @@ def find_value_at_tag(xml_received, tag_name) end it 'validates against the SAMPLE XSD schema' do - # Schema downloaded from https://ena-docs.readthedocs.io/en/latest/submit/general-guide/webin-v1.html xsd_path = Rails.root.join('test/data/xsd/SRA.sample.xsd') - xsd_file = File.open(xsd_path) - schema = Nokogiri::XML::Schema(xsd_file) - document = Nokogiri::XML(xml) - errors = schema.validate(document) - expect(errors).to be_empty, "XML did not validate against XSD schema: #{errors.map(&:message).join('; ')}" - ensure - xsd_file.close + File.open(xsd_path) do |xsd_file| + schema = Nokogiri::XML::Schema(xsd_file) + document = Nokogiri::XML(xml) + errors = schema.validate(document) + expect(errors).to be_empty, "XML did not validate against XSD schema: #{errors.map(&:message).join('; ')}" + end end end diff --git a/spec/lib/deployed_spec.rb b/spec/lib/deployed_spec.rb index aa7192c76d..8adecb937b 100644 --- a/spec/lib/deployed_spec.rb +++ b/spec/lib/deployed_spec.rb @@ -2,37 +2,39 @@ require 'rails_helper' -RSpec.describe Deployed::RepoData do - subject(:repo_data) { described_class.new } - - describe '#release_timestamp' do - before do - # freeze time to ensure consistent test results - allow(DateTime).to receive(:now).and_return(DateTime.parse('2025-07-18T12:00:00')) - allow(repo_data).to receive(:read_file).with('RELEASE').and_return(file_contents) # rubocop:disable RSpec/SubjectStub - end +RSpec.describe Deployed do + describe Deployed::RepoData do + subject(:repo_data) { described_class.new } + + describe '#release_timestamp' do + before do + # freeze time to ensure consistent test results + allow(DateTime).to receive(:now).and_return(DateTime.parse('2025-07-18T12:00:00')) + allow(repo_data).to receive(:read_file).with('RELEASE').and_return(file_contents) # rubocop:disable RSpec/SubjectStub + end - context 'when a RELEASE file exists with a timestamp' do - let(:file_contents) { '20231025123000' } + context 'when a RELEASE file exists with a timestamp' do + let(:file_contents) { '20231025123000' } - it 'returns the correct ISO 8601 formatted time' do - expect(repo_data.release_timestamp).to eq('2023-10-25T12:30:00') + it 'returns the correct ISO 8601 formatted time' do + expect(repo_data.release_timestamp).to eq('2023-10-25T12:30:00') + end end - end - context 'when a RELEASE file exists with a non-timestamp string' do - let(:file_contents) { 'release-v1.0.0' } + context 'when a RELEASE file exists with a non-timestamp string' do + let(:file_contents) { 'release-v1.0.0' } - it 'returns the current time in ISO 8601 format' do - expect(repo_data.release_timestamp).to eq('2025-07-18T12:00:00') + it 'returns the current time in ISO 8601 format' do + expect(repo_data.release_timestamp).to eq('2025-07-18T12:00:00') + end end - end - context 'when a RELEASE file does not exist' do - let(:file_contents) { '' } + context 'when a RELEASE file does not exist' do + let(:file_contents) { '' } - it 'returns the current time in ISO 8601 format' do - expect(repo_data.release_timestamp).to eq('2025-07-18T12:00:00') + it 'returns the current time in ISO 8601 format' do + expect(repo_data.release_timestamp).to eq('2025-07-18T12:00:00') + end end end end diff --git a/spec/lib/label_printer/batch_plate_amp_spec.rb b/spec/lib/label_printer/label/batch_plate_amp_spec.rb similarity index 100% rename from spec/lib/label_printer/batch_plate_amp_spec.rb rename to spec/lib/label_printer/label/batch_plate_amp_spec.rb diff --git a/spec/lib/label_printer/batch_tube_spec.rb b/spec/lib/label_printer/label/batch_tube_spec.rb similarity index 100% rename from spec/lib/label_printer/batch_tube_spec.rb rename to spec/lib/label_printer/label/batch_tube_spec.rb diff --git a/spec/lib/label_printer/sample_manifest_plate_double_spec.rb b/spec/lib/label_printer/label/sample_manifest_plate_double_spec.rb similarity index 100% rename from spec/lib/label_printer/sample_manifest_plate_double_spec.rb rename to spec/lib/label_printer/label/sample_manifest_plate_double_spec.rb diff --git a/spec/models/accession/sample_status_spec.rb b/spec/models/accession/sample_status_spec.rb index c55a9b8aa2..fa206d7980 100644 --- a/spec/models/accession/sample_status_spec.rb +++ b/spec/models/accession/sample_status_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe Accession::SampleStatus, type: :model do +RSpec.describe Accession::SampleStatus do let(:sample) { create(:sample) } describe 'associations' do diff --git a/spec/models/accessionable/study_spec.rb b/spec/models/accessionable/study_spec.rb index 9029e9c43d..c70b77d0bf 100644 --- a/spec/models/accessionable/study_spec.rb +++ b/spec/models/accessionable/study_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe Accessionable::Study, type: :model do +RSpec.describe Accessionable::Study do let(:user) { create(:user) } let(:study_metadata) { create(:study_metadata, study_ebi_accession_number: nil) } let(:study) { create(:study, study_metadata:) } diff --git a/spec/models/asset_links_create_edge_spec.rb b/spec/models/asset_links_create_edge_spec.rb index 975407db60..f04ebb0574 100644 --- a/spec/models/asset_links_create_edge_spec.rb +++ b/spec/models/asset_links_create_edge_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe AssetLink, type: :model do +RSpec.describe AssetLink do # rubocop:disable RSpec/InstanceVariable,Metrics/MethodLength,RSpec/ExampleLength,RSpec/MultipleExpectations # Test the overridden create_edge class method. describe '.create_edge' do diff --git a/spec/models/element_aviti_sequencing_pipeline_spec.rb b/spec/models/element_aviti_sequencing_pipeline_spec.rb index 694b4a7c6d..09a997ed52 100644 --- a/spec/models/element_aviti_sequencing_pipeline_spec.rb +++ b/spec/models/element_aviti_sequencing_pipeline_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe ElementAvitiSequencingPipeline, type: :model do +RSpec.describe ElementAvitiSequencingPipeline do describe '#post_release_batch' do let(:pipeline) { create(:element_aviti_sequencing_pipeline) } let(:batch) { create(:batch) } diff --git a/spec/models/element_aviti_sequencing_request_spec.rb b/spec/models/element_aviti_sequencing_request_spec.rb index 1a196a0099..38f4343c87 100644 --- a/spec/models/element_aviti_sequencing_request_spec.rb +++ b/spec/models/element_aviti_sequencing_request_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe ElementAvitiSequencingRequest, type: :model do +RSpec.describe ElementAvitiSequencingRequest do let(:request) { create(:element_aviti_sequencing_request) } let(:validator) { ElementAvitiSequencingRequest::ElementAvitiRequestOptionsValidator.new(request) } diff --git a/spec/models/heron/factories/concerns/contents_spec.rb b/spec/models/heron/factories/concerns/contents_spec.rb index 6e512e5017..2f02f811af 100644 --- a/spec/models/heron/factories/concerns/contents_spec.rb +++ b/spec/models/heron/factories/concerns/contents_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::Concerns::Contents, :heron, :lighthouse, type: :model do +RSpec.describe Heron::Factories::Concerns::Contents, :heron, :lighthouse do require 'rspec/mocks/standalone' let(:factory_klass) do Class.new do diff --git a/spec/models/heron/factories/event_spec.rb b/spec/models/heron/factories/event_spec.rb index 36b9737714..0dd5a773a5 100644 --- a/spec/models/heron/factories/event_spec.rb +++ b/spec/models/heron/factories/event_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::Event, :heron, :heron_events, type: :model do +RSpec.describe Heron::Factories::Event, :heron, :heron_events do let(:plate) { create(:plate) } let(:subjects) do [ diff --git a/spec/models/heron/factories/plate_from_rack_spec.rb b/spec/models/heron/factories/plate_from_rack_spec.rb index fc6a0f00b1..86ef419909 100644 --- a/spec/models/heron/factories/plate_from_rack_spec.rb +++ b/spec/models/heron/factories/plate_from_rack_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::PlateFromRack, :heron, type: :model do +RSpec.describe Heron::Factories::PlateFromRack, :heron do let(:purpose) { create(:plate_purpose, target_type: 'Plate', name: 'Stock Plate', size: '96') } let(:rack) { create(:tube_rack) } let(:plate_factory) { described_class.new(tube_rack: rack, plate_purpose: purpose) } diff --git a/spec/models/heron/factories/plate_spec.rb b/spec/models/heron/factories/plate_spec.rb index b119a792cd..f952d9ea6c 100644 --- a/spec/models/heron/factories/plate_spec.rb +++ b/spec/models/heron/factories/plate_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::Plate, :heron, :heron_events, :lighthouse, type: :model do +RSpec.describe Heron::Factories::Plate, :heron, :heron_events, :lighthouse do let(:purpose) { create(:plate_purpose, target_type: 'Plate', name: 'Stock Plate', size: '96') } let(:study) { create(:study) } let(:barcode) { '0000000001' } diff --git a/spec/models/heron/factories/sample_spec.rb b/spec/models/heron/factories/sample_spec.rb index 54f7ff80c5..a57357342e 100644 --- a/spec/models/heron/factories/sample_spec.rb +++ b/spec/models/heron/factories/sample_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::Sample, :heron, :lighthouse, type: :model do +RSpec.describe Heron::Factories::Sample, :heron, :lighthouse do let(:study) { create(:study) } describe '#valid?' do diff --git a/spec/models/heron/factories/tube_rack_spec.rb b/spec/models/heron/factories/tube_rack_spec.rb index 8ba2fcadd9..65188844db 100644 --- a/spec/models/heron/factories/tube_rack_spec.rb +++ b/spec/models/heron/factories/tube_rack_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::TubeRack, :heron, type: :model do +RSpec.describe Heron::Factories::TubeRack, :heron do let(:study) { create(:study) } let(:params) do diff --git a/spec/models/heron/factories/tube_rack_status_spec.rb b/spec/models/heron/factories/tube_rack_status_spec.rb index 8ca3b9b5cd..05e54ae46c 100644 --- a/spec/models/heron/factories/tube_rack_status_spec.rb +++ b/spec/models/heron/factories/tube_rack_status_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::TubeRackStatus, :heron, type: :model do +RSpec.describe Heron::Factories::TubeRackStatus, :heron do before { create(:study) } let(:params) { { barcode: '0000000001', status: 'validation_failed', messages: ['message 1', 'message 2'] } } diff --git a/spec/models/heron/factories/tube_spec.rb b/spec/models/heron/factories/tube_spec.rb index b8f55f84d5..ef23e493b0 100644 --- a/spec/models/heron/factories/tube_spec.rb +++ b/spec/models/heron/factories/tube_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::Tube, :heron, type: :model do +RSpec.describe Heron::Factories::Tube, :heron do let(:params) { { barcode: 'FD00000001' } } it 'is valid with all relevant attributes' do diff --git a/spec/models/library_assets_stocks_spec.rb b/spec/models/library_assets_stocks_spec.rb index febc26dd80..cbe10ccd24 100644 --- a/spec/models/library_assets_stocks_spec.rb +++ b/spec/models/library_assets_stocks_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe SampleManifest, type: :model do +RSpec.describe SampleManifest do describe 'Library behaviours' do let(:study) { create(:study) } diff --git a/spec/models/map_spec.rb b/spec/models/map_spec.rb index e48c87e784..002eed8542 100644 --- a/spec/models/map_spec.rb +++ b/spec/models/map_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe Map, type: :model do +describe Map do context 'with Chromium Chip 16-well' do # The Map class contains a nested module called Coordinate. For clarity, we # use map_class to refer to the Map class and coordinate_module to refer to diff --git a/spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb b/spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb index 10385735ae..22561d75c2 100644 --- a/spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb +++ b/spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe NovaSeq6000PESequencingRequest, type: :model do +RSpec.describe NovaSeq6000PESequencingRequest do let(:request) { create(:nova_seq_6000_p_e_sequencing_request) } let(:validator) { NovaSeq6000PESequencingRequest::NovaSeq6000PERequestOptionsValidator.new(request) } diff --git a/spec/models/plate_purpose_spec.rb b/spec/models/plate_purpose_spec.rb index 67d8aa808e..7b9c08ca29 100644 --- a/spec/models/plate_purpose_spec.rb +++ b/spec/models/plate_purpose_spec.rb @@ -9,8 +9,6 @@ shared_examples 'a plate factory' do before { expect(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode)) } - # rubocop:enable RSpec/ExpectInHook - describe '#create!' do subject { plate_purpose.create! } diff --git a/spec/models/poly_metadatum_spec.rb b/spec/models/poly_metadatum_spec.rb index 0bbaea5171..9651ec8e0e 100644 --- a/spec/models/poly_metadatum_spec.rb +++ b/spec/models/poly_metadatum_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe PolyMetadatum, type: :model do +RSpec.describe PolyMetadatum do subject(:test_metadatum) { build(:poly_metadatum) } # Tests for validations diff --git a/spec/models/presenters/batch_submenu_presenter_spec.rb b/spec/models/presenters/batch_submenu_presenter_spec.rb index 8a4f04ed04..7388891a0b 100644 --- a/spec/models/presenters/batch_submenu_presenter_spec.rb +++ b/spec/models/presenters/batch_submenu_presenter_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe Presenters::BatchSubmenuPresenter, type: :model do +RSpec.describe Presenters::BatchSubmenuPresenter do subject(:batch_submenu_presenter) { described_class.new(current_user, batch) } context 'when we are in the Ultima sequencing pipeline' do diff --git a/spec/models/sample_manifest/uploader_spec.rb b/spec/models/sample_manifest/uploader_spec.rb index 3451efe88f..85339a4ce9 100644 --- a/spec/models/sample_manifest/uploader_spec.rb +++ b/spec/models/sample_manifest/uploader_spec.rb @@ -20,7 +20,7 @@ after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } describe '#initialize' do it 'will not be valid without a filename' do diff --git a/spec/models/stock_stamper_spec.rb b/spec/models/stock_stamper_spec.rb index d9335c3a3b..50fa61aa84 100644 --- a/spec/models/stock_stamper_spec.rb +++ b/spec/models/stock_stamper_spec.rb @@ -100,10 +100,11 @@ end it 'generates the right tecan file' do - file = File.open('spec/data/tecan/stock_stamper.gwl', 'rb') - expected_output = file.read - @stock_stamper.generate_tecan_gwl_file_as_text - expect(@stock_stamper.file_content).to eq expected_output + File.open('spec/data/tecan/stock_stamper.gwl', 'rb') do |file| + expected_output = file.read + @stock_stamper.generate_tecan_gwl_file_as_text + expect(@stock_stamper.file_content).to eq expected_output + end end it 'creates asset_audit on plate' do diff --git a/spec/models/tag_group_form_object_spec.rb b/spec/models/tag_group/form_object_spec.rb similarity index 100% rename from spec/models/tag_group_form_object_spec.rb rename to spec/models/tag_group/form_object_spec.rb diff --git a/spec/models/tube_purpose_spec.rb b/spec/models/tube/purpose_spec.rb similarity index 100% rename from spec/models/tube_purpose_spec.rb rename to spec/models/tube/purpose_spec.rb diff --git a/spec/models/tube_from_plate_creation_spec.rb b/spec/models/tube_from_plate_creation_spec.rb index c55c825a1f..a9e3419580 100644 --- a/spec/models/tube_from_plate_creation_spec.rb +++ b/spec/models/tube_from_plate_creation_spec.rb @@ -3,7 +3,7 @@ # spec/models/tube_from_plate_creation_spec.rb require 'rails_helper' -RSpec.describe TubeFromPlateCreation, type: :model do +RSpec.describe TubeFromPlateCreation do let(:child_purpose) { create(:tube_purpose) } let(:child) { create(:tube) } let(:parent) { create(:plate) } diff --git a/spec/models/ultima_sequencing_pipeline_spec.rb b/spec/models/ultima_sequencing_pipeline_spec.rb index cb83f647db..9e55c1018e 100644 --- a/spec/models/ultima_sequencing_pipeline_spec.rb +++ b/spec/models/ultima_sequencing_pipeline_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe UltimaSequencingPipeline, type: :model do +RSpec.describe UltimaSequencingPipeline do let(:pipeline) do described_class.new( workflow: Workflow.new, diff --git a/spec/models/ultima_sequencing_request_spec.rb b/spec/models/ultima_sequencing_request_spec.rb index eee50a02ff..d152679b4e 100644 --- a/spec/models/ultima_sequencing_request_spec.rb +++ b/spec/models/ultima_sequencing_request_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe UltimaSequencingRequest, type: :model do +RSpec.describe UltimaSequencingRequest do let(:request) { create(:ultima_sequencing_request) } describe 'Validations' do diff --git a/spec/resources/api/v2/faculty_sponsor_spec.rb b/spec/resources/api/v2/faculty_sponsor_resource_spec.rb similarity index 100% rename from spec/resources/api/v2/faculty_sponsor_spec.rb rename to spec/resources/api/v2/faculty_sponsor_resource_spec.rb diff --git a/spec/resources/api/v2/project_resource_spec.rb b/spec/resources/api/v2/project_resource_spec.rb deleted file mode 100644 index 80f1f93da1..0000000000 --- a/spec/resources/api/v2/project_resource_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' -require './app/resources/api/v2/sample_resource' - -RSpec.describe Api::V2::SampleResource, type: :resource do - subject(:resource) { described_class.new(sample, {}) } - - let(:sample) { create(:sample) } - - it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording - expect(resource).to have_attribute :sanger_sample_id - expect(resource).to have_attribute :uuid - end -end diff --git a/spec/sample_manifest_excel/download_spec.rb b/spec/sample_manifest_excel/download_spec.rb index bf634bd64f..51aafc74ce 100644 --- a/spec/sample_manifest_excel/download_spec.rb +++ b/spec/sample_manifest_excel/download_spec.rb @@ -23,7 +23,7 @@ def save_file after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } it 'is not valid without a sample manifest' do download = diff --git a/spec/sample_manifest_excel/retention_instruction_verification_spec.rb b/spec/sample_manifest_excel/retention_instruction_verification_spec.rb index 0c6a533ec2..78eed4c49d 100644 --- a/spec/sample_manifest_excel/retention_instruction_verification_spec.rb +++ b/spec/sample_manifest_excel/retention_instruction_verification_spec.rb @@ -14,7 +14,7 @@ after do SampleManifestExcel.reset! - File.delete(test_file) if File.exist?(test_file) + FileUtils.rm_f(test_file) end shared_examples 'manifest with retention instruction' do |template_name, config_column| diff --git a/spec/sample_manifest_excel/tags_spec.rb b/spec/sample_manifest_excel/tags_spec.rb index 4c85c3701e..f2a4a02625 100644 --- a/spec/sample_manifest_excel/tags_spec.rb +++ b/spec/sample_manifest_excel/tags_spec.rb @@ -59,7 +59,7 @@ def initialize(upload) after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } context 'tag sequences' do let(:columns) { SampleManifestExcel.configuration.columns.tube_multiplexed_library_with_tag_sequences.dup } diff --git a/spec/sample_manifest_excel/test_download_spec.rb b/spec/sample_manifest_excel/test_download_spec.rb index 12ee3fb207..251f745ecc 100644 --- a/spec/sample_manifest_excel/test_download_spec.rb +++ b/spec/sample_manifest_excel/test_download_spec.rb @@ -27,7 +27,7 @@ after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } it 'creates a file' do expect(File.file?(test_file)) diff --git a/spec/sample_manifest_excel/upload/data_spec.rb b/spec/sample_manifest_excel/upload/data_spec.rb index b1bbeb7c2d..e739d0ad36 100644 --- a/spec/sample_manifest_excel/upload/data_spec.rb +++ b/spec/sample_manifest_excel/upload/data_spec.rb @@ -19,7 +19,7 @@ after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } it 'is not valid without a filename' do expect(described_class.new(nil)).not_to be_valid diff --git a/spec/sample_manifest_excel/upload/processor_spec.rb b/spec/sample_manifest_excel/upload/processor_spec.rb index 8462938501..8f8a97b21e 100644 --- a/spec/sample_manifest_excel/upload/processor_spec.rb +++ b/spec/sample_manifest_excel/upload/processor_spec.rb @@ -44,7 +44,7 @@ def cell(row, column) download.save(test_file_name) end - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } shared_examples 'it updates downstream aliquots' do |rows, columns| it 'will update the aliquots downstream if aliquots data has changed and override is set to true' do @@ -296,7 +296,7 @@ def cell(row, column) 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) } + after { FileUtils.rm_f(new_test_file_name) } shared_examples_for 'a mandatory field in the manifest' do it 'cannot have blank' do @@ -333,7 +333,7 @@ def cell(row, column) 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) } + after { FileUtils.rm_f(new_test_file_name) } it 'cannot have blank retention instruction' do column = download.worksheet.columns.find_by(:name, :retention_instruction) @@ -437,7 +437,7 @@ def cell(row, column) upload.sample_manifest.state = 'completed' end - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it_behaves_like 'it updates downstream aliquots', [10, 11], insert_size_from: 6, insert_size_to: 7, i7: 2 end @@ -509,7 +509,7 @@ def cell(row, column) upload.sample_manifest.state = 'completed' end - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it 'will update the aliquots downstream if aliquots data has changed and override is set to true' do cell(10, 7).value = '100' @@ -685,7 +685,7 @@ def cell(row, column) upload.sample_manifest.state = 'completed' end - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it 'will update the samples if samples data has changed and override is set true' do reupload = @@ -731,7 +731,7 @@ def cell(row, column) upload.sample_manifest.state = 'completed' end - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it 'the same barcode cannot be used for multiple plates' do cell(9, 0).value = 'CGAP-00000' @@ -767,7 +767,7 @@ def cell(row, column) upload.sample_manifest.state = 'completed' end - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it 'the retention instructions cannot be left blank' do col1 = download.worksheet.columns.find_by(:name, :retention_instruction).number - 1 diff --git a/spec/sample_manifest_excel/upload/rows_spec.rb b/spec/sample_manifest_excel/upload/rows_spec.rb index 8efd3e9186..50abecd143 100644 --- a/spec/sample_manifest_excel/upload/rows_spec.rb +++ b/spec/sample_manifest_excel/upload/rows_spec.rb @@ -16,7 +16,7 @@ after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } before do create(:insdc_country, name: 'United Kingdom') diff --git a/spec/sample_manifest_excel/upload/upload_spec.rb b/spec/sample_manifest_excel/upload/upload_spec.rb index fb7456dae6..1d180f88d6 100644 --- a/spec/sample_manifest_excel/upload/upload_spec.rb +++ b/spec/sample_manifest_excel/upload/upload_spec.rb @@ -18,7 +18,7 @@ after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } before do create(:insdc_country, name: 'United Kingdom') diff --git a/spec/sample_manifest_excel/worksheet_spec.rb b/spec/sample_manifest_excel/worksheet_spec.rb index b77883e4d1..b507967eb2 100644 --- a/spec/sample_manifest_excel/worksheet_spec.rb +++ b/spec/sample_manifest_excel/worksheet_spec.rb @@ -30,7 +30,7 @@ def save_file after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } context 'type' do let(:options) { { workbook: workbook, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' } } diff --git a/spec/sequencescape_excel/worksheet_spec.rb b/spec/sequencescape_excel/worksheet_spec.rb index 118cb6cf58..f5a71e57a3 100644 --- a/spec/sequencescape_excel/worksheet_spec.rb +++ b/spec/sequencescape_excel/worksheet_spec.rb @@ -34,7 +34,7 @@ def save_file after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } describe 'validations ranges worksheet' do let!(:range_list) { SampleManifestExcel.configuration.ranges.dup } diff --git a/spec/views/batches/print_amp_plate_labels_spec.rb b/spec/views/batches/print_amp_plate_labels_spec.rb index 8cce2e1a7b..d1ecc5616c 100644 --- a/spec/views/batches/print_amp_plate_labels_spec.rb +++ b/spec/views/batches/print_amp_plate_labels_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'batches/print_amp_plate_labels.html.erb', type: :view do +RSpec.describe 'batches/print_amp_plate_labels.html.erb' do include AuthenticatedSystem let(:current_user) { create(:user) } diff --git a/spec/views/batches/print_labels_spec.rb b/spec/views/batches/print_labels_spec.rb index 696ca3397c..b83806507f 100644 --- a/spec/views/batches/print_labels_spec.rb +++ b/spec/views/batches/print_labels_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'batches/print_labels.html.erb', type: :view do +RSpec.describe 'batches/print_labels.html.erb' do include AuthenticatedSystem let(:current_user) { create(:user) } diff --git a/test/unit/import_fluidigm_data_test.rb b/test/unit/import_fluidigm_data_test.rb index 072e6e38f5..d10eb08e84 100644 --- a/test/unit/import_fluidigm_data_test.rb +++ b/test/unit/import_fluidigm_data_test.rb @@ -9,23 +9,15 @@ class ImportFluidigmDataTest < ActiveSupport::TestCase NC = 'Unknown' def create_fluidigm_file - @file = File.open("#{Rails.root}/test/data/fluidigm.csv") - @fluidigm = FluidigmFile.new(@file.read) - @well_maps = { - 'S06' => { - markers: [XY, XY, XY], - count: 94 - }, - 'S04' => { - markers: [NC, XX, XX], - count: 92 - }, - 'S43' => { - markers: [XX, XX, XX], - count: 94 + File.open("#{Rails.root}/test/data/fluidigm.csv") do |file| + @fluidigm = FluidigmFile.new(file.read) + @well_maps = { + 'S06' => { markers: [XY, XY, XY], count: 94 }, + 'S04' => { markers: [NC, XX, XX], count: 92 }, + 'S43' => { markers: [XX, XX, XX], count: 94 } } - } - @fluidigm + @fluidigm + end end def create_stock_plate(barcode) diff --git a/yarn.lock b/yarn.lock index e10b4ef20f..86edb394bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1922,7 +1922,7 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.1.0, postcss-value-parser@^ resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== -postcss@^8.4.33, postcss@^8.4.43, postcss@^8.5.6: +postcss@^8.4.33, postcss@^8.4.43: version "8.5.6" resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.6.tgz#2825006615a619b4f62a9e7426cc120b349a8f3c" integrity sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg== @@ -1931,6 +1931,15 @@ postcss@^8.4.33, postcss@^8.4.43, postcss@^8.5.6: picocolors "^1.1.1" source-map-js "^1.2.1" +postcss@^8.5.8: + version "8.5.8" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.8.tgz#6230ecc8fb02e7a0f6982e53990937857e13f399" + integrity sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg== + dependencies: + nanoid "^3.3.11" + picocolors "^1.1.1" + source-map-js "^1.2.1" + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"