From a7a256956d8c198bfc6f521ae53f212802518fa0 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Thu, 31 Jan 2008 04:44:50 +0000 Subject: [PATCH] Fail gracefully when double-colons are used to delimit namespaces (closes #10472) git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@8758 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- CHANGELOG | 2 ++ lib/capistrano/configuration/namespaces.rb | 3 ++- test/configuration/namespace_dsl_test.rb | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7052b011..76ef9933 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fail gracefully when double-colons are used to delimit namespaces [richie] + * Add support for :git_enable_submodules variable, to enable submodules with the git SCM [halorgium] * If subversion asks for a password, prompt as a last resort [Jamis Buck] diff --git a/lib/capistrano/configuration/namespaces.rb b/lib/capistrano/configuration/namespaces.rb index 08872349..12dc36fa 100644 --- a/lib/capistrano/configuration/namespaces.rb +++ b/lib/capistrano/configuration/namespaces.rb @@ -116,7 +116,8 @@ module Capistrano ns = self until parts.empty? - ns = ns.namespaces[parts.shift.to_sym] + next_part = parts.shift + ns = next_part.empty? ? nil : ns.namespaces[next_part.to_sym] return nil if ns.nil? end diff --git a/test/configuration/namespace_dsl_test.rb b/test/configuration/namespace_dsl_test.rb index ae822a1e..26f526c3 100644 --- a/test/configuration/namespace_dsl_test.rb +++ b/test/configuration/namespace_dsl_test.rb @@ -294,4 +294,12 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase @config.namespace(:outer) { namespace(:middle) { namespace(:inner) {} } } assert_equal @config, @config.namespaces[:outer].namespaces[:middle].namespaces[:inner].top end + + def test_find_task_should_return_nil_when_empty_inner_task + @config.namespace :outer do + namespace :inner do + end + end + assert_nil @config.find_task("outer::inner") + end end \ No newline at end of file