aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorZog2018-01-29 11:54:47 +0100
committercedricnjanga2018-02-06 11:04:59 -0800
commit5e1b7a06a9958580fc18a0a4e33ff66ea6adcdf9 (patch)
treebc05cba6cd5b2b594b5991f7b1d5b58ebdbddff1 /spec
parentbde34143629e19273493fba8ba9e50bcd5f0c547 (diff)
downloadchouette-core-5e1b7a06a9958580fc18a0a4e33ff66ea6adcdf9.tar.bz2
Refs #5754; Add a filter on purchase_windows on ReferentialVJs#index
Diffstat (limited to 'spec')
-rw-r--r--spec/models/chouette/vehicle_journey_spec.rb41
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 21bbc1ba8..06f392d65 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