Commit 6bb121a2e173f2e2091b425d2cd008ad9a2a5a7b

Authored by Caio Salgado + Diego Araújo + Pedro Leal
Committed by Caio
1 parent 07e19481

[mezuro] add list box for peridically avaliation of the project, and made tests

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/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/>