diff --git a/app/helpers/kalibro_ranges_helper.rb b/app/helpers/kalibro_ranges_helper.rb
index df3b9ce..721f4a5 100644
--- a/app/helpers/kalibro_ranges_helper.rb
+++ b/app/helpers/kalibro_ranges_helper.rb
@@ -2,4 +2,12 @@ module KalibroRangesHelper
def readings_options(readings)
readings.map { |reading| [reading.label, reading.id] }
end
+
+ # FIXME: this is a workaround while kalibro_client does not handle Infinity text instead of INF
+ # see: https://github.com/mezuro/kalibro_client/issues/73
+ def format_boundary(value)
+ return "INF" if value == Float::INFINITY
+ return "-INF" if value == -Float::INFINITY
+ value
+ end
end
diff --git a/app/views/metric_configurations/_ranges.html.erb b/app/views/metric_configurations/_ranges.html.erb
index f6e9098..30dc565 100644
--- a/app/views/metric_configurations/_ranges.html.erb
+++ b/app/views/metric_configurations/_ranges.html.erb
@@ -5,8 +5,8 @@
<%= kalibro_range.label %>
-
<%= kalibro_range.beginning %> |
- <%= kalibro_range.end %> |
+ <%= format_boundary(kalibro_range.beginning) %> |
+ <%= format_boundary(kalibro_range.end) %> |
<% if kalibro_configuration_owner? @metric_configuration.kalibro_configuration_id %>
<%= link_to t('edit'), edit_kalibro_configuration_metric_configuration_kalibro_range_path(
diff --git a/spec/helpers/kalibro_ranges_helper_spec.rb b/spec/helpers/kalibro_ranges_helper_spec.rb
index 96037a4..d6855e1 100644
--- a/spec/helpers/kalibro_ranges_helper_spec.rb
+++ b/spec/helpers/kalibro_ranges_helper_spec.rb
@@ -7,5 +7,31 @@ describe KalibroRangesHelper, :type => :helper do
expect(helper.readings_options([reading])).to eq [[reading.label, reading.id]]
end
end
+
+ describe 'format_boundary' do
+ context 'with a finite value' do
+ let(:value) { 10 }
+
+ it 'is expected to return the value itself' do
+ expect(helper.format_boundary(value)).to eq(value)
+ end
+ end
+
+ context 'with positive infinity value' do
+ let(:value) { Float::INFINITY }
+
+ it 'is expected to return the string "INF"' do
+ expect(helper.format_boundary(value)).to eq("INF")
+ end
+ end
+
+ context 'with negative infinity value' do
+ let(:value) { -Float::INFINITY }
+
+ it 'is expected to return the string "-INF"' do
+ expect(helper.format_boundary(value)).to eq("-INF")
+ end
+ end
+ end
end
--
libgit2 0.21.2 |