diff --git a/plugins/mezuro/lib/kalibro/client/kalibro_client.rb b/plugins/mezuro/lib/kalibro/client/kalibro_client.rb index 3faf08f..ca23792 100644 --- a/plugins/mezuro/lib/kalibro/client/kalibro_client.rb +++ b/plugins/mezuro/lib/kalibro/client/kalibro_client.rb @@ -12,8 +12,16 @@ class Kalibro::Client::KalibroClient @port.request(:process_project, {:project_name => project_name}) end - def self.process_project(project_name) - new.process_project(project_name) + def process_periodically(project_name, days) + @port.request(:process_periodically, {:project_name => project_name, :period_in_days => days}) + end + + def self.process_project(project_name, days) + if days.to_i.zero? + new.process_project(project_name) + else + new.process_periodically(project_name, days) + end end end diff --git a/plugins/mezuro/lib/mezuro_plugin/project_content.rb b/plugins/mezuro/lib/mezuro_plugin/project_content.rb index 1e39cce..089a8b3 100644 --- a/plugins/mezuro/lib/mezuro_plugin/project_content.rb +++ b/plugins/mezuro/lib/mezuro_plugin/project_content.rb @@ -8,7 +8,7 @@ class MezuroPlugin::ProjectContent < Article 'Software project tracked by Kalibro' end - settings_items :license, :description, :repository_type, :repository_url, :configuration_name + settings_items :license, :description, :repository_type, :repository_url, :configuration_name, :periodicity_in_days include ActionView::Helpers::TagHelper def to_html(options = {}) @@ -37,7 +37,7 @@ class MezuroPlugin::ProjectContent < Article def send_project_to_service Kalibro::Client::ProjectClient.save(self) - Kalibro::Client::KalibroClient.process_project(name) + Kalibro::Client::KalibroClient.process_project(name, periodicity_in_days) end def remove_project_from_service diff --git a/plugins/mezuro/test/unit/kalibro/client/kalibro_client_test.rb b/plugins/mezuro/test/unit/kalibro/client/kalibro_client_test.rb index db5c88d..4ef3417 100644 --- a/plugins/mezuro/test/unit/kalibro/client/kalibro_client_test.rb +++ b/plugins/mezuro/test/unit/kalibro/client/kalibro_client_test.rb @@ -24,7 +24,20 @@ class KalibroClientTest < ActiveSupport::TestCase instance = mock Kalibro::Client::KalibroClient.expects(:new).returns(instance) instance.expects(:process_project).with('myproject') - Kalibro::Client::KalibroClient.process_project('myproject') + Kalibro::Client::KalibroClient.process_project('myproject', 0) + end + + should 'process project with periodicity' do + name = 'KalibroClientTest' + @port.expects(:request).with(:process_periodically, {:project_name => name, :period_in_days => 30}) + @client.process_periodically(name, 30) + end + + should 'instantiate for processing project periodically' do + instance = mock + Kalibro::Client::KalibroClient.expects(:new).returns(instance) + instance.expects(:process_periodically).with('myproject', 30) + Kalibro::Client::KalibroClient.process_project('myproject', 30) end end diff --git a/plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb b/plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb index 175bcf5..30ad64a 100644 --- a/plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb +++ b/plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb @@ -31,4 +31,8 @@ <% @configuration_names = Kalibro::Client::ConfigurationClient.new.configuration_names.sort %> <% @selected = (@project.nil? ? @configuration_names[0] : @project.configuration_name) %> <%= required labelled_form_field _('Configuration'), - f.select(:configuration_name, @configuration_names.sort, {:selected => @selected}) %>
\ No newline at end of file + f.select(:configuration_name, @configuration_names.sort, {:selected => @selected}) %>
+ +<% options = [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweekly", 15], ["Monthly", 30]] %> +<%= required labelled_form_field _('Periodic Avaliation'), + f.select(:periodicity_in_days, options, {:selected => 0}) %>
-- libgit2 0.21.2