Sha256: b0a9cb8af1470070cc848a4063976bd393a2afad2960860ae3627ff2aad9831d

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe Chouette::StopPoint do
  let!(:vehicle_journey) { Factory(:vehicle_journey)}
  subject { Chouette::Route.find( vehicle_journey.route_id).stop_points.first }

  it { should validate_uniqueness_of :objectid }
  it { should validate_presence_of :stop_area }
  it { should validate_presence_of :route }
  
  its(:objectid) { should be_kind_of(Chouette::ObjectId) }

  describe "#destroy" do
    before(:each) do
      @vehicle = Factory(:vehicle_journey)
      @stop_point = Chouette::Route.find( @vehicle.route_id).stop_points.first
    end
    def vjas_stop_point_ids( vehicle_id)
      Chouette::VehicleJourney.find( vehicle_id).vehicle_journey_at_stops.map(&:stop_point_id)
    end
    def jpsp_stop_point_ids( journey_id)
      Chouette::JourneyPattern.find( journey_id).stop_points.map(&:id)
    end
    it "should remove dependent vehicle_journey_at_stop" do
      vjas_stop_point_ids(@vehicle.id).should include(@stop_point.id)

      @stop_point.destroy

      vjas_stop_point_ids(@vehicle.id).should_not include(@stop_point.id)
    end
    it "should remove dependent journey_pattern_stop_point" do
      jpsp_stop_point_ids(@vehicle.journey_pattern_id).should include(@stop_point.id)

      @stop_point.destroy

      jpsp_stop_point_ids(@vehicle.journey_pattern_id).should_not include(@stop_point.id)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ninoxe-0.1.6 spec/models/chouette/stop_point_spec.rb
ninoxe-0.1.3 spec/models/chouette/stop_point_spec.rb
ninoxe-0.1.2 spec/models/chouette/stop_point_spec.rb