diff options
| author | Zog | 2018-01-12 10:11:51 +0100 | 
|---|---|---|
| committer | Zog | 2018-02-26 10:00:34 +0100 | 
| commit | 3e2ec765db2835be3772a57b4fc045c7c2e0e4ed (patch) | |
| tree | a387ac9dc478699188de13e5fa9df5d685d7d3dd /spec | |
| parent | 9af498376d51dbd505cf6d276a02e7bfb24e9aa5 (diff) | |
| download | chouette-core-3e2ec765db2835be3772a57b4fc045c7c2e0e4ed.tar.bz2 | |
Add a validation mechanism
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/custom_field_spec.rb | 9 | 
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rb index d1c6d803a..54a905116 100644 --- a/spec/models/custom_field_spec.rb +++ b/spec/models/custom_field_spec.rb @@ -44,6 +44,15 @@ RSpec.describe CustomField, type: :model do      it "should cast the value" do        expect(vj.custom_fields[:energy].value).to eq 99      end + +    it "should validate the value" do +      vj = build :vehicle_journey, custom_field_values: {energy: "99"} +      expect(vj.validate).to be_truthy + +      vj = build :vehicle_journey, custom_field_values: {energy: "azerty"} +      expect(vj.validate).to be_falsy +      expect(vj.errors.messages[:"custom_fields.energy"]).to be_present +    end    end    context "with a 'string' field_type" do  | 
