carrierwave_backgrounder 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/CHANGELOG.md +5 -0
  4. data/carrierwave_backgrounder.gemspec +1 -1
  5. data/lib/backgrounder/support/backends.rb +17 -5
  6. data/lib/backgrounder/version.rb +1 -1
  7. data/lib/carrierwave_backgrounder.rb +2 -11
  8. data/spec/backgrounder/support/backends_spec.rb +3 -1
  9. data/spec/integrations/queue_name_spec.rb +68 -0
  10. data/spec/rails_helper.rb +13 -0
  11. data/spec/support/dummy_app/Gemfile +3 -4
  12. data/spec/support/dummy_app/app/jobs/portrait_process_job.rb +5 -0
  13. data/spec/support/dummy_app/app/models/user.rb +3 -0
  14. data/spec/support/dummy_app/bin/ci +6 -0
  15. data/spec/support/dummy_app/bin/dev +2 -0
  16. data/spec/support/dummy_app/bin/setup +7 -5
  17. data/spec/support/dummy_app/config/application.rb +6 -1
  18. data/spec/support/dummy_app/config/ci.rb +14 -0
  19. data/spec/support/dummy_app/config/environments/development.rb +19 -29
  20. data/spec/support/dummy_app/config/environments/production.rb +35 -54
  21. data/spec/support/dummy_app/config/environments/test.rb +16 -36
  22. data/spec/support/dummy_app/config/initializers/cors.rb +1 -1
  23. data/spec/support/dummy_app/config/initializers/filter_parameter_logging.rb +4 -4
  24. data/spec/support/dummy_app/config/initializers/new_framework_defaults_8_0.rb +30 -0
  25. data/spec/support/dummy_app/config/initializers/new_framework_defaults_8_1.rb +74 -0
  26. data/spec/support/dummy_app/config/puma.rb +42 -0
  27. data/spec/support/dummy_app/db/migrate/20250926184915_add_columns_for_portrait.rb +7 -0
  28. data/spec/support/dummy_app/db/schema.rb +4 -2
  29. data/spec/support/mock_worker.rb +6 -0
  30. metadata +21 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e007beb6c4d7bdd9d12f197d3dd1ef9a1fd0db2cff176c91bf556167311c916
4
- data.tar.gz: d6d3ffca8551ea931c9788c02b1b6aa73ace34274229152c5816ed871f9e50a2
3
+ metadata.gz: 5261f9e14c16c978b41ba71d0074359b5ec321d0ee7e3b410685e770f246fb87
4
+ data.tar.gz: 105e8b097e25d084f33d75e1556c3227aa6b758e5045315ce893fe2f0cda086b
5
5
  SHA512:
6
- metadata.gz: 2186ebdc16e2e3dd6dc76d5998ba79b23903caaf956d18fa403228f75e636b145bb3b7a0b0d0ef078e3c9530bb868dbae20d3b83beddd0a4bfa9a168c351b667
7
- data.tar.gz: 35cc9df51de365463319a0d4cdd9df204ecb44105f5975d37cbaf1a1e3aff68335082fbf3f83ac98975722e9012447dc93429c039603d44def6856fe1c2cab7d
6
+ metadata.gz: 2c9a5084377b753246a7be2c3d5f087c24b524c0f821b8a3375047512f766d0c0ca8a876e826a93bec2a389394e9e892c6e727ef11854c2e247721b4640ae8e0
7
+ data.tar.gz: 3d1d565d67a68c651b56a5eed01e10fa5a50e69a5b6b8880ee88daaa2507eda01eba2015732455ab64de8e5cb267d8f7640048e96649586c28fe04058f51cb2e
data/.gitignore CHANGED
@@ -4,3 +4,5 @@
4
4
  Gemfile.lock
