Merge pull request #41199 from jmalcic/patch-2

Fix Active Storage update task when running in an engine
This commit is contained in:
Eugene Kenny 2021-05-26 14:03:49 +01:00 committed by GitHub
commit 5a8d7d904f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

@ -17,6 +17,10 @@ namespace :active_storage do
task update: :environment do
ENV["MIGRATIONS_PATH"] = "db/update_migrate"
Rake::Task["active_storage:install"].invoke
if Rake::Task.task_defined?("active_storage:install")
Rake::Task["active_storage:install"].invoke
else
Rake::Task["app:active_storage:install"].invoke
end
end
end

@ -1613,6 +1613,21 @@ def index
end
end
test "active_storage:update task works within engine" do
@plugin.write "Rakefile", <<-RUBY
APP_RAKEFILE = '#{app_path}/Rakefile'
load "rails/tasks/engine.rake"
RUBY
Dir.chdir(@plugin.path) do
output = `bundle exec rake app:active_storage:update`
assert $?.success?, output
assert migrations.detect { |migration| migration.name == "AddServiceNameToActiveStorageBlobs" }
assert migrations.detect { |migration| migration.name == "CreateActiveStorageVariantRecords" }
end
end
private
def app
Rails.application