Commit 32b790e73c1b2019397835748c180a6418f90ea0

Authored by Diego Camarinha
Committed by Paulo Meireles
1 parent 8f642cb7

[Mezuro] Fixed 'get module result' test

plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
@@ -97,6 +97,14 @@ class MezuroPluginProfileController < ProfileController @@ -97,6 +97,14 @@ class MezuroPluginProfileController < ProfileController
97 redirect_to "/#{profile.identifier}/#{configuration_name.downcase.gsub(/\s/, '-')}" 97 redirect_to "/#{profile.identifier}/#{configuration_name.downcase.gsub(/\s/, '-')}"
98 end 98 end
99 99
  100 + def module_metrics_history
  101 + metric_name = params[:metric_name]
  102 + content = profile.articles.find(params[:id])
  103 + module_history = content.result_history(params[:module_name])
  104 + date_history = module_history.collect { |x| x.date }
  105 + metric_history = module_history.collect { |x| (x.metric_results.select { |y| y.metric.name.delete("() ") == metric_name })[0] }
  106 + render :partial => 'content_viewer/metric_history', :locals => {:metric_history => metric_history, :date_history => date_history }
  107 + end
100 private 108 private
101 109
102 def new_metric_configuration_instance 110 def new_metric_configuration_instance
@@ -124,14 +132,4 @@ class MezuroPluginProfileController < ProfileController @@ -124,14 +132,4 @@ class MezuroPluginProfileController < ProfileController
124 range 132 range
125 end 133 end
126 134
127 - def module_metrics_history  
128 - metric_name = params[:metric_name]  
129 - content = profile.articles.find(params[:id])  
130 - module_history = content.result_history(params[:module_name])  
131 - date_history = module_history.collect { |x| x.date }  
132 - metric_history = module_history.collect { |x| (x.metric_results.select { |y| y.metric.name.delete("() ") == metric_name })[0] }  
133 - #precisamos que uma variável receba um array com os valores da métrica passada a partir do result history  
134 -render :partial => 'content_viewer/metric_history', :locals => {:metric_history => metric_history, :date_history => date_history }  
135 - end  
136 -  
137 end 135 end
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
@@ -68,7 +68,10 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase @@ -68,7 +68,10 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
68 68
69 should 'get module result' do 69 should 'get module result' do
70 create_project_content 70 create_project_content
71 - Kalibro::Client::ModuleResultClient.expects(:module_result).with(@content, @name).returns(@module_result) 71 + module_result_client = mock
  72 + Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result)
  73 + Kalibro::Client::ModuleResultClient.expects(:new).returns(module_result_client)
  74 + module_result_client.expects(:module_result).with(@name, @name, @project_result.date).returns(@module_result)
72 get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @name 75 get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @name
73 assert_response 200 76 assert_response 200
74 assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') 77 assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)')
plugins/mezuro/views/content_viewer/_module_result.rhtml
@@ -17,30 +17,24 @@ @@ -17,30 +17,24 @@
17 <tbody> 17 <tbody>
18 <% module_result.metric_results.each do |metric_result| %> 18 <% module_result.metric_results.each do |metric_result| %>
19 <% range = metric_result.range %> 19 <% range = metric_result.range %>
20 - <tr>  
21 - <td><a href="#" data-show=".<%= metric_result.metric.name.delete("() ")%>"><%= metric_result.metric.name %></a></td>  
22 - <td><%= "%.02f" % metric_result.value %></td>  
23 - <td><%= metric_result.weight %></td>  
24 - <% if range.nil? %>  
25 - <td></td>  
26 - <% else %> 20 + <% if !range.nil? %>
  21 + <tr>
  22 + <td><a href="#" data-show=".<%= metric_result.metric.name.delete("() ")%>"><%= metric_result.metric.name %></a></td>
  23 + <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td>
  24 + <td><%= metric_result.weight %></td>
27 <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> 25 <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td>
28 - <% end %>  
29 - </tr>  
30 - <tr class="<%= metric_result.metric.name.delete("() ")%>" style="display: none;">  
31 - <td colspan="4" align="right">  
32 - <%= range.nil? or range.comments.nil? ? 'comment empty' : range.comments %>  
33 - </td>  
34 - <td>  
35 - <td colspan="4">  
36 - <div id='historical-<%= metric_result.metric.name.delete("() ") %>'>  
37 - <a href="#" show-metric-history="<%= metric_result.metric.name.delete("() ") %>" data-module-name="<%= the_module.name %>" data-metric-name="<%= metric_result.metric.name.delete("() ") %>"> <p style="text-indent: 3em;"> Draw Historical Graphic </p> </a>  
38 - </div>  
39 - </td>  
40 - <td colspan="3" align="right">  
41 - <%= range.comments.nil? ? '' : range.comments %>  
42 - </td>  
43 - </tr> 26 + </tr>
  27 + <tr class="<%= metric_result.metric.name.delete("() ")%>" style="display: none;">
  28 + <td colspan="4">
  29 + <div id='historical-<%= metric_result.metric.name.delete("() ") %>'>
  30 + <a href="#" show-metric-history="<%= metric_result.metric.name.delete("() ") %>" data-module-name="<%= the_module.name %>" data-metric-name="<%= metric_result.metric.name.delete("() ") %>"> <p style="text-indent: 3em;"> Draw Historical Graphic </p> </a>
  31 + </div>
  32 + </td>
  33 + <td colspan="3" align="right">
  34 + <%= range.comments.nil? ? '' : range.comments %>
  35 + </td>
  36 + </tr>
  37 + <% end %>
44 <% end %> 38 <% end %>
45 </tbody> 39 </tbody>
46 <tfoot> 40 <tfoot>