Commit 5a8e308c402e5cf9421f881011fb653035e0706f

Authored by Diego Camarinha
Committed by Paulo Meireles
1 parent dbfafb3d

[Mezuro] Fixed bug for when there are no projects.

plugins/mezuro/lib/kalibro/model.rb
... ... @@ -14,12 +14,14 @@ class Kalibro::Model
14 14 fields.each do |field|
15 15 if(!excepts.include?(field))
16 16 field_value = send(field)
17   - hash[field] = convert_to_hash(field_value) if ! field_value.nil?
18   - if field_value.is_a?(Kalibro::Model)
19   - hash = {:attributes! => {}}.merge(hash)
20   - hash[:attributes!][field.to_sym] = {
21   - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
22   - 'xsi:type' => 'kalibro:' + xml_class_name(field_value) }
  17 + if !field_value.nil?
  18 + hash[field] = convert_to_hash(field_value)
  19 + if field_value.is_a?(Kalibro::Model)
  20 + hash = {:attributes! => {}}.merge(hash)
  21 + hash[:attributes!][field.to_sym] = {
  22 + 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
  23 + 'xsi:type' => 'kalibro:' + xml_class_name(field_value) }
  24 + end
23 25 end
24 26 end
25 27 end
... ...
plugins/mezuro/lib/kalibro/project.rb
... ... @@ -3,7 +3,9 @@ class Kalibro::Project < Kalibro::Model
3 3 attr_accessor :name, :license, :description, :repository, :configuration_name, :state, :kalibro_error
4 4  
5 5 def self.all_names
6   - request("Project", :get_project_names)[:project_name]
  6 + response = request("Project", :get_project_names)[:project_name]
  7 + response = [] if response.nil?
  8 + response
7 9 end
8 10  
9 11 def self.find_by_name(project_name)
... ...
plugins/mezuro/test/unit/kalibro/project_test.rb
... ... @@ -16,6 +16,12 @@ class ProjectTest < ActiveSupport::TestCase
16 16 assert_equal response_hash[:project_name], Kalibro::Project.all_names
17 17 end
18 18  
  19 + should 'return empty when there are no projects' do
  20 + response_hash = {:project_name => nil}
  21 + Kalibro::Project.expects(:request).with("Project", :get_project_names).returns(response_hash)
  22 + assert_equal [], Kalibro::Project.all_names
  23 + end
  24 +
19 25 should 'find project by name' do
20 26 request_body = {:project_name => @project.name}
21 27 response_hash = {:project => @hash}
... ...
plugins/mezuro/views/mezuro_plugin_module/_module_result.rhtml
... ... @@ -2,7 +2,7 @@
2 2  
3 3 <hr/>
4 4 <div class="zoomable-image">
5   -<table style="width: 116%">
  5 +<table style="width: 100%">
6 6 <thead>
7 7 <tr>
8 8 <th style="width: 74%">Metric</th>
... ...