Commit 5a8e308c402e5cf9421f881011fb653035e0706f
Committed by
Paulo Meireles
1 parent
dbfafb3d
Exists in
master
and in
28 other branches
[Mezuro] Fixed bug for when there are no projects.
Showing
4 changed files
with
18 additions
and
8 deletions
Show diff stats
plugins/mezuro/lib/kalibro/model.rb
@@ -14,12 +14,14 @@ class Kalibro::Model | @@ -14,12 +14,14 @@ class Kalibro::Model | ||
14 | fields.each do |field| | 14 | fields.each do |field| |
15 | if(!excepts.include?(field)) | 15 | if(!excepts.include?(field)) |
16 | field_value = send(field) | 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 | end | 25 | end |
24 | end | 26 | end |
25 | end | 27 | end |
plugins/mezuro/lib/kalibro/project.rb
@@ -3,7 +3,9 @@ class Kalibro::Project < Kalibro::Model | @@ -3,7 +3,9 @@ class Kalibro::Project < Kalibro::Model | ||
3 | attr_accessor :name, :license, :description, :repository, :configuration_name, :state, :kalibro_error | 3 | attr_accessor :name, :license, :description, :repository, :configuration_name, :state, :kalibro_error |
4 | 4 | ||
5 | def self.all_names | 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 | end | 9 | end |
8 | 10 | ||
9 | def self.find_by_name(project_name) | 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,6 +16,12 @@ class ProjectTest < ActiveSupport::TestCase | ||
16 | assert_equal response_hash[:project_name], Kalibro::Project.all_names | 16 | assert_equal response_hash[:project_name], Kalibro::Project.all_names |
17 | end | 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 | should 'find project by name' do | 25 | should 'find project by name' do |
20 | request_body = {:project_name => @project.name} | 26 | request_body = {:project_name => @project.name} |
21 | response_hash = {:project => @hash} | 27 | response_hash = {:project => @hash} |
plugins/mezuro/views/mezuro_plugin_module/_module_result.rhtml