mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Merge pull request #1516 from thickpaddy/fix_namespaced_after_task_invocation
Fix post task lookup in TaskEnhancements#after
This commit is contained in:
commit
fabb37fb75
3 changed files with 24 additions and 2 deletions
|
@ -27,6 +27,7 @@ https://github.com/capistrano/capistrano/compare/v3.4.0...HEAD
|
|||
instead of `Capfile`. (@mattbrictson)
|
||||
* Return first 12 characters (instead of 7) of SHA1 hash when determining current git revision (@sds)
|
||||
* Clean up rubocop lint warnings (@cshaffer)
|
||||
* Ensure task invocation within after hooks is namespace aware (@thickpaddy)
|
||||
|
||||
## `3.4.0`
|
||||
|
||||
|
|
|
@ -9,8 +9,9 @@ module Capistrano
|
|||
|
||||
def after(task, post_task, *args, &block)
|
||||
Rake::Task.define_task(post_task, *args, &block) if block_given?
|
||||
Rake::Task[task].enhance do
|
||||
Rake::Task[post_task].invoke
|
||||
task = Rake::Task[task]
|
||||
task.enhance do
|
||||
Rake.application.lookup(post_task, task.scope).invoke
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -80,6 +80,26 @@ module Capistrano
|
|||
expect(order).to eq(['before_task', 'task', 'after_task'])
|
||||
end
|
||||
|
||||
it "invokes using the correct namespace when defined within a namespace" do
|
||||
Rake.application.in_namespace('namespace') {
|
||||
Rake::Task.define_task('task') do |t|
|
||||
order.push(t.name)
|
||||
end
|
||||
task_enhancements.before('task', 'before_task', :order) do |t|
|
||||
order.push(t.name)
|
||||
end
|
||||
task_enhancements.after('task', 'after_task', :order) do |t|
|
||||
order.push(t.name)
|
||||
end
|
||||
}
|
||||
|
||||
Rake::Task['namespace:task'].invoke
|
||||
|
||||
expect(order).to eq(
|
||||
['namespace:before_task', 'namespace:task', 'namespace:after_task']
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'remote_file' do
|
||||
|
|
Loading…
Reference in a new issue