aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcedricnjanga2018-01-04 10:40:26 +0100
committercedricnjanga2018-01-04 10:40:49 +0100
commit28d3edbe08b2e8ff55b1f586b0652086f3beb18c (patch)
tree9e53a774bc330fcccd71104af09053728991a5b1
parentafd3b615aa880145aade35780679bb744df21a47 (diff)
downloadchouette-core-28d3edbe08b2e8ff55b1f586b0652086f3beb18c.tar.bz2
Refs ##5461 Add validation on some Compliance Controls to avoid negative values on dynamic attributes
-rw-r--r--app/models/generic_attribute_control/min_max.rb4
-rw-r--r--app/models/vehicle_journey_control/delta.rb2
-rw-r--r--db/schema.rb2
3 files changed, 4 insertions, 4 deletions
diff --git a/app/models/generic_attribute_control/min_max.rb b/app/models/generic_attribute_control/min_max.rb
index 1c429b9a4..18873b683 100644
--- a/app/models/generic_attribute_control/min_max.rb
+++ b/app/models/generic_attribute_control/min_max.rb
@@ -2,8 +2,8 @@ module GenericAttributeControl
class MinMax < ComplianceControl
store_accessor :control_attributes, :minimum, :maximum, :target
- validates :minimum, numericality: true, allow_nil: true
- validates :maximum, numericality: true, allow_nil: true
+ validates_numericality_of :minimum, allow_nil: true, greater_than_or_equal_to: 0
+ validates_numericality_of :maximum, allow_nil: true, greater_than_or_equal_to: 0
validates :target, presence: true
include MinMaxValuesValidation
diff --git a/app/models/vehicle_journey_control/delta.rb b/app/models/vehicle_journey_control/delta.rb
index 077dd6c4a..f061b9fdd 100644
--- a/app/models/vehicle_journey_control/delta.rb
+++ b/app/models/vehicle_journey_control/delta.rb
@@ -3,7 +3,7 @@ module VehicleJourneyControl
store_accessor :control_attributes, :maximum
- validates :maximum, numericality: true, allow_nil: true
+ validates_numericality_of :maximum, allow_nil: true, greater_than_or_equal_to: 0
def self.default_code; "3-VehicleJourney-3" end
end
diff --git a/db/schema.rb b/db/schema.rb
index 943af87c1..e6fdd9d74 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -403,9 +403,9 @@ ActiveRecord::Schema.define(version: 20171227113809) do
t.string "type"
t.integer "parent_id", limit: 8
t.string "parent_type"
+ t.datetime "notified_parent_at"
t.integer "current_step", default: 0
t.integer "total_steps", default: 0
- t.datetime "notified_parent_at"
t.string "creator"
end