Commit fccc9c746bf933727162a1ed96b0103bdef538a1
Committed by
Caio
1 parent
6512befb
Exists in
master
and in
28 other branches
[Mezuro] found where to expect error in project content and in show_project and initiated test
Showing
3 changed files
with
26 additions
and
12 deletions
Show diff stats
plugins/mezuro/lib/mezuro_plugin/project_content.rb
| @@ -14,7 +14,17 @@ class MezuroPlugin::ProjectContent < Article | @@ -14,7 +14,17 @@ class MezuroPlugin::ProjectContent < Article | ||
| 14 | include ActionView::Helpers::TagHelper | 14 | include ActionView::Helpers::TagHelper |
| 15 | def to_html(options = {}) | 15 | def to_html(options = {}) |
| 16 | lambda do | 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 | end | 28 | end |
| 19 | end | 29 | end |
| 20 | 30 |
plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb
| @@ -14,15 +14,6 @@ class ProjectContentTest < ActiveSupport::TestCase | @@ -14,15 +14,6 @@ class ProjectContentTest < ActiveSupport::TestCase | ||
| 14 | @content.repository_url = @project.repository.address | 14 | @content.repository_url = @project.repository.address |
| 15 | @content.configuration_name = @project.configuration_name | 15 | @content.configuration_name = @project.configuration_name |
| 16 | @content.periodicity_in_days = 1 | 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 | end | 17 | end |
| 27 | 18 | ||
| 28 | should 'be an article' do | 19 | should 'be an article' do |
| @@ -40,6 +31,11 @@ class ProjectContentTest < ActiveSupport::TestCase | @@ -40,6 +31,11 @@ class ProjectContentTest < ActiveSupport::TestCase | ||
| 40 | should 'have an html view' do | 31 | should 'have an html view' do |
| 41 | assert_not_nil @content.to_html | 32 | assert_not_nil @content.to_html |
| 42 | end | 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 | should 'get project from service' do | 40 | should 'get project from service' do |
| 45 | Kalibro::Client::ProjectClient.expects(:project).with(@content.name).returns(@project) | 41 | Kalibro::Client::ProjectClient.expects(:project).with(@content.name).returns(@project) |
| @@ -107,6 +103,7 @@ returns(module_result) | @@ -107,6 +103,7 @@ returns(module_result) | ||
| 107 | end | 103 | end |
| 108 | 104 | ||
| 109 | private | 105 | private |
| 106 | + | ||
| 110 | def mock_project_client | 107 | def mock_project_client |
| 111 | Kalibro::Client::ProjectClient.expects(:project).with(@content.name).returns(@project) | 108 | Kalibro::Client::ProjectClient.expects(:project).with(@content.name).returns(@project) |
| 112 | end | 109 | end |
| @@ -117,4 +114,8 @@ returns(module_result) | @@ -117,4 +114,8 @@ returns(module_result) | ||
| 117 | project_result | 114 | project_result |
| 118 | end | 115 | end |
| 119 | 116 | ||
| 117 | + def create_project_error | ||
| 118 | + raise "Error on Kalibro" | ||
| 119 | + end | ||
| 120 | + | ||
| 120 | end | 121 | end |
plugins/mezuro/views/content_viewer/show_project.rhtml
| 1 | <script src="/plugins/mezuro/javascripts/project_content.js" type="text/javascript"></script> | 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 | <table> | 6 | <table> |
| 5 | <tr> | 7 | <tr> |
| 6 | <td><%= _('Name') %></td> | 8 | <td><%= _('Name') %></td> |
| @@ -43,3 +45,4 @@ | @@ -43,3 +45,4 @@ | ||
| 43 | <div id="project-tree"></div> | 45 | <div id="project-tree"></div> |
| 44 | <div id="module-result"> | 46 | <div id="module-result"> |
| 45 | </div> | 47 | </div> |
| 48 | +<% end %> |