5
5
  pkg/*
6
6
  vendor/*
7
+ spec/support/dummy_app/log/*
8
+ spec/support/dummy_app/tmp/*
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.1.2
2
+
3
+ ### enhancements
4
+ * Add support for Rails 8.1 [gstokkink]
5
+
1
6
  ## 1.1.0
2
7
 
3
8
  ### enhancements
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.required_ruby_version = '>= 3.0'
22
22
 
23
23
  s.add_dependency "carrierwave", ["> 2.0", "< 4.0"]
24
- s.add_dependency "rails", ["> 6.0", "< 8.1"]
24
+ s.add_dependency "rails", ["> 6.0", "< 8.2"]
25
25
 
26
26
  s.add_development_dependency "rspec", ["~> 3.12"]
27
27
  s.add_development_dependency "rake"
@@ -10,10 +10,10 @@ module CarrierWave
10
10
  module ClassMethods
11
11
  attr_reader :queue_options
12
12
 
13
- def backend(queue_name=nil, args={})
13
+ def backend(backend_name=nil, args={})
14
14
  return @backend if @backend
15
- @queue_options = args
16
- @backend = queue_name
15
+ @queue_options = set_queue_name_default(args)
16
+ @backend = backend_name
17
17
  end
18
18
 
19
19
  def enqueue_for_backend(worker, class_name, subject_id, mounted_as)
@@ -23,17 +23,29 @@ module CarrierWave
23
23
  private
24
24
 
25
25
  def enqueue_active_job(worker, *args)
26
- worker.perform_later(*args.map(&:to_s))
26
+ options = if worker.new.queue_name != 'default'
27
+ queue_options.except(:queue)
28
+ else
29
+ queue_options
30
+ end
31
+
32
+ worker.set(options).perform_later(*args.map(&:to_s))
27
33
  end
28
34
 
29
35
  def enqueue_sidekiq(worker, *args)
30
- override_queue_name = worker.sidekiq_options['queue'] == 'default' || worker.sidekiq_options['queue'].nil?
36
+ override_queue_name = worker.sidekiq_options['queue'] == 'default'
31
37
  args = sidekiq_queue_options(override_queue_name, 'class' => worker, 'args' => args.map(&:to_s))
32
38
  worker.client_push(args)
33
39
  end
34
40
 
35
41
  private
36
42
 
43
+ def set_queue_name_default(options)
44
+ options.tap do |opts|
45
+ opts[:queue] ||= :carrierwave
46
+ end
47
+ end
48
+
37
49
  def sidekiq_queue_options(override_queue_name, args)
38
50
  if override_queue_name && queue_options[:queue]
39
51
  args['queue'] = queue_options[:queue]
@@ -1,5 +1,5 @@
1
1
  module CarrierWave
2
2
  module Backgrounder
3
- VERSION = "1.1.1"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
@@ -22,15 +22,6 @@ module CarrierWave
22
22
  @worker_klass = 'CarrierWave::Workers::ActiveJob'
23
23
  require 'backgrounder/workers/active_job/process_asset'
24
24
  require 'backgrounder/workers/active_job/store_asset'
25
-
26
- queue_name = queue_options[:queue] || 'carrierwave'
27
-
28
- ::CarrierWave::Workers::ActiveJob::ProcessAsset.class_eval do
29
- queue_as queue_name
30
- end
31
- ::CarrierWave::Workers::ActiveJob::StoreAsset.class_eval do
32
- queue_as queue_name
33
- end
34
25
  when :sidekiq
35
26
  @worker_klass = 'CarrierWave::Workers'
36
27
 
@@ -43,8 +34,8 @@ module CarrierWave
43
34
  end
44
35
  end
45
36
 
46
- def self.suppress_record_not_found_errors(surpress_errors = true)
47
- @suppress_not_found_errors = surpress_errors
37
+ def self.suppress_record_not_found_errors(suppress_errors = true)
38
+ @suppress_not_found_errors = suppress_errors
48
39
  end
49
40
  end
50
41
  end
@@ -44,7 +44,9 @@ module CarrierWave::Backgrounder
44
44
  let(:args) { ['FakeClass', 1, :image] }
45
45
 
46
46
  it 'invokes client_push on the class with passed args' do
47
- expect(MockSidekiqWorker).to receive(:client_push).with({ 'class' => MockSidekiqWorker, 'args' => args.map(&:to_s) })
47
+ expect(MockSidekiqWorker).to receive(:client_push).with({ 'class' => MockSidekiqWorker,
48
+ 'args' => args.map(&:to_s),
49
+ 'queue' => :carrierwave })
48
50
  mock_module.backend :sidekiq
49
51
  mock_module.enqueue_for_backend(MockSidekiqWorker, *args)
50
52
  end
@@ -0,0 +1,68 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe 'Queue Name', clear_images: true do
4
+ let(:user) { User.new }
5
+
6
+ context 'when using built in worker' do
7
+ context 'when queue name is passed in via config' do
8
+ before do
9
+ CarrierWave::Backgrounder.instance_variable_set(:@queue_options, queue: 'carrierwaver')
10
+ end
11
+
12
+ after do
13
+ CarrierWave::Backgrounder.instance_variable_set(:@queue_options, queue: 'carrierwave')
14
+ end
15
+
16
+ it 'uses the config queue name' do
17
+ user.update(avatar: load_file('test-1.jpg'))
18
+ expect(Sidekiq::Queues["carrierwaver"].size).to eql(1)
19
+ end
20
+ end
21
+
22
+ context 'when not queue name is not set' do
23
+ it 'uses the default name carrierwave' do
24
+ user.update(avatar: load_file('test-1.jpg'))
25
+ expect(Sidekiq::Queues["carrierwave"].size).to eql(1)
26
+ end
27
+ end
28
+ end
29
+
30
+ context 'when using a subclassed worker' do
31
+ context 'when queue name is passed in via config' do
32
+ before do
33
+ CarrierWave::Backgrounder.instance_variable_set(:@queue_options, queue: 'carrierwaver')
34
+ end
35
+
36
+ after do
37
+ CarrierWave::Backgrounder.instance_variable_set(:@queue_options, queue: 'carrierwave')
38
+ end
39
+
40
+ it 'uses the config queue name' do
41
+ user.update(portrait: load_file('test-1.jpg'))
42
+ expect(Sidekiq::Queues["carrierwaver"].size).to eql(1)
43
+ end
44
+ end
45
+
46
+ context 'when not queue name is not set' do
47
+ it 'uses the default name carrierwave' do
48
+ user.update(portrait: load_file('test-1.jpg'))
49
+ expect(Sidekiq::Queues["carrierwave"].size).to eql(1)
50
+ end
51
+ end
52
+
53
+ context 'when overridden via subclassed worker' do
54
+ before do
55
+ PortraitProcessJob.queue_as :custom_queue
56
+ end
57
+
58
+ after do
59
+ PortraitProcessJob.queue_as :carrierwave
60
+ end
61
+
62
+ it 'uses the queue name passed in' do
63
+ user.update(portrait: load_file('test-1.jpg'))
64
+ expect(Sidekiq::Queues["custom_queue"].size).to eql(1)
65
+ end
66
+ end
67
+ end
68
+ end
data/spec/rails_helper.rb CHANGED
@@ -7,6 +7,19 @@ require 'sidekiq/testing'
7
7
  require 'rspec/rails'
8
8
  require 'backgrounder/railtie'
9
9
 
10
+ if ENV['QUEUE_ADAPTER'] == 'sidekiq'
11
+ Object.send(:remove_const, :PortraitProcessJob) if defined?(PortraitProcessJob)
12
+ class PortraitProcessJob
13
+ include CarrierWave::Workers::ProcessAssetMixin
14
+ include Sidekiq::Worker
15
+ end
16
+ else
17
+ Object.send(:remove_const, :PortraitProcessJob) if defined?(PortraitProcessJob)
18
+ class PortraitProcessJob < ::ActiveJob::Base
19
+ include CarrierWave::Workers::ProcessAssetMixin
20
+ end
21
+ end
22
+
10
23
  begin
11
24
  ActiveRecord::Migration.maintain_test_schema!
12
25
  rescue ActiveRecord::PendingMigrationError => e
@@ -1,13 +1,13 @@
1
1
  source "https://rubygems.org"
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
- ruby "3.0.0"
4
+ ruby "3.4.5"
5
5
 
6
6
  # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
7
- gem "rails", "~> 8.0.2"
7
+ gem "rails", "~> 8.1.1"
8
8
 
9
9
  # Use sqlite3 as the database for Active Record
10
- gem "sqlite3", "~> 1.4"
10
+ gem "sqlite3", "~> 2.7"
11
11
 
12
12
  # Use the Puma web server [https://github.com/puma/puma]
13
13
  # gem "puma", "~> 5.0"
@@ -46,4 +46,3 @@ group :development do
46
46
  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
47
47
  # gem "spring"
48
48
  end
49
-
@@ -0,0 +1,5 @@
1
+ class PortraitProcessJob
2
+ def perform(*args)
3
+ # Do something later
4
+ end
5
+ end
@@ -7,4 +7,7 @@ class User < ApplicationRecord
7
7
  mount_uploaders :images, AvatarUploader
8
8
  store_in_background :images
9
9
  serialize :images, coder: JSON
10
+
11
+ mount_uploader :portrait, AvatarUploader
12
+ store_in_background :portrait, PortraitProcessJob
10
13
  end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "active_support/continuous_integration"
4
+
5
+ CI = ActiveSupport::ContinuousIntegration
6
+ require_relative "../config/ci.rb"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ exec "./bin/rails", "server", *ARGV
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "fileutils"
3
3
 
4
- # path to your application root.
5
4
  APP_ROOT = File.expand_path("..", __dir__)
6
5
 
7
6
  def system!(*args)
8
- system(*args) || abort("\n== Command #{args} failed ==")
7
+ system(*args, exception: true)
9
8
  end
10
9
 
11
10
  FileUtils.chdir APP_ROOT do
@@ -14,7 +13,6 @@ FileUtils.chdir APP_ROOT do
14
13
  # Add necessary setup steps to this file.
15
14
 
16
15
  puts "== Installing dependencies =="
17
- system! "gem install bundler --conservative"
18
16
  system("bundle check") || system!("bundle install")
19
17
 
20
18
  # puts "\n== Copying sample files =="
@@ -24,10 +22,14 @@ FileUtils.chdir APP_ROOT do
24
22
 
25
23
  puts "\n== Preparing database =="
26
24
  system! "bin/rails db:prepare"
25
+ system! "bin/rails db:reset" if ARGV.include?("--reset")
27
26
 
28
27
  puts "\n== Removing old logs and tempfiles =="
29
28
  system! "bin/rails log:clear tmp:clear"
30
29
 
31
- puts "\n== Restarting application server =="
32
- system! "bin/rails restart"
30
+ unless ARGV.include?("--skip-server")
31
+ puts "\n== Starting development server =="
32
+ STDOUT.flush # flush the output before exec(2) so that it displays
33
+ exec "bin/dev"
34
+ end
33
35
  end
@@ -21,7 +21,12 @@ Bundler.require(*Rails.groups)
21
21
  module DummyApp
22
22
  class Application < Rails::Application
23
23
  # Initialize configuration defaults for originally generated Rails version.
24
- config.load_defaults 7.0
24
+ config.load_defaults 8.0
25
+
26
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
27
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
28
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
29
+ config.autoload_lib(ignore: %w[assets tasks])
25
30
 
26
31
  # Configuration for the application, engines, and railties goes here.
27
32
  #
@@ -0,0 +1,14 @@
1
+ # Run using bin/ci
2
+
3
+ CI.run do
4
+ step "Setup", "bin/setup --skip-server"
5
+
6
+
7
+ # Optional: set a green GitHub commit status to unblock PR merge.
8
+ # Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`.
9
+ # if success?
10
+ # step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
11
+ # else
12
+ # failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
13
+ # end
14
+ end
@@ -3,10 +3,8 @@ require "active_support/core_ext/integer/time"
3
3
  Rails.application.configure do
4
4
  # Settings specified here will take precedence over those in config/application.rb.
5
5
 
6
- # In the development environment your application's code is reloaded any time
7
- # it changes. This slows down response time but is perfect for development
8
- # since you don't have to restart the web server when you make code changes.
9
- config.cache_classes = false
6
+ # Make code changes take effect immediately without server restart.
7
+ config.enable_reloading = true
10
8
 
11
9
  # Do not eager load code on boot.
12
10
  config.eager_load = false
@@ -14,52 +12,44 @@ Rails.application.configure do
14
12
  # Show full error reports.
15
13
  config.consider_all_requests_local = true
16
14
 
17
- # Enable server timing
15
+ # Enable server timing.
18
16
  config.server_timing = true
19
17
 
20
- # Enable/disable caching. By default caching is disabled.
21
- # Run rails dev:cache to toggle caching.
18
+ # Enable/disable Action Controller caching. By default Action Controller caching is disabled.
19
+ # Run rails dev:cache to toggle Action Controller caching.
22
20
  if Rails.root.join("tmp/caching-dev.txt").exist?
23
- config.cache_store = :memory_store
24
- config.public_file_server.headers = {
25
- "Cache-Control" => "public, max-age=#{2.days.to_i}"
26
- }
21
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
27
22
  else
28
23
  config.action_controller.perform_caching = false
29
-
30
- config.cache_store = :null_store
31
24
  end
32
25
 
33
- # Store uploaded files on the local file system (see config/storage.yml for options).
34
- # config.active_storage.service = :local
35
-
36
- # Don't care if the mailer can't send.
37
- # config.action_mailer.raise_delivery_errors = false
38
-
39
- # config.action_mailer.perform_caching = false
26
+ # Change to :null_store to avoid any caching.
27
+ config.cache_store = :memory_store
40
28
 
41
29
  # Print deprecation notices to the Rails logger.
42
30
  config.active_support.deprecation = :log
43
31
 
44
- # Raise exceptions for disallowed deprecations.
45
- config.active_support.disallowed_deprecation = :raise
46
-
47
- # Tell Active Support which deprecation messages to disallow.
48
- config.active_support.disallowed_deprecation_warnings = []
49
-
50
32
  # Raise an error on page load if there are pending migrations.
51
33
  config.active_record.migration_error = :page_load
52
34
 
53
35
  # Highlight code that triggered database queries in logs.
54
36
  config.active_record.verbose_query_logs = true
55
37
 
38
+ # Append comments with runtime information tags to SQL queries in logs.
39
+ config.active_record.query_log_tags_enabled = true
40
+
41
+ # Highlight code that enqueued background job in logs.
42
+ config.active_job.verbose_enqueue_logs = true
43
+
44
+ # Highlight code that triggered redirect in logs.
45
+ config.action_dispatch.verbose_redirect_logs = true
56
46
 
57
47
  # Raises error for missing translations.
58
48
  # config.i18n.raise_on_missing_translations = true
59
49
 
60
50
  # Annotate rendered view with file names.
61
- # config.action_view.annotate_rendered_view_with_filenames = true
51
+ config.action_view.annotate_rendered_view_with_filenames = true
62
52
 
63
- # Uncomment if you wish to allow Action Cable access from any origin.
64
- # config.action_cable.disable_request_forgery_protection = true
53
+ # Raise error when a before_action's only/except options reference missing actions.
54
+ config.action_controller.raise_on_missing_callback_actions = true
65
55
  end
@@ -4,83 +4,64 @@ Rails.application.configure do
4
4
  # Settings specified here will take precedence over those in config/application.rb.
5
5
 
6
6
  # Code is not reloaded between requests.
7
- config.cache_classes = true
7
+ config.enable_reloading = false
8
8
 
9
- # Eager load code on boot. This eager loads most of Rails and
10
- # your application in memory, allowing both threaded web servers
11
- # and those relying on copy on write to perform better.
12
- # Rake tasks automatically ignore this option for performance.
9
+ # Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
13
10
  config.eager_load = true
14
11
 
15
- # Full error reports are disabled and caching is turned on.
16
- config.consider_all_requests_local = false
12
+ # Full error reports are disabled.
13
+ config.consider_all_requests_local = false
17
14
 
18
- # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
19
- # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
20
- # config.require_master_key = true
21
-
22
- # Disable serving static files from the `/public` folder by default since
23
- # Apache or NGINX already handles this.
24
- config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
15
+ # Cache assets for far-future expiry since they are all digest stamped.
16
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
25
17
 
26
18
  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
27
19
  # config.asset_host = "http://assets.example.com"
28
20
 
29
- # Specifies the header that your server uses for sending files.
30
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
31
- # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
32
-
33
- # Store uploaded files on the local file system (see config/storage.yml for options).
34
- # config.active_storage.service = :local
35
-
36
- # Mount Action Cable outside main process or domain.
37
- # config.action_cable.mount_path = nil
38
- # config.action_cable.url = "wss://example.com/cable"
39
- # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
21
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
22
+ # config.assume_ssl = true
40
23
 
41
24
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
42
25
  # config.force_ssl = true
43
26
 
44
- # Include generic and useful information about system operation, but avoid logging too much
45
- # information to avoid inadvertent exposure of personally identifiable information (PII).
46
- config.log_level = :info
27
+ # Skip http-to-https redirect for the default health check endpoint.
28
+ # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
47
29
 
48
- # Prepend all log lines with the following tags.
30
+ # Log to STDOUT with the current request id as a default log tag.
49
31
  config.log_tags = [ :request_id ]
32
+ config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
50
33
 
51
- # Use a different cache store in production.
52
- # config.cache_store = :mem_cache_store
53
-
54
- # Use a real queuing backend for Active Job (and separate queues per environment).
55
- # config.active_job.queue_adapter = :resque
56
- # config.active_job.queue_name_prefix = "dummy_app_production"
57
-
58
- config.action_mailer.perform_caching = false
34
+ # Change to "debug" to log everything (including potentially personally-identifiable information!).
35
+ config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
59
36
 
60
- # Ignore bad email addresses and do not raise email delivery errors.
61
- # Set this to true and configure the email server for immediate delivery to raise delivery errors.
62
- # config.action_mailer.raise_delivery_errors = false
63
-
64
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
65
- # the I18n.default_locale when a translation cannot be found).
66
- config.i18n.fallbacks = true
37
+ # Prevent health checks from clogging up the logs.
38
+ config.silence_healthcheck_path = "/up"
67
39
 
68
40
  # Don't log any deprecations.
69
41
  config.active_support.report_deprecations = false
70
42
 
71
- # Use default logging formatter so that PID and timestamp are not suppressed.
72
- config.log_formatter = ::Logger::Formatter.new
43
+ # Replace the default in-process memory cache store with a durable alternative.
44
+ # config.cache_store = :mem_cache_store
73
45
 
74
- # Use a different logger for distributed setups.
75
- # require "syslog/logger"
76
- # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
46
+ # Replace the default in-process and non-durable queuing backend for Active Job.
47
+ # config.active_job.queue_adapter = :resque
77
48
 
78
- if ENV["RAILS_LOG_TO_STDOUT"].present?
79
- logger = ActiveSupport::Logger.new(STDOUT)
80
- logger.formatter = config.log_formatter
81
- config.logger = ActiveSupport::TaggedLogging.new(logger)
82
- end
49
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
50
+ # the I18n.default_locale when a translation cannot be found).
51
+ config.i18n.fallbacks = true
83
52
 
84
53
  # Do not dump schema after migrations.
85
54
  config.active_record.dump_schema_after_migration = false
55
+
56
+ # Only use :id for inspections in production.
57
+ config.active_record.attributes_for_inspect = [ :id ]
58
+
59
+ # Enable DNS rebinding protection and other `Host` header attacks.
60
+ # config.hosts = [
61
+ # "example.com", # Allow requests from example.com
62
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
63
+ # ]
64
+ #
65
+ # Skip DNS rebinding protection for the default health check endpoint.
66
+ # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
86
67
  end
@@ -1,5 +1,3 @@
1
- require "active_support/core_ext/integer/time"
2
-
3
1
  # The test environment is used exclusively to run your application's
4
2
  # test suite. You never need to work with it otherwise. Remember that
5
3
  # your test database is "scratch space" for the test suite and is wiped
@@ -8,56 +6,38 @@ require "active_support/core_ext/integer/time"
8
6
  Rails.application.configure do
9
7
  # Settings specified here will take precedence over those in config/application.rb.
10
8
 
11
- # Turn false under Spring and add config.action_view.cache_template_loading = true.
12
- config.cache_classes = true
9
+ # While tests run files are not watched, reloading is not necessary.
10
+ config.enable_reloading = false
13
11
 
14
- # Eager loading loads your whole application. When running a single test locally,
15
- # this probably isn't necessary. It's a good idea to do in a continuous integration
16
- # system, or in some way before deploying your code.
12
+ # Eager loading loads your entire application. When running a single test locally,
13
+ # this is usually not necessary, and can slow down your test suite. However, it's
14
+ # recommended that you enable it in continuous integration systems to ensure eager
15
+ # loading is working properly before deploying your code.
17
16
  config.eager_load = ENV["CI"].present?
18
17
 
19
- # Configure public file server for tests with Cache-Control for performance.
20
- config.public_file_server.enabled = true
21
- config.public_file_server.headers = {
22
- "Cache-Control" => "public, max-age=#{1.hour.to_i}"
23
- }
18
+ # Configure public file server for tests with cache-control for performance.
19
+ config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
24
20
 
25
- # Show full error reports and disable caching.
26
- config.consider_all_requests_local = true
27
- config.action_controller.perform_caching = false
21
+ # Show full error reports.
22
+ config.consider_all_requests_local = true
28
23
  config.cache_store = :null_store
29
24
 
30
- # Raise exceptions instead of rendering exception templates.
31
- config.action_dispatch.show_exceptions = false
25
+ # Render exception templates for rescuable exceptions and raise for other exceptions.
26
+ config.action_dispatch.show_exceptions = :rescuable
32
27
 
33
28
  # Disable request forgery protection in test environment.
34
29
  config.action_controller.allow_forgery_protection = false
35
30
 
36
- # Store uploaded files on the local file system in a temporary directory.
37
- # config.active_storage.service = :test
38
-
39
- # config.action_mailer.perform_caching = false
40
-
41
- # Tell Action Mailer not to deliver emails to the real world.
42
- # The :test delivery method accumulates sent emails in the
43
- # ActionMailer::Base.deliveries array.
44
- # config.action_mailer.delivery_method = :test
45
- config.log_level = :info
46
-
47
31
  # Print deprecation notices to the stderr.
48
32
  config.active_support.deprecation = :stderr
49
33
 
50
- # Raise exceptions for disallowed deprecations.
51
- config.active_support.disallowed_deprecation = :raise
52
-
53
- # Tell Active Support which deprecation messages to disallow.
54
- config.active_support.disallowed_deprecation_warnings = []
55
-
56
- config.active_job.queue_adapter = :sidekiq
57
-
58
34
  # Raises error for missing translations.
59
35
  # config.i18n.raise_on_missing_translations = true
60
36
 
61
37
  # Annotate rendered view with file names.
62
38
  # config.action_view.annotate_rendered_view_with_filenames = true
39
+
40
+ # Raise error when a before_action's only/except options reference missing actions.
41
+ config.action_controller.raise_on_missing_callback_actions = true
42
+ config.active_job.queue_adapter = :sidekiq
63
43
  end
@@ -1,7 +1,7 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  # Avoid CORS issues when API is called from the frontend app.
4
- # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
4
+ # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests.
5
5
 
6
6
  # Read more: https://github.com/cyu/rack-cors
7
7
 
@@ -1,8 +1,8 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Configure parameters to be filtered from the log file. Use this to limit dissemination of
4
- # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5
- # notations and behaviors.
3
+ # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
4
+ # Use this to limit dissemination of sensitive information.
5
+ # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
6
6
  Rails.application.config.filter_parameters += [
7
- :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
7
+ :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc
8
8
  ]
@@ -0,0 +1,30 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file eases your Rails 8.0 framework defaults upgrade.
4
+ #
5
+ # Uncomment each configuration one by one to switch to the new default.
6
+ # Once your application is ready to run with all new defaults, you can remove
7
+ # this file and set the `config.load_defaults` to `8.0`.
8
+ #
9
+ # Read the Guide for Upgrading Ruby on Rails for more info on each option.
10
+ # https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
11
+
12
+ ###
13
+ # Specifies whether `to_time` methods preserve the UTC offset of their receivers or preserves the timezone.
14
+ # If set to `:zone`, `to_time` methods will use the timezone of their receivers.
15
+ # If set to `:offset`, `to_time` methods will use the UTC offset.
16
+ # If `false`, `to_time` methods will convert to the local system UTC offset instead.
17
+ #++
18
+ # Rails.application.config.active_support.to_time_preserves_timezone = :zone
19
+
20
+ ###
21
+ # When both `If-Modified-Since` and `If-None-Match` are provided by the client
22
+ # only consider `If-None-Match` as specified by RFC 7232 Section 6.
23
+ # If set to `false` both conditions need to be satisfied.
24
+ #++
25
+ # Rails.application.config.action_dispatch.strict_freshness = true
26
+
27
+ ###
28
+ # Set `Regexp.timeout` to `1`s by default to improve security over Regexp Denial-of-Service attacks.
29
+ #++
30
+ # Regexp.timeout = 1
@@ -0,0 +1,74 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file eases your Rails 8.1 framework defaults upgrade.
4
+ #
5
+ # Uncomment each configuration one by one to switch to the new default.
6
+ # Once your application is ready to run with all new defaults, you can remove
7
+ # this file and set the `config.load_defaults` to `8.1`.
8
+ #
9
+ # Read the Guide for Upgrading Ruby on Rails for more info on each option.
10
+ # https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
11
+
12
+ ###
13
+ # Skips escaping HTML entities and line separators. When set to `false`, the
14
+ # JSON renderer no longer escapes these to improve performance.
15
+ #
16
+ # Example:
17
+ # class PostsController < ApplicationController
18
+ # def index
19
+ # render json: { key: "\u2028\u2029<>&" }
20
+ # end
21
+ # end
22
+ #
23
+ # Renders `{"key":"\u2028\u2029\u003c\u003e\u0026"}` with the previous default, but `{"key":"

<>&"}` with the config
24
+ # set to `false`.
25
+ #
26
+ # Applications that want to keep the escaping behavior can set the config to `true`.
27
+ #++
28
+ # Rails.configuration.action_controller.escape_json_responses = false
29
+
30
+ ###
31
+ # Skips escaping LINE SEPARATOR (U+2028) and PARAGRAPH SEPARATOR (U+2029) in JSON.
32
+ #
33
+ # Historically these characters were not valid inside JavaScript literal strings but that changed in ECMAScript 2019.
34
+ # As such it's no longer a concern in modern browsers: https://caniuse.com/mdn-javascript_builtins_json_json_superset.
35
+ #++
36
+ # Rails.configuration.active_support.escape_js_separators_in_json = false
37
+
38
+ ###
39
+ # Raises an error when order dependent finder methods (e.g. `#first`, `#second`) are called without `order` values
40
+ # on the relation, and the model does not have any order columns (`implicit_order_column`, `query_constraints`, or
41
+ # `primary_key`) to fall back on.
42
+ #
43
+ # The current behavior of not raising an error has been deprecated, and this configuration option will be removed in
44
+ # Rails 8.2.
45
+ #++
46
+ # Rails.configuration.active_record.raise_on_missing_required_finder_order_columns = true
47
+
48
+ ###
49
+ # Controls how Rails handles path relative URL redirects.
50
+ # When set to `:raise`, Rails will raise an `ActionController::Redirecting::UnsafeRedirectError`
51
+ # for relative URLs without a leading slash, which can help prevent open redirect vulnerabilities.
52
+ #
53
+ # Example:
54
+ # redirect_to "example.com" # Raises UnsafeRedirectError
55
+ # redirect_to "@attacker.com" # Raises UnsafeRedirectError
56
+ # redirect_to "/safe/path" # Works correctly
57
+ #
58
+ # Applications that want to allow these redirects can set the config to `:log` (previous default)
59
+ # to only log warnings, or `:notify` to send ActiveSupport notifications.
60
+ #++
61
+ # Rails.configuration.action_controller.action_on_path_relative_redirect = :raise
62
+
63
+ ###
64
+ # Use a Ruby parser to track dependencies between Action View templates
65
+ #++
66
+ # Rails.configuration.action_view.render_tracker = :ruby
67
+
68
+ ###
69
+ # When enabled, hidden inputs generated by `form_tag`, `token_tag`, `method_tag`, and the hidden parameter fields
70
+ # included in `button_to` forms will omit the `autocomplete="off"` attribute.
71
+ #
72
+ # Applications that want to keep generating the `autocomplete` attribute for those tags can set it to `false`.
73
+ #++
74
+ # Rails.configuration.action_view.remove_hidden_field_autocomplete = true
@@ -0,0 +1,42 @@
1
+ # This configuration file will be evaluated by Puma. The top-level methods that
2
+ # are invoked here are part of Puma's configuration DSL. For more information
3
+ # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
4
+ #
5
+ # Puma starts a configurable number of processes (workers) and each process
6
+ # serves each request in a thread from an internal thread pool.
7
+ #
8
+ # You can control the number of workers using ENV["WEB_CONCURRENCY"]. You
9
+ # should only set this value when you want to run 2 or more workers. The
10
+ # default is already 1. You can set it to `auto` to automatically start a worker
11
+ # for each available processor.
12
+ #
13
+ # The ideal number of threads per worker depends both on how much time the
14
+ # application spends waiting for IO operations and on how much you wish to
15
+ # prioritize throughput over latency.
16
+ #
17
+ # As a rule of thumb, increasing the number of threads will increase how much
18
+ # traffic a given process can handle (throughput), but due to CRuby's
19
+ # Global VM Lock (GVL) it has diminishing returns and will degrade the
20
+ # response time (latency) of the application.
21
+ #
22
+ # The default is set to 3 threads as it's deemed a decent compromise between
23
+ # throughput and latency for the average Rails application.
24
+ #
25
+ # Any libraries that use a connection pool or another resource pool should
26
+ # be configured to provide at least as many connections as the number of
27
+ # threads. This includes Active Record's `pool` parameter in `database.yml`.
28
+ threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
29
+ threads threads_count, threads_count
30
+
31
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
32
+ port ENV.fetch("PORT", 3000)
33
+
34
+ # Allow puma to be restarted by `bin/rails restart` command.
35
+ plugin :tmp_restart
36
+
37
+ # Run the Solid Queue supervisor inside of Puma for single-server deployments.
38
+ plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
39
+
40
+ # Specify the PID file. Defaults to tmp/pids/server.pid in development.
41
+ # In other environments, only set the PID file if requested.
42
+ pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
@@ -0,0 +1,7 @@
1
+ class AddColumnsForPortrait < ActiveRecord::Migration[8.0]
2
+ def change
3
+ add_column :users, :portrait, :string
4
+ add_column :users, :portrait_tmp, :string
5
+ add_column :users, :portrait_processing, :boolean, null: false, default:false
6
+ end
7
+ end
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema[7.0].define(version: 2023_08_11_155811) do
13
+ ActiveRecord::Schema[8.0].define(version: 2025_09_26_184915) do
14
14
  create_table "admins", force: :cascade do |t|
15
15
  t.string "avatar"
16
16
  t.boolean "avatar_processing", default: false, null: false
@@ -29,6 +29,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_11_155811) do
29
29
  t.string "images"
30
30
  t.string "images_tmp"
31
31
  t.boolean "images_processing", default: false, null: false
32
+ t.string "portrait"
33
+ t.string "portrait_tmp"
34
+ t.boolean "portrait_processing", default: false, null: false
32
35
  end
33
-
34
36
  end
@@ -5,6 +5,10 @@ class MockWorker < Struct.new(:klass, :id, :column)
5
5
  new(*args).perform
6
6
  end
7
7
 
8
+ def self.set(*)
9
+ self
10
+ end
11
+
8
12
  def perform(*args)
9
13
  set_args(*args) unless args.empty?
10
14
  end
@@ -12,6 +16,8 @@ class MockWorker < Struct.new(:klass, :id, :column)
12
16
  def set_args(klass, id, column)
13
17
  self.klass, self.id, self.column = klass, id, column
14
18
  end
19
+
20
+ def queue_name; end
15
21
  end
16
22
 
17
23
  class MockSidekiqWorker < MockWorker
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave_backgrounder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Larry Sprock
@@ -38,7 +38,7 @@ dependencies:
38
38
  version: '6.0'
39
39
  - - "<"
40
40
  - !ruby/object:Gem::Version
41
- version: '8.1'
41
+ version: '8.2'
42
42
  type: :runtime
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
@@ -48,7 +48,7 @@ dependencies:
48
48
  version: '6.0'
49
49
  - - "<"
50
50
  - !ruby/object:Gem::Version
51
- version: '8.1'
51
+ version: '8.2'
52
52
  - !ruby/object:Gem::Dependency
53
53
  name: rspec
54
54
  requirement: !ruby/object:Gem::Requirement
@@ -175,6 +175,7 @@ files:
175
175
  - spec/backgrounder/workers/store_asset_spec.rb
176
176
  - spec/integrations/process_in_background_multi_upload_spec.rb
177
177
  - spec/integrations/process_in_background_spec.rb
178
+ - spec/integrations/queue_name_spec.rb
178
179
  - spec/integrations/store_in_background_multi_upload_spec.rb
179
180
  - spec/integrations/store_in_background_spec.rb
180
181
  - spec/rails_helper.rb
@@ -185,18 +186,22 @@ files:
185
186
  - spec/support/dummy_app/app/controllers/application_controller.rb
186
187
  - spec/support/dummy_app/app/controllers/concerns/.keep
187
188
  - spec/support/dummy_app/app/jobs/application_job.rb
189
+ - spec/support/dummy_app/app/jobs/portrait_process_job.rb
188
190
  - spec/support/dummy_app/app/models/admin.rb
189
191
  - spec/support/dummy_app/app/models/application_record.rb
190
192
  - spec/support/dummy_app/app/models/concerns/.keep
191
193
  - spec/support/dummy_app/app/models/user.rb
192
194
  - spec/support/dummy_app/app/uploaders/avatar_uploader.rb
193
195
  - spec/support/dummy_app/bin/bundle
196
+ - spec/support/dummy_app/bin/ci
197
+ - spec/support/dummy_app/bin/dev
194
198
  - spec/support/dummy_app/bin/rails
195
199
  - spec/support/dummy_app/bin/rake
196
200
  - spec/support/dummy_app/bin/setup
197
201
  - spec/support/dummy_app/config.ru
198
202
  - spec/support/dummy_app/config/application.rb
199
203
  - spec/support/dummy_app/config/boot.rb
204
+ - spec/support/dummy_app/config/ci.rb
200
205
  - spec/support/dummy_app/config/database.yml
201
206
  - spec/support/dummy_app/config/environment.rb
202
207
  - spec/support/dummy_app/config/environments/development.rb
@@ -206,7 +211,10 @@ files:
206
211
  - spec/support/dummy_app/config/initializers/cors.rb
207
212
  - spec/support/dummy_app/config/initializers/filter_parameter_logging.rb
208
213
  - spec/support/dummy_app/config/initializers/inflections.rb
214
+ - spec/support/dummy_app/config/initializers/new_framework_defaults_8_0.rb
215
+ - spec/support/dummy_app/config/initializers/new_framework_defaults_8_1.rb
209
216
  - spec/support/dummy_app/config/locales/en.yml
217
+ - spec/support/dummy_app/config/puma.rb
210
218
  - spec/support/dummy_app/config/routes.rb
211
219
  - spec/support/dummy_app/config/storage.yml
212
220
  - spec/support/dummy_app/db/migrate/20230804214459_create_users.rb
@@ -215,6 +223,7 @@ files:
215
223
  - spec/support/dummy_app/db/migrate/20230809215320_create_admins.rb
216
224
  - spec/support/dummy_app/db/migrate/20230810182011_add_images_to_users.rb
217
225
  - spec/support/dummy_app/db/migrate/20230811155811_add_images_to_admins.rb
226
+ - spec/support/dummy_app/db/migrate/20250926184915_add_columns_for_portrait.rb
218
227
  - spec/support/dummy_app/db/schema.rb
219
228
  - spec/support/dummy_app/db/seeds.rb
220
229
  - spec/support/dummy_app/lib/tasks/.keep
@@ -262,6 +271,7 @@ test_files:
262
271
  - spec/backgrounder/workers/store_asset_spec.rb
263
272
  - spec/integrations/process_in_background_multi_upload_spec.rb
264
273
  - spec/integrations/process_in_background_spec.rb
274
+ - spec/integrations/queue_name_spec.rb
265
275
  - spec/integrations/store_in_background_multi_upload_spec.rb
266
276
  - spec/integrations/store_in_background_spec.rb
267
277
  - spec/rails_helper.rb
@@ -272,18 +282,22 @@ test_files:
272
282
  - spec/support/dummy_app/app/controllers/application_controller.rb
273
283
  - spec/support/dummy_app/app/controllers/concerns/.keep
274
284
  - spec/support/dummy_app/app/jobs/application_job.rb
285
+ - spec/support/dummy_app/app/jobs/portrait_process_job.rb
275
286
  - spec/support/dummy_app/app/models/admin.rb
276
287
  - spec/support/dummy_app/app/models/application_record.rb
277
288
  - spec/support/dummy_app/app/models/concerns/.keep
278
289
  - spec/support/dummy_app/app/models/user.rb
279
290
  - spec/support/dummy_app/app/uploaders/avatar_uploader.rb
280
291
  - spec/support/dummy_app/bin/bundle
292
+ - spec/support/dummy_app/bin/ci
293
+ - spec/support/dummy_app/bin/dev
281
294
  - spec/support/dummy_app/bin/rails
282
295
  - spec/support/dummy_app/bin/rake
283
296
  - spec/support/dummy_app/bin/setup
284
297
  - spec/support/dummy_app/config.ru
285
298
  - spec/support/dummy_app/config/application.rb
286
299
  - spec/support/dummy_app/config/boot.rb
300
+ - spec/support/dummy_app/config/ci.rb
287
301
  - spec/support/dummy_app/config/database.yml
288
302
  - spec/support/dummy_app/config/environment.rb
289
303
  - spec/support/dummy_app/config/environments/development.rb
@@ -293,7 +307,10 @@ test_files:
293
307
  - spec/support/dummy_app/config/initializers/cors.rb
294
308
  - spec/support/dummy_app/config/initializers/filter_parameter_logging.rb
295
309
  - spec/support/dummy_app/config/initializers/inflections.rb
310
+ - spec/support/dummy_app/config/initializers/new_framework_defaults_8_0.rb
311
+ - spec/support/dummy_app/config/initializers/new_framework_defaults_8_1.rb
296
312
  - spec/support/dummy_app/config/locales/en.yml
313
+ - spec/support/dummy_app/config/puma.rb
297
314
  - spec/support/dummy_app/config/routes.rb
298
315
  - spec/support/dummy_app/config/storage.yml
299
316
  - spec/support/dummy_app/db/migrate/20230804214459_create_users.rb
@@ -302,6 +319,7 @@ test_files:
302
319
  - spec/support/dummy_app/db/migrate/20230809215320_create_admins.rb
303
320
  - spec/support/dummy_app/db/migrate/20230810182011_add_images_to_users.rb
304
321
  - spec/support/dummy_app/db/migrate/20230811155811_add_images_to_admins.rb
322
+ - spec/support/dummy_app/db/migrate/20250926184915_add_columns_for_portrait.rb
305
323
  - spec/support/dummy_app/db/schema.rb
306
324
  - spec/support/dummy_app/db/seeds.rb
307
325
  - spec/support/dummy_app/lib/tasks/.keep