chore: rubocop

chore: fix api test conventions

chore: rubocop -A spec/

chore: more rubocop -A

fix failing test

rubocop fixes

removes helper methods that are in my opinion dead code

more rubocop fixes

rubocop -a --auto-gen-config
This commit is contained in:
Philipp Rothmann 2023-05-12 13:01:12 +02:00 committed by Philipp Rothmann
parent f6fb804bbe
commit fb2b4d8a8a
331 changed files with 4263 additions and 4507 deletions

View file

@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks
@ -34,4 +34,4 @@ Rake::TestTask.new(:test) do |t|
t.verbose = false
end
task :default => :test
task default: :test

View file

@ -37,9 +37,7 @@ class PrinterController < ApplicationController
job = PrinterJob.unfinished.find_by_id(json[:id])
return unless job
if json[:state]
job.add_update! json[:state], json[:message]
end
job.add_update! json[:state], json[:message] if json[:state]
job.finish! if json[:finish]
end

View file

@ -15,7 +15,7 @@ class PrinterJobsController < ApplicationController
state = order.open? ? 'queued' : 'ready'
count = 0
PrinterJob.transaction do
%w(articles fax groups matrix).each do |document|
%w[articles fax groups matrix].each do |document|
next unless FoodsoftConfig["printer_print_order_#{document}"]
job = PrinterJob.create! order: order, document: document, created_by: current_user
@ -47,7 +47,7 @@ class PrinterJobsController < ApplicationController
job = PrinterJob.find(params[:id])
job.finish! current_user
redirect_to printer_jobs_path, notice: t('.notice')
rescue => error
redirect_to printer_jobs_path, t('errors.general_msg', msg: error.message)
rescue StandardError => e
redirect_to printer_jobs_path, t('errors.general_msg', msg: e.message)
end
end

View file

@ -4,7 +4,7 @@ Rails.application.routes.draw do
get :socket, on: :collection
end
resources :printer_jobs, only: [:index, :create, :show, :destroy] do
resources :printer_jobs, only: %i[index create show destroy] do
post :requeue, on: :member
get :document, on: :member
end

View file

@ -15,6 +15,6 @@ class CreatePrinterJobs < ActiveRecord::Migration[4.2]
t.text :message
end
add_index :printer_job_updates, [:printer_job_id, :created_at]
add_index :printer_job_updates, %i[printer_job_id created_at]
end
end

View file

@ -1,21 +1,22 @@
$:.push File.expand_path("../lib", __FILE__)
$:.push File.expand_path('lib', __dir__)
# Maintain your gem's version:
require "foodsoft_printer/version"
require 'foodsoft_printer/version'
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "foodsoft_printer"
s.name = 'foodsoft_printer'
s.version = FoodsoftPrinter::VERSION
s.authors = ["paroga"]
s.email = ["paroga@paroga.com"]
s.homepage = "https://github.com/foodcoops/foodsoft"
s.summary = "Printer plugin for foodsoft."
s.description = "Add a printer queue to foodsoft."
s.authors = ['paroga']
s.email = ['paroga@paroga.com']
s.homepage = 'https://github.com/foodcoops/foodsoft'
s.summary = 'Printer plugin for foodsoft.'
s.description = 'Add a printer queue to foodsoft.'
s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"]
s.files = Dir['{app,config,db,lib}/**/*'] + ['Rakefile', 'README.md']
s.add_dependency "rails"
s.add_dependency "deface", "~> 1.0"
s.add_dependency "tubesock"
s.add_dependency 'rails'
s.add_dependency 'deface', '~> 1.0'
s.add_dependency 'tubesock'
s.metadata['rubygems_mfa_required'] = 'true'
end

View file

@ -3,18 +3,19 @@ module FoodsoftPrinter
def navigation(primary, context)
return unless FoodsoftPrinter.enabled?
unless primary[:orders].nil?
sub_nav = primary[:orders].sub_navigation
sub_nav.items <<
SimpleNavigation::Item.new(primary, :printer_jobs, I18n.t('navigation.orders.printer_jobs'), context.printer_jobs_path)
end
return if primary[:orders].nil?
sub_nav = primary[:orders].sub_navigation
sub_nav.items <<
SimpleNavigation::Item.new(primary, :printer_jobs, I18n.t('navigation.orders.printer_jobs'),
context.printer_jobs_path)
end
def default_foodsoft_config(cfg)
cfg[:use_printer] = false
end
initializer 'foodsoft_printer.order_printer_jobs' do |app|
initializer 'foodsoft_printer.order_printer_jobs' do |_app|
if Rails.configuration.cache_classes
OrderPrinterJobs.install
else

View file

@ -4,14 +4,14 @@ module FoodsoftPrinter
base.class_eval do
has_many :printer_jobs, dependent: :destroy
alias foodsoft_printer_orig_finish! finish!
alias_method :foodsoft_printer_orig_finish!, :finish!
def finish!(user)
foodsoft_printer_orig_finish!(user)
unless finished?
printer_jobs.unfinished.each do |job|
job.add_update! 'ready'
end
return if finished?
printer_jobs.unfinished.each do |job|
job.add_update! 'ready'
end
end
end

View file

@ -1,3 +1,3 @@
module FoodsoftPrinter
VERSION = "0.0.1"
VERSION = '0.0.1'
end