ninoxe 1.1.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -12
- data/app/models/chouette/access_link.rb +52 -51
- data/app/models/chouette/access_point.rb +7 -7
- data/app/models/chouette/active_record.rb +28 -28
- data/app/models/chouette/company.rb +3 -3
- data/app/models/chouette/connection_link.rb +3 -3
- data/app/models/chouette/footnote.rb +1 -1
- data/app/models/chouette/group_of_line.rb +2 -2
- data/app/models/chouette/journey_pattern.rb +7 -3
- data/app/models/chouette/line.rb +11 -9
- data/app/models/chouette/network.rb +2 -2
- data/app/models/chouette/pt_link.rb +1 -1
- data/app/models/chouette/route.rb +9 -10
- data/app/models/chouette/stop_area.rb +8 -8
- data/app/models/chouette/stop_point.rb +3 -3
- data/app/models/chouette/time_table.rb +25 -122
- data/app/models/chouette/time_table_date.rb +1 -1
- data/app/models/chouette/time_table_period.rb +1 -1
- data/app/models/chouette/vehicle_journey.rb +82 -77
- data/app/models/chouette/vehicle_journey_at_stop.rb +1 -1
- data/config/database.yml +16 -8
- data/config/database.yml.travis +15 -6
- data/db/migrate/20150526075108_add_foreign_key_to_routes.rb +28 -0
- data/lib/ninoxe/engine.rb +4 -0
- data/lib/ninoxe/version.rb +1 -1
- data/lib/ninoxe.rb +3 -0
- data/spec/dummy/README.rdoc +15 -248
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/{mailers/.gitkeep → assets/images/.keep} +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +3 -5
- data/spec/dummy/app/assets/stylesheets/application.css +1 -1
- data/spec/dummy/app/controllers/application_controller.rb +3 -1
- data/spec/dummy/app/{models/.gitkeep → controllers/concerns/.keep} +0 -0
- data/spec/dummy/{lib/assets/.gitkeep → app/mailers/.keep} +0 -0
- data/spec/dummy/{log/.gitkeep → app/models/.keep} +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +8 -36
- data/spec/dummy/config/boot.rb +4 -9
- data/spec/dummy/config/database.yml +16 -8
- data/spec/dummy/config/environment.rb +2 -4
- data/spec/dummy/config/environments/development.rb +11 -19
- data/spec/dummy/config/environments/production.rb +41 -28
- data/spec/dummy/config/environments/test.rb +13 -14
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +6 -5
- data/spec/dummy/config/initializers/secret_token.rb +7 -2
- data/spec/dummy/config/initializers/session_store.rb +1 -6
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/spec/dummy/config/locales/en.yml +20 -2
- data/spec/dummy/config/locales/fr.yml +23 -0
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/db/schema.rb +147 -143
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +43 -11
- data/spec/dummy/public/422.html +43 -11
- data/spec/dummy/public/500.html +43 -11
- data/spec/dummy/script/rails +1 -1
- data/spec/factories/chouette_access_links.rb +13 -0
- data/spec/factories/chouette_access_points.rb +12 -0
- data/spec/factories/chouette_companies.rb +9 -0
- data/spec/factories/chouette_connection_links.rb +13 -0
- data/spec/factories/chouette_footnotes.rb +10 -0
- data/spec/factories/chouette_group_of_lines.rb +9 -0
- data/spec/factories/chouette_journey_pattern.rb +40 -0
- data/spec/factories/chouette_lines.rb +44 -0
- data/spec/factories/chouette_networks.rb +9 -0
- data/spec/factories/chouette_routes.rb +26 -0
- data/spec/factories/chouette_stop_areas.rb +12 -0
- data/spec/factories/chouette_stop_points.rb +10 -0
- data/spec/factories/chouette_time_table.rb +37 -0
- data/spec/factories/chouette_vehicle_journey.rb +66 -0
- data/spec/factories/chouette_vehicle_journey_at_stop.rb +8 -0
- data/spec/models/chouette/access_link_spec.rb +17 -13
- data/spec/models/chouette/access_point_spec.rb +106 -103
- data/spec/models/chouette/active_record_spec.rb +57 -57
- data/spec/models/chouette/area_type_spec.rb +8 -8
- data/spec/models/chouette/company_spec.rb +18 -18
- data/spec/models/chouette/connection_link_spec.rb +19 -15
- data/spec/models/chouette/direction_spec.rb +8 -8
- data/spec/models/chouette/exporter_spec.rb +4 -4
- data/spec/models/chouette/file_validator_spec.rb +4 -4
- data/spec/models/chouette/footnote_spec.rb +1 -1
- data/spec/models/chouette/group_of_line_spec.rb +11 -11
- data/spec/models/chouette/journey_pattern_spec.rb +16 -14
- data/spec/models/chouette/line_spec.rb +36 -32
- data/spec/models/chouette/loader_spec.rb +9 -9
- data/spec/models/chouette/network_spec.rb +9 -9
- data/spec/models/chouette/object_id_spec.rb +31 -28
- data/spec/models/chouette/route_spec.rb +51 -47
- data/spec/models/chouette/stop_area_spec.rb +191 -188
- data/spec/models/chouette/stop_point_spec.rb +13 -10
- data/spec/models/chouette/time_table_period_spec.rb +18 -18
- data/spec/models/chouette/time_table_spec.rb +303 -255
- data/spec/models/chouette/transport_mode_spec.rb +10 -10
- data/spec/models/chouette/trident_active_record_spec.rb +17 -17
- data/spec/models/chouette/vehicle_journey_at_stop_spec.rb +13 -12
- data/spec/models/chouette/vehicle_journey_spec.rb +46 -46
- data/spec/presenters/chouette/geometry/line_presenter_spec.rb +2 -2
- data/spec/spec_helper.rb +22 -9
- metadata +102 -87
- data/config/database.yml.ci +0 -14
- data/lib/factories/chouette_access_links.rb +0 -11
- data/lib/factories/chouette_access_points.rb +0 -8
- data/lib/factories/chouette_companies.rb +0 -5
- data/lib/factories/chouette_connection_links.rb +0 -11
- data/lib/factories/chouette_footnotes.rb +0 -6
- data/lib/factories/chouette_group_of_lines.rb +0 -5
- data/lib/factories/chouette_journey_pattern.rb +0 -32
- data/lib/factories/chouette_lines.rb +0 -31
- data/lib/factories/chouette_networks.rb +0 -5
- data/lib/factories/chouette_routes.rb +0 -20
- data/lib/factories/chouette_stop_areas.rb +0 -8
- data/lib/factories/chouette_stop_points.rb +0 -7
- data/lib/factories/chouette_time_table.rb +0 -23
- data/lib/factories/chouette_vehicle_journey.rb +0 -51
- data/lib/factories/chouette_vehicle_journey_at_stop.rb +0 -5
- data/spec/dummy/config/initializers/active_record.rb +0 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chouette::ObjectId do
|
3
|
+
describe Chouette::ObjectId, :type => :model do
|
4
4
|
|
5
5
|
def objectid(value = "abc:StopArea:abc123")
|
6
6
|
Chouette::ObjectId.new value
|
@@ -12,10 +12,17 @@ describe Chouette::ObjectId do
|
|
12
12
|
|
13
13
|
subject { objectid("abc") }
|
14
14
|
|
15
|
-
it {
|
15
|
+
it { is_expected.not_to be_valid }
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
describe '#parts' do
|
18
|
+
subject { super().parts }
|
19
|
+
it { is_expected.to be_nil }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#system_id' do
|
23
|
+
subject { super().system_id }
|
24
|
+
it { is_expected.to be_nil }
|
25
|
+
end
|
19
26
|
|
20
27
|
end
|
21
28
|
|
@@ -23,7 +30,7 @@ describe Chouette::ObjectId do
|
|
23
30
|
|
24
31
|
subject { objectid("abc:Line:Aze toto") }
|
25
32
|
|
26
|
-
it {
|
33
|
+
it { is_expected.not_to be_valid }
|
27
34
|
|
28
35
|
|
29
36
|
end
|
@@ -32,7 +39,7 @@ describe Chouette::ObjectId do
|
|
32
39
|
|
33
40
|
subject { objectid("ae abc:Line:Aze") }
|
34
41
|
|
35
|
-
it {
|
42
|
+
it { is_expected.not_to be_valid }
|
36
43
|
|
37
44
|
|
38
45
|
end
|
@@ -41,7 +48,7 @@ describe Chouette::ObjectId do
|
|
41
48
|
|
42
49
|
subject { objectid("aeabc:Li ne:Aze") }
|
43
50
|
|
44
|
-
it {
|
51
|
+
it { is_expected.not_to be_valid }
|
45
52
|
|
46
53
|
|
47
54
|
end
|
@@ -50,33 +57,33 @@ describe Chouette::ObjectId do
|
|
50
57
|
|
51
58
|
subject { objectid("Abc_+19:Line:Abc") }
|
52
59
|
|
53
|
-
it {
|
60
|
+
it { is_expected.not_to be_valid }
|
54
61
|
end
|
55
62
|
|
56
63
|
context "when invalid in middle part" do
|
57
64
|
|
58
65
|
subject { objectid("Abc_19:Li56ne:Abc") }
|
59
66
|
|
60
|
-
it {
|
67
|
+
it { is_expected.not_to be_valid }
|
61
68
|
end
|
62
69
|
|
63
70
|
context "when invalid in last part" do
|
64
71
|
|
65
72
|
subject { objectid("Abc_19:Line:Ab+c") }
|
66
73
|
|
67
|
-
it {
|
74
|
+
it { is_expected.not_to be_valid }
|
68
75
|
end
|
69
76
|
context "when valid" do
|
70
77
|
|
71
78
|
subject { objectid("Abc_19:Line:Abc_12-") }
|
72
79
|
|
73
|
-
it {
|
80
|
+
it { is_expected.to be_valid }
|
74
81
|
end
|
75
82
|
|
76
83
|
describe "#parts" do
|
77
84
|
|
78
85
|
it "should be the 3 parts of the ObjectId" do
|
79
|
-
objectid("abc:StopArea:abc123").parts.
|
86
|
+
expect(objectid("abc:StopArea:abc123").parts).to eq(%w{abc StopArea abc123})
|
80
87
|
end
|
81
88
|
|
82
89
|
end
|
@@ -84,7 +91,7 @@ describe Chouette::ObjectId do
|
|
84
91
|
describe "#system_id" do
|
85
92
|
|
86
93
|
it "should be the first ObjectId parts" do
|
87
|
-
objectid("first:second:third").system_id.
|
94
|
+
expect(objectid("first:second:third").system_id).to eq("first")
|
88
95
|
end
|
89
96
|
|
90
97
|
end
|
@@ -92,7 +99,7 @@ describe Chouette::ObjectId do
|
|
92
99
|
describe "#object_type" do
|
93
100
|
|
94
101
|
it "should be the second ObjectId parts" do
|
95
|
-
objectid("first:second:third").object_type.
|
102
|
+
expect(objectid("first:second:third").object_type).to eq("second")
|
96
103
|
end
|
97
104
|
|
98
105
|
end
|
@@ -100,14 +107,14 @@ describe Chouette::ObjectId do
|
|
100
107
|
describe "#local_id" do
|
101
108
|
|
102
109
|
it "should be the third ObjectId parts" do
|
103
|
-
objectid("first:second:third").local_id.
|
110
|
+
expect(objectid("first:second:third").local_id).to eq("third")
|
104
111
|
end
|
105
112
|
|
106
113
|
end
|
107
114
|
|
108
115
|
it "should be valid when parts are found" do
|
109
|
-
subject.
|
110
|
-
subject.
|
116
|
+
allow(subject).to receive_messages :parts => "dummy"
|
117
|
+
expect(subject).to be_valid
|
111
118
|
end
|
112
119
|
|
113
120
|
describe ".create" do
|
@@ -117,27 +124,23 @@ describe Chouette::ObjectId do
|
|
117
124
|
let(:given_local_id) { "localId" }
|
118
125
|
|
119
126
|
subject { Chouette::ObjectId.create(given_system_id, given_object_type, given_local_id) }
|
120
|
-
|
121
|
-
RSpec::Matchers.define :return_an_objectid_with_given do |attribute|
|
122
|
-
match do |actual|
|
123
|
-
actual.send(attribute).should == send("given_#{attribute}")
|
124
|
-
end
|
125
|
-
end
|
126
127
|
|
127
|
-
it
|
128
|
-
|
129
|
-
|
128
|
+
it "should return ObjectId attributes" do
|
129
|
+
expect(subject.send(:system_id)).to eq(given_system_id)
|
130
|
+
expect(subject.send(:object_type)).to eq(given_object_type)
|
131
|
+
expect(subject.send(:local_id)).to eq(given_local_id)
|
132
|
+
end
|
130
133
|
|
131
134
|
end
|
132
135
|
|
133
136
|
describe ".new" do
|
134
137
|
|
135
138
|
it "should return an existing ObjectId" do
|
136
|
-
Chouette::ObjectId.new(objectid).
|
139
|
+
expect(Chouette::ObjectId.new(objectid)).to eq(objectid)
|
137
140
|
end
|
138
141
|
|
139
142
|
it "should create an empty ObjectId with nil" do
|
140
|
-
Chouette::ObjectId.new(nil).
|
143
|
+
expect(Chouette::ObjectId.new(nil)).to be_empty
|
141
144
|
end
|
142
145
|
|
143
146
|
end
|
@@ -1,15 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chouette::Route do
|
4
|
-
subject {
|
3
|
+
describe Chouette::Route, :type => :model do
|
4
|
+
subject { create(:route) }
|
5
5
|
|
6
|
-
it {
|
7
|
-
its(:objectid) { should be_kind_of(Chouette::ObjectId) }
|
6
|
+
it { is_expected.to validate_uniqueness_of :objectid }
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
describe '#objectid' do
|
9
|
+
subject { super().objectid }
|
10
|
+
it { is_expected.to be_kind_of(Chouette::ObjectId) }
|
11
|
+
end
|
12
|
+
|
13
|
+
#it { is_expected.to validate_presence_of :name }
|
14
|
+
it { is_expected.to validate_presence_of :line }
|
15
|
+
#it { is_expected.to validate_presence_of :wayback_code }
|
16
|
+
#it { is_expected.to validate_presence_of :direction_code }
|
13
17
|
|
14
18
|
context "reordering methods" do
|
15
19
|
let( :bad_stop_point_ids){subject.stop_points.map { |sp| sp.id + 1}}
|
@@ -19,7 +23,7 @@ describe Chouette::Route do
|
|
19
23
|
describe "#reorder!" do
|
20
24
|
context "invalid stop_point_ids" do
|
21
25
|
let( :new_stop_point_ids) { bad_stop_point_ids}
|
22
|
-
it { subject.reorder!( new_stop_point_ids).
|
26
|
+
it { expect(subject.reorder!( new_stop_point_ids)).to be_falsey}
|
23
27
|
end
|
24
28
|
|
25
29
|
context "swaped last and first stop_point_ids" do
|
@@ -28,13 +32,13 @@ describe Chouette::Route do
|
|
28
32
|
let!( :old_stop_area_ids) { subject.stop_areas.map(&:id) }
|
29
33
|
|
30
34
|
it "should keep stop_point_ids order unchanged" do
|
31
|
-
subject.reorder!( new_stop_point_ids).
|
32
|
-
subject.stop_points.map(&:id).
|
35
|
+
expect(subject.reorder!( new_stop_point_ids)).to be_truthy
|
36
|
+
expect(subject.stop_points.map(&:id)).to eq( old_stop_point_ids)
|
33
37
|
end
|
34
38
|
it "should have changed stop_area_ids order" do
|
35
|
-
subject.reorder!( new_stop_point_ids).
|
39
|
+
expect(subject.reorder!( new_stop_point_ids)).to be_truthy
|
36
40
|
subject.reload
|
37
|
-
subject.stop_areas.map(&:id).
|
41
|
+
expect(subject.stop_areas.map(&:id)).to eq( [old_stop_area_ids.last] + old_stop_area_ids[1..-2] + [old_stop_area_ids.first])
|
38
42
|
end
|
39
43
|
end
|
40
44
|
end
|
@@ -42,29 +46,29 @@ describe Chouette::Route do
|
|
42
46
|
describe "#stop_point_permutation?" do
|
43
47
|
context "invalid stop_point_ids" do
|
44
48
|
let( :new_stop_point_ids) { bad_stop_point_ids}
|
45
|
-
it {
|
49
|
+
it { is_expected.not_to be_stop_point_permutation( new_stop_point_ids)}
|
46
50
|
end
|
47
51
|
context "unchanged stop_point_ids" do
|
48
52
|
let( :new_stop_point_ids) { ident}
|
49
|
-
it {
|
53
|
+
it { is_expected.to be_stop_point_permutation( new_stop_point_ids)}
|
50
54
|
end
|
51
55
|
context "swaped last and first stop_point_ids" do
|
52
56
|
let( :new_stop_point_ids) { first_last_swap}
|
53
|
-
it {
|
57
|
+
it { is_expected.to be_stop_point_permutation( new_stop_point_ids)}
|
54
58
|
end
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
58
62
|
describe "#stop_points_attributes=" do
|
59
|
-
let( :journey_pattern) {
|
60
|
-
let( :vehicle_journey) {
|
63
|
+
let( :journey_pattern) { create( :journey_pattern, :route => subject )}
|
64
|
+
let( :vehicle_journey) { create( :vehicle_journey, :journey_pattern => journey_pattern)}
|
61
65
|
def subject_stop_points_attributes
|
62
66
|
{}.tap do |hash|
|
63
67
|
subject.stop_points.each_with_index { |sp,index| hash[ index.to_s ] = sp.attributes }
|
64
68
|
end
|
65
69
|
end
|
66
70
|
context "route having swapped a new stop" do
|
67
|
-
let( :new_stop_point ){
|
71
|
+
let( :new_stop_point ){build( :stop_point, :route => subject)}
|
68
72
|
def added_stop_hash
|
69
73
|
subject_stop_points_attributes.tap do |h|
|
70
74
|
h["4"] = new_stop_point.attributes.merge( "position" => "4", "_destroy" => "" )
|
@@ -74,15 +78,15 @@ describe Chouette::Route do
|
|
74
78
|
|
75
79
|
it "should have added stop_point in route" do
|
76
80
|
subject.update_attributes( :stop_points_attributes => added_stop_hash)
|
77
|
-
Chouette::Route.find( subject.id ).stop_points.size.
|
81
|
+
expect(Chouette::Route.find( subject.id ).stop_points.size).to eq(new_route_size)
|
78
82
|
end
|
79
83
|
it "should have added stop_point in route's journey pattern" do
|
80
84
|
subject.update_attributes( :stop_points_attributes => added_stop_hash)
|
81
|
-
Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.size.
|
85
|
+
expect(Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.size).to eq(new_route_size)
|
82
86
|
end
|
83
87
|
it "should have added stop_point in route's vehicle journey at stop" do
|
84
88
|
subject.update_attributes( :stop_points_attributes => added_stop_hash)
|
85
|
-
Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.size.
|
89
|
+
expect(Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.size).to eq(new_route_size)
|
86
90
|
end
|
87
91
|
end
|
88
92
|
context "route having swapped stop" do
|
@@ -92,19 +96,19 @@ describe Chouette::Route do
|
|
92
96
|
h[ "3" ][ "position" ] = "1"
|
93
97
|
end
|
94
98
|
end
|
95
|
-
let!( :new_stop_id_list ){ subject.stop_points.map(&:id).tap {|array| array.insert( 1, array.delete_at(3)); array.insert( 3, array.delete_at(2) )}
|
99
|
+
let!( :new_stop_id_list ){ subject.stop_points.map(&:id).tap {|array| array.insert( 1, array.delete_at(3)); array.insert( 3, array.delete_at(2) )} }
|
96
100
|
|
97
101
|
it "should have swap stop_points from route" do
|
98
102
|
subject.update_attributes( :stop_points_attributes => swapped_stop_hash)
|
99
|
-
Chouette::Route.find( subject.id ).stop_points.map(&:id)
|
103
|
+
expect(Chouette::Route.find( subject.id ).stop_points.map(&:id)).to eq(new_stop_id_list)
|
100
104
|
end
|
101
105
|
it "should have swap stop_points from route's journey pattern" do
|
102
106
|
subject.update_attributes( :stop_points_attributes => swapped_stop_hash)
|
103
|
-
Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.map(&:id)
|
107
|
+
expect(Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.map(&:id)).to eq(new_stop_id_list)
|
104
108
|
end
|
105
109
|
it "should have swap stop_points from route's vehicle journey at stop" do
|
106
110
|
subject.update_attributes( :stop_points_attributes => swapped_stop_hash)
|
107
|
-
Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.map(&:stop_point_id)
|
111
|
+
expect(Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.map(&:stop_point_id)).to match_array(new_stop_id_list)
|
108
112
|
end
|
109
113
|
end
|
110
114
|
context "route having a deleted stop" do
|
@@ -113,19 +117,19 @@ describe Chouette::Route do
|
|
113
117
|
h[ "1" ][ "_destroy" ] = "1"
|
114
118
|
end
|
115
119
|
end
|
116
|
-
let!( :new_stop_id_list ){ subject.stop_points.map(&:id).tap {|array| array.delete_at(1) }
|
120
|
+
let!( :new_stop_id_list ){ subject.stop_points.map(&:id).tap {|array| array.delete_at(1) } }
|
117
121
|
|
118
122
|
it "should ignore deleted stop_point from route" do
|
119
123
|
subject.update_attributes( :stop_points_attributes => removed_stop_hash)
|
120
|
-
Chouette::Route.find( subject.id ).stop_points.map(&:id)
|
124
|
+
expect(Chouette::Route.find( subject.id ).stop_points.map(&:id)).to eq(new_stop_id_list)
|
121
125
|
end
|
122
126
|
it "should ignore deleted stop_point from route's journey pattern" do
|
123
127
|
subject.update_attributes( :stop_points_attributes => removed_stop_hash)
|
124
|
-
Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.map(&:id)
|
128
|
+
expect(Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.map(&:id)).to eq(new_stop_id_list)
|
125
129
|
end
|
126
130
|
it "should ignore deleted stop_point from route's vehicle journey at stop" do
|
127
131
|
subject.update_attributes( :stop_points_attributes => removed_stop_hash)
|
128
|
-
Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.map(&:stop_point_id)
|
132
|
+
expect(Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.map(&:stop_point_id)).to match_array(new_stop_id_list)
|
129
133
|
end
|
130
134
|
end
|
131
135
|
end
|
@@ -135,29 +139,29 @@ describe Chouette::Route do
|
|
135
139
|
context "when arg is first quay id" do
|
136
140
|
let(:first_stop_point) { subject.stop_points.first}
|
137
141
|
it "should return first quay" do
|
138
|
-
subject.stop_points.find_by_stop_area( first_stop_point.stop_area_id).
|
142
|
+
expect(subject.stop_points.find_by_stop_area( first_stop_point.stop_area_id)).to eq( first_stop_point)
|
139
143
|
end
|
140
144
|
end
|
141
145
|
end
|
142
146
|
end
|
143
147
|
describe "#stop_areas" do
|
144
|
-
let(:line){
|
145
|
-
let(:route_1){
|
146
|
-
let(:route_2){
|
148
|
+
let(:line){ create(:line)}
|
149
|
+
let(:route_1){ create(:route, :line => line)}
|
150
|
+
let(:route_2){ create(:route, :line => line)}
|
147
151
|
it "should retreive all stop_area on route" do
|
148
152
|
route_1.stop_areas.each do |sa|
|
149
|
-
sa.stop_points.map(&:route_id).uniq.
|
153
|
+
expect(sa.stop_points.map(&:route_id).uniq).to eq([route_1.id])
|
150
154
|
end
|
151
155
|
end
|
152
156
|
|
153
157
|
context "when route is looping: last and first stop area are the same" do
|
154
158
|
it "should retreive same stop_area one last and first position" do
|
155
|
-
route_loop =
|
159
|
+
route_loop = create(:route, :line => line)
|
156
160
|
first_stop = Chouette::StopPoint.where( :route_id => route_loop.id, :position => 0).first
|
157
|
-
last_stop =
|
161
|
+
last_stop = create(:stop_point, :route => route_loop, :position => 4, :stop_area => first_stop.stop_area)
|
158
162
|
|
159
|
-
route_loop.stop_areas.size.
|
160
|
-
route_loop.stop_areas.select {|s| s.id == first_stop.stop_area.id}.size.
|
163
|
+
expect(route_loop.stop_areas.size).to eq(6)
|
164
|
+
expect(route_loop.stop_areas.select {|s| s.id == first_stop.stop_area.id}.size).to eq(2)
|
161
165
|
end
|
162
166
|
end
|
163
167
|
end
|
@@ -172,14 +176,14 @@ describe Chouette::Route do
|
|
172
176
|
direction_code = Chouette::Direction.new( Chouette::Route.direction_binding[ direction])
|
173
177
|
it "should be #{direction_code}" do
|
174
178
|
subject.direction = direction
|
175
|
-
subject.direction_code.
|
179
|
+
expect(subject.direction_code).to eq(direction_code)
|
176
180
|
end
|
177
181
|
end
|
178
182
|
end
|
179
183
|
context "when direction is nil" do
|
180
184
|
it "should be nil" do
|
181
185
|
subject.direction = nil
|
182
|
-
subject.direction_code.
|
186
|
+
expect(subject.direction_code).to be_nil
|
183
187
|
end
|
184
188
|
end
|
185
189
|
end
|
@@ -187,13 +191,13 @@ describe Chouette::Route do
|
|
187
191
|
context "when unknown direction is provided" do
|
188
192
|
it "should change direction to nil" do
|
189
193
|
subject.direction_code = "dummy"
|
190
|
-
subject.direction.
|
194
|
+
expect(subject.direction).to be_nil
|
191
195
|
end
|
192
196
|
end
|
193
197
|
context "when an existing direction (west) is provided" do
|
194
198
|
it "should change direction Direction.west" do
|
195
199
|
subject.direction_code = "west"
|
196
|
-
subject.direction.
|
200
|
+
expect(subject.direction).to eq("West")
|
197
201
|
end
|
198
202
|
end
|
199
203
|
end
|
@@ -206,14 +210,14 @@ describe Chouette::Route do
|
|
206
210
|
wayback_code = Chouette::Wayback.new( Chouette::Route.wayback_binding[ wayback])
|
207
211
|
it "should be #{wayback_code}" do
|
208
212
|
subject.wayback = wayback
|
209
|
-
subject.wayback_code.
|
213
|
+
expect(subject.wayback_code).to eq(wayback_code)
|
210
214
|
end
|
211
215
|
end
|
212
216
|
end
|
213
217
|
context "when wayback is nil" do
|
214
218
|
it "should be nil" do
|
215
219
|
subject.wayback = nil
|
216
|
-
subject.wayback_code.
|
220
|
+
expect(subject.wayback_code).to be_nil
|
217
221
|
end
|
218
222
|
end
|
219
223
|
end
|
@@ -221,13 +225,13 @@ describe Chouette::Route do
|
|
221
225
|
context "when unknown wayback is provided" do
|
222
226
|
it "should change wayback to nil" do
|
223
227
|
subject.wayback_code = "dummy"
|
224
|
-
subject.wayback.
|
228
|
+
expect(subject.wayback).to be_nil
|
225
229
|
end
|
226
230
|
end
|
227
231
|
context "when an existing wayback (straight_forward) is provided" do
|
228
232
|
it "should change wayback Wayback.straight_forward" do
|
229
233
|
subject.wayback_code = "straight_forward"
|
230
|
-
subject.wayback.
|
234
|
+
expect(subject.wayback).to eq("A")
|
231
235
|
end
|
232
236
|
end
|
233
237
|
end
|