aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorTeddy Wing2018-01-30 14:48:01 +0100
committerTeddy Wing2018-01-30 14:51:26 +0100
commit82ecc871b8b9409b09fc89f41ff9d65640e6f8ca (patch)
treea3cc7fdfd970f3c9d1dec5547320e15942870f43 /spec
parent617a54cf63d7f11111b168534d49cdc04a5865d4 (diff)
downloadchouette-core-82ecc871b8b9409b09fc89f41ff9d65640e6f8ca.tar.bz2
VehicleJourney: Allow deletion of associated company
If the state doesn't contain a company, that means it was deleted on the frontend. In that case, the backend code should correctly delete the associated company from the vehicle journey. Refs #5574
Diffstat (limited to 'spec')
-rw-r--r--spec/models/chouette/vehicle_journey_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb
index 2a88ac3ce..21bbc1ba8 100644
--- a/spec/models/chouette/vehicle_journey_spec.rb
+++ b/spec/models/chouette/vehicle_journey_spec.rb
@@ -231,6 +231,14 @@ describe Chouette::VehicleJourney, :type => :model do
expect(vehicle_journey.reload.company_id).to eq state['company']['id']
end
+ it "handles vehicle journey company deletion" do
+ vehicle_journey.update(company: create(:company))
+ state.delete('company')
+ Chouette::VehicleJourney.state_update(route, collection)
+
+ expect(vehicle_journey.reload.company_id).to be_nil
+ end
+
it 'should update vj attributes from state' do
state['published_journey_name'] = 'edited_name'
state['published_journey_identifier'] = 'edited_identifier'