aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZog2017-12-28 09:28:42 +0100
committerAlban Peignier2017-12-28 09:34:15 +0100
commitfee41e6002c1a3c6273225befb7be2f06b6b63f9 (patch)
tree09045a4c6dcef877bad47e0dd05669677c675000
parent64920d79cdaa358bfe89250b2c66a78779bfc837 (diff)
downloadchouette-core-fee41e6002c1a3c6273225befb7be2f06b6b63f9.tar.bz2
Refs #5407; Fix data not being updated in the DB
-rw-r--r--spec/models/chouette/vehicle_journey_spec.rb18
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)