diff options
| author | Zog | 2018-01-10 16:39:08 +0100 | 
|---|---|---|
| committer | Zog | 2018-01-10 16:56:53 +0100 | 
| commit | 5c3abf69c50f00e0caab1517be2beccca10e635b (patch) | |
| tree | 1bc56181320dcad4b091ca6a57e5ef49153881fa /spec/models/chouette | |
| parent | 71614a19f62ed3f9ca3068e149dcd60471bef27d (diff) | |
| download | chouette-core-5c3abf69c50f00e0caab1517be2beccca10e635b.tar.bz2 | |
Refs #5535 @0.25h; Adds a `full_schedule?` on `JourneyPattern`
To know if all the costs between the stops of the pattern are set.
Diffstat (limited to 'spec/models/chouette')
| -rw-r--r-- | spec/models/chouette/journey_pattern_spec.rb | 38 | 
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/chouette/journey_pattern_spec.rb b/spec/models/chouette/journey_pattern_spec.rb index 077c85e85..b5eb9004c 100644 --- a/spec/models/chouette/journey_pattern_spec.rb +++ b/spec/models/chouette/journey_pattern_spec.rb @@ -32,6 +32,44 @@ describe Chouette::JourneyPattern, :type => :model do    #   end    # end +  describe "full_schedule?" do +    let(:journey_pattern) { create :journey_pattern } +    subject{ journey_pattern.full_schedule? } +    context "when no time is set" do +      it { should be_falsy } +    end + +    context "when the costs are incomplete" do +      context "with a missing distance" do +        before(:each){ +          journey_pattern.costs = generate_journey_pattern_costs(->(i){i == 1 ? nil : 10}, 10) +        } +        it { should be_falsy } +      end + +      context "with a missing time" do +        before(:each){ +          journey_pattern.costs = generate_journey_pattern_costs(10, ->(i){i == 1 ? nil : 10}) +        } +        it { should be_falsy } +      end +    end + +    context "with a zeroed cost" do +      before(:each){ +        journey_pattern.costs = generate_journey_pattern_costs(->(i){i == 1 ? 0 : 10}, 10) +      } +      it { should be_falsy } +    end + +    context "when all the times are set" do +      before(:each){ +        journey_pattern.costs = generate_journey_pattern_costs(10, 10) +      } +      it { should be_truthy } +    end +  end +    describe "state_update" do      def journey_pattern_to_state jp        jp.attributes.slice('name', 'published_name', 'registration_number').tap do |item|  | 
