Commit 1bd30704489121887fe458a551e7f47a298af13c

Authored by João M. M. da Silva + Alessandro Palmeira
Committed by Alessandro Palmeira
1 parent 4c59058f

[Mezuro] Fixed Repository when kalibro has just a repository in a project

plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
@@ -68,6 +68,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController @@ -68,6 +68,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
68 if( repository.errors.empty? ) 68 if( repository.errors.empty? )
69 redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}" 69 redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}"
70 else 70 else
  71 + raise repository.errors[0].message
71 redirect_to_error_page repository.errors[0].message 72 redirect_to_error_page repository.errors[0].message
72 end 73 end
73 end 74 end
plugins/mezuro/lib/kalibro/repository.rb
@@ -11,7 +11,10 @@ class Kalibro::Repository < Kalibro::Model @@ -11,7 +11,10 @@ class Kalibro::Repository < Kalibro::Model
11 end 11 end
12 12
13 def self.repositories_of(project_id) 13 def self.repositories_of(project_id)
14 - request(:repositories_of, {:project_id => project_id})[:repository].to_a.map { |repository| new repository } 14 + response = request(:repositories_of, {:project_id => project_id})[:repository]
  15 + response = [] if response.nil?
  16 + response = [response] if response.is_a? (Hash)
  17 + response.map {|repository| new repository}
15 end 18 end
16 19
17 def process_repository 20 def process_repository
plugins/mezuro/test/unit/kalibro/repository_test.rb
@@ -40,6 +40,7 @@ class RepositoryTest < ActiveSupport::TestCase @@ -40,6 +40,7 @@ class RepositoryTest < ActiveSupport::TestCase
40 id_from_kalibro = 1 40 id_from_kalibro = 1
41 project_id = 56 41 project_id = 56
42 Kalibro::Repository.expects(:request).with(:save_repository, {:repository => @created_repository.to_hash, :project_id => project_id}).returns(:repository_id => id_from_kalibro) 42 Kalibro::Repository.expects(:request).with(:save_repository, {:repository => @created_repository.to_hash, :project_id => project_id}).returns(:repository_id => id_from_kalibro)
  43 + Kalibro::Repository.expects(:request).with(:process_repository, :repository_id => id_from_kalibro).returns(:repository_id => id_from_kalibro)
43 assert @created_repository.save(project_id) 44 assert @created_repository.save(project_id)
44 assert_equal id_from_kalibro, @created_repository.id 45 assert_equal id_from_kalibro, @created_repository.id
45 end 46 end
plugins/mezuro/test/unit/mezuro_plugin/helpers/content_viewer_helper_test.rb
@@ -10,7 +10,7 @@ class ContentViewerHelperTest < ActiveSupport::TestCase @@ -10,7 +10,7 @@ class ContentViewerHelperTest < ActiveSupport::TestCase
10 end 10 end
11 11
12 should 'create the periodicity options array' do 12 should 'create the periodicity options array' do
13 - assert_equal [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweeky", 15], ["Monthly", 30]], MezuroPlugin::Helpers::ContentViewerHelper.create_periodicity_options 13 + assert_equal [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweeky", 15], ["Monthly", 30]], MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options
14 end 14 end
15 15
16 should 'format metric name for metric configuration snapshot' do 16 should 'format metric name for metric configuration snapshot' do