From eb28bf1e0ab563ed3b47fee780f1c9e6f7fc174c Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 13:01:26 +0000 Subject: [PATCH 1/2] Update rails to version 7.0.8.3 --- Gemfile | 2 +- Gemfile.lock | 157 +++++++++++++++++++++++++-------------------------- 2 files changed, 79 insertions(+), 80 deletions(-) diff --git a/Gemfile b/Gemfile index 7bdcc99..7a2a653 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -gem 'rails', '~>6.1.0' +gem 'rails', '~> 7.0.8' group :development, :test do gem 'byebug' diff --git a/Gemfile.lock b/Gemfile.lock index 826ca1e..8cf4f36 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,40 +7,47 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.7) - actionpack (= 6.1.7.7) - activesupport (= 6.1.7.7) + actioncable (7.0.8.3) + actionpack (= 7.0.8.3) + activesupport (= 7.0.8.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.7) - actionpack (= 6.1.7.7) - activejob (= 6.1.7.7) - activerecord (= 6.1.7.7) - activestorage (= 6.1.7.7) - activesupport (= 6.1.7.7) + actionmailbox (7.0.8.3) + actionpack (= 7.0.8.3) + activejob (= 7.0.8.3) + activerecord (= 7.0.8.3) + activestorage (= 7.0.8.3) + activesupport (= 7.0.8.3) mail (>= 2.7.1) - actionmailer (6.1.7.7) - actionpack (= 6.1.7.7) - actionview (= 6.1.7.7) - activejob (= 6.1.7.7) - activesupport (= 6.1.7.7) + net-imap + net-pop + net-smtp + actionmailer (7.0.8.3) + actionpack (= 7.0.8.3) + actionview (= 7.0.8.3) + activejob (= 7.0.8.3) + activesupport (= 7.0.8.3) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7.7) - actionview (= 6.1.7.7) - activesupport (= 6.1.7.7) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.8.3) + actionview (= 7.0.8.3) + activesupport (= 7.0.8.3) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.7) - actionpack (= 6.1.7.7) - activerecord (= 6.1.7.7) - activestorage (= 6.1.7.7) - activesupport (= 6.1.7.7) + actiontext (7.0.8.3) + actionpack (= 7.0.8.3) + activerecord (= 7.0.8.3) + activestorage (= 7.0.8.3) + activesupport (= 7.0.8.3) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.7) - activesupport (= 6.1.7.7) + actionview (7.0.8.3) + activesupport (= 7.0.8.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -50,40 +57,39 @@ GEM activemodel (>= 4.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (6.1.7.7) - activesupport (= 6.1.7.7) + activejob (7.0.8.3) + activesupport (= 7.0.8.3) globalid (>= 0.3.6) - activemodel (6.1.7.7) - activesupport (= 6.1.7.7) - activerecord (6.1.7.7) - activemodel (= 6.1.7.7) - activesupport (= 6.1.7.7) - activestorage (6.1.7.7) - actionpack (= 6.1.7.7) - activejob (= 6.1.7.7) - activerecord (= 6.1.7.7) - activesupport (= 6.1.7.7) + activemodel (7.0.8.3) + activesupport (= 7.0.8.3) + activerecord (7.0.8.3) + activemodel (= 7.0.8.3) + activesupport (= 7.0.8.3) + activestorage (7.0.8.3) + actionpack (= 7.0.8.3) + activejob (= 7.0.8.3) + activerecord (= 7.0.8.3) + activesupport (= 7.0.8.3) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.7) + activesupport (7.0.8.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) ast (2.4.2) bootsnap (1.18.3) msgpack (~> 1.2) - builder (3.2.4) + builder (3.3.0) byebug (11.1.3) case_transform (0.2) activesupport coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.3) crass (1.0.6) date (3.3.4) diff-lcs (1.5.1) - erubi (1.12.0) + erubi (1.13.0) exception_notification (4.5.0) actionmailer (>= 5.2, < 8) activesupport (>= 5.2, < 8) @@ -95,7 +101,7 @@ GEM ffi (1.16.3) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.4) + i18n (1.14.5) concurrent-ruby (~> 1.0) json (2.7.2) jsonapi-renderer (0.2.2) @@ -111,29 +117,29 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) - method_source (1.0.0) + marcel (1.0.4) + method_source (1.1.0) mini_mime (1.1.5) - minitest (5.22.3) + minitest (5.24.0) mocha (2.3.0) ruby2_keywords (>= 0.0.5) msgpack (1.7.2) mysql2 (0.5.6) - net-imap (0.4.10) + net-imap (0.4.13) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.0) net-protocol - nio4r (2.7.0) - nokogiri (1.16.5-arm64-darwin) + nio4r (2.7.3) + nokogiri (1.16.6-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-darwin) + nokogiri (1.16.6-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-linux) + nokogiri (1.16.6-x86_64-linux) racc (~> 1.4) parallel (1.24.0) parser (3.3.1.0) @@ -150,21 +156,20 @@ GEM rack (>= 2.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.7) - actioncable (= 6.1.7.7) - actionmailbox (= 6.1.7.7) - actionmailer (= 6.1.7.7) - actionpack (= 6.1.7.7) - actiontext (= 6.1.7.7) - actionview (= 6.1.7.7) - activejob (= 6.1.7.7) - activemodel (= 6.1.7.7) - activerecord (= 6.1.7.7) - activestorage (= 6.1.7.7) - activesupport (= 6.1.7.7) + rails (7.0.8.3) + actioncable (= 7.0.8.3) + actionmailbox (= 7.0.8.3) + actionmailer (= 7.0.8.3) + actionpack (= 7.0.8.3) + actiontext (= 7.0.8.3) + actionview (= 7.0.8.3) + activejob (= 7.0.8.3) + activemodel (= 7.0.8.3) + activerecord (= 7.0.8.3) + activestorage (= 7.0.8.3) + activesupport (= 7.0.8.3) bundler (>= 1.15.0) - railties (= 6.1.7.7) - sprockets-rails (>= 2.0.0) + railties (= 7.0.8.3) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -173,14 +178,15 @@ GEM loofah (~> 2.21) nokogiri (~> 1.14) rails-perftest (0.0.7) - railties (6.1.7.7) - actionpack (= 6.1.7.7) - activesupport (= 6.1.7.7) + railties (7.0.8.3) + actionpack (= 7.0.8.3) + activesupport (= 7.0.8.3) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) @@ -238,13 +244,6 @@ GEM ruby2_keywords (0.0.5) spring (4.2.1) sprint_client (0.1.0) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - sprockets (>= 3.0.0) sqlite3 (1.7.3-arm64-darwin) sqlite3 (1.7.3-x86_64-darwin) sqlite3 (1.7.3-x86_64-linux) @@ -257,7 +256,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.13) + zeitwerk (2.6.16) PLATFORMS arm64-darwin-22 @@ -277,7 +276,7 @@ DEPENDENCIES psd_logger! puma rack-cors - rails (~> 6.1.0) + rails (~> 7.0.8) rails-perftest rspec-rails rubocop From 25f2ea6e5f2edf97f56eba07f123d608935770e1 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Fri, 21 Jun 2024 15:31:40 +0100 Subject: [PATCH 2/2] feat: removes config references to assets, removes subclass checker - Removes config references to assets as they are no longer included by default in rails 7 - Removes subclass checker as it was causing issues with subclass detection - Adds barcode? and bitmap? references inplace of subclass checker concern --- Gemfile.lock | 1 + app/label_printer/label_printer/print_job.rb | 10 ---------- .../label_printer/print_job/base.rb | 3 --- app/models/concerns/subclass_checker.rb | 20 ------------------- app/models/drawing.rb | 12 +++++++---- config/application.rb | 2 +- config/environments/development.rb | 8 -------- config/environments/production.rb | 9 --------- config/initializers/assets.rb | 16 --------------- spec/label_printer/print_job_spec.rb | 4 ++-- spec/models/barcode_spec.rb | 8 ++++++++ spec/models/bitmap_spec.rb | 8 ++++++++ 12 files changed, 28 insertions(+), 73 deletions(-) delete mode 100644 app/models/concerns/subclass_checker.rb delete mode 100644 config/initializers/assets.rb diff --git a/Gemfile.lock b/Gemfile.lock index 8cf4f36..b9affc4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -260,6 +260,7 @@ GEM PLATFORMS arm64-darwin-22 + arm64-darwin-23 x86_64-darwin-21 x86_64-linux diff --git a/app/label_printer/label_printer/print_job.rb b/app/label_printer/label_printer/print_job.rb index 1dd6fe8..c25e353 100644 --- a/app/label_printer/label_printer/print_job.rb +++ b/app/label_printer/label_printer/print_job.rb @@ -10,16 +10,6 @@ module LabelPrinter # TOF is also available to check that the text is # correct or to allow you to send a job manually. module PrintJob - # This is neccessary for Travis to pass. - # When the build method is called in tests the - # subclasses of print job are not loaded - # so we get a constant does not exist method. - # TODO: modify the build method so it doesn't use constantize." - require_relative 'print_job/base' - require_relative 'print_job/LPD' - require_relative 'print_job/IPP' - require_relative 'print_job/TOF' - ## # Build a new print job based on the protocol # of the printer name that is passed. diff --git a/app/label_printer/label_printer/print_job/base.rb b/app/label_printer/label_printer/print_job/base.rb index 069fc38..5cf0fe2 100644 --- a/app/label_printer/label_printer/print_job/base.rb +++ b/app/label_printer/label_printer/print_job/base.rb @@ -13,9 +13,6 @@ module PrintJob class Base include ActiveModel::Model include ActiveModel::Serialization - include SubclassChecker - - subclasses :LPD, :IPP, :TOF attr_accessor :printer_name, :label_template_id, :printer, :labels attr_reader :label_template, :data_input diff --git a/app/models/concerns/subclass_checker.rb b/app/models/concerns/subclass_checker.rb deleted file mode 100644 index b63336c..0000000 --- a/app/models/concerns/subclass_checker.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# SubclassChecker -module SubclassChecker - extend ActiveSupport::Concern - - # SubclassChecker::ClassMethods - module ClassMethods - def subclasses(*classes) - options = classes.extract_options! - classes.each do |klass| - object_type = klass.to_s.capitalize - object_type << to_s.capitalize if options[:suffix] - define_method "#{klass}?" do - type == object_type - end - end - end - end -end diff --git a/app/models/drawing.rb b/app/models/drawing.rb index e11dfa7..6004b57 100644 --- a/app/models/drawing.rb +++ b/app/models/drawing.rb @@ -7,8 +7,6 @@ # respect to its label. # Each drawing must have a field name, x origin and y origin class Drawing < ApplicationRecord - include SubclassChecker - before_create :add_placeholder_id belongs_to :label, optional: true @@ -16,8 +14,6 @@ class Drawing < ApplicationRecord validates :field_name, presence: true, format: { with: /\A[\w_]+\z/ } validates :x_origin, :y_origin, presence: true, format: { with: /\A\d{4}\z/ } - subclasses :bitmap, :barcode - ## # e.g. 0001 def padded_placeholder_id @@ -50,6 +46,14 @@ def self.permitted_attributes (stored_attributes[:options] || []) + %i[x_origin y_origin field_name] end + def barcode? + instance_of?(Barcode) + end + + def bitmap? + instance_of?(Bitmap) + end + private def add_placeholder_id diff --git a/config/application.rb b/config/application.rb index 6583d4d..7c30ddf 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,7 @@ module PrintMyBarcode class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.1 + config.load_defaults 7.0 # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/environments/development.rb b/config/environments/development.rb index f5efef9..38e9b94 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -44,14 +44,6 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - config.assets.debug = true - - # Suppress logger output for asset requests. - config.assets.quiet = true - # Default setting for adding printers to cupsd server on printer create config.auto_create_printer_in_cupsd = false diff --git a/config/environments/production.rb b/config/environments/production.rb index db1727a..a2c1858 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -22,15 +22,6 @@ # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier - # config.assets.css_compressor = :sass - - # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false - - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb - # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb deleted file mode 100644 index a9b0d0f..0000000 --- a/config/initializers/assets.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -# Be sure to restart your server when you modify this file. - -# Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' - -# Add additional assets to the asset load path. -# Rails.application.config.assets.paths << Emoji.images_path -# Add Yarn node_modules folder to the asset load path. -Rails.application.config.assets.paths << Rails.root.join('node_modules') - -# Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in the app/assets -# folder are already added. -# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/spec/label_printer/print_job_spec.rb b/spec/label_printer/print_job_spec.rb index 0ebba9b..1b45316 100644 --- a/spec/label_printer/print_job_spec.rb +++ b/spec/label_printer/print_job_spec.rb @@ -51,9 +51,9 @@ it 'with a particular protocol should build a print job of the correct class' do print_job = LabelPrinter::PrintJob.build(printer_name: printer.name, label_template_id: label_template.id, labels: label_template.dummy_labels.to_h) - expect(print_job).to be_LPD + expect(print_job).to be_a(LabelPrinter::PrintJob::LPD) print_job = LabelPrinter::PrintJob.build(printer_name: create(:printer, protocol: 'IPP').name, label_template_id: label_template.id, labels: label_template.dummy_labels.to_h) - expect(print_job).to be_IPP + expect(print_job).to be_a(LabelPrinter::PrintJob::IPP) end describe '#convert_labels' do diff --git a/spec/models/barcode_spec.rb b/spec/models/barcode_spec.rb index 7c7c213..4d4a83a 100644 --- a/spec/models/barcode_spec.rb +++ b/spec/models/barcode_spec.rb @@ -91,4 +91,12 @@ barcode = create(:barcode) expect(barcode.template_attributes).to eq(barcode.options.merge(id: barcode.padded_placeholder_id, x_origin: barcode.x_origin, y_origin: barcode.y_origin)) end + + it 'should return true for barcode?' do + expect(build(:barcode).barcode?).to be_truthy + end + + it 'should return false for bitmap?' do + expect(build(:barcode).bitmap?).to be_falsey + end end diff --git a/spec/models/bitmap_spec.rb b/spec/models/bitmap_spec.rb index 3dda83c..ddee624 100644 --- a/spec/models/bitmap_spec.rb +++ b/spec/models/bitmap_spec.rb @@ -44,4 +44,12 @@ bitmap = create(:bitmap) expect(bitmap.template_attributes).to eq(bitmap.options.merge(id: bitmap.padded_placeholder_id, x_origin: bitmap.x_origin, y_origin: bitmap.y_origin)) end + + it 'should return false for barcode?' do + expect(build(:bitmap).barcode?).to be_falsey + end + + it 'should return true for bitmap?' do + expect(build(:bitmap).bitmap?).to be_truthy + end end