Commit 771bfe3fbe869b2316fcf03b497aa27f60d69017
Committed by
Diego Camarinha
1 parent
0532543b
Exists in
master
and in
8 other branches
[Mezuro] Fixed aggregated value.
Showing
3 changed files
with
11 additions
and
7 deletions
Show diff stats
plugins/mezuro/lib/kalibro/metric_result.rb
... | ... | @@ -4,9 +4,9 @@ class Kalibro::MetricResult < Kalibro::Model |
4 | 4 | |
5 | 5 | def initialize(attributes={}) |
6 | 6 | value = attributes[:value] |
7 | - value == "NaN" ? @value = attributes[:agreggated_value] : @value = value.to_f | |
7 | + @value = (value == "NaN") ? attributes[:aggregated_value].to_f : value.to_f | |
8 | 8 | attributes.each do |field, value| |
9 | - if field!="value" and field!="agreggated_value" and self.class.is_valid?(field) | |
9 | + if field!= :value and field!= :aggregated_value and self.class.is_valid?(field) | |
10 | 10 | send("#{field}=", value) |
11 | 11 | end |
12 | 12 | end |
... | ... | @@ -25,10 +25,6 @@ class Kalibro::MetricResult < Kalibro::Model |
25 | 25 | configuration |
26 | 26 | end |
27 | 27 | |
28 | - def value=(value) | |
29 | - @value = value.to_f | |
30 | - end | |
31 | - | |
32 | 28 | def error=(value) |
33 | 29 | @error = Kalibro::Throwable.to_object value |
34 | 30 | end | ... | ... |
plugins/mezuro/test/unit/kalibro/metric_result_test.rb
... | ... | @@ -18,6 +18,14 @@ class MetricResultTest < ActiveSupport::TestCase |
18 | 18 | assert_equal @native_hash[:value].to_f, metric_result.value |
19 | 19 | end |
20 | 20 | |
21 | + should 'create metric result with aggregated value from hash' do | |
22 | + hash = @native_hash | |
23 | + hash[:aggregated_value] = "2.0" | |
24 | + hash[:value] = "NaN" | |
25 | + metric_result = Kalibro::MetricResult.new(hash) | |
26 | + assert_equal @native_hash[:aggregated_value].to_f, metric_result.value | |
27 | + end | |
28 | + | |
21 | 29 | should 'convert metric result to hash' do |
22 | 30 | assert_equal @native_hash, @result.to_hash |
23 | 31 | end | ... | ... |
plugins/mezuro/views/mezuro_plugin_module_result/_metric_results.rhtml
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> |
19 | 19 | <td><%= metric_configuration_snapshot.weight %></td> |
20 | 20 | <% range_snapshots.each do |range_snapshot| %> |
21 | - <% if range_snapshot.beginning.to_f <= metric_result.value and range_snapshot.end.to_f > metric_result.value %> | |
21 | + <% if range_snapshot.beginning <= metric_result.value and range_snapshot.end > metric_result.value %> | |
22 | 22 | <td style="background-color: #<%= range_snapshot.color %>"> |
23 | 23 | <span title="<%= range_snapshot.comments %>" > |
24 | 24 | <%= range_snapshot.label %> | ... | ... |