diff options
| author | Robert | 2018-01-09 18:45:26 +0100 |
|---|---|---|
| committer | Alban Peignier | 2018-01-10 17:47:10 +0100 |
| commit | a7fe8da0bc230ee7f5d3173454fc07b596970d13 (patch) | |
| tree | 9b698c4d1d8c2bc1eecceaeed0f25ce76088392a /spec/models/custom_field_spec.rb | |
| parent | fd553851e9e6c59b998eef8577836a954c4d43f3 (diff) | |
| download | chouette-core-a7fe8da0bc230ee7f5d3173454fc07b596970d13.tar.bz2 | |
Fixes: #5505@2h; Migrations, specs and implementations
- Migration index_resource_type_on_custom_fields
- Specing behavior of custom field's resource (VehicleJourney)
- Migration create json col custom_field_values for resource (VehicleJourney)
- Create accessor methods inside resource (VehicleJourney)
Diffstat (limited to 'spec/models/custom_field_spec.rb')
| -rw-r--r-- | spec/models/custom_field_spec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rb index b93d98187..80873683c 100644 --- a/spec/models/custom_field_spec.rb +++ b/spec/models/custom_field_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe CustomField, type: :model do + let( :vj ){ create :vehicle_journey, custom_field_values: {energy: 99} } context "validates" do it { should validate_uniqueness_of(:name).scoped_to(:resource_type) } @@ -12,6 +13,15 @@ RSpec.describe CustomField, type: :model do it "option's values can be accessed by a key" do expect( custom_field.options['capacity'] ).to eq("0") end + end + + + context "custom fields for a resource" do + let!( :fields ){ (1..2).map{ create :custom_field } } + it { expect(vj.custom_fields).to eq(fields) } + end + context "custom field_values for a resource" do + it { expect(vj.custom_field_value("energy")).to eq(99) } end end |
