Skip to content
Permalink
Browse files

Add deprecation warning if someone uses old deploy:symlink syntax on …

…callbacks.
  • Loading branch information...
kenmazaika committed Apr 19, 2012
1 parent bde27c1 commit 021c0574dafb839c4145b1180cb866c8bddbcbf0
Showing with 32 additions and 0 deletions.
  1. +12 −0 lib/capistrano/configuration/callbacks.rb
  2. +20 −0 test/configuration/callbacks_test.rb
@@ -107,6 +107,18 @@ def on(event, *args, &block)
callbacks[event] << ProcCallback.new(block, options)
else
args.each do |name|
[:only, :except].each do |key|
if options[key] == 'deploy:symlink'
warn "[Deprecation Warning] This API has changed, please hook `deploy:create_symlink` instead of `deploy:symlink`."
options[key] = 'deploy:create_symlink'
elsif options[key].is_a?(Array) && options[key].include?('deploy:symlink')
warn "[Deprecation Warning] This API has changed, please hook `deploy:create_symlink` instead of `deploy:symlink`."
options[key] = options[key].collect do |task|
task == 'deploy:symlink' ? 'deploy:create_symlink' : task
end
end
end

callbacks[event] << TaskCallback.new(self, name, options)
end
end
@@ -39,11 +39,31 @@ def test_before_should_delegate_to_on
@config.before :bar, :foo, "bing:blang", :zip => :zing
end

def test_before_should_map_before_deploy_symlink
@config.before "deploy:symlink", "bing:blang"
assert_equal ["deploy:create_symlink"], @config.callbacks[:before].last.only
end

def test_before_should_map_before_deploy_symlink_array
@config.before ["deploy:symlink", "bingo:blast"], "bing:blang"
assert_equal ["deploy:create_symlink", "bingo:blast"], @config.callbacks[:before].last.only
end

def test_after_should_delegate_to_on
@config.expects(:on).with(:after, :foo, "bing:blang", {:only => :bar, :zip => :zing})
@config.after :bar, :foo, "bing:blang", :zip => :zing
end

def test_after_should_map_before_deploy_symlink
@config.after "deploy:symlink", "bing:blang"
assert_equal ["deploy:create_symlink"], @config.callbacks[:after].last.only
end

def test_after_should_map_before_deploy_symlink_array
@config.after ["deploy:symlink", 'bingo:blast'], "bing:blang"
assert_equal ["deploy:create_symlink", 'bingo:blast'], @config.callbacks[:after].last.only
end

def test_on_with_single_reference_should_add_task_callback
@config.on :before, :a_test
assert_equal 1, @config.callbacks[:before].length

0 comments on commit 021c057

Please sign in to comment.
You can’t perform that action at this time.