From 32b790e73c1b2019397835748c180a6418f90ea0 Mon Sep 17 00:00:00 2001 From: Diego Araújo + Pedro Leal Date: Thu, 19 Apr 2012 15:12:26 -0300 Subject: [PATCH] [Mezuro] Fixed 'get module result' test --- plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb | 18 ++++++++---------- plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb | 5 ++++- plugins/mezuro/views/content_viewer/_module_result.rhtml | 40 +++++++++++++++++----------------------- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb b/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb index 95e2798..d089e2a 100644 --- a/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb +++ b/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb @@ -97,6 +97,14 @@ class MezuroPluginProfileController < ProfileController redirect_to "/#{profile.identifier}/#{configuration_name.downcase.gsub(/\s/, '-')}" end + def module_metrics_history + metric_name = params[:metric_name] + content = profile.articles.find(params[:id]) + module_history = content.result_history(params[:module_name]) + date_history = module_history.collect { |x| x.date } + metric_history = module_history.collect { |x| (x.metric_results.select { |y| y.metric.name.delete("() ") == metric_name })[0] } + render :partial => 'content_viewer/metric_history', :locals => {:metric_history => metric_history, :date_history => date_history } + end private def new_metric_configuration_instance @@ -124,14 +132,4 @@ class MezuroPluginProfileController < ProfileController range end - def module_metrics_history - metric_name = params[:metric_name] - content = profile.articles.find(params[:id]) - module_history = content.result_history(params[:module_name]) - date_history = module_history.collect { |x| x.date } - metric_history = module_history.collect { |x| (x.metric_results.select { |y| y.metric.name.delete("() ") == metric_name })[0] } - #precisamos que uma variável receba um array com os valores da métrica passada a partir do result history -render :partial => 'content_viewer/metric_history', :locals => {:metric_history => metric_history, :date_history => date_history } - end - end 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..45a8935 100644 --- a/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb +++ b/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb @@ -68,7 +68,10 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase should 'get module result' do create_project_content - Kalibro::Client::ModuleResultClient.expects(:module_result).with(@content, @name).returns(@module_result) + module_result_client = mock + Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) + Kalibro::Client::ModuleResultClient.expects(:new).returns(module_result_client) + module_result_client.expects(:module_result).with(@name, @name, @project_result.date).returns(@module_result) get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @name assert_response 200 assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') diff --git a/plugins/mezuro/views/content_viewer/_module_result.rhtml b/plugins/mezuro/views/content_viewer/_module_result.rhtml index 93d3bf4..2d06a3a 100644 --- a/plugins/mezuro/views/content_viewer/_module_result.rhtml +++ b/plugins/mezuro/views/content_viewer/_module_result.rhtml @@ -17,30 +17,24 @@ <% module_result.metric_results.each do |metric_result| %> <% range = metric_result.range %> - - "><%= metric_result.metric.name %> - <%= "%.02f" % metric_result.value %> - <%= metric_result.weight %> - <% if range.nil? %> - - <% else %> + <% if !range.nil? %> + + "><%= metric_result.metric.name %> + <%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %> + <%= metric_result.weight %> <%= range.label %> - <% end %> - - " style="display: none;"> - - <%= range.nil? or range.comments.nil? ? 'comment empty' : range.comments %> - - - -
- " data-module-name="<%= the_module.name %>" data-metric-name="<%= metric_result.metric.name.delete("() ") %>">

Draw Historical Graphic

-
- - - <%= range.comments.nil? ? '' : range.comments %> - - + + " style="display: none;"> + +
+ " data-module-name="<%= the_module.name %>" data-metric-name="<%= metric_result.metric.name.delete("() ") %>">

Draw Historical Graphic

+
+ + + <%= range.comments.nil? ? '' : range.comments %> + + + <% end %> <% end %> -- libgit2 0.21.2