From 3eecac2f4ea1c967bc7ef5667cedc8ea8ab5b578 Mon Sep 17 00:00:00 2001 From: Lee Hambley Date: Mon, 20 Feb 2012 21:19:05 +0100 Subject: [PATCH] Formerly remove all support for before_, around_, and after_ magical method names --- lib/capistrano/configuration/callbacks.rb | 21 +---------- test/configuration/callbacks_test.rb | 43 ----------------------- test/configuration_test.rb | 11 ------ 3 files changed, 1 insertion(+), 74 deletions(-) diff --git a/lib/capistrano/configuration/callbacks.rb b/lib/capistrano/configuration/callbacks.rb index ea0aad1dc..32b0046fc 100644 --- a/lib/capistrano/configuration/callbacks.rb +++ b/lib/capistrano/configuration/callbacks.rb @@ -19,18 +19,13 @@ def initialize_with_callbacks(*args) #:nodoc: end def invoke_task_directly_with_callbacks(task) #:nodoc: - before = find_hook(task, :before) - execute_task(before) if before - + trigger :before, task result = invoke_task_directly_without_callbacks(task) trigger :after, task - after = find_hook(task, :after) - execute_task(after) if after - return result end @@ -132,20 +127,6 @@ def trigger(event, task=nil) end end - private - - # Looks for before_foo or after_foo tasks. This method of extending tasks - # is now discouraged (though not formally deprecated). You should use the - # before and after methods to declare hooks for such callbacks. - def find_hook(task, hook) - if task == task.namespace.default_task - result = task.namespace.search_task("#{hook}_#{task.namespace.name}") - return result if result - end - - task.namespace.search_task("#{hook}_#{task.name}") - end - end end end diff --git a/test/configuration/callbacks_test.rb b/test/configuration/callbacks_test.rb index 5847d739c..d1bdf8864 100644 --- a/test/configuration/callbacks_test.rb +++ b/test/configuration/callbacks_test.rb @@ -186,47 +186,4 @@ def test_execute_task_without_named_hooks_should_just_call_task assert_equal [task], @config.called end - def test_execute_task_with_named_before_hook_should_call_named_before_hook - ns = stub("namespace", :default_task => nil, :name => "old", :fully_qualified_name => "any:old") - task = stub(:fully_qualified_name => "any:old:thing", :name => "thing", :namespace => ns) - before_task = stub(:fully_qualified_name => "any:old:before_thing", :name => "before_thing", :namespace => ns) - - ns.stubs(:search_task).returns(nil) - ns.expects(:search_task).with("before_thing").returns(before_task) - - @config.execute_task(task) - assert_equal [before_task, task], @config.called - end - - def test_execute_task_with_named_after_hook_should_call_named_after_hook - ns = stub("namespace", :default_task => nil, :name => "old", :fully_qualified_name => "any:old") - task = stub(:fully_qualified_name => "any:old:thing", :name => "thing", :namespace => ns) - after_task = stub(:fully_qualified_name => "any:old:after_thing", :name => "after_thing", :namespace => ns) - - ns.stubs(:search_task).returns(nil) - ns.expects(:search_task).with("after_thing").returns(after_task) - - @config.execute_task(task) - assert_equal [task, after_task], @config.called - end - - def test_execute_task_with_on_hooks_should_trigger_hooks_around_task - ns = stub("namespace", :default_task => nil, :name => "old", :fully_qualified_name => "any:old") - task = stub(:fully_qualified_name => "any:old:thing", :name => "thing", :namespace => ns) - before_task = stub(:fully_qualified_name => "any:old:before_thing", :name => "before_thing", :namespace => ns) - after_task = stub(:fully_qualified_name => "any:old:after_thing", :name => "after_thing", :namespace => ns) - - ns.stubs(:search_task).returns(nil) - ns.expects(:search_task).with("before_thing").returns(before_task) - ns.expects(:search_task).with("after_thing").returns(after_task) - - @config.before("any:old:thing", :first_this, :then_this) - @config.after("any:old:thing", :and_then_this, :lastly_this) - - [:first_this, :then_this, :and_then_this, :lastly_this].each do |t| - @config.expects(:find_and_execute_task).with(t) - end - - @config.execute_task(task) - end end diff --git a/test/configuration_test.rb b/test/configuration_test.rb index d0f88acfe..31f6a1b64 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -74,15 +74,4 @@ def test_tasks_in_nested_namespace_should_be_able_to_call_shadowed_tasks_in_pare assert !@config[:called_inner_first] end - def test_hooks_for_default_task_should_be_found_if_named_after_the_namespace - @config.namespace(:outer) do - task(:default) { set :called_default, true } - task(:before_outer) { set :called_before_outer, true } - task(:after_outer) { set :called_after_outer, true } - end - @config.outer.default - assert @config[:called_before_outer] - assert @config[:called_default] - assert @config[:called_after_outer] - end end