Skip to content

Commit

Permalink
Invoke namespaced task when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalcic committed May 26, 2021
1 parent 56cfefe commit 3787ffe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion activestorage/lib/tasks/activestorage.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions railties/test/railties/engine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3787ffe

Please sign in to comment.