Skip to content

Commit 52f9787

Browse files
Support Rails 6.1.6.1
This commit does the bare minimum to support Rails 6.1.6.1 Because the `gem` command is no longer reversible, we decided to override the method by borrowing as much from the [existing method](https://github.com/rails/rails/blob/04972d9b9ef60796dc8f0917817b5392d61fcf09/railties/lib/rails/generators/actions.rb#L22). The main difference being that we call `append_file` instead of `gsub_file`, so that we can preserve reversibility. However, #1066 provides a more elegant solution. Closes #1060
1 parent e6e07b0 commit 52f9787

File tree

7 files changed

+29
-7
lines changed

7 files changed

+29
-7
lines changed

lib/suspenders/actions.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,27 @@ def expand_json(file, data)
3131
action ExpandJson.new(destination_root, file, data)
3232
end
3333

34+
def gem(*args)
35+
options = args.extract_options!
36+
name, *versions = args
37+
38+
parts = [quote(name)]
39+
40+
if (versions = versions.any? ? versions : options.delete(:version))
41+
versions = Array(versions)
42+
versions.each do |version|
43+
parts << quote(version)
44+
end
45+
end
46+
47+
parts << quote(options) unless options.empty?
48+
49+
str = []
50+
str << indentation
51+
str << "gem #{parts.join(", ")}"
52+
append_file "Gemfile", %(\n#{str.join}\n), verbose: false
53+
end
54+
3455
class ExpandJson
3556
def initialize(destination_root, file, data)
3657
@destination_root = destination_root

lib/suspenders/app_builder.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def configure_local_mail
100100

101101
def setup_asset_host
102102
replace_in_file "config/environments/production.rb",
103-
"# config.action_controller.asset_host = 'http://assets.example.com'",
104-
'config.action_controller.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))'
103+
"# config.asset_host = 'http://assets.example.com'",
104+
'config.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))'
105105

106106
if File.exist?("config/initializers/assets.rb")
107107
replace_in_file "config/initializers/assets.rb",
@@ -250,7 +250,7 @@ def development_env?
250250
end
251251

252252
def raise_on_missing_translations_in(environment)
253-
config = "config.action_view.raise_on_missing_translations = true"
253+
config = "config.i18n.raise_on_missing_translations = true"
254254

255255
uncomment_lines("config/environments/#{environment}.rb", config)
256256
end

lib/suspenders/generators/advisories_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Suspenders
44
class AdvisoriesGenerator < Generators::Base
55
def bundler_audit_gem
6-
gem "bundler-audit", ">= 0.7.0", require: false, group: %i[development test]
6+
gem "bundler-audit", ">= 0.7.0", require: false, group: [:development, :test]
77
Bundler.with_unbundled_env { run "bundle install" }
88
end
99

lib/suspenders/generators/jobs_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Suspenders
44
class JobsGenerator < Generators::Base
55
def add_jobs_gem
6-
append_file "Gemfile", %(\ngem "sidekiq"\n)
6+
gem "sidekiq"
77
Bundler.with_unbundled_env { run "bundle install" }
88
end
99

lib/suspenders/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Suspenders
2-
RAILS_VERSION = "~> 6.0.0".freeze
2+
RAILS_VERSION = "~> 6.1.6.1".freeze
33
RUBY_VERSION = IO
44
.read("#{File.dirname(__FILE__)}/../../.ruby-version")
55
.strip

spec/features/new_project_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
it "raises on missing translations in development and test" do
126126
[development_config, test_config].each do |environment_file|
127127
expect(environment_file).to match(
128-
/^ +config.action_view.raise_on_missing_translations = true$/
128+
/^ +config.i18n.raise_on_missing_translations = true$/
129129
)
130130
end
131131
end

templates/active_job.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require "active_job/logging"
2+
require "active_job/log_subscriber"
23

34
ActiveSupport::Notifications.unsubscribe("enqueue.active_job")
45

0 commit comments

Comments
 (0)