From 61fc449867a97d10b5e98f7154d52df4cd3d41b2 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Thu, 6 Jul 2006 04:36:58 +0000 Subject: [PATCH] Make previous_release return nil if there are no previous releases (closes #4959) git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@4565 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- CHANGELOG | 8 ++++++++ lib/capistrano/actor.rb | 2 +- test/actor_test.rb | 20 +++++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0d5da955..ec8af169 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,13 @@ *SVN* +* Make previous_release return nil if there are no previous releases (closes #4959) [bdabney@cavoksolutions.com] + +* Uncache releases list after update_code is called so that newly released dir is included (closes #3766) [Jamis Buck] + +* Allow the subversion scm to accept HTTPS certificates (closes #4792) [Jamis Buck] + +* Make sure rollbacks occur within the scope of the task that triggered them [Jamis Buck] + * Fixed the default recipe to work with setups that haven't yet gone pids [DHH] * Symlink and setup for shared/pids to tmp/pids [DHH] diff --git a/lib/capistrano/actor.rb b/lib/capistrano/actor.rb index e8519658..c5c631de 100644 --- a/lib/capistrano/actor.rb +++ b/lib/capistrano/actor.rb @@ -366,7 +366,7 @@ module Capistrano # Returns the release immediately before the currently deployed one def previous_release - release_path(releases[-2]) + release_path(releases[-2]) if releases[-2] end # Invoke a set of tasks in a transaction. If any task fails (raises an diff --git a/test/actor_test.rb b/test/actor_test.rb index 51edc9dd..957c6215 100644 --- a/test/actor_test.rb +++ b/test/actor_test.rb @@ -55,11 +55,16 @@ class ActorTest < Test::Unit::TestCase end end - class MockConfiguration + class MockConfiguration < Capistrano::Configuration Role = Struct.new(:host, :options) attr_accessor :gateway, :pretend + def initialize(*args) + super + @logger = Capistrano::Logger.new(:output => StringIO.new) + end + def delegated_method "result of method" end @@ -78,10 +83,6 @@ class ActorTest < Test::Unit::TestCase def roles ROLES end - - def logger - @logger ||= Capistrano::Logger.new(:output => StringIO.new) - end end module CustomExtension @@ -97,6 +98,15 @@ class ActorTest < Test::Unit::TestCase ENV["HOSTS"] = nil end + def test_previous_release_returns_nil_with_one_release + class << @actor + def releases + ["1234567890"] + end + end + assert_equal @actor.previous_release, nil + end + def test_define_task_creates_method @actor.define_task :hello do "result"