Commit f5693a835caa3e9b49c85a22502f0994002fd962
1 parent
ac3f9b5f
Exists in
colab
and in
4 other branches
Fixes range overlapping checking
All the values are converted to Float Signed off by: Diego Araújo <diegoamc90@gmail.com>
Showing
2 changed files
with
25 additions
and
0 deletions
Show diff stats
app/models/validators/range_overlapping_validator.rb
| @@ -21,6 +21,7 @@ class RangeOverlappingValidator < ActiveModel::Validator | @@ -21,6 +21,7 @@ class RangeOverlappingValidator < ActiveModel::Validator | ||
| 21 | def to_float(value) | 21 | def to_float(value) |
| 22 | return 1.0/0 if value=="INF" | 22 | return 1.0/0 if value=="INF" |
| 23 | return -1.0/0 if value=="-INF" | 23 | return -1.0/0 if value=="-INF" |
| 24 | + return value.to_f if value.is_a?(String) | ||
| 24 | return value | 25 | return value |
| 25 | end | 26 | end |
| 26 | end | 27 | end |
features/mezuro_range/create.feature
| @@ -158,4 +158,28 @@ Feature: Create range | @@ -158,4 +158,28 @@ Feature: Create range | ||
| 158 | When I press the Save button | 158 | When I press the Save button |
| 159 | Then I should be at metric configuration sample page | 159 | Then I should be at metric configuration sample page |
| 160 | And I should see "-INF" | 160 | And I should see "-INF" |
| 161 | + And I should see "INF" | ||
| 162 | + | ||
| 163 | + @kalibro_restart @javascript | ||
| 164 | + Scenario: Two valid ranges (one with INF) | ||
| 165 | + Given I am a regular user | ||
| 166 | + And I am signed in | ||
| 167 | + And I own a sample configuration | ||
| 168 | + And I own a sample reading group | ||
| 169 | + And I have a sample metric configuration within the given mezuro configuration | ||
| 170 | + And I have a sample reading within the sample reading group labeled "My Reading" | ||
| 171 | + And I am at the New Range page | ||
| 172 | + And I fill the Beginning field with "2" | ||
| 173 | + And I fill the End field with "666" | ||
| 174 | + And I fill the Comments field with "My Comment" | ||
| 175 | + And I set the select field "Reading" as "My Reading" | ||
| 176 | + And I press the Save button | ||
| 177 | + And I am at the New Range page | ||
| 178 | + And I fill the Beginning field with "666" | ||
| 179 | + And I click the ∞ link | ||
| 180 | + And I fill the Comments field with "My Comment" | ||
| 181 | + And I set the select field "Reading" as "My Reading" | ||
| 182 | + When I press the Save button | ||
| 183 | + Then I should be at metric configuration sample page | ||
| 184 | + And I should see "666" | ||
| 161 | And I should see "INF" | 185 | And I should see "INF" |
| 162 | \ No newline at end of file | 186 | \ No newline at end of file |