Skip to content

Commit

Permalink
Merge pull request capistrano#196 from kenmazaika/add-deprecation-war…
Browse files Browse the repository at this point in the history
…ning

Add deprecation warning if someone uses old deploy:symlink syntax when specifying callbacks.
  • Loading branch information
leehambley committed Apr 19, 2012
2 parents bde27c1 + 021c057 commit c500a49
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/capistrano/configuration/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions test/configuration/callbacks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c500a49

Please sign in to comment.