diff options
| author | Marc Florisson | 2014-08-26 10:52:06 +0200 |
|---|---|---|
| committer | Marc Florisson | 2014-08-26 10:52:06 +0200 |
| commit | e59dfb8339e8576b3085d794a8f705f43f0d9f61 (patch) | |
| tree | b13fc90a420f94b8427a7b33254f060c16869300 /spec/models | |
| parent | d7529f24c340cbe4ec4acd64435faac02b29a3c7 (diff) | |
| download | chouette-core-e59dfb8339e8576b3085d794a8f705f43f0d9f61.tar.bz2 | |
complete vehicle translation. Mantis 26839
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/vehicle_translation_spec.rb | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/spec/models/vehicle_translation_spec.rb b/spec/models/vehicle_translation_spec.rb index 47be9ff3a..bc16f2260 100644 --- a/spec/models/vehicle_translation_spec.rb +++ b/spec/models/vehicle_translation_spec.rb @@ -13,7 +13,32 @@ describe VehicleTranslation do )} subject {Factory.build(:vehicle_translation, :vehicle_journey_id => vehicle_journey.id, - :first_stop_departure_time => "12:00")} + :first_stop_time => "12:00", + :departure_or_arrival => "departure", + :duration => 9, + :count => 2)} + + describe "#first_stop_time=" do + context "when setting invalid value" do + it "should have an error on first_stop_departure_time" do + subject.first_stop_time = "dummy" + subject.valid? + subject.errors[ :first_stop_time].should_not be_nil + end + end + + end + describe "#evaluate_delta" do + it "should return 3600 seconds" do + subject.evaluate_delta( Time.parse( "11:00")).should == 3600.0 + end + end + describe "#first_delta" do + it "should return 3600 seconds" do + subject.should_receive( :first_vjas_time).and_return( Time.parse( "11:00")) + subject.first_delta + end + end describe "#translate" do it "should add new vehicle" do @@ -51,10 +76,11 @@ describe VehicleTranslation do end it "should add vehicle where vehicle_journey_at_stops are translated with #duration" do read_vehicle = Chouette::VehicleJourney.find(vehicle_journey.id) # read from bd, change time values + delta = subject.first_delta subject.translate last_created_vehicle.vehicle_journey_at_stops.each_with_index do |vjas, index| - vjas.departure_time.should == (read_vehicle.vehicle_journey_at_stops[index].departure_time + subject.duration.minutes) - vjas.arrival_time.should == (read_vehicle.vehicle_journey_at_stops[index].arrival_time + subject.duration.minutes) + vjas.departure_time.should == (read_vehicle.vehicle_journey_at_stops[index].departure_time + delta + subject.duration.minutes) + vjas.arrival_time.should == (read_vehicle.vehicle_journey_at_stops[index].arrival_time + delta + subject.duration.minutes) end end end |
