Commit 88bbff0210da75e55da43c47eda5561e64037426

Authored by Diego Camarinha
Committed by João M. M. da Silva
1 parent 5f82a4d1

[Mezuro] Finished source tree view.

plugins/mezuro/lib/kalibro/module_result.rb
@@ -7,7 +7,7 @@ class Kalibro::ModuleResult < Kalibro::Model @@ -7,7 +7,7 @@ class Kalibro::ModuleResult < Kalibro::Model
7 end 7 end
8 8
9 def children 9 def children
10 - response = self.class.request(:children_of, {:module_result_id => self.id})[:module_result] 10 + response = self.class.request(:children_of, {:module_result_id => id})[:module_result]
11 response = [] if response.nil? 11 response = [] if response.nil?
12 response = [response] if response.is_a?(Hash) 12 response = [response] if response.is_a?(Hash)
13 response.map {|module_result| Kalibro::ModuleResult.new module_result} 13 response.map {|module_result| Kalibro::ModuleResult.new module_result}
plugins/mezuro/test/functional/profile/mezuro_plugin_module_result_controller_test.rb
@@ -20,10 +20,15 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase @@ -20,10 +20,15 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase
20 end 20 end
21 21
22 should 'find module result on kalibro' do 22 should 'find module result on kalibro' do
  23 + parent_module_result = ModuleResultFixtures.parent_module_result_hash
23 Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:id] }). 24 Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:id] }).
24 returns({:module_result => @module_result_hash}) 25 returns({:module_result => @module_result_hash})
25 Kalibro::MetricResult.expects(:request).with(:metric_results_of, { :module_result_id => @module_result_hash[:id] }). 26 Kalibro::MetricResult.expects(:request).with(:metric_results_of, { :module_result_id => @module_result_hash[:id] }).
26 returns({:metric_result => @metric_result_hash}) 27 returns({:metric_result => @metric_result_hash})
  28 + Kalibro::ModuleResult.expects(:request).with(:get_module_result, { :module_result_id => @module_result_hash[:parent_id] }).
  29 + returns({:module_result => parent_module_result})
  30 + Kalibro::ModuleResult.expects(:request).with(:children_of, {:module_result_id => @module_result_hash[:id]}).
  31 + returns({:module_result => nil})
27 get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] 32 get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id]
28 assert_equal @module_result_hash[:grade], assigns(:module_result).grade 33 assert_equal @module_result_hash[:grade], assigns(:module_result).grade
29 assert_equal @metric_result_hash[:value], assigns(:metric_results).first.value 34 assert_equal @metric_result_hash[:value], assigns(:metric_results).first.value
plugins/mezuro/views/mezuro_plugin_module_result/_module_result.rhtml
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <div id='historical-grade' style="display: none;"></div> 11 <div id='historical-grade' style="display: none;"></div>
12 </td> 12 </td>
13 <td align = "right"> 13 <td align = "right">
14 - <a href="#" show-grade-history="<%= @module_result.id %>" data-module-id="<%= module_result.id %>" > 14 + <a href="#" show-grade-history="<%= @module_result.id %>" data-module-id="<%= @module_result.id %>" >
15 <strong> 15 <strong>
16 <%= _('Grade:') %> 16 <%= _('Grade:') %>
17 <%= "%.02f" % @module_result.grade %> 17 <%= "%.02f" % @module_result.grade %>
plugins/mezuro/views/mezuro_plugin_module_result/_source_tree.rhtml
1 <h4><%= _('Source tree') %></h4> 1 <h4><%= _('Source tree') %></h4>
2 -<% module_name = @module_result.module.name %>  
3 -<% module_label = "#{module_name} (#{@module_result.module.granularity})" %> 2 +<% module_name = module_result.module.name %>
  3 +<% module_label = "#{module_name} (#{module_result.module.granularity})" %>
4 4
5 <p> 5 <p>
6 <h2 class="path"> 6 <h2 class="path">
7 - <% parents = @module_result.parents %>  
8 - <% parents.each do |parent| %> 7 + <% module_result.parents.each do |parent| %>
9 /<a href="#" class="source-tree-link" data-module-id="<%= parent.id %>"> 8 /<a href="#" class="source-tree-link" data-module-id="<%= parent.id %>">
10 <%= parent.module.name %> 9 <%= parent.module.name %>
11 </a> 10 </a>
@@ -14,7 +13,7 @@ @@ -14,7 +13,7 @@
14 </p> 13 </p>
15 14
16 <table border="0" class="source-tree"> 15 <table border="0" class="source-tree">
17 - <% @module_result.children.each do |child| %> 16 + <% module_result.children.each do |child| %>
18 <% if child.module.granularity=='PACKAGE' %> 17 <% if child.module.granularity=='PACKAGE' %>
19 <tr> 18 <tr>
20 <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> 19 <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td>