diff --git a/plugins/mezuro/lib/kalibro/client/kalibro_client.rb b/plugins/mezuro/lib/kalibro/client/kalibro_client.rb index b64c33a..e1c143d 100644 --- a/plugins/mezuro/lib/kalibro/client/kalibro_client.rb +++ b/plugins/mezuro/lib/kalibro/client/kalibro_client.rb @@ -16,6 +16,14 @@ class Kalibro::Client::KalibroClient @port.request(:process_project, {:project_name => project_name}) 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 + def process_periodically(project_name, period_in_days) @port.request(:process_periodically, {:project_name => project_name, :period_in_days => period_in_days}) end diff --git a/plugins/mezuro/lib/mezuro_plugin/project_content.rb b/plugins/mezuro/lib/mezuro_plugin/project_content.rb index 8ef7d66..6863c64 100644 --- a/plugins/mezuro/lib/mezuro_plugin/project_content.rb +++ b/plugins/mezuro/lib/mezuro_plugin/project_content.rb @@ -30,8 +30,8 @@ class MezuroPlugin::ProjectContent < Article end def get_date_result(date) - client = Kalibro::Client::ProjectResultClient.new - @project_result ||= client.has_results_before(name, date) ? client.last_result_before(name, date) : client.first_result_after(name, date) +#client = Kalibro::Client::ProjectResultClient.new + @project_result ||= Kalibro::Client::ProjectResultClient.has_results_before(name, date) ? Kalibro::Client::ProjectResultClient.last_result_before(name, date) : Kalibro::Client::ProjectResultClient.first_result_after(name, date) end def module_result(module_name) diff --git a/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb b/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb index b8e4383..7b83fa8 100644 --- a/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb +++ b/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb @@ -25,6 +25,8 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase @metric = NativeMetricFixtures.amloc @metric_configuration_client = Kalibro::Client::MetricConfigurationClient.new @metric_configuration = MetricConfigurationFixtures.amloc_configuration + + @date = "2012-04-13T20:39:41+04:00" end should 'not find module result for inexistent project content' do @@ -65,7 +67,16 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase assert_response 200 assert_select('h4', 'Last Result') end - + + should 'get project results from a specific date' do + create_project_content +#client = mock +#Kalibro::Client::ProjectResultClient.expects(:new).returns(client) + Kalibro::Client::ProjectResultClient.expects(:has_results_before).with(@name, @date).returns(true) + Kalibro::Client::ProjectResultClient.expects(:last_result_before).with(@name, @date).returns(@project_result) + assert_response 200 + end + should 'get module result' do create_project_content Kalibro::Client::ModuleResultClient.expects(:module_result).with(@content, @name).returns(@module_result) -- libgit2 0.21.2