diff options
| author | Xinhui | 2017-04-13 16:03:33 +0200 |
|---|---|---|
| committer | Xinhui | 2017-04-13 16:03:38 +0200 |
| commit | dc692f9eb2cfe7181e561065c8fea2e4b19d1504 (patch) | |
| tree | aead5da3338dfc3c52c759b13232896bca082fb9 /spec | |
| parent | 147cb5733741aff77b0cf191b18d56bc235a6e3b (diff) | |
| download | chouette-core-dc692f9eb2cfe7181e561065c8fea2e4b19d1504.tar.bz2 | |
Vehicle journeys clear time_tableas association when remove from state
Refs #3121
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/chouette/vehicle_journey_spec.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb index 0208ac69b..0de74c0cc 100644 --- a/spec/models/chouette/vehicle_journey_spec.rb +++ b/spec/models/chouette/vehicle_journey_spec.rb @@ -83,15 +83,22 @@ describe Chouette::VehicleJourney, :type => :model do expect(vehicle_journey.reload.journey_pattern_id).to eq state['journey_pattern']['id'] end - it 'should update vj time_tables association' do + it 'should update vj time_tables association from state' do state['time_tables'] = [] 2.times{state['time_tables'] << create(:time_table).attributes.slice('id', 'comment', 'objectid')} - Chouette::VehicleJourney.state_update(route, collection) + vehicle_journey.update_time_tables_from_state(state) expect(state['errors']).to be_nil expect(vehicle_journey.reload.time_tables.map(&:id)).to eq(state['time_tables'].map{|tt| tt['id']}) end + it 'should clear vj time_tableas association when remove from state' do + vehicle_journey.time_tables << create(:time_table) + state['time_tables'] = [] + vehicle_journey.update_time_tables_from_state(state) + expect(vehicle_journey.reload.time_tables).to be_empty + end + it 'should update vj company' do state['company'] = create(:company).attributes.slice('id', 'name', 'objectid') Chouette::VehicleJourney.state_update(route, collection) |
