diff options
| -rw-r--r-- | spec/models/chouette/vehicle_journey_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb index d74c0ebee..eb2a31794 100644 --- a/spec/models/chouette/vehicle_journey_spec.rb +++ b/spec/models/chouette/vehicle_journey_spec.rb @@ -77,6 +77,7 @@ describe Chouette::VehicleJourney, :type => :model do vj.slice('objectid', 'published_journey_name', 'journey_pattern_id', 'company_id').tap do |item| item['vehicle_journey_at_stops'] = [] item['time_tables'] = [] + item['purchase_windows'] = [] item['footnotes'] = [] item['purchase_windows'] = [] @@ -161,6 +162,23 @@ describe Chouette::VehicleJourney, :type => :model do expect(vehicle_journey.reload.time_tables).to be_empty end + it 'should update vj purchase_windows association from state' do + 2.times{state['purchase_windows'] << create(:purchase_window, referential: referential).slice('id', 'name', 'objectid', 'color')} + vehicle_journey.update_has_and_belongs_to_many_from_state(state) + + expected = state['purchase_windows'].map{|tt| tt['id']} + actual = vehicle_journey.reload.purchase_windows.map(&:id) + expect(actual).to match_array(expected) + end + + it 'should clear vj purchase_windows association when remove from state' do + vehicle_journey.purchase_windows << create(:purchase_window, referential: referential) + state['purchase_windows'] = [] + vehicle_journey.update_has_and_belongs_to_many_from_state(state) + + expect(vehicle_journey.reload.purchase_windows).to be_empty + end + it 'should update vj footnote association from state' do 2.times{state['footnotes'] << create(:footnote, line: route.line).slice('id', 'code', 'label', 'line_id')} vehicle_journey.update_has_and_belongs_to_many_from_state(state) |
