diff --git a/.release-version b/.release-version index 84cc5294..ec6d649b 100644 --- a/.release-version +++ b/.release-version @@ -1 +1 @@ -1.18.0 +1.18.1 diff --git a/.ruby-version b/.ruby-version index f9892605..7921bd0c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.4.4 +3.4.8 diff --git a/Gemfile.lock b/Gemfile.lock index 2bed2b91..c0811f51 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -95,7 +95,7 @@ GEM execjs (~> 2) base64 (0.3.0) benchmark (0.5.0) - bigdecimal (3.3.1) + bigdecimal (4.0.1) bootsnap (1.21.1) msgpack (~> 1.2) bootstrap-datepicker-rails (1.10.0.1) @@ -155,18 +155,20 @@ GEM faraday-retry (1.0.3) faraday_middleware (1.2.0) faraday (~> 1.0) - ffi (1.16.3) + ffi (1.17.3-arm64-darwin) + ffi (1.17.3-x86_64-darwin) + ffi (1.17.3-x86_64-linux-gnu) globalid (1.3.0) activesupport (>= 6.1) hashie (5.1.0) logger - i18n (1.14.7) + i18n (1.14.8) concurrent-ruby (~> 1.0) jquery-rails (4.6.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.16.0) + json (2.18.1) json_api_client (1.21.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) @@ -180,7 +182,8 @@ GEM childprocess (~> 5.0) logger (~> 1.6) lint_roller (1.1.0) - listen (3.9.0) + listen (3.10.0) + logger rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) @@ -204,7 +207,7 @@ GEM minitest-rails-capybara (0.0.2) capybara minitest-rails - mocha (2.8.2) + mocha (3.0.1) ruby2_keywords (>= 0.0.5) msgpack (1.8.0) multi_json (1.15.0) @@ -219,7 +222,7 @@ GEM timeout net-smtp (0.5.1) net-protocol - nio4r (2.7.4) + nio4r (2.7.5) nokogiri (1.18.10-arm64-darwin) racc (~> 1.4) nokogiri (1.18.10-x86_64-darwin) @@ -231,17 +234,17 @@ GEM ostruct (>= 0.2) ostruct (0.6.3) parallel (1.27.0) - parser (3.3.10.0) + parser (3.3.10.1) ast (~> 2.4.1) racc - prism (1.6.0) + prism (1.9.0) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) pry-rails (0.3.11) pry (>= 0.13.0) public_suffix (6.0.1) - puma (7.1.0) + puma (7.2.0) nio4r (~> 2.0) racc (1.8.1) rack (2.2.21) @@ -282,14 +285,14 @@ GEM rainbow (3.1.1) rake (13.3.1) rb-fsevent (0.11.2) - rb-inotify (0.10.1) + rb-inotify (0.11.1) ffi (~> 1.0) regexp_parser (2.11.3) rexml (3.4.4) roo (2.8.3) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) - rubocop (1.81.7) + rubocop (1.84.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -297,13 +300,13 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.47.1, < 2.0) + rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.48.0) + rubocop-ast (1.49.0) parser (>= 3.3.7.2) - prism (~> 1.4) - rubocop-rails (2.34.0) + prism (~> 1.7) + rubocop-rails (2.34.3) activesupport (>= 4.2.0) lint_roller (~> 1.1) rack (>= 1.1) @@ -321,7 +324,7 @@ GEM sprockets-rails tilt securerandom (0.4.1) - selenium-webdriver (4.39.0) + selenium-webdriver (4.40.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) @@ -347,7 +350,8 @@ GEM actionpack (>= 6.1) activesupport (>= 6.1) sprockets (>= 3.0.0) - syslog (0.2.0) + syslog (0.4.0) + logger thor (1.4.0) tilt (2.1.0) timecop (0.9.10) @@ -358,7 +362,7 @@ GEM execjs (>= 0.3.0, < 3) unicode-display_width (3.2.0) unicode-emoji (~> 4.1) - unicode-emoji (4.1.0) + unicode-emoji (4.2.0) websocket (1.2.11) websocket-driver (0.8.0) base64 @@ -373,6 +377,7 @@ PLATFORMS arm64-darwin-22 arm64-darwin-23 arm64-darwin-24 + arm64-darwin-25 x86_64-darwin-21 x86_64-linux diff --git a/app/controllers/concerns/barcode_printing.rb b/app/controllers/concerns/barcode_printing.rb index 4d4e9fa2..c8275e6c 100644 --- a/app/controllers/concerns/barcode_printing.rb +++ b/app/controllers/concerns/barcode_printing.rb @@ -4,10 +4,6 @@ # Include to provide barcode printing functionality to a controller module BarcodePrinting def find_printer - @printer = api.barcode_printer.find(params[:barcode_printer]) - end - - def find_printer_v2 - @printer_v2 = Sequencescape::Api::V2::BarcodePrinter.where(uuid: params[:barcode_printer]).first + @printer = Sequencescape::Api::V2::BarcodePrinter.where(uuid: params[:barcode_printer]).first end end diff --git a/app/controllers/qcables_controller.rb b/app/controllers/qcables_controller.rb index c928e3bd..e05f46f0 100644 --- a/app/controllers/qcables_controller.rb +++ b/app/controllers/qcables_controller.rb @@ -6,7 +6,7 @@ class QcablesController < ApplicationController include BarcodePrinting before_action :find_user, :find_lot - before_action :find_printer_v2, only: [:create] + before_action :find_printer, only: [:create] ## # This action should generally get called through the nested @@ -87,7 +87,7 @@ def print_labels(qc_creator) end begin - BarcodeSheet.new(@printer_v2, labels).print! + BarcodeSheet.new(@printer, labels).print! rescue BarcodeSheet::PrintError => e flash[:danger] = "There was a problem printing your barcodes. Your #{qcable_name.pluralize} have still been created. #{e.message}" rescue Errno::ECONNREFUSED diff --git a/app/models/qc_asset_creator/multiple_tag2_conversion.rb b/app/models/qc_asset_creator/multiple_tag2_conversion.rb index a68790a2..2ccd682b 100644 --- a/app/models/qc_asset_creator/multiple_tag2_conversion.rb +++ b/app/models/qc_asset_creator/multiple_tag2_conversion.rb @@ -105,8 +105,8 @@ def tag2_qcables @tag2_qcables ||= api.search.find(Settings.searches['Find qcable by barcode']) .all(Gatekeeper::Qcable, barcode: tag2_tubes_barcodes.values) .inject({}) do |hash, qcable| - hash[qcable.barcode.ean13] = qcable - hash + hash[qcable.barcode.ean13] = qcable + hash end end diff --git a/lib/tasks/config.rake b/lib/tasks/config.rake index c4787bf9..6d7ac34a 100644 --- a/lib/tasks/config.rake +++ b/lib/tasks/config.rake @@ -6,13 +6,6 @@ namespace :config do task generate: :environment do api = Sequencescape::Api.new(Gatekeeper::Application.config.api_connection_options) - barcode_printer_uuid = lambda do |printers| - ->(printer_name) { - printers.detect { |prt| prt.name == printer_name }.try(:uuid) || - raise("Printer #{printer_name}: not found!") - } - end.(api.barcode_printer.all) - # Build the configuration file based on the server we are connected to. CONFIG = {}.tap do |configuration| configuration[:searches] = {}.tap do |searches| @@ -25,8 +18,8 @@ namespace :config do configuration[:printers] = Hash.new { |h, i| h[i] = Array.new }.tap do |printers| approved_printers = Gatekeeper::Application.config.approved_printers puts 'Preparing printers ...' - selected = api.barcode_printer.all.select { |printer| printer.active && (approved_printers == :all || approved_printers.include?(printer.name)) } - selected.each { |printer| printers[printer.type.name] << { name: printer.name, uuid: printer.uuid } } + selected = Sequencescape::Api::V2::BarcodePrinter.all.select { |printer| printer.active && (approved_printers == :all || approved_printers.include?(printer.name)) } + selected.each { |printer| printers[printer.barcode_type] << { name: printer.name, uuid: printer.uuid } } end # Might want to switch this out for something more dynamic, but seeing as we'll almost certainly be working with a filtered set diff --git a/test/controllers/barcode_labels_controller_test.rb b/test/controllers/barcode_labels_controller_test.rb index a685418f..5c38649e 100644 --- a/test/controllers/barcode_labels_controller_test.rb +++ b/test/controllers/barcode_labels_controller_test.rb @@ -7,8 +7,6 @@ class BarcodeLabelsControllerTest < ActionController::TestCase setup do mock_api - printer = api.barcode_printer.find('baac0dea-0000-0000-0000-000000000000') - printer.stubs(:print_service).returns('PMB') @params = { prefix: 'ABC', study: 'Study1', @@ -19,6 +17,9 @@ class BarcodeLabelsControllerTest < ActionController::TestCase end test 'should print barcodes and return success' do + Sequencescape::Api::V2::BarcodePrinter.expects(:where).returns([Sequencescape::Api::V2::BarcodePrinter.new( + print_service: 'PMB', name: 'Test Printer', barcode_type: 'something' + )]) mock_barcode_sheet = mock('printer') mock_barcode_sheet.expects(:print!).returns(true) BarcodeSheet.expects(:new).returns(mock_barcode_sheet) @@ -31,6 +32,9 @@ class BarcodeLabelsControllerTest < ActionController::TestCase end test 'should handle BarcodeSheet::PrintError' do + Sequencescape::Api::V2::BarcodePrinter.expects(:where).returns([Sequencescape::Api::V2::BarcodePrinter.new( + print_service: 'PMB', name: 'Test Printer', barcode_type: 'something' + )]) mock_barcode_sheet = mock('printer') mock_barcode_sheet.expects(:print!).raises(BarcodeSheet::PrintError.new('Printer jammed')) BarcodeSheet.expects(:new).returns(mock_barcode_sheet) @@ -44,6 +48,9 @@ class BarcodeLabelsControllerTest < ActionController::TestCase end test 'should handle connection refused error' do + Sequencescape::Api::V2::BarcodePrinter.expects(:where).returns([Sequencescape::Api::V2::BarcodePrinter.new( + print_service: 'PMB', name: 'Test Printer', barcode_type: 'something' + )]) mock_barcode_sheet = mock('printer') mock_barcode_sheet.expects(:print!).raises(Errno::ECONNREFUSED) BarcodeSheet.expects(:new).returns(mock_barcode_sheet) diff --git a/test/controllers/stamps_controller_test.rb b/test/controllers/stamps_controller_test.rb index 01105bdf..5b56b80b 100644 --- a/test/controllers/stamps_controller_test.rb +++ b/test/controllers/stamps_controller_test.rb @@ -112,8 +112,8 @@ class StampsControllerTest < ActionController::TestCase @robot.expects(:valid?) .with('58000000180', @lot, - '58000000281' => @plate_a, - '58000000382' => @plate_b) + { '58000000281' => @plate_a, + '58000000382' => @plate_b }) .returns([true, 'Okay']) @request.headers['Accept'] = 'application/json' post :validation, params: { @@ -147,8 +147,8 @@ class StampsControllerTest < ActionController::TestCase @robot.expects(:valid?) .with('58000000180', @lot, - '58000000281' => @plate_a, - '58000000382' => @plate_c) + { '58000000281' => @plate_a, + '58000000382' => @plate_c }) .returns([false, 'Not okay']) @request.headers['Accept'] = 'application/json' @@ -242,13 +242,12 @@ class StampsControllerTest < ActionController::TestCase @robot.expects(:valid?) .with('58000000180', @lot, - '58000000281' => @plate_a, - '58000000382' => @plate_b) + { '58000000281' => @plate_a, '58000000382' => @plate_b }) .returns([true, 'Okay']) @robot.expects(:beds_for).with( - '58000000281' => @plate_a, - '58000000382' => @plate_b + { '58000000281' => @plate_a, + '58000000382' => @plate_b } ) .returns([ { bed: '2', order: 1, qcable: '11111111-2222-3333-4444-100000000001' }, @@ -303,13 +302,13 @@ class StampsControllerTest < ActionController::TestCase @robot.expects(:valid?) .with('58000000180', @lot, - '58000000281' => @plate_a, - '58000000382' => @plate_b) + { '58000000281' => @plate_a, + '58000000382' => @plate_b }) .returns([true, 'Okay']) @robot.expects(:beds_for).with( - '58000000281' => @plate_a, - '58000000382' => @plate_b + { '58000000281' => @plate_a, + '58000000382' => @plate_b } ) .returns([ { bed: '2', order: 1, qcable: '11111111-2222-3333-4444-100000000001' }, diff --git a/test/models/barcode_sheet_test.rb b/test/models/barcode_sheet_test.rb index 5695aa12..37a5940a 100644 --- a/test/models/barcode_sheet_test.rb +++ b/test/models/barcode_sheet_test.rb @@ -19,8 +19,9 @@ class BarcodeSheetTest < ActiveSupport::TestCase test '#initialise' do received_labels = [BarcodeSheet::Label.new(barcode: 'DN1S', prefix: 'DN', number: '1', lot: 'lot_number', template: 'tag_set')] - printer = api.barcode_printer.find('baac0dea-0000-0000-0000-000000000000') - printer.stubs(:print_service).returns('PMB') + printer = Sequencescape::Api::V2::BarcodePrinter.new( + print_service: 'PMB', name: @printer_name, barcode_type: '96 Well Plate' + ) barcode_sheet = BarcodeSheet.new(printer, received_labels) assert_equal barcode_sheet.printer.name, @printer_name @@ -44,9 +45,9 @@ class BarcodeSheetTest < ActiveSupport::TestCase barcode: 'DN1S' }] - printer = api.barcode_printer.find('baac0dea-0000-0000-0000-000000000000') - - printer.stubs(:print_service).returns('PMB') + printer = Sequencescape::Api::V2::BarcodePrinter.new( + print_service: 'PMB', name: @printer_name, barcode_type: '96 Well Plate' + ) PMB::TestSuiteStubs.get(@label_template_url) do |_env| [ @@ -74,9 +75,9 @@ class BarcodeSheetTest < ActiveSupport::TestCase Timecop.freeze(Date.parse('02-02-2019')) do received_labels = [BarcodeSheet::Label.new(barcode: 'DN1S', prefix: 'DN', number: '1', lot: 'lot_number', template: 'tag_set')] - printer = api.barcode_printer.find('baac0dea-0000-0000-0000-000000000000') - - printer.stubs(:print_service).returns('SPrint') + printer = Sequencescape::Api::V2::BarcodePrinter.new( + print_service: 'SPrint', name: @printer_name, barcode_type: '96 Well Plate' + ) response = mock('response') response.stubs(:code).returns('200') @@ -91,9 +92,9 @@ class BarcodeSheetTest < ActiveSupport::TestCase Timecop.freeze(Date.parse('02-02-2019')) do received_labels = [BarcodeSheet::Label.new(barcode: 'DN1S', prefix: 'DN', number: '1', lot: 'lot_number', template: 'tag_set')] - printer = api.barcode_printer.find('baac0dea-0000-0000-0000-000000000000') - - printer.stubs(:print_service).returns('SPrint') + printer = Sequencescape::Api::V2::BarcodePrinter.new( + print_service: 'SPrint', name: @printer_name, barcode_type: '96 Well Plate' + ) response = mock('response') response.stubs(:code).returns('422')