Commit 0b587c59462b48ca11fafeddd2584388c78bcd0f
Exists in
master
and in
29 other branches
Merge branch 'peridiocity' into merge
Showing
5 changed files
with
33 additions
and
7 deletions
Show diff stats
plugins/mezuro/lib/kalibro/client/kalibro_client.rb
@@ -12,8 +12,16 @@ class Kalibro::Client::KalibroClient | @@ -12,8 +12,16 @@ 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 | - def self.process_project(project_name) | ||
16 | - new.process_project(project_name) | 15 | + def process_periodically(project_name, days) |
16 | + @port.request(:process_periodically, {:project_name => project_name, :period_in_days => days}) | ||
17 | + end | ||
18 | + | ||
19 | + def self.process_project(project_name, days) | ||
20 | + if days.to_i.zero? | ||
21 | + new.process_project(project_name) | ||
22 | + else | ||
23 | + new.process_periodically(project_name, days) | ||
24 | + end | ||
17 | end | 25 | end |
18 | 26 | ||
19 | end | 27 | end |
plugins/mezuro/lib/mezuro_plugin/project_content.rb
@@ -8,7 +8,7 @@ class MezuroPlugin::ProjectContent < Article | @@ -8,7 +8,7 @@ class MezuroPlugin::ProjectContent < Article | ||
8 | 'Software project tracked by Kalibro' | 8 | 'Software project tracked by Kalibro' |
9 | end | 9 | end |
10 | 10 | ||
11 | - settings_items :license, :description, :repository_type, :repository_url, :configuration_name | 11 | + settings_items :license, :description, :repository_type, :repository_url, :configuration_name, :periodicity_in_days |
12 | 12 | ||
13 | include ActionView::Helpers::TagHelper | 13 | include ActionView::Helpers::TagHelper |
14 | def to_html(options = {}) | 14 | def to_html(options = {}) |
@@ -37,7 +37,7 @@ class MezuroPlugin::ProjectContent < Article | @@ -37,7 +37,7 @@ class MezuroPlugin::ProjectContent < Article | ||
37 | 37 | ||
38 | def send_project_to_service | 38 | def send_project_to_service |
39 | Kalibro::Client::ProjectClient.save(self) | 39 | Kalibro::Client::ProjectClient.save(self) |
40 | - Kalibro::Client::KalibroClient.process_project(name) | 40 | + Kalibro::Client::KalibroClient.process_project(name, periodicity_in_days) |
41 | end | 41 | end |
42 | 42 | ||
43 | def remove_project_from_service | 43 | def remove_project_from_service |
plugins/mezuro/test/unit/kalibro/client/kalibro_client_test.rb
@@ -24,7 +24,20 @@ class KalibroClientTest < ActiveSupport::TestCase | @@ -24,7 +24,20 @@ class KalibroClientTest < ActiveSupport::TestCase | ||
24 | instance = mock | 24 | instance = mock |
25 | Kalibro::Client::KalibroClient.expects(:new).returns(instance) | 25 | Kalibro::Client::KalibroClient.expects(:new).returns(instance) |
26 | instance.expects(:process_project).with('myproject') | 26 | instance.expects(:process_project).with('myproject') |
27 | - Kalibro::Client::KalibroClient.process_project('myproject') | 27 | + Kalibro::Client::KalibroClient.process_project('myproject', 0) |
28 | + end | ||
29 | + | ||
30 | + should 'process project with periodicity' do | ||
31 | + name = 'KalibroClientTest' | ||
32 | + @port.expects(:request).with(:process_periodically, {:project_name => name, :period_in_days => 30}) | ||
33 | + @client.process_periodically(name, 30) | ||
34 | + end | ||
35 | + | ||
36 | + should 'instantiate for processing project periodically' do | ||
37 | + instance = mock | ||
38 | + Kalibro::Client::KalibroClient.expects(:new).returns(instance) | ||
39 | + instance.expects(:process_periodically).with('myproject', 30) | ||
40 | + Kalibro::Client::KalibroClient.process_project('myproject', 30) | ||
28 | end | 41 | end |
29 | 42 | ||
30 | end | 43 | end |
plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb
@@ -13,6 +13,7 @@ class ProjectContentTest < ActiveSupport::TestCase | @@ -13,6 +13,7 @@ class ProjectContentTest < ActiveSupport::TestCase | ||
13 | @content.repository_type = @project.repository.type | 13 | @content.repository_type = @project.repository.type |
14 | @content.repository_url = @project.repository.address | 14 | @content.repository_url = @project.repository.address |
15 | @content.configuration_name = @project.configuration_name | 15 | @content.configuration_name = @project.configuration_name |
16 | + @content.periodicity_in_days = 1 | ||
16 | end | 17 | end |
17 | 18 | ||
18 | should 'be an article' do | 19 | should 'be an article' do |
@@ -71,7 +72,7 @@ class ProjectContentTest < ActiveSupport::TestCase | @@ -71,7 +72,7 @@ class ProjectContentTest < ActiveSupport::TestCase | ||
71 | 72 | ||
72 | should 'send correct project to service' do | 73 | should 'send correct project to service' do |
73 | Kalibro::Client::ProjectClient.expects(:save).with(@content) | 74 | Kalibro::Client::ProjectClient.expects(:save).with(@content) |
74 | - Kalibro::Client::KalibroClient.expects(:process_project).with(@content.name) | 75 | + Kalibro::Client::KalibroClient.expects(:process_project).with(@content.name, @content.periodicity_in_days) |
75 | @content.send :send_project_to_service | 76 | @content.send :send_project_to_service |
76 | end | 77 | end |
77 | 78 |
plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb
@@ -31,4 +31,8 @@ | @@ -31,4 +31,8 @@ | ||
31 | <% @configuration_names = Kalibro::Client::ConfigurationClient.new.configuration_names.sort %> | 31 | <% @configuration_names = Kalibro::Client::ConfigurationClient.new.configuration_names.sort %> |
32 | <% @selected = (@project.nil? ? @configuration_names[0] : @project.configuration_name) %> | 32 | <% @selected = (@project.nil? ? @configuration_names[0] : @project.configuration_name) %> |
33 | <%= required labelled_form_field _('Configuration'), | 33 | <%= required labelled_form_field _('Configuration'), |
34 | - f.select(:configuration_name, @configuration_names.sort, {:selected => @selected}) %><br/> | ||
35 | \ No newline at end of file | 34 | \ No newline at end of file |
35 | + f.select(:configuration_name, @configuration_names.sort, {:selected => @selected}) %><br/> | ||
36 | + | ||
37 | +<% options = [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweekly", 15], ["Monthly", 30]] %> | ||
38 | +<%= required labelled_form_field _('Periodic Avaliation'), | ||
39 | + f.select(:periodicity_in_days, options, {:selected => 0}) %><br/> |