Commit dfaed08522adedf792d5d41d339332139b300858
Committed by
Paulo Meireles
1 parent
e43b3875
Exists in
master
and in
28 other branches
[Mezuro] Trying to create tests for periodicity
Showing
3 changed files
with
22 additions
and
3 deletions
Show diff stats
plugins/mezuro/lib/kalibro/client/kalibro_client.rb
| ... | ... | @@ -16,6 +16,14 @@ class Kalibro::Client::KalibroClient |
| 16 | 16 | @port.request(:process_project, {:project_name => project_name}) |
| 17 | 17 | end |
| 18 | 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 | |
| 25 | + end | |
| 26 | + | |
| 19 | 27 | def process_periodically(project_name, period_in_days) |
| 20 | 28 | @port.request(:process_periodically, {:project_name => project_name, :period_in_days => period_in_days}) |
| 21 | 29 | end | ... | ... |
plugins/mezuro/lib/mezuro_plugin/project_content.rb
| ... | ... | @@ -30,8 +30,8 @@ class MezuroPlugin::ProjectContent < Article |
| 30 | 30 | end |
| 31 | 31 | |
| 32 | 32 | def get_date_result(date) |
| 33 | - client = Kalibro::Client::ProjectResultClient.new | |
| 34 | - @project_result ||= client.has_results_before(name, date) ? client.last_result_before(name, date) : client.first_result_after(name, date) | |
| 33 | +#client = Kalibro::Client::ProjectResultClient.new | |
| 34 | + @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) | |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | 37 | def module_result(module_name) | ... | ... |
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
| ... | ... | @@ -25,6 +25,8 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
| 25 | 25 | @metric = NativeMetricFixtures.amloc |
| 26 | 26 | @metric_configuration_client = Kalibro::Client::MetricConfigurationClient.new |
| 27 | 27 | @metric_configuration = MetricConfigurationFixtures.amloc_configuration |
| 28 | + | |
| 29 | + @date = "2012-04-13T20:39:41+04:00" | |
| 28 | 30 | end |
| 29 | 31 | |
| 30 | 32 | should 'not find module result for inexistent project content' do |
| ... | ... | @@ -65,7 +67,16 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase |
| 65 | 67 | assert_response 200 |
| 66 | 68 | assert_select('h4', 'Last Result') |
| 67 | 69 | end |
| 68 | - | |
| 70 | + | |
| 71 | + should 'get project results from a specific date' do | |
| 72 | + create_project_content | |
| 73 | +#client = mock | |
| 74 | +#Kalibro::Client::ProjectResultClient.expects(:new).returns(client) | |
| 75 | + Kalibro::Client::ProjectResultClient.expects(:has_results_before).with(@name, @date).returns(true) | |
| 76 | + Kalibro::Client::ProjectResultClient.expects(:last_result_before).with(@name, @date).returns(@project_result) | |
| 77 | + assert_response 200 | |
| 78 | + end | |
| 79 | + | |
| 69 | 80 | should 'get module result' do |
| 70 | 81 | create_project_content |
| 71 | 82 | Kalibro::Client::ModuleResultClient.expects(:module_result).with(@content, @name).returns(@module_result) | ... | ... |