Commit fccc9c746bf933727162a1ed96b0103bdef538a1

Authored by Caio Salgado + Jefferson Fernandes
Committed by Caio
1 parent 6512befb

[Mezuro] found where to expect error in project content and in show_project and initiated test

plugins/mezuro/lib/mezuro_plugin/project_content.rb
... ... @@ -14,7 +14,17 @@ class MezuroPlugin::ProjectContent < Article
14 14 include ActionView::Helpers::TagHelper
15 15 def to_html(options = {})
16 16 lambda do
17   - render :file => 'content_viewer/show_project.rhtml'
  17 +
  18 + render :file => 'content_viewer/show_project.rhtml', :locals => { :project => project_kalibro, :error_kalibro => error_kalibro }
  19 + end
  20 + end
  21 +
  22 + def rescue_error_kalibro
  23 + error_kalibro = false
  24 + begin
  25 + project_kalibro = project
  26 + rescue
  27 + error_kalibro = true
18 28 end
19 29 end
20 30  
... ...
plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb
... ... @@ -14,15 +14,6 @@ class ProjectContentTest < ActiveSupport::TestCase
14 14 @content.repository_url = @project.repository.address
15 15 @content.configuration_name = @project.configuration_name
16 16 @content.periodicity_in_days = 1
17   -
18   - @content2 = MezuroPlugin::ProjectContent.new
19   - @content2.name = @content.name
20   - @content2.license = @project.license
21   - @content2.description = @project.description
22   - @content2.repository_type = @project.repository.type
23   - @content2.repository_url = @project.repository.address
24   - @content2.configuration_name = @project.configuration_name
25   - @content2.periodicity_in_days = 1
26 17 end
27 18  
28 19 should 'be an article' do
... ... @@ -40,6 +31,11 @@ class ProjectContentTest < ActiveSupport::TestCase
40 31 should 'have an html view' do
41 32 assert_not_nil @content.to_html
42 33 end
  34 +
  35 + should 'rescue error when project doesnt exist in kalibro' do
  36 + MezuroPlugin::ProjectContent.expects(:project).returns(create_project_error)
  37 + assert_equal true, @content.rescue_error_kalibro
  38 + end
43 39  
44 40 should 'get project from service' do
45 41 Kalibro::Client::ProjectClient.expects(:project).with(@content.name).returns(@project)
... ... @@ -107,6 +103,7 @@ returns(module_result)
107 103 end
108 104  
109 105 private
  106 +
110 107 def mock_project_client
111 108 Kalibro::Client::ProjectClient.expects(:project).with(@content.name).returns(@project)
112 109 end
... ... @@ -117,4 +114,8 @@ returns(module_result)
117 114 project_result
118 115 end
119 116  
  117 + def create_project_error
  118 + raise "Error on Kalibro"
  119 + end
  120 +
120 121 end
... ...
plugins/mezuro/views/content_viewer/show_project.rhtml
1 1 <script src="/plugins/mezuro/javascripts/project_content.js" type="text/javascript"></script>
2   -
3   -<% @project = @page.project %>
  2 +<% if error_kalibro %>
  3 + Projeto nao existe TODO: Perguntar oa usuário se deseja excluir o projeto do Noosfero
  4 +<% else %>
  5 +<% @project = project %>
4 6 <table>
5 7 <tr>
6 8 <td><%= _('Name') %></td>
... ... @@ -43,3 +45,4 @@
43 45 <div id="project-tree"></div>
44 46 <div id="module-result">
45 47 </div>
  48 +<% end %>
... ...