From 5a8e308c402e5cf9421f881011fb653035e0706f Mon Sep 17 00:00:00 2001 From: Diego Araújo + Eduardo Morais + Paulo Meirelles Date: Wed, 10 Oct 2012 16:53:20 -0300 Subject: [PATCH] [Mezuro] Fixed bug for when there are no projects. --- plugins/mezuro/lib/kalibro/model.rb | 14 ++++++++------ plugins/mezuro/lib/kalibro/project.rb | 4 +++- plugins/mezuro/test/unit/kalibro/project_test.rb | 6 ++++++ plugins/mezuro/views/mezuro_plugin_module/_module_result.rhtml | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/plugins/mezuro/lib/kalibro/model.rb b/plugins/mezuro/lib/kalibro/model.rb index 7da2a03..6a72619 100644 --- a/plugins/mezuro/lib/kalibro/model.rb +++ b/plugins/mezuro/lib/kalibro/model.rb @@ -14,12 +14,14 @@ class Kalibro::Model fields.each do |field| if(!excepts.include?(field)) field_value = send(field) - hash[field] = convert_to_hash(field_value) if ! field_value.nil? - if field_value.is_a?(Kalibro::Model) - hash = {:attributes! => {}}.merge(hash) - hash[:attributes!][field.to_sym] = { - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:type' => 'kalibro:' + xml_class_name(field_value) } + if !field_value.nil? + hash[field] = convert_to_hash(field_value) + if field_value.is_a?(Kalibro::Model) + hash = {:attributes! => {}}.merge(hash) + hash[:attributes!][field.to_sym] = { + 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:type' => 'kalibro:' + xml_class_name(field_value) } + end end end end diff --git a/plugins/mezuro/lib/kalibro/project.rb b/plugins/mezuro/lib/kalibro/project.rb index 2d3a1a2..1de0b02 100644 --- a/plugins/mezuro/lib/kalibro/project.rb +++ b/plugins/mezuro/lib/kalibro/project.rb @@ -3,7 +3,9 @@ class Kalibro::Project < Kalibro::Model attr_accessor :name, :license, :description, :repository, :configuration_name, :state, :kalibro_error def self.all_names - request("Project", :get_project_names)[:project_name] + response = request("Project", :get_project_names)[:project_name] + response = [] if response.nil? + response end def self.find_by_name(project_name) diff --git a/plugins/mezuro/test/unit/kalibro/project_test.rb b/plugins/mezuro/test/unit/kalibro/project_test.rb index e61d080..39e80bf 100644 --- a/plugins/mezuro/test/unit/kalibro/project_test.rb +++ b/plugins/mezuro/test/unit/kalibro/project_test.rb @@ -16,6 +16,12 @@ class ProjectTest < ActiveSupport::TestCase assert_equal response_hash[:project_name], Kalibro::Project.all_names end + should 'return empty when there are no projects' do + response_hash = {:project_name => nil} + Kalibro::Project.expects(:request).with("Project", :get_project_names).returns(response_hash) + assert_equal [], Kalibro::Project.all_names + end + should 'find project by name' do request_body = {:project_name => @project.name} response_hash = {:project => @hash} diff --git a/plugins/mezuro/views/mezuro_plugin_module/_module_result.rhtml b/plugins/mezuro/views/mezuro_plugin_module/_module_result.rhtml index 2e8dc74..c07f944 100644 --- a/plugins/mezuro/views/mezuro_plugin_module/_module_result.rhtml +++ b/plugins/mezuro/views/mezuro_plugin_module/_module_result.rhtml @@ -2,7 +2,7 @@
- +
-- libgit2 0.21.2
Metric