Commit 53e454a3e899258274d3eedbd4095d09939c2e29
1 parent
f3f87611
Exists in
master
and in
29 other branches
Isolate internal class logic
Showing
6 changed files
with
32 additions
and
13 deletions
Show diff stats
plugins/mezuro/lib/kalibro/client/kalibro_client.rb
... | ... | @@ -12,4 +12,8 @@ class Kalibro::Client::KalibroClient |
12 | 12 | @port.request(:process_project, {:project_name => project_name}) |
13 | 13 | end |
14 | 14 | |
15 | -end | |
16 | 15 | \ No newline at end of file |
16 | + def self.process_project(project_name) | |
17 | + new.process_project(project_name) | |
18 | + end | |
19 | + | |
20 | +end | ... | ... |
plugins/mezuro/lib/kalibro/client/project_client.rb
... | ... | @@ -8,6 +8,10 @@ class Kalibro::Client::ProjectClient |
8 | 8 | @port.request(:save_project, {:project => project.to_hash}) |
9 | 9 | end |
10 | 10 | |
11 | + def self.save(project) | |
12 | + new.save(project) | |
13 | + end | |
14 | + | |
11 | 15 | def project_names |
12 | 16 | @port.request(:get_project_names)[:project_name].to_a |
13 | 17 | end |
... | ... | @@ -21,4 +25,4 @@ class Kalibro::Client::ProjectClient |
21 | 25 | @port.request(:remove_project, {:project_name => project_name}) |
22 | 26 | end |
23 | 27 | |
24 | -end | |
25 | 28 | \ No newline at end of file |
29 | +end | ... | ... |
plugins/mezuro/lib/mezuro_plugin/project_content.rb
... | ... | @@ -22,8 +22,8 @@ class MezuroPlugin::ProjectContent < Article |
22 | 22 | private |
23 | 23 | |
24 | 24 | def send_project_to_service |
25 | - Kalibro::Client::ProjectClient.new.save(project) | |
26 | - Kalibro::Client::KalibroClient.new.process_project(title) | |
25 | + Kalibro::Client::ProjectClient.save(project) | |
26 | + Kalibro::Client::KalibroClient.process_project(title) | |
27 | 27 | end |
28 | 28 | |
29 | 29 | def project | ... | ... |
plugins/mezuro/test/unit/kalibro/client/kalibro_client_test.rb
... | ... | @@ -18,5 +18,12 @@ class KalibroClientTest < Test::Unit::TestCase |
18 | 18 | @port.expects(:request).with(:process_project, {:project_name => name}) |
19 | 19 | @client.process_project(name) |
20 | 20 | end |
21 | + | |
22 | + should 'instantiate for processing project' do | |
23 | + instance = mock | |
24 | + Kalibro::Client::KalibroClient.expects(:new).returns(instance) | |
25 | + instance.expects(:process_project).with('myproject') | |
26 | + Kalibro::Client::KalibroClient.process_project('myproject') | |
27 | + end | |
21 | 28 | |
22 | -end | |
23 | 29 | \ No newline at end of file |
30 | +end | ... | ... |
plugins/mezuro/test/unit/kalibro/client/project_client_test.rb
... | ... | @@ -44,4 +44,12 @@ class ProjectClientTest < Test::Unit::TestCase |
44 | 44 | @client.remove(name) |
45 | 45 | end |
46 | 46 | |
47 | -end | |
48 | 47 | \ No newline at end of file |
48 | + should 'instantiate for saving a project' do | |
49 | + project = mock | |
50 | + instance = mock | |
51 | + Kalibro::Client::ProjectClient.expects(:new).returns(instance) | |
52 | + instance.expects(:save).with(project) | |
53 | + Kalibro::Client::ProjectClient.save(project) | |
54 | + end | |
55 | + | |
56 | +end | ... | ... |
plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb
... | ... | @@ -34,13 +34,9 @@ class ProjectContentTest < Test::Unit::TestCase |
34 | 34 | end |
35 | 35 | |
36 | 36 | should 'send correct project to service' do |
37 | - project_client = mock | |
38 | - kalibro_client = mock | |
39 | - Kalibro::Client::ProjectClient.expects(:new).returns(project_client) | |
40 | - project_client.expects(:save).with(@project) | |
41 | - Kalibro::Client::KalibroClient.expects(:new).returns(kalibro_client) | |
42 | - kalibro_client.expects(:process_project).with(@project.name) | |
37 | + Kalibro::Client::ProjectClient.expects(:save).with(@project) | |
38 | + Kalibro::Client::KalibroClient.expects(:process_project).with(@project.name) | |
43 | 39 | @content.send :send_project_to_service |
44 | 40 | end |
45 | 41 | |
46 | -end | |
47 | 42 | \ No newline at end of file |
43 | +end | ... | ... |