diff --git a/.rubocop.yml b/.rubocop.yml
index 187a0333..14ca2e2a 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -24,7 +24,7 @@ Style/DocumentationMethod:
- lib/**/*.rb
Style/StringLiterals:
- EnforcedStyle: single_quotes
+ EnforcedStyle: double_quotes
Style/SymbolArray:
EnforcedStyle: brackets
diff --git a/Gemfile b/Gemfile
index c857d165..4c3d7a4b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-source 'https://rubygems.org'
+source "https://rubygems.org"
gemspec
-gem 'capybara'
-gem 'mocha'
-gem 'pry-byebug'
-gem 'puma'
-gem 'rails'
-gem 'rubocop-shopify'
-gem 'selenium-webdriver'
-gem 'sqlite3'
-gem 'webdrivers', require: false
-gem 'yard'
+gem "capybara"
+gem "mocha"
+gem "pry-byebug"
+gem "puma"
+gem "rails"
+gem "rubocop-shopify"
+gem "selenium-webdriver"
+gem "sqlite3"
+gem "webdrivers", require: false
+gem "yard"
diff --git a/Rakefile b/Rakefile
index 1cd33b59..72236961 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,29 +1,29 @@
# frozen_string_literal: true
begin
- require 'bundler/setup'
+ require "bundler/setup"
rescue LoadError
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
end
-require 'rdoc/task'
+require "rdoc/task"
RDoc::Task.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'MaintenanceTasks'
- rdoc.options << '--line-numbers'
- rdoc.rdoc_files.include('README.md')
- rdoc.rdoc_files.include('lib/**/*.rb')
+ rdoc.rdoc_dir = "rdoc"
+ rdoc.title = "MaintenanceTasks"
+ rdoc.options << "--line-numbers"
+ rdoc.rdoc_files.include("README.md")
+ rdoc.rdoc_files.include("lib/**/*.rb")
end
-APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
-load('rails/tasks/engine.rake')
+APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
+load("rails/tasks/engine.rake")
-load('rails/tasks/statistics.rake')
+load("rails/tasks/statistics.rake")
-require 'bundler/gem_tasks'
+require "bundler/gem_tasks"
-require 'rubocop/rake_task'
+require "rubocop/rake_task"
RuboCop::RakeTask.new
-task(test: 'app:test')
-task('test:system' => 'app:test:system')
-task(default: ['db:test:prepare', 'test', 'test:system', 'rubocop'])
+task(test: "app:test")
+task("test:system" => "app:test:system")
+task(default: ["db:test:prepare", "test", "test:system", "rubocop"])
diff --git a/app/controllers/maintenance_tasks/application_controller.rb b/app/controllers/maintenance_tasks/application_controller.rb
index 56b9e02a..dbe91b44 100644
--- a/app/controllers/maintenance_tasks/application_controller.rb
+++ b/app/controllers/maintenance_tasks/application_controller.rb
@@ -5,7 +5,7 @@ module MaintenanceTasks
#
# Can be extended to add different authentication and authorization code.
class ApplicationController < ActionController::Base
- BULMA_CDN = 'https://cdn.jsdelivr.net'
+ BULMA_CDN = "https://cdn.jsdelivr.net"
content_security_policy do |policy|
policy.style_src(BULMA_CDN)
@@ -15,7 +15,7 @@ class ApplicationController < ActionController::Base
before_action do
request.content_security_policy_nonce_generator ||=
->(_request) { SecureRandom.base64(16) }
- request.content_security_policy_nonce_directives = ['style-src']
+ request.content_security_policy_nonce_directives = ["style-src"]
end
protect_from_forgery with: :exception
diff --git a/app/helpers/maintenance_tasks/application_helper.rb b/app/helpers/maintenance_tasks/application_helper.rb
index 352e88b4..f3813932 100644
--- a/app/helpers/maintenance_tasks/application_helper.rb
+++ b/app/helpers/maintenance_tasks/application_helper.rb
@@ -13,8 +13,8 @@ module ApplicationHelper
# @param datetime [ActiveSupport::TimeWithZone] the time to be presented.
# @return [String] the HTML to render with the relative datetime in words.
def time_ago(datetime)
- time_tag(datetime, title: datetime.utc.iso8601, class: 'is-clickable') do
- time_ago_in_words(datetime) + ' ago'
+ time_tag(datetime, title: datetime.utc.iso8601, class: "is-clickable") do
+ time_ago_in_words(datetime) + " ago"
end
end
end
diff --git a/app/helpers/maintenance_tasks/tasks_helper.rb b/app/helpers/maintenance_tasks/tasks_helper.rb
index fa0a2a20..a0c8307d 100644
--- a/app/helpers/maintenance_tasks/tasks_helper.rb
+++ b/app/helpers/maintenance_tasks/tasks_helper.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'ripper'
+require "ripper"
module MaintenanceTasks
# Helpers for formatting data in the maintenance_tasks views.
@@ -8,16 +8,16 @@ module MaintenanceTasks
# @api private
module TasksHelper
STATUS_COLOURS = {
- 'new' => ['is-primary'],
- 'enqueued' => ['is-primary is-light'],
- 'running' => ['is-info'],
- 'interrupted' => ['is-info', 'is-light'],
- 'pausing' => ['is-warning', 'is-light'],
- 'paused' => ['is-warning'],
- 'succeeded' => ['is-success'],
- 'cancelling' => ['is-light'],
- 'cancelled' => ['is-dark'],
- 'errored' => ['is-danger'],
+ "new" => ["is-primary"],
+ "enqueued" => ["is-primary is-light"],
+ "running" => ["is-info"],
+ "interrupted" => ["is-info", "is-light"],
+ "pausing" => ["is-warning", "is-light"],
+ "paused" => ["is-warning"],
+ "succeeded" => ["is-success"],
+ "cancelling" => ["is-light"],
+ "cancelled" => ["is-dark"],
+ "errored" => ["is-danger"],
}
# Formats a run backtrace.
@@ -48,7 +48,7 @@ def progress(run)
value: progress.value,
max: progress.max,
title: progress.title,
- class: ['progress'] + STATUS_COLOURS.fetch(run.status)
+ class: ["progress"] + STATUS_COLOURS.fetch(run.status)
)
end
@@ -59,7 +59,7 @@ def progress(run)
# @return [String] the span element containing the status, with the
# appropriate tag class attached.
def status_tag(status)
- tag.span(status.capitalize, class: ['tag'] + STATUS_COLOURS.fetch(status))
+ tag.span(status.capitalize, class: ["tag"] + STATUS_COLOURS.fetch(status))
end
# Returns the distance between now and the Run's expected completion time,
@@ -100,7 +100,7 @@ def highlight_code(code)
when :on_nl, :on_sp, :on_ignored_nl
content
else
- tag.span(content, class: type.to_s.sub('on_', 'ruby-').dasherize)
+ tag.span(content, class: type.to_s.sub("on_", "ruby-").dasherize)
end
end
safe_join(tokens)
diff --git a/app/jobs/maintenance_tasks/task_job.rb b/app/jobs/maintenance_tasks/task_job.rb
index 373a48ee..30b4c391 100644
--- a/app/jobs/maintenance_tasks/task_job.rb
+++ b/app/jobs/maintenance_tasks/task_job.rb
@@ -19,7 +19,7 @@ class << self
# Overrides ActiveJob::Exceptions.retry_on to declare it unsupported.
# The use of rescue_from prevents retry_on from being usable.
def retry_on(*, **)
- raise NotImplementedError, 'retry_on is not supported'
+ raise NotImplementedError, "retry_on is not supported"
end
end
@@ -38,7 +38,7 @@ def build_enumerator(_run, cursor:)
JobIteration::CsvEnumerator.new(collection).rows(cursor: cursor)
else
raise ArgumentError, "#{@task.class.name}#collection must be either "\
- 'an Active Record Relation, Array, or CSV.'
+ "an Active Record Relation, Array, or CSV."
end
end
diff --git a/app/models/maintenance_tasks/csv_collection.rb b/app/models/maintenance_tasks/csv_collection.rb
index 2b2339ce..05c240bb 100644
--- a/app/models/maintenance_tasks/csv_collection.rb
+++ b/app/models/maintenance_tasks/csv_collection.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'csv'
+require "csv"
module MaintenanceTasks
# Module that is included into Task classes by Task.csv_collection for
diff --git a/app/models/maintenance_tasks/run.rb b/app/models/maintenance_tasks/run.rb
index 6d8af229..6d29d4ce 100644
--- a/app/models/maintenance_tasks/run.rb
+++ b/app/models/maintenance_tasks/run.rb
@@ -192,9 +192,9 @@ def stuck?
# if the Run does not meet the above criteria.
def csv_attachment_presence
if Task.named(task_name) < CsvCollection && !csv_file.attached?
- errors.add(:csv_file, 'must be attached to CSV Task.')
+ errors.add(:csv_file, "must be attached to CSV Task.")
elsif !(Task.named(task_name) < CsvCollection) && csv_file.present?
- errors.add(:csv_file, 'should not be attached to non-CSV Task.')
+ errors.add(:csv_file, "should not be attached to non-CSV Task.")
end
rescue Task::NotFoundError
nil
diff --git a/app/models/maintenance_tasks/runner.rb b/app/models/maintenance_tasks/runner.rb
index f2c3a499..8a68d1e8 100644
--- a/app/models/maintenance_tasks/runner.rb
+++ b/app/models/maintenance_tasks/runner.rb
@@ -8,7 +8,7 @@ module Runner
# @deprecated Use {Runner} directly instead.
def new
ActiveSupport::Deprecation.warn(
- 'Use Runner.run instead of Runner.new.run'
+ "Use Runner.run instead of Runner.new.run"
)
self
end
@@ -57,7 +57,7 @@ def run(name:, csv_file: nil)
def enqueue(run)
unless MaintenanceTasks.job.constantize.perform_later(run)
raise "The job to perform #{run.task_name} could not be enqueued. "\
- 'Enqueuing has been prevented by a callback.'
+ "Enqueuing has been prevented by a callback."
end
rescue => error
run.persist_error(error)
diff --git a/app/models/maintenance_tasks/runs_page.rb b/app/models/maintenance_tasks/runs_page.rb
index 18019530..b8ce4d37 100644
--- a/app/models/maintenance_tasks/runs_page.rb
+++ b/app/models/maintenance_tasks/runs_page.rb
@@ -28,7 +28,7 @@ def initialize(runs, cursor)
def records
@records ||= begin
runs_after_cursor = if @cursor.present?
- @runs.where('id < ?', @cursor)
+ @runs.where("id < ?", @cursor)
else
@runs
end
diff --git a/app/models/maintenance_tasks/task_data.rb b/app/models/maintenance_tasks/task_data.rb
index 4d0bb3a7..3daf39dc 100644
--- a/app/models/maintenance_tasks/task_data.rb
+++ b/app/models/maintenance_tasks/task_data.rb
@@ -41,7 +41,7 @@ def available_tasks
task_names = Task.available_tasks.map(&:name)
available_task_runs = Run.where(task_name: task_names)
last_runs = Run.where(
- id: available_task_runs.select('MAX(id) as id').group(:task_name)
+ id: available_task_runs.select("MAX(id) as id").group(:task_name)
)
task_names.map do |task_name|
@@ -111,7 +111,7 @@ def deleted?
#
# @return [String] the Task status.
def status
- last_run&.status || 'new'
+ last_run&.status || "new"
end
# Retrieves the Task's category, which is one of active, new, or completed.
diff --git a/app/validators/maintenance_tasks/run_status_validator.rb b/app/validators/maintenance_tasks/run_status_validator.rb
index 60c60808..143561d8 100644
--- a/app/validators/maintenance_tasks/run_status_validator.rb
+++ b/app/validators/maintenance_tasks/run_status_validator.rb
@@ -13,7 +13,7 @@ class RunStatusValidator < ActiveModel::Validator
# before starting.
# enqueued -> errored occurs when the task job fails to be enqueued, or
# if the Task is deleted before is starts running.
- 'enqueued' => ['running', 'pausing', 'cancelling', 'errored'],
+ "enqueued" => ["running", "pausing", "cancelling", "errored"],
# pausing -> paused occurs when the task actually halts performing and
# occupies a status of paused.
# pausing -> cancelling occurs when the user cancels a task immediately
@@ -24,14 +24,14 @@ class RunStatusValidator < ActiveModel::Validator
# nothing in its collection to process.
# pausing -> errored occurs when the job raises an exception after the
# user has paused it.
- 'pausing' => ['paused', 'cancelling', 'succeeded', 'errored'],
+ "pausing" => ["paused", "cancelling", "succeeded", "errored"],
# cancelling -> cancelled occurs when the task actually halts performing
# and occupies a status of cancelled.
# cancelling -> succeeded occurs when the task completes immediately after
# being cancelled. See description for pausing -> succeeded.
# cancelling -> errored occurs when the job raises an exception after the
# user has cancelled it.
- 'cancelling' => ['cancelled', 'succeeded', 'errored'],
+ "cancelling" => ["cancelled", "succeeded", "errored"],
# running -> succeeded occurs when the task completes successfully.
# running -> pausing occurs when a user pauses the task as
# it's performing.
@@ -40,17 +40,17 @@ class RunStatusValidator < ActiveModel::Validator
# running -> interrupted occurs when the job infra shuts down the task as
# it's performing.
# running -> errored occurs when the job raises an exception when running.
- 'running' => [
- 'succeeded',
- 'pausing',
- 'cancelling',
- 'interrupted',
- 'errored',
+ "running" => [
+ "succeeded",
+ "pausing",
+ "cancelling",
+ "interrupted",
+ "errored",
],
# paused -> enqueued occurs when the task is resumed after being paused.
# paused -> cancelling when the user cancels the task after it is paused.
# paused -> cancelled when the user cancels the task after it is paused.
- 'paused' => ['enqueued', 'cancelling', 'cancelled'],
+ "paused" => ["enqueued", "cancelling", "cancelled"],
# interrupted -> running occurs when the task is resumed after being
# interrupted by the job infrastructure.
# interrupted -> pausing occurs when the task is paused by the user while
@@ -59,7 +59,7 @@ class RunStatusValidator < ActiveModel::Validator
# while it is interrupted.
# interrupted -> errored occurs when the task is deleted while it is
# interrupted.
- 'interrupted' => ['running', 'pausing', 'cancelling', 'errored'],
+ "interrupted" => ["running", "pausing", "cancelling", "errored"],
}
# Validate whether a transition from one Run status
diff --git a/bin/rails b/bin/rails
index 69af770e..590669d9 100755
--- a/bin/rails
+++ b/bin/rails
@@ -3,12 +3,12 @@
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.
-ENGINE_ROOT = File.expand_path('..', __dir__)
-ENGINE_PATH = File.expand_path('../lib/maintenance_tasks/engine', __dir__)
-APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
+ENGINE_ROOT = File.expand_path("..", __dir__)
+ENGINE_PATH = File.expand_path("../lib/maintenance_tasks/engine", __dir__)
+APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)
# Set up gems listed in the Gemfile.
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
-require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
+require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
-require 'rails/engine/commands'
+require "rails/engine/commands"
diff --git a/config/routes.rb b/config/routes.rb
index fb5a936a..789f9b0a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,16 +2,16 @@
MaintenanceTasks::Engine.routes.draw do
resources :tasks, only: [:index, :show], format: false do
member do
- put 'run'
+ put "run"
end
resources :runs, only: [], format: false do
member do
- put 'pause'
- put 'cancel'
+ put "pause"
+ put "cancel"
end
end
end
- root to: 'tasks#index'
+ root to: "tasks#index"
end
diff --git a/exe/maintenance_tasks b/exe/maintenance_tasks
index 6dcb4d7f..72e10b48 100755
--- a/exe/maintenance_tasks
+++ b/exe/maintenance_tasks
@@ -2,11 +2,11 @@
# frozen_string_literal: true
-require File.expand_path('config/application', Dir.pwd)
+require File.expand_path("config/application", Dir.pwd)
Rails.application.require_environment!
-require 'maintenance_tasks/cli'
+require "maintenance_tasks/cli"
module MaintenanceTasks
CLI.start(ARGV)
diff --git a/lib/generators/maintenance_tasks/install_generator.rb b/lib/generators/maintenance_tasks/install_generator.rb
index 5defc05b..07e0ff21 100644
--- a/lib/generators/maintenance_tasks/install_generator.rb
+++ b/lib/generators/maintenance_tasks/install_generator.rb
@@ -5,17 +5,17 @@ module MaintenanceTasks
#
# @api private
class InstallGenerator < Rails::Generators::Base
- source_root File.expand_path('templates', __dir__)
+ source_root File.expand_path("templates", __dir__)
# Mounts the engine in the host application's config/routes.rb
def mount_engine
- route("mount MaintenanceTasks::Engine => '/maintenance_tasks'")
+ route("mount MaintenanceTasks::Engine => \"/maintenance_tasks\"")
end
# Copies engine migrations to host application and migrates the database
def install_migrations
- rake('maintenance_tasks:install:migrations')
- rake('db:migrate')
+ rake("maintenance_tasks:install:migrations")
+ rake("db:migrate")
end
end
end
diff --git a/lib/generators/maintenance_tasks/task_generator.rb b/lib/generators/maintenance_tasks/task_generator.rb
index d80b1a43..aa0ef9d2 100644
--- a/lib/generators/maintenance_tasks/task_generator.rb
+++ b/lib/generators/maintenance_tasks/task_generator.rb
@@ -5,14 +5,14 @@ module MaintenanceTasks
#
# @api private
class TaskGenerator < Rails::Generators::NamedBase
- source_root File.expand_path('templates', __dir__)
- desc 'This generator creates a task file at app/tasks and a corresponding '\
- 'test.'
+ source_root File.expand_path("templates", __dir__)
+ desc "This generator creates a task file at app/tasks and a corresponding "\
+ "test."
class_option :csv, type: :boolean, default: false,
- desc: 'Generate a CSV Task.'
+ desc: "Generate a CSV Task."
- check_class_collision suffix: 'Task'
+ check_class_collision suffix: "Task"
# Creates the Task file.
def create_task_file
@@ -22,9 +22,9 @@ def create_task_file
"#{file_name}_task.rb"
)
if options[:csv]
- template('csv_task.rb', template_file)
+ template("csv_task.rb", template_file)
else
- template('task.rb', template_file)
+ template("task.rb", template_file)
end
end
@@ -49,7 +49,7 @@ def create_task_test_file
class_path,
"#{file_name}_task_test.rb"
)
- template('task_test.rb', template_file)
+ template("task_test.rb", template_file)
end
def create_task_spec_file
@@ -58,11 +58,11 @@ def create_task_spec_file
class_path,
"#{file_name}_task_spec.rb"
)
- template('task_spec.rb', template_file)
+ template("task_spec.rb", template_file)
end
def file_name
- super.sub(/_task\z/i, '')
+ super.sub(/_task\z/i, "")
end
def tasks_module
diff --git a/lib/maintenance_tasks.rb b/lib/maintenance_tasks.rb
index 590e92b3..db720d43 100644
--- a/lib/maintenance_tasks.rb
+++ b/lib/maintenance_tasks.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
-require 'action_controller'
-require 'action_view'
-require 'active_job'
-require 'active_record'
+require "action_controller"
+require "action_view"
+require "active_job"
+require "active_record"
-require 'job-iteration'
-require 'maintenance_tasks/engine'
+require "job-iteration"
+require "maintenance_tasks/engine"
# Force the TaskJob class to load so we can verify upstream compatibility with
# the JobIteration gem
-require_relative '../app/jobs/maintenance_tasks/task_job'
+require_relative "../app/jobs/maintenance_tasks/task_job"
# The engine's namespace module. It provides isolation between the host
# application's code and the engine-specific code. Top-level engine constants
@@ -17,13 +17,13 @@
module MaintenanceTasks
# The module to namespace Tasks in, as a String. Defaults to 'Maintenance'.
# @param [String] the tasks_module value.
- mattr_accessor :tasks_module, default: 'Maintenance'
+ mattr_accessor :tasks_module, default: "Maintenance"
# Defines the job to be used to perform Tasks. This job must be either
# `MaintenanceTasks::TaskJob` or a class that inherits from it.
#
# @param [String] the name of the job class.
- mattr_accessor :job, default: 'MaintenanceTasks::TaskJob'
+ mattr_accessor :job, default: "MaintenanceTasks::TaskJob"
# After each iteration, the progress of the task may be updated. This duration
# in seconds limits these updates, skipping if the duration since the last
@@ -50,8 +50,8 @@ def self.error_handler
def self.error_handler=(error_handler)
unless error_handler.arity == 3
ActiveSupport::Deprecation.warn(
- 'MaintenanceTasks.error_handler should be a lambda that takes three '\
- 'arguments: error, task_context, and errored_element.'
+ "MaintenanceTasks.error_handler should be a lambda that takes three "\
+ "arguments: error, task_context, and errored_element."
)
@error_handler = ->(error, _task_context, _errored_element) do
error_handler.call(error)
diff --git a/lib/maintenance_tasks/cli.rb b/lib/maintenance_tasks/cli.rb
index 1aac42b4..35cf1ecb 100644
--- a/lib/maintenance_tasks/cli.rb
+++ b/lib/maintenance_tasks/cli.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'thor'
+require "thor"
module MaintenanceTasks
# Defines the command line interface commands exposed by Maintenance Tasks in
@@ -13,7 +13,7 @@ def exit_on_failure?
end
end
- desc 'perform [TASK NAME]', 'Runs the given Maintenance Task'
+ desc "perform [TASK NAME]", "Runs the given Maintenance Task"
long_desc <<-LONGDESC
`maintenance_tasks perform` will run the Maintenance Task specified by the
@@ -25,7 +25,7 @@ def exit_on_failure?
LONGDESC
# Specify the CSV file to process for CSV Tasks
- option :csv, desc: 'Supply a CSV file to be processed by a CSV Task, '\
+ option :csv, desc: "Supply a CSV file to be processed by a CSV Task, "\
'--csv "path/to/csv/file.csv"'
# Command to run a Task.
diff --git a/lib/maintenance_tasks/engine.rb b/lib/maintenance_tasks/engine.rb
index 75641a85..15e98c3f 100644
--- a/lib/maintenance_tasks/engine.rb
+++ b/lib/maintenance_tasks/engine.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require 'active_record/railtie'
+require "active_record/railtie"
module MaintenanceTasks
# The engine's main class, which defines its namespace. The engine is mounted
@@ -7,7 +7,7 @@ module MaintenanceTasks
class Engine < ::Rails::Engine
isolate_namespace MaintenanceTasks
- initializer 'eager_load_for_classic_autoloader' do
+ initializer "eager_load_for_classic_autoloader" do
eager_load! unless Rails.autoloaders.zeitwerk_enabled?
end
@@ -25,7 +25,7 @@ class Engine < ::Rails::Engine
end
config.action_dispatch.rescue_responses.merge!(
- 'MaintenanceTasks::Task::NotFoundError' => :not_found,
+ "MaintenanceTasks::Task::NotFoundError" => :not_found,
)
end
end
diff --git a/maintenance_tasks.gemspec b/maintenance_tasks.gemspec
index e040abd8..6ef05cb2 100644
--- a/maintenance_tasks.gemspec
+++ b/maintenance_tasks.gemspec
@@ -1,30 +1,30 @@
# frozen_string_literal: true
Gem::Specification.new do |spec|
- spec.name = 'maintenance_tasks'
- spec.version = '1.1.2'
- spec.author = 'Shopify Engineering'
- spec.email = 'gems@shopify.com'
- spec.homepage = 'https://github.com/Shopify/maintenance_tasks'
- spec.summary = 'A Rails engine for queuing and managing maintenance tasks'
+ spec.name = "maintenance_tasks"
+ spec.version = "1.1.2"
+ spec.author = "Shopify Engineering"
+ spec.email = "gems@shopify.com"
+ spec.homepage = "https://github.com/Shopify/maintenance_tasks"
+ spec.summary = "A Rails engine for queuing and managing maintenance tasks"
spec.metadata = {
- 'source_code_uri' =>
+ "source_code_uri" =>
"https://github.com/Shopify/maintenance_tasks/tree/v#{spec.version}",
- 'allowed_push_host' => 'https://rubygems.org',
+ "allowed_push_host" => "https://rubygems.org",
}
- spec.files = Dir['{app,config,db,lib}/**/*', 'Rakefile', 'README.md']
- spec.bindir = 'exe'
- spec.executables = ['maintenance_tasks']
+ spec.files = Dir["{app,config,db,lib}/**/*", "Rakefile", "README.md"]
+ spec.bindir = "exe"
+ spec.executables = ["maintenance_tasks"]
- spec.post_install_message = 'Thank you for installing Maintenance Tasks '\
+ spec.post_install_message = "Thank you for installing Maintenance Tasks "\
"#{spec.version}. To complete, please run:\n\nrails generate "\
- 'maintenance_tasks:install'
+ "maintenance_tasks:install"
- spec.add_dependency('actionpack', '>= 6.0')
- spec.add_dependency('activejob', '>= 6.0')
- spec.add_dependency('activerecord', '>= 6.0')
- spec.add_dependency('job-iteration', '~> 1.1')
- spec.add_dependency('railties', '>= 6.0')
+ spec.add_dependency("actionpack", ">= 6.0")
+ spec.add_dependency("activejob", ">= 6.0")
+ spec.add_dependency("activerecord", ">= 6.0")
+ spec.add_dependency("job-iteration", "~> 1.1")
+ spec.add_dependency("railties", ">= 6.0")
end
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
index 34085f1a..4240335f 100644
--- a/test/application_system_test_case.rb
+++ b/test/application_system_test_case.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'test_helper'
-require 'webdrivers/chromedriver'
-require 'action_dispatch/system_testing/server'
+require "test_helper"
+require "webdrivers/chromedriver"
+require "action_dispatch/system_testing/server"
ActionDispatch::SystemTesting::Server.silence_puma = true
@@ -10,10 +10,10 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
include ActiveJob::TestHelper
driven_by :selenium, using: :headless_chrome do |options|
- options.add_argument('--disable-dev-shm-usage')
+ options.add_argument("--disable-dev-shm-usage")
options.add_preference(
:download,
- default_directory: 'test/dummy/tmp/downloads'
+ default_directory: "test/dummy/tmp/downloads"
)
end
@@ -25,6 +25,6 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
teardown do
assert_empty page.driver.browser.manage.logs.get(:browser)
Maintenance::UpdatePostsTask.fast_task = true
- FileUtils.rm_rf('test/dummy/tmp/downloads')
+ FileUtils.rm_rf("test/dummy/tmp/downloads")
end
end
diff --git a/test/documentation_test.rb b/test/documentation_test.rb
index b05f362c..93da8a2a 100644
--- a/test/documentation_test.rb
+++ b/test/documentation_test.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'active_support'
-require 'active_support/test_case'
-require 'yard'
+require "active_support"
+require "active_support/test_case"
+require "yard"
class DocumentationTest < ActiveSupport::TestCase
- test 'documentation is correctly written' do
+ test "documentation is correctly written" do
assert_empty %x(bundle exec yard --no-save --no-output --no-stats)
end
end
diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile
index 6d1041e3..c4f95238 100644
--- a/test/dummy/Rakefile
+++ b/test/dummy/Rakefile
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative 'config/application'
+require_relative "config/application"
Rails.application.load_tasks
diff --git a/test/dummy/app/controllers/posts_controller.rb b/test/dummy/app/controllers/posts_controller.rb
index f2323e3a..d0926ae0 100644
--- a/test/dummy/app/controllers/posts_controller.rb
+++ b/test/dummy/app/controllers/posts_controller.rb
@@ -20,7 +20,7 @@ def create
@post = Post.new(post_params)
if @post.save
- redirect_to(@post, notice: 'Post was successfully created.')
+ redirect_to(@post, notice: "Post was successfully created.")
else
render(:new)
end
@@ -28,7 +28,7 @@ def create
def update
if @post.update(post_params)
- redirect_to(@post, notice: 'Post was successfully updated.')
+ redirect_to(@post, notice: "Post was successfully updated.")
else
render(:edit)
end
@@ -36,7 +36,7 @@ def update
def destroy
@post.destroy
- redirect_to(posts_url, notice: 'Post was successfully destroyed.')
+ redirect_to(posts_url, notice: "Post was successfully destroyed.")
end
private
diff --git a/test/dummy/app/jobs/custom_task_job.rb b/test/dummy/app/jobs/custom_task_job.rb
index 9a5f9664..551c6682 100644
--- a/test/dummy/app/jobs/custom_task_job.rb
+++ b/test/dummy/app/jobs/custom_task_job.rb
@@ -3,7 +3,7 @@
class CustomTaskJob < MaintenanceTasks::TaskJob
before_enqueue do |job|
run = job.arguments.first
- raise 'Error enqueuing' if run.task_name == 'Maintenance::EnqueueErrorTask'
- throw :abort if run.task_name == 'Maintenance::CancelledEnqueueTask'
+ raise "Error enqueuing" if run.task_name == "Maintenance::EnqueueErrorTask"
+ throw :abort if run.task_name == "Maintenance::CancelledEnqueueTask"
end
end
diff --git a/test/dummy/app/mailers/application_mailer.rb b/test/dummy/app/mailers/application_mailer.rb
index 24289009..45b2abda 100644
--- a/test/dummy/app/mailers/application_mailer.rb
+++ b/test/dummy/app/mailers/application_mailer.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base
- default from: 'from@example.com'
- layout 'mailer'
+ default from: "from@example.com"
+ layout "mailer"
end
diff --git a/test/dummy/app/tasks/maintenance/error_task.rb b/test/dummy/app/tasks/maintenance/error_task.rb
index b9e20ef1..730cea7f 100644
--- a/test/dummy/app/tasks/maintenance/error_task.rb
+++ b/test/dummy/app/tasks/maintenance/error_task.rb
@@ -6,7 +6,7 @@ def collection
end
def process(input)
- raise ArgumentError, 'Something went wrong' if input == 2
+ raise ArgumentError, "Something went wrong" if input == 2
end
end
end
diff --git a/test/dummy/app/tasks/maintenance/import_posts_task.rb b/test/dummy/app/tasks/maintenance/import_posts_task.rb
index f2bc571d..9d7b6eac 100644
--- a/test/dummy/app/tasks/maintenance/import_posts_task.rb
+++ b/test/dummy/app/tasks/maintenance/import_posts_task.rb
@@ -4,7 +4,7 @@ class ImportPostsTask < MaintenanceTasks::Task
csv_collection
def process(row)
- Post.create!(title: row['title'], content: row['content'])
+ Post.create!(title: row["title"], content: row["content"])
end
end
end
diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails
index dd027b40..cbfe38b1 100755
--- a/test/dummy/bin/rails
+++ b/test/dummy/bin/rails
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
-APP_PATH = File.expand_path('../config/application', __dir__)
-require_relative '../config/boot'
-require 'rails/commands'
+APP_PATH = File.expand_path("../config/application", __dir__)
+require_relative "../config/boot"
+require "rails/commands"
diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake
index 609af747..d648cf02 100755
--- a/test/dummy/bin/rake
+++ b/test/dummy/bin/rake
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
-require_relative '../config/boot'
-require 'rake'
+require_relative "../config/boot"
+require "rake"
Rake.application.run
diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup
index cc587463..f9ae3cb4 100755
--- a/test/dummy/bin/setup
+++ b/test/dummy/bin/setup
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
-require 'fileutils'
+require "fileutils"
# path to your application root.
-APP_ROOT = File.expand_path('..', __dir__)
+APP_ROOT = File.expand_path("..", __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
@@ -16,9 +16,9 @@ FileUtils.chdir(APP_ROOT) do
# expectable outcome.
# Add necessary setup steps to this file.
- puts '== Installing dependencies =='
- system! 'gem install bundler --conservative'
- system('bundle check') || system!('bundle install')
+ puts "== Installing dependencies =="
+ system! "gem install bundler --conservative"
+ system("bundle check") || system!("bundle install")
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
@@ -26,11 +26,11 @@ FileUtils.chdir(APP_ROOT) do
# end
puts "\n== Preparing database =="
- system! 'bin/rails db:prepare'
+ system! "bin/rails db:prepare"
puts "\n== Removing old logs and tempfiles =="
- system! 'bin/rails log:clear tmp:clear'
+ system! "bin/rails log:clear tmp:clear"
puts "\n== Restarting application server =="
- system! 'bin/rails restart'
+ system! "bin/rails restart"
end
diff --git a/test/dummy/config.ru b/test/dummy/config.ru
index 1a864952..81cd2904 100644
--- a/test/dummy/config.ru
+++ b/test/dummy/config.ru
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application.
-require_relative 'config/environment'
+require_relative "config/environment"
run(Rails.application)
Rails.application.load_server
diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb
index 138a47d3..3d3e97b3 100644
--- a/test/dummy/config/application.rb
+++ b/test/dummy/config/application.rb
@@ -1,28 +1,28 @@
# frozen_string_literal: true
-require_relative 'boot'
+require_relative "boot"
verbose = $VERBOSE
$VERBOSE = false
-require 'action_mailbox/engine'
+require "action_mailbox/engine"
$VERBOSE = verbose
-require 'rails/all'
+require "rails/all"
Bundler.require(*Rails.groups)
-require 'maintenance_tasks'
+require "maintenance_tasks"
module Dummy
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults(6.1)
- if ENV['CLASSIC_AUTOLOADER'].present?
- puts '=> Using classic autoloader'
+ if ENV["CLASSIC_AUTOLOADER"].present?
+ puts "=> Using classic autoloader"
config.autoloader = :classic
end
config.to_prepare do
- MaintenanceTasks.job = 'CustomTaskJob'
+ MaintenanceTasks.job = "CustomTaskJob"
end
# Only include the helper module which match the name of the controller.
diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb
index 72fab4ce..4b7e9f81 100644
--- a/test/dummy/config/boot.rb
+++ b/test/dummy/config/boot.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
# Set up gems listed in the Gemfile.
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
-require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
-$LOAD_PATH.unshift(File.expand_path('../../../lib', __dir__))
+require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
+$LOAD_PATH.unshift(File.expand_path("../../../lib", __dir__))
diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb
index 12ea62f8..a21c0c58 100644
--- a/test/dummy/config/environment.rb
+++ b/test/dummy/config/environment.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
# Load the Rails application.
-require_relative 'application'
+require_relative "application"
# Initialize the Rails application.
Rails.application.initialize!
diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb
index a3a17c61..ae34435a 100644
--- a/test/dummy/config/environments/development.rb
+++ b/test/dummy/config/environments/development.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require 'active_support/core_ext/integer/time'
+require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in
@@ -18,13 +18,13 @@
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
- if Rails.root.join('tmp', 'caching-dev.txt').exist?
+ if Rails.root.join("tmp", "caching-dev.txt").exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :memory_store
config.public_file_server.headers = {
- 'Cache-Control' => "public, max-age=#{2.days.to_i}",
+ "Cache-Control" => "public, max-age=#{2.days.to_i}",
}
else
config.action_controller.perform_caching = false
diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb
index 01930fbf..20c79000 100644
--- a/test/dummy/config/environments/production.rb
+++ b/test/dummy/config/environments/production.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require 'active_support/core_ext/integer/time'
+require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in
@@ -25,7 +25,7 @@
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
- config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+ config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
@@ -99,7 +99,7 @@
# Syslog::Logger.new 'app-name'
# )
- if ENV['RAILS_LOG_TO_STDOUT'].present?
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb
index b6fde784..f948d1ba 100644
--- a/test/dummy/config/environments/test.rb
+++ b/test/dummy/config/environments/test.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require 'active_support/core_ext/integer/time'
+require "active_support/core_ext/integer/time"
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
@@ -20,7 +20,7 @@
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
- 'Cache-Control' => "public, max-age=#{1.hour.to_i}",
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}",
}
# Show full error reports and disable caching.
diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb
index f7deda5e..3bb606b2 100644
--- a/test/dummy/config/initializers/assets.rb
+++ b/test/dummy/config/initializers/assets.rb
@@ -2,7 +2,7 @@
# 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'
+Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
diff --git a/test/dummy/config/initializers/backtrace_silencers.rb b/test/dummy/config/initializers/backtrace_silencers.rb
index b228b301..7bcc81bb 100644
--- a/test/dummy/config/initializers/backtrace_silencers.rb
+++ b/test/dummy/config/initializers/backtrace_silencers.rb
@@ -8,4 +8,4 @@
# You can also remove all the silencers if you're trying to debug a problem
# that might stem from framework code by setting BACKTRACE=1 before calling
# your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
-Rails.backtrace_cleaner.remove_silencers! if ENV['BACKTRACE']
+Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]
diff --git a/test/dummy/config/puma.rb b/test/dummy/config/puma.rb
index 7cb0e8aa..19acbd80 100644
--- a/test/dummy/config/puma.rb
+++ b/test/dummy/config/puma.rb
@@ -5,21 +5,21 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
-max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
-min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
+max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads(min_threads_count, max_threads_count)
# Specifies the `port` that Puma will listen on to receive requests;
# default is 3000.
#
-port(ENV.fetch('PORT') { 3000 })
+port(ENV.fetch("PORT") { 3000 })
# Specifies the `environment` that Puma will run in.
#
-environment(ENV.fetch('RAILS_ENV') { 'development' })
+environment(ENV.fetch("RAILS_ENV") { "development" })
# Specifies the `pidfile` that Puma will use.
-pidfile(ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' })
+pidfile(ENV.fetch("PIDFILE") { "tmp/pids/server.pid" })
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb
index 7d96dd92..d39117e8 100644
--- a/test/dummy/config/routes.rb
+++ b/test/dummy/config/routes.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
Rails.application.routes.draw do
- mount MaintenanceTasks::Engine => '/maintenance_tasks'
+ mount MaintenanceTasks::Engine => "/maintenance_tasks"
resources :posts
- root to: 'posts#index'
+ root to: "posts#index"
end
diff --git a/test/dummy/config/spring.rb b/test/dummy/config/spring.rb
index 9a455793..3b898aff 100644
--- a/test/dummy/config/spring.rb
+++ b/test/dummy/config/spring.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
Spring.watch(
- '.ruby-version',
- '.rbenv-vars',
- 'tmp/restart.txt',
- 'tmp/caching-dev.txt'
+ ".ruby-version",
+ ".rbenv-vars",
+ "tmp/restart.txt",
+ "tmp/caching-dev.txt"
)
diff --git a/test/dummy/db/migrate/20210112141723_create_active_storage_tables.active_storage.rb b/test/dummy/db/migrate/20210112141723_create_active_storage_tables.active_storage.rb
index 18661282..48cced06 100644
--- a/test/dummy/db/migrate/20210112141723_create_active_storage_tables.active_storage.rb
+++ b/test/dummy/db/migrate/20210112141723_create_active_storage_tables.active_storage.rb
@@ -24,7 +24,7 @@ def change
t.index(
[:record_type, :record_id, :name, :blob_id],
- name: 'index_active_storage_attachments_uniqueness', unique: true
+ name: "index_active_storage_attachments_uniqueness", unique: true
)
t.foreign_key(:active_storage_blobs, column: :blob_id)
end
@@ -35,7 +35,7 @@ def change
t.index(
[:blob_id, :variation_digest],
- name: 'index_active_storage_variant_records_uniqueness',
+ name: "index_active_storage_variant_records_uniqueness",
unique: true
)
t.foreign_key(:active_storage_blobs, column: :blob_id)
diff --git a/test/dummy/db/seeds.rb b/test/dummy/db/seeds.rb
index 3b457a31..a963d5b9 100644
--- a/test/dummy/db/seeds.rb
+++ b/test/dummy/db/seeds.rb
@@ -6,7 +6,7 @@
module MaintenanceTasks
10.times do
Run.create!(
- task_name: 'Maintenance::UpdatePostsTask',
+ task_name: "Maintenance::UpdatePostsTask",
started_at: Time.now,
tick_count: 10,
tick_total: 10,
diff --git a/test/helpers/maintenance_tasks/application_helper_test.rb b/test/helpers/maintenance_tasks/application_helper_test.rb
index 60afa2f5..ef8c8963 100644
--- a/test/helpers/maintenance_tasks/application_helper_test.rb
+++ b/test/helpers/maintenance_tasks/application_helper_test.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
module MaintenanceTasks
class ApplicationHelperTest < ActionView::TestCase
- test '#time_ago returns a time element with the given datetime worded as relative to now and ISO 8601 UTC time in title attribute' do
+ test "#time_ago returns a time element with the given datetime worded as relative to now and ISO 8601 UTC time in title attribute" do
travel_to Time.zone.local(2020, 1, 9, 9, 41, 44)
time = Time.zone.local(2020, 01, 01, 01, 00, 00)
diff --git a/test/helpers/maintenance_tasks/tasks_helper_test.rb b/test/helpers/maintenance_tasks/tasks_helper_test.rb
index fdc369a5..1899d010 100644
--- a/test/helpers/maintenance_tasks/tasks_helper_test.rb
+++ b/test/helpers/maintenance_tasks/tasks_helper_test.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'test_helper'
+require "test_helper"
module MaintenanceTasks
class TasksHelperTest < ActionView::TestCase
@@ -8,23 +8,23 @@ class TasksHelperTest < ActionView::TestCase
@run = Run.new
end
- test '#format_backtrace converts the backtrace to a formatted string' do
+ test "#format_backtrace converts the backtrace to a formatted string" do
backtrace = [
"app/jobs/maintenance/error_task.rb:13:in `foo'",
"app/jobs/maintenance/error_task.rb:9:in `process'",
]
- expected_trace = 'app/jobs/maintenance/error_task.rb:13:in `foo'' \
- '
app/jobs/maintenance/error_task.rb:9:in `process''
+ expected_trace = "app/jobs/maintenance/error_task.rb:13:in `foo'" \
+ "
app/jobs/maintenance/error_task.rb:9:in `process'"
assert_equal expected_trace, format_backtrace(backtrace)
end
- test '#progress renders a