Commit 69091f13798d1f94935658c314ea7ad86a3db7de
Committed by
Carlos Morais
1 parent
2058c115
Exists in
master
and in
29 other branches
[Mezuro] Remove project only if it exists on service
Showing
2 changed files
with
12 additions
and
2 deletions
Show diff stats
plugins/mezuro/lib/kalibro/client/project_client.rb
... | ... | @@ -10,7 +10,10 @@ class Kalibro::Client::ProjectClient |
10 | 10 | end |
11 | 11 | |
12 | 12 | def self.remove(project_name) |
13 | - new.remove(project_name) | |
13 | + instance = new | |
14 | + if (instance.project_names.include?(project_name)) | |
15 | + instance.remove(project_name) | |
16 | + end | |
14 | 17 | end |
15 | 18 | |
16 | 19 | def self.create_project (project_content) | ... | ... |
plugins/mezuro/test/unit/kalibro/client/project_client_test.rb
... | ... | @@ -24,11 +24,18 @@ class ProjectClientTest < ActiveSupport::TestCase |
24 | 24 | Kalibro::Client::ProjectClient.save(@project_content) |
25 | 25 | end |
26 | 26 | |
27 | - should 'remove project by name' do | |
27 | + should 'remove existent project from service' do | |
28 | + @port.expects(:request).with(:get_project_names).returns({:project_name => @project.name}) | |
28 | 29 | @port.expects(:request).with(:remove_project, {:project_name => @project.name}) |
29 | 30 | Kalibro::Client::ProjectClient.remove(@project.name) |
30 | 31 | end |
31 | 32 | |
33 | + should 'not try to remove inexistent project from service' do | |
34 | + @port.expects(:request).with(:get_project_names).returns({:project_name => 'Different project'}) | |
35 | + @port.expects(:request).with(:remove_project, {:project_name => @project.name}).never | |
36 | + Kalibro::Client::ProjectClient.remove(@project.name) | |
37 | + end | |
38 | + | |
32 | 39 | private |
33 | 40 | |
34 | 41 | def create_project_content_mock | ... | ... |