diff options
| author | Zog | 2018-01-29 11:54:47 +0100 |
|---|---|---|
| committer | Zog | 2018-01-31 14:11:35 +0100 |
| commit | 5e79f52c2d9db09f7c1bc94772d9b2a231cabf94 (patch) | |
| tree | 5eb86bbd6eca54d3546f4a858ff710363f64a447 /spec/models | |
| parent | c100b5ae399d3c092801a13c26e8f28ea1a1797f (diff) | |
| download | chouette-core-5e79f52c2d9db09f7c1bc94772d9b2a231cabf94.tar.bz2 | |
Refs #5754; Add a filter on purchase_windows on ReferentialVJs#index
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/chouette/vehicle_journey_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb index 2a88ac3ce..ea30d4e2c 100644 --- a/spec/models/chouette/vehicle_journey_spec.rb +++ b/spec/models/chouette/vehicle_journey_spec.rb @@ -24,6 +24,47 @@ describe Chouette::VehicleJourney, :type => :model do it_behaves_like 'checksum support', :vehicle_journey end + describe '#in_purchase_window' do + let(:start_date){2.month.ago.to_date} + let(:end_date){1.month.ago.to_date} + + subject{Chouette::VehicleJourney.in_purchase_window start_date..end_date} + + let!(:without_purchase_window){ create :vehicle_journey } + let!(:without_matching_purchase_window){ + pw = create :purchase_window, referential: Referential.first, date_ranges: [(end_date+1.day..end_date+2.days)] + pw2 = create :purchase_window, referential: Referential.first, date_ranges: [(end_date+10.day..end_date+20.days)] + create :vehicle_journey, purchase_windows: [pw, pw2] + } + let!(:included_purchase_window){ + pw = create :purchase_window, referential: Referential.first, date_ranges: [(start_date..end_date)] + pw2 = create :purchase_window, referential: Referential.first + create :vehicle_journey, purchase_windows: [pw, pw2] + } + let!(:overlapping_purchase_window){ + pw = create :purchase_window, referential: Referential.first, date_ranges: [(end_date..end_date+1.day)] + pw2 = create :purchase_window, referential: Referential.first + create :vehicle_journey, purchase_windows: [pw, pw2] + } + + + it "should not include VJ with no purchase window" do + expect(subject).to_not include without_purchase_window + end + + it "should not include VJ with no matching purchase window" do + expect(subject).to_not include without_matching_purchase_window + end + + it "should include VJ with included purchase window" do + expect(subject).to include included_purchase_window + end + + it "should include VJ with overlapping_purchase_window purchase window" do + expect(subject).to include overlapping_purchase_window + end + end + describe "vjas_departure_time_must_be_before_next_stop_arrival_time", skip: "Validation currently commented out because it interferes with day offsets" do |
