From 6cbd22d0c45a2d240c18795834fe2143cc69b632 Mon Sep 17 00:00:00 2001 From: Diego Araújo + Jefferson Fernandes Date: Wed, 23 May 2012 16:39:59 -0300 Subject: [PATCH] [Mezuro] Continued refactoring tests. --- plugins/mezuro/lib/mezuro_plugin/configuration_content.rb | 2 +- plugins/mezuro/test/unit/mezuro_plugin/metric_configuration_content_test.rb | 24 ++++++++++++++++++++++-- plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb | 14 ++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/plugins/mezuro/lib/mezuro_plugin/configuration_content.rb b/plugins/mezuro/lib/mezuro_plugin/configuration_content.rb index 6d40368..c153e55 100644 --- a/plugins/mezuro/lib/mezuro_plugin/configuration_content.rb +++ b/plugins/mezuro/lib/mezuro_plugin/configuration_content.rb @@ -17,7 +17,7 @@ class MezuroPlugin::ConfigurationContent < Article end end - def configuration + def configuration #FIXME invalid method name Kalibro::Client::ConfigurationClient.configuration(name) end diff --git a/plugins/mezuro/test/unit/mezuro_plugin/metric_configuration_content_test.rb b/plugins/mezuro/test/unit/mezuro_plugin/metric_configuration_content_test.rb index 91ffcdb..0e0515c 100644 --- a/plugins/mezuro/test/unit/mezuro_plugin/metric_configuration_content_test.rb +++ b/plugins/mezuro/test/unit/mezuro_plugin/metric_configuration_content_test.rb @@ -18,7 +18,27 @@ class MetricConfigurationContentTest < ActiveSupport::TestCase assert_equal 'Sets of thresholds to interpret a metric', MezuroPlugin::MetricConfigurationContent.description end - should 'return metric configuration' do - pending "Need refactoring" + should 'have an html view' do + assert_not_nil @metric_configuration.to_html end + + #should 'return metric configuration' do + # pending "Need refactoring" + #end + + should 'send metric configuration to service after saving' do + @metric_configuration.expects :send_metric_configuration_to_service + @metric_configuration.run_callbacks :after_save + end + + should 'send correct metric configuration to service' do + Kalibro::Client::MetricConfigurationClient.expects(:save).with(@metric_configuration) + @metric_configuration.send :send_metric_configuration_to_service + end + + should 'remove metric configuration from service' do + Kalibro::Client::MetricConfigurationClient.expects(:remove).with(@metric_configuration.name) + @metric_configuration.send :remove_metric_configuration_from_service + end + end diff --git a/plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb b/plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb index 019a3fb..71e65a4 100644 --- a/plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb +++ b/plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb @@ -1,6 +1,7 @@ require "test_helper" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_fixtures" +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" class ProjectContentTest < ActiveSupport::TestCase @@ -42,6 +43,19 @@ class ProjectContentTest < ActiveSupport::TestCase Kalibro::Client::ProjectResultClient.expects(:last_result).with(@content.name).returns(project_result) assert_equal project_result, @content.project_result 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) + #end + + should 'get date result from service when has_result_before is true' do + client = mock + Kalibro::Client::ProjectResultClient.expects(:new).returns(client) + client.expects(:has_results_before).with(@project.name, "2012-05-22T22:00:33+04:00").returns(true) + client.expects(:last_result_before).with(@project.name, "2012-05-22T22:00:33+04:00").returns(project_result) + assert_equal project_result, @content.project_result + end should 'get module result from service' do mock_project_client -- libgit2 0.21.2