aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/models/chouette/journey_pattern_spec.rb8
-rw-r--r--spec/models/chouette/vehicle_journey_spec.rb9
2 files changed, 17 insertions, 0 deletions
diff --git a/spec/models/chouette/journey_pattern_spec.rb b/spec/models/chouette/journey_pattern_spec.rb
index 57ee5ab4e..fbc48c95a 100644
--- a/spec/models/chouette/journey_pattern_spec.rb
+++ b/spec/models/chouette/journey_pattern_spec.rb
@@ -6,6 +6,14 @@ describe Chouette::JourneyPattern, :type => :model do
describe 'checksum' do
it_behaves_like 'checksum support'
+
+ context "when a stop_point is updated" do
+ it "should update checksum" do
+ expect do
+ subject.stop_points.first.update position: subject.stop_points.size
+ end.to change{subject.reload.checksum}
+ end
+ end
end
# context 'validate minimum stop_points size' do
diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb
index 8682d59a2..e0d4309d2 100644
--- a/spec/models/chouette/vehicle_journey_spec.rb
+++ b/spec/models/chouette/vehicle_journey_spec.rb
@@ -35,6 +35,15 @@ describe Chouette::VehicleJourney, :type => :model do
expect{create(:vehicle_journey_at_stop, vehicle_journey: vehicle_journey)}.to change{vehicle_journey.checksum}
end
+ it "changes when a stop_point is updated" do
+ vehicle_journey = create(:vehicle_journey)
+ stop_point = vehicle_journey.vehicle_journey_at_stops.first.stop_point
+ expect(stop_point.vehicle_journeys).to include vehicle_journey
+ expect do
+ stop_point.update position: stop_point.route.stop_points.size
+ end.to change{vehicle_journey.reload.checksum}
+ end
+
context "when custom_field_values change" do
let(:vehicle_journey){ create(:vehicle_journey, custom_field_values: {custom_field.code.to_s => former_value}) }
let(:custom_field){ create :custom_field, field_type: :string, code: :energy, name: :energy, resource_type: "VehicleJourney" }