Commit 2a69d623caee93abf582b999d050bef02d31babf
Committed by
Paulo Meireles
1 parent
2a1fac14
Exists in
master
and in
29 other branches
[Mezuro] refactoring name format in module result view
Showing
3 changed files
with
17 additions
and
7 deletions
Show diff stats
plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb
... | ... | @@ -23,8 +23,12 @@ class MezuroPlugin::Helpers::ContentViewerHelper |
23 | 23 | end |
24 | 24 | |
25 | 25 | def self.get_periodicity_option(index) |
26 | - options = [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweeky", 15], ["Monthly", 30]] | |
27 | - selected_option = options.find { |option| option.last == index.to_i } | |
28 | - selected_option.first | |
26 | + options = [["Not Periodically", 0], ["1 day", 1], ["2 days", 2], ["Weekly", 7], ["Biweeky", 15], ["Monthly", 30]] | |
27 | + selected_option = options.find { |option| option.last == index.to_i } | |
28 | + selected_option.first | |
29 | + end | |
30 | + | |
31 | + def self.format_name(metric_result) | |
32 | + metric_result.metric.name.delete("() ") | |
29 | 33 | end |
30 | 34 | end | ... | ... |
plugins/mezuro/test/unit/mezuro_plugin/helpers/content_viewer_helper_test.rb
1 | 1 | require "test_helper" |
2 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_result_fixtures" | |
2 | 3 | |
3 | 4 | class ContentViewerHelperTest < ActiveSupport::TestCase |
4 | 5 | |
... | ... | @@ -11,4 +12,9 @@ class ContentViewerHelperTest < ActiveSupport::TestCase |
11 | 12 | should 'create the periodicity options array' do |
12 | 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 | 14 | end |
15 | + | |
16 | + should 'format metric name for module result' do | |
17 | + metric_result = MetricResultFixtures.amloc_result | |
18 | + assert_equal 'AverageMethodLOC', MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) | |
19 | + end | |
14 | 20 | end | ... | ... |
plugins/mezuro/views/content_viewer/_module_result.rhtml
... | ... | @@ -19,15 +19,15 @@ |
19 | 19 | <% range = metric_result.range %> |
20 | 20 | <% if !range.nil? %> |
21 | 21 | <tr> |
22 | - <td><a href="#" data-show=".<%= metric_result.metric.name.delete("() ")%>"><%= metric_result.metric.name %></a></td> | |
22 | + <td><a href="#" data-show=".<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>"><%= metric_result.metric.name %></a></td> | |
23 | 23 | <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> |
24 | 24 | <td><%= metric_result.weight %></td> |
25 | 25 | <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> |
26 | 26 | </tr> |
27 | - <tr class="<%= metric_result.metric.name.delete("() ")%>" style="display: none;"> | |
27 | + <tr class="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" style="display: none;"> | |
28 | 28 | <td colspan="3"> |
29 | - <div id='historical-<%= metric_result.metric.name.delete("() ") %>'> | |
30 | - <a href="#" show-metric-history="<%= metric_result.metric.name.delete("() ") %>" data-module-name="<%= the_module.name %>" data-metric-name="<%= metric_result.metric.name.delete("() ") %>"> <p style="text-indent: 3em;"> Get Historical Values </p> </a> | |
29 | + <div id='historical-<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>'> | |
30 | + <a href="#" show-metric-history="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" data-module-name="<%= the_module.name %>" data-metric-name="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>"> <p style="text-indent: 3em;"> Get Historical Values </p> </a> | |
31 | 31 | </div> |
32 | 32 | </td> |
33 | 33 | <td align="right"> | ... | ... |