diff options
| -rw-r--r-- | app/models/chouette/access_point.rb | 1 | ||||
| -rw-r--r-- | app/models/chouette/time_table.rb | 1 | ||||
| -rw-r--r-- | spec/factories/chouette_journey_pattern.rb | 2 | ||||
| -rw-r--r-- | spec/factories/chouette_lines.rb | 2 | ||||
| -rw-r--r-- | spec/factories/chouette_routes.rb | 2 | ||||
| -rw-r--r-- | spec/factories/chouette_routing_constraint_zones.rb | 1 | ||||
| -rw-r--r-- | spec/factories/chouette_time_table.rb | 2 | ||||
| -rw-r--r-- | spec/factories/chouette_vehicle_journey.rb | 2 | ||||
| -rw-r--r-- | spec/models/chouette/routing_constraint_zone_spec.rb | 21 | ||||
| -rw-r--r-- | spec/models/chouette/trident_active_record_spec.rb | 104 | ||||
| -rw-r--r-- | spec/models/vehicle_translation_spec.rb | 1 |
11 files changed, 69 insertions, 70 deletions
diff --git a/app/models/chouette/access_point.rb b/app/models/chouette/access_point.rb index 9e5dcedf9..04ea40d33 100644 --- a/app/models/chouette/access_point.rb +++ b/app/models/chouette/access_point.rb @@ -4,6 +4,7 @@ require 'geo_ruby' class Chouette::AccessPoint < Chouette::ActiveRecord # FIXME http://jira.codehaus.org/browse/JRUBY-6358 self.primary_key = "id" + include StifReflexAttributesSupport include Geokit::Mappable include ProjectionFields diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb index f8d45f9b8..2f8188673 100644 --- a/app/models/chouette/time_table.rb +++ b/app/models/chouette/time_table.rb @@ -584,7 +584,6 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord def duplicate tt = self.deep_clone :include => [:periods, :dates], :except => :object_version - tt.uniq_objectid tt.tag_list.add(*self.tag_list) unless self.tag_list.empty? tt.created_from = self tt.comment = I18n.t("activerecord.copy", :name => self.comment) diff --git a/spec/factories/chouette_journey_pattern.rb b/spec/factories/chouette_journey_pattern.rb index 50ff10a77..2ca9b5488 100644 --- a/spec/factories/chouette_journey_pattern.rb +++ b/spec/factories/chouette_journey_pattern.rb @@ -5,7 +5,7 @@ FactoryGirl.define do sequence(:published_name) { |n| "jp publishedname #{n}" } sequence(:comment) { |n| "jp comment #{n}" } sequence(:registration_number) { |n| "jp registration_number #{n}" } - sequence(:objectid) { |n| "test:JourneyPattern:#{n}:loc" } + sequence(:objectid) { |n| "organisation:JourneyPattern:lineId-#{n}:LOC" } association :route, :factory => :route diff --git a/spec/factories/chouette_lines.rb b/spec/factories/chouette_lines.rb index 24b182b83..e8d75fc67 100644 --- a/spec/factories/chouette_lines.rb +++ b/spec/factories/chouette_lines.rb @@ -2,7 +2,7 @@ FactoryGirl.define do factory :line, :class => Chouette::Line do sequence(:name) { |n| "Line #{n}" } - sequence(:objectid) { |n| "chouette:test:Line:#{n}" } + sequence(:objectid) { |n| "organisation:Line:#{n}:LOC" } sequence(:transport_mode) { |n| "bus" } sequence(:number, 1) diff --git a/spec/factories/chouette_routes.rb b/spec/factories/chouette_routes.rb index 50c9ad230..501d94da8 100644 --- a/spec/factories/chouette_routes.rb +++ b/spec/factories/chouette_routes.rb @@ -6,7 +6,7 @@ FactoryGirl.define do sequence(:number) { |n| "#{n}" } sequence(:wayback) { |n| Chouette::Route.wayback.values[n % 2] } sequence(:direction) { |n| Chouette::Route.direction.values[n % 12] } - sequence(:objectid) { |n| "test:Route:#{n}:loc" } + sequence(:objectid) { |n| "organisation:Route:lineId-routeId#{n}:LOC" } association :line, :factory => :line diff --git a/spec/factories/chouette_routing_constraint_zones.rb b/spec/factories/chouette_routing_constraint_zones.rb index 8ef2ddb43..7748a4f74 100644 --- a/spec/factories/chouette_routing_constraint_zones.rb +++ b/spec/factories/chouette_routing_constraint_zones.rb @@ -1,6 +1,7 @@ FactoryGirl.define do factory :routing_constraint_zone, class: Chouette::RoutingConstraintZone do sequence(:name) { |n| "Routing constraint zone #{n}" } + sequence(:objectid) { |n| "organisation:RoutingConstraintZone:lineId-routeId-#{n}:LOC" } association :route, factory: :route after(:build) do |zone| route = Chouette::Route.find(zone.route_id) diff --git a/spec/factories/chouette_time_table.rb b/spec/factories/chouette_time_table.rb index 3df0305f0..0106395a5 100644 --- a/spec/factories/chouette_time_table.rb +++ b/spec/factories/chouette_time_table.rb @@ -9,7 +9,7 @@ FactoryGirl.define do factory :time_table, :class => Chouette::TimeTable do sequence(:comment) { |n| "Timetable #{n}" } - sequence(:objectid) { |n| "test:Timetable:#{n}:loc" } + sequence(:objectid) { |n| "organisation:Timetable:#{n}:LOC" } sequence(:int_day_types) { (1..7).to_a.map{ |n| 2**(n+1)}.sum } calendar nil diff --git a/spec/factories/chouette_vehicle_journey.rb b/spec/factories/chouette_vehicle_journey.rb index a95b462bf..fa661de2e 100644 --- a/spec/factories/chouette_vehicle_journey.rb +++ b/spec/factories/chouette_vehicle_journey.rb @@ -1,7 +1,7 @@ FactoryGirl.define do factory :vehicle_journey_common, :class => Chouette::VehicleJourney do - sequence(:objectid) { |n| "test:VehicleJourney:#{n}:loc" } + sequence(:objectid) { |n| "organisation:VehicleJourney:lineid-#{n}:LOC" } factory :vehicle_journey_empty do association :journey_pattern, :factory => :journey_pattern diff --git a/spec/models/chouette/routing_constraint_zone_spec.rb b/spec/models/chouette/routing_constraint_zone_spec.rb index 87ee9e9ac..656cb6755 100644 --- a/spec/models/chouette/routing_constraint_zone_spec.rb +++ b/spec/models/chouette/routing_constraint_zone_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe Chouette::RoutingConstraintZone, type: :model do subject { create(:routing_constraint_zone) } - let!(:routing_constraint_zone) { create(:routing_constraint_zone) } it { is_expected.to validate_presence_of :name } # shoulda matcher to validate length of array ? @@ -12,38 +11,38 @@ describe Chouette::RoutingConstraintZone, type: :model do describe 'validations' do it 'validates the presence of route_id' do expect { - routing_constraint_zone.update!(route_id: nil) + subject.update!(route_id: nil) }.to raise_error(NoMethodError) end it 'validates the presence of stop_point_ids' do expect { - routing_constraint_zone.update!(stop_point_ids: []) + subject.update!(stop_point_ids: []) }.to raise_error(ActiveRecord::RecordInvalid) end it 'validates that stop points belong to the route' do route = create(:route) expect { - routing_constraint_zone.update!(route_id: route.id) + subject.update!(route_id: route.id) }.to raise_error(ActiveRecord::RecordInvalid) end it 'validates that not all stop points from the route are selected' do - routing_constraint_zone.stop_points = routing_constraint_zone.route.stop_points + subject.stop_points = subject.route.stop_points expect { - routing_constraint_zone.save! + subject.save! }.to raise_error(ActiveRecord::RecordInvalid) end end describe 'deleted stop areas' do it 'does not have them in stop_area_ids' do - stop_point = routing_constraint_zone.route.stop_points.last - routing_constraint_zone.stop_points << stop_point - routing_constraint_zone.save! - routing_constraint_zone.route.stop_points.last.destroy! - expect(routing_constraint_zone.stop_points.map(&:id)).not_to include(stop_point.id) + stop_point = subject.route.stop_points.last + subject.stop_points << stop_point + subject.save! + subject.route.stop_points.last.destroy! + expect(subject.stop_points.map(&:id)).not_to include(stop_point.id) end end diff --git a/spec/models/chouette/trident_active_record_spec.rb b/spec/models/chouette/trident_active_record_spec.rb index 76544f85d..e6fa259e0 100644 --- a/spec/models/chouette/trident_active_record_spec.rb +++ b/spec/models/chouette/trident_active_record_spec.rb @@ -6,27 +6,27 @@ describe Chouette::TridentActiveRecord, :type => :model do subject { create(:time_table) } - describe "#uniq_objectid" do - - it "should rebuild objectid" do - tm = create(:time_table) - tm.objectid = subject.objectid - tm.uniq_objectid - expect(tm.objectid).to eq(subject.objectid+"_1") - end - - it "should rebuild objectid" do - tm = create(:time_table) - tm.objectid = subject.objectid - tm.uniq_objectid - tm.save - tm = create(:time_table) - tm.objectid = subject.objectid - tm.uniq_objectid - expect(tm.objectid).to eq(subject.objectid+"_2") - end - - end + # describe "#uniq_objectid" do + + # it "should rebuild objectid" do + # tm = create(:time_table) + # tm.objectid = subject.objectid + # tm.uniq_objectid + # expect(tm.objectid).to eq(subject.objectid+"_1") + # end + + # it "should rebuild objectid" do + # tm = create(:time_table) + # tm.objectid = subject.objectid + # tm.uniq_objectid + # tm.save + # tm = create(:time_table) + # tm.objectid = subject.objectid + # tm.uniq_objectid + # expect(tm.objectid).to eq(subject.objectid+"_2") + # end + + # end def create_object(options = {}) options = {name: "merge1"}.merge options @@ -34,37 +34,37 @@ describe Chouette::TridentActiveRecord, :type => :model do Chouette::TimeTable.new attributes end - describe "#prepare_auto_columns" do - - it "should left objectid" do - tm = create_object :objectid => "first:Timetable:merge1" - tm.prepare_auto_columns - expect(tm.objectid).to eq("first:Timetable:merge1") - end - - it "should add pending_id to objectid" do - tm = create_object - tm.prepare_auto_columns - expect(tm.objectid.start_with?("first:Timetable:__pending_id__")).to be_truthy - end - - it "should set id to objectid" do - tm = create_object - tm.save - expect(tm.objectid).to eq("first:Timetable:"+tm.id.to_s) - end - - it "should detect objectid conflicts" do - tm = create_object - tm.save - tm.objectid = "first:Timetable:"+(tm.id+1).to_s - tm.save - tm = create_object - tm.save - expect(tm.objectid).to eq("first:Timetable:"+tm.id.to_s+"_1") - end - - end + # describe "#prepare_auto_columns" do + + # it "should left objectid" do + # tm = create_object :objectid => "first:Timetable:merge1" + # tm.prepare_auto_columns + # expect(tm.objectid).to eq("first:Timetable:merge1") + # end + + # it "should add pending_id to objectid" do + # tm = create_object + # tm.prepare_auto_columns + # expect(tm.objectid.start_with?("first:Timetable:__pending_id__")).to be_truthy + # end + + # it "should set id to objectid" do + # tm = create_object + # tm.save + # expect(tm.objectid).to eq("first:Timetable:"+tm.id.to_s) + # end + + # it "should detect objectid conflicts" do + # tm = create_object + # tm.save + # tm.objectid = "first:Timetable:"+(tm.id+1).to_s + # tm.save + # tm = create_object + # tm.save + # expect(tm.objectid).to eq("first:Timetable:"+tm.id.to_s+"_1") + # end + + # end describe "objectid" do diff --git a/spec/models/vehicle_translation_spec.rb b/spec/models/vehicle_translation_spec.rb index c9a573ae2..d30cfa03e 100644 --- a/spec/models/vehicle_translation_spec.rb +++ b/spec/models/vehicle_translation_spec.rb @@ -6,7 +6,6 @@ describe VehicleTranslation, :type => :model do # To fix : need to comment :company => company # after adding company to apartment excluded models let!(:vehicle_journey){ create(:vehicle_journey, - :objectid => "dummy", :journey_pattern => journey_pattern, :route => journey_pattern.route, # :company => company, |
