Skip to content

Commit a2cd0a5

Browse files
author
David Heinemeier Hansson
authored
Ensure image processing gem is enabled when turning on action text so image uploads work out-of-the-box (rails#43010)
* Ensure image processing gem is enabled when turning on action text so uploads will work * Test enabling image_processing gem * Fix rubocop issue
1 parent a2a28e6 commit a2cd0a5

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

actiontext/lib/generators/action_text/install/install_generator.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ def create_actiontext_files
6666
"app/views/layouts/action_text/contents/_content.html.erb"
6767
end
6868

69+
def enable_image_processing_gem
70+
if (gemfile_path = Rails.root.join("Gemfile")).exist?
71+
say "Ensure image_processing gem has been enabled so image uploads will work"
72+
uncomment_lines gemfile_path, /gem "image_processing"/
73+
run "bundle install"
74+
end
75+
end
76+
6977
def create_migrations
7078
rails_command "railties:install:migrations FROM=active_storage,action_text", inline: true
7179
end

railties/test/generators/action_text_install_generator_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ class ActionText::Generators::InstallGeneratorTest < Rails::Generators::TestCase
7777
assert_migration "db/migrate/create_action_text_tables.action_text.rb"
7878
end
7979

80+
test "uncomments image_processing gem" do
81+
gemfile = Pathname("Gemfile").expand_path(destination_root)
82+
gemfile.dirname.mkpath
83+
gemfile.write(%(# gem "image_processing"))
84+
85+
run_generator_instance
86+
87+
assert_file gemfile do |content|
88+
assert_equal %(gem "image_processing"), content
89+
end
90+
end
91+
8092
test "#yarn_command runs bin/yarn via Ruby" do
8193
ran = nil
8294
run_stub = -> (command, *) { ran = command }

0 commit comments

Comments
 (0)