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,4 +12,8 @@ class Kalibro::Client::KalibroClient | ||
12 | @port.request(:process_project, {:project_name => project_name}) | 12 | @port.request(:process_project, {:project_name => project_name}) |
13 | end | 13 | end |
14 | 14 | ||
15 | -end | ||
16 | \ No newline at end of file | 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,6 +8,10 @@ class Kalibro::Client::ProjectClient | ||
8 | @port.request(:save_project, {:project => project.to_hash}) | 8 | @port.request(:save_project, {:project => project.to_hash}) |
9 | end | 9 | end |
10 | 10 | ||
11 | + def self.save(project) | ||
12 | + new.save(project) | ||
13 | + end | ||
14 | + | ||
11 | def project_names | 15 | def project_names |
12 | @port.request(:get_project_names)[:project_name].to_a | 16 | @port.request(:get_project_names)[:project_name].to_a |
13 | end | 17 | end |
@@ -21,4 +25,4 @@ class Kalibro::Client::ProjectClient | @@ -21,4 +25,4 @@ class Kalibro::Client::ProjectClient | ||
21 | @port.request(:remove_project, {:project_name => project_name}) | 25 | @port.request(:remove_project, {:project_name => project_name}) |
22 | end | 26 | end |
23 | 27 | ||
24 | -end | ||
25 | \ No newline at end of file | 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,8 +22,8 @@ class MezuroPlugin::ProjectContent < Article | ||
22 | private | 22 | private |
23 | 23 | ||
24 | def send_project_to_service | 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 | end | 27 | end |
28 | 28 | ||
29 | def project | 29 | def project |
plugins/mezuro/test/unit/kalibro/client/kalibro_client_test.rb
@@ -18,5 +18,12 @@ class KalibroClientTest < Test::Unit::TestCase | @@ -18,5 +18,12 @@ class KalibroClientTest < Test::Unit::TestCase | ||
18 | @port.expects(:request).with(:process_project, {:project_name => name}) | 18 | @port.expects(:request).with(:process_project, {:project_name => name}) |
19 | @client.process_project(name) | 19 | @client.process_project(name) |
20 | end | 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 | \ No newline at end of file | 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,4 +44,12 @@ class ProjectClientTest < Test::Unit::TestCase | ||
44 | @client.remove(name) | 44 | @client.remove(name) |
45 | end | 45 | end |
46 | 46 | ||
47 | -end | ||
48 | \ No newline at end of file | 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,13 +34,9 @@ class ProjectContentTest < Test::Unit::TestCase | ||
34 | end | 34 | end |
35 | 35 | ||
36 | should 'send correct project to service' do | 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 | @content.send :send_project_to_service | 39 | @content.send :send_project_to_service |
44 | end | 40 | end |
45 | 41 | ||
46 | -end | ||
47 | \ No newline at end of file | 42 | \ No newline at end of file |
43 | +end |