diff options
| author | Zog | 2018-04-06 10:09:10 +0200 |
|---|---|---|
| committer | cedricnjanga | 2018-04-10 13:42:14 -0700 |
| commit | 7f7f93caf090aee755b23b408d5da2374088217b (patch) | |
| tree | 967e5bb385449db3acd3e42762ce68de865ebbf5 /spec | |
| parent | 3ad0c0d06a821d1d5632b64c7c6b51f8cd43c538 (diff) | |
| download | chouette-core-7f7f93caf090aee755b23b408d5da2374088217b.tar.bz2 | |
Refs #6461; Don't initilialize CustomFields when they are not loaded by the model
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/custom_field_spec.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rb index 1dfe6d33c..4c1b65a15 100644 --- a/spec/models/custom_field_spec.rb +++ b/spec/models/custom_field_spec.rb @@ -47,11 +47,14 @@ RSpec.describe CustomField, type: :model do let!(:field){ [create(:custom_field, code: :energy, field_type: 'list', options: {list_values: %w(foo bar baz)})] } let!( :vj ){ create :vehicle_journey, custom_field_values: {energy: "1"} } it "should cast the value" do - p vj.custom_fields expect(vj.custom_fields[:energy].value).to eq 1 expect(vj.custom_fields[:energy].display_value).to eq "bar" end + it "should not break initailizartion if the model does not have the :custom_field_values attribute" do + expect{Chouette::VehicleJourney.where(id: vj.id).select(:id).last}.to_not raise_error(ActiveModel::MissingAttributeError) + end + it "should validate the value" do { "1" => true, |
