Commit efe7e543f33b0a4d5c5818fb17529efb2cdcbcf1
Committed by
Carlos Morais
1 parent
c4d258c2
Exists in
master
and in
28 other branches
[Mezuro] Case when range is nil
Showing
3 changed files
with
12 additions
and
7 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
| @@ -15,6 +15,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -15,6 +15,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
| 15 | @module_result = ModuleResultFixtures.create | 15 | @module_result = ModuleResultFixtures.create |
| 16 | @project_result = ProjectResultFixtures.qt_calculator | 16 | @project_result = ProjectResultFixtures.qt_calculator |
| 17 | @project = @project_result.project | 17 | @project = @project_result.project |
| 18 | + @project_content = create_project_content(@profile) | ||
| 18 | end | 19 | end |
| 19 | 20 | ||
| 20 | def test_metrics_for_unknown_project | 21 | def test_metrics_for_unknown_project |
| @@ -28,13 +29,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -28,13 +29,12 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
| 28 | end | 29 | end |
| 29 | 30 | ||
| 30 | should 'get metrics from a known module' do | 31 | should 'get metrics from a known module' do |
| 31 | - project_content = create_project_content(@profile) | ||
| 32 | - project_name = project_content.name | 32 | + project_name = @project_content.name |
| 33 | module_name = project_name | 33 | module_name = project_name |
| 34 | Kalibro::Client::ProjectResultClient.expects(:last_result).with(project_name).returns(@project_result) | 34 | Kalibro::Client::ProjectResultClient.expects(:last_result).with(project_name).returns(@project_result) |
| 35 | - Kalibro::Client::ModuleResultClient.expects(:module_result).with(project_content, module_name). | 35 | + Kalibro::Client::ModuleResultClient.expects(:module_result).with(@project_content, module_name). |
| 36 | returns(@module_result) | 36 | returns(@module_result) |
| 37 | - get :metrics, :profile => @profile_id, :id => project_content.id, :module_name => module_name | 37 | + get :metrics, :profile => @profile_id, :id => @project_content.id, :module_name => module_name |
| 38 | assert_response 200 | 38 | assert_response 200 |
| 39 | # assert_tag # TODO | 39 | # assert_tag # TODO |
| 40 | end | 40 | end |
| @@ -48,7 +48,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -48,7 +48,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
| 48 | Kalibro::Client::KalibroClient.expects(:process_project).with(project_content.name) | 48 | Kalibro::Client::KalibroClient.expects(:process_project).with(project_content.name) |
| 49 | project_content.save | 49 | project_content.save |
| 50 | 50 | ||
| 51 | -# MezuroPlugin::ProjectContent.any_instance.stubs(:project_content).returns(project_content) | 51 | + MezuroPlugin::ProjectContent.any_instance.stubs(:project_content).returns(project_content) |
| 52 | project_content | 52 | project_content |
| 53 | end | 53 | end |
| 54 | 54 |
plugins/mezuro/views/content_viewer/_module_result.rhtml
| @@ -17,11 +17,15 @@ | @@ -17,11 +17,15 @@ | ||
| 17 | <tbody> | 17 | <tbody> |
| 18 | <% module_result.metric_results.each do |metric_result| %> | 18 | <% module_result.metric_results.each do |metric_result| %> |
| 19 | <% range = metric_result.range %> | 19 | <% range = metric_result.range %> |
| 20 | - <tr title=" <%= range.comments %>"> | 20 | + <tr title="<%= range.nil? ? '' : range.comments %>"> |
| 21 | <td><%= metric_result.metric.name %></td> | 21 | <td><%= metric_result.metric.name %></td> |
| 22 | <td><%= metric_result.value %></td> | 22 | <td><%= metric_result.value %></td> |
| 23 | <td><%= metric_result.weight %></td> | 23 | <td><%= metric_result.weight %></td> |
| 24 | - <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> | 24 | + <% if range.nil? %> |
| 25 | + <td></td> | ||
| 26 | + <% else %> | ||
| 27 | + <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> | ||
| 28 | + <% end %> | ||
| 25 | </tr> | 29 | </tr> |
| 26 | <% end %> | 30 | <% end %> |
| 27 | </tbody> | 31 | </tbody> |