From 69091f13798d1f94935658c314ea7ad86a3db7de Mon Sep 17 00:00:00 2001 From: Carlos Morais + Paulo Meirelles Date: Fri, 10 Feb 2012 12:22:29 -0200 Subject: [PATCH] [Mezuro] Remove project only if it exists on service --- plugins/mezuro/lib/kalibro/client/project_client.rb | 5 ++++- plugins/mezuro/test/unit/kalibro/client/project_client_test.rb | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/mezuro/lib/kalibro/client/project_client.rb b/plugins/mezuro/lib/kalibro/client/project_client.rb index 0fcbbc6..159ef08 100644 --- a/plugins/mezuro/lib/kalibro/client/project_client.rb +++ b/plugins/mezuro/lib/kalibro/client/project_client.rb @@ -10,7 +10,10 @@ class Kalibro::Client::ProjectClient end def self.remove(project_name) - new.remove(project_name) + instance = new + if (instance.project_names.include?(project_name)) + instance.remove(project_name) + end end def self.create_project (project_content) diff --git a/plugins/mezuro/test/unit/kalibro/client/project_client_test.rb b/plugins/mezuro/test/unit/kalibro/client/project_client_test.rb index f908a50..0476312 100644 --- a/plugins/mezuro/test/unit/kalibro/client/project_client_test.rb +++ b/plugins/mezuro/test/unit/kalibro/client/project_client_test.rb @@ -24,11 +24,18 @@ class ProjectClientTest < ActiveSupport::TestCase Kalibro::Client::ProjectClient.save(@project_content) end - should 'remove project by name' do + should 'remove existent project from service' do + @port.expects(:request).with(:get_project_names).returns({:project_name => @project.name}) @port.expects(:request).with(:remove_project, {:project_name => @project.name}) Kalibro::Client::ProjectClient.remove(@project.name) end + should 'not try to remove inexistent project from service' do + @port.expects(:request).with(:get_project_names).returns({:project_name => 'Different project'}) + @port.expects(:request).with(:remove_project, {:project_name => @project.name}).never + Kalibro::Client::ProjectClient.remove(@project.name) + end + private def create_project_content_mock -- libgit2 0.21.2