Skip to content

Commit

Permalink
Jobs Generator: Remove obsolete configuration (#1197)
Browse files Browse the repository at this point in the history
Follow-up to #1147

The [introduction][] of `config/initializers/active_job.rb` was rendered
obsolete by [rails/rails#43390][].

Additionally, the following Rails 7 defaults match the [existing
configuration][], so there is no need to redeclare them.

```ruby
Rails.application.config.action_mailer.deliver_later_queue_name
=> nil

Rails.application.config.action_mailbox.queues.routing
=> nil

Rails.application.config.active_storage.queues.analysis
=> nil

Rails.application.config.active_storage.queues.purge
=> nil

Rails.application.config.active_storage.queues.mirror
=> nil
```

This is relevant because the next release of Suspenders will only
support `rails >= 7.0`.

[introduction]: 38b530c
[rails/rails#43390]: rails/rails#43390
[existing configuration]: https://github.com/thoughtbot/suspenders/blob/bd40e33a585891afba380a7884284f5accc003cf/lib/suspenders/generators/jobs_generator.rb#L19-L23
  • Loading branch information
stevepolitodesign committed Apr 24, 2024
1 parent ea9553c commit 2c8616a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 53 deletions.
10 changes: 0 additions & 10 deletions lib/generators/suspenders/jobs_generator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Suspenders
module Generators
class JobsGenerator < Rails::Generators::Base
source_root File.expand_path("../../templates/active_job", __FILE__)
desc <<~MARKDOWN
Installs Sidekiq for background job processing.
MARKDOWN
Expand All @@ -11,17 +10,8 @@ def add_sidekiq_gem
Bundler.with_unbundled_env { run "bundle install" }
end

def initialize_active_job
copy_file "active_job.rb", "config/initializers/active_job.rb"
end

def configure_active_job
environment "config.active_job.queue_adapter = :sidekiq"
environment "config.action_mailer.deliver_later_queue_name = nil"
environment "config.action_mailbox.queues.routing = nil"
environment "config.active_storage.queues.analysis = nil"
environment "config.active_storage.queues.purge = nil"
environment "config.active_storage.queues.mirror = nil"
environment "config.active_job.queue_adapter = :inline", env: "test"
end

Expand Down
14 changes: 0 additions & 14 deletions lib/generators/templates/active_job/active_job.rb

This file was deleted.

14 changes: 0 additions & 14 deletions test/fixtures/files/active_job.rb

This file was deleted.

15 changes: 0 additions & 15 deletions test/generators/suspenders/jobs_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,11 @@ class JobsGeneratorTest < Rails::Generators::TestCase
assert_match(/bundle install/, output)
end

test "configures ActiveJob logging" do
expected_configuration = file_fixture("active_job.rb").read

run_generator

assert_file app_root("config/initializers/active_job.rb") do |file|
assert_equal(expected_configuration, file)
end
end

test "adds ActiveJob configuration to the application file" do
run_generator

assert_file app_root("config/application.rb") do |file|
assert_match(/config.active_job.queue_adapter = :sidekiq/, file)
assert_match(/config.action_mailer.deliver_later_queue_name = nil/, file)
assert_match(/config.action_mailbox.queues.routing = nil/, file)
assert_match(/config.active_storage.queues.analysis = nil/, file)
assert_match(/config.active_storage.queues.purge = nil/, file)
assert_match(/config.active_storage.queues.mirror = nil/, file)
end
end

Expand Down

0 comments on commit 2c8616a

Please sign in to comment.