aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/chouette/access_point.rb7
-rw-r--r--app/models/concerns/stif_codifligne_attributes_support.rb2
-rw-r--r--app/models/concerns/stif_reflex_attributes_support.rb2
-rw-r--r--spec/factories/chouette_access_points.rb2
-rw-r--r--spec/factories/chouette_lines.rb2
-rw-r--r--spec/factories/chouette_stop_areas.rb2
-rw-r--r--spec/models/chouette/access_point_spec.rb9
-rw-r--r--spec/models/chouette/stop_area_spec.rb4
8 files changed, 17 insertions, 13 deletions
diff --git a/app/models/chouette/access_point.rb b/app/models/chouette/access_point.rb
index 04ea40d33..c81867b52 100644
--- a/app/models/chouette/access_point.rb
+++ b/app/models/chouette/access_point.rb
@@ -24,12 +24,15 @@ class Chouette::AccessPoint < Chouette::ActiveRecord
validates_numericality_of :longitude, :less_than_or_equal_to => 180, :greater_than_or_equal_to => -180, :allow_nil => true
validates_format_of :coordinates, :with => %r{\A *-?(0?[0-9](\.[0-9]*)?|[0-8][0-9](\.[0-9]*)?|90(\.[0]*)?) *\, *-?(0?[0-9]?[0-9](\.[0-9]*)?|1[0-7][0-9](\.[0-9]*)?|180(\.[0]*)?) *\Z}, :allow_nil => true, :allow_blank => true
-
+ before_save :coordinates_to_lat_lng
def self.nullable_attributes
[:street_name, :country_code, :comment, :long_lat_type, :zip_code, :city_name]
end
- before_save :coordinates_to_lat_lng
+
+ def referential
+ @referential ||= Referential.where(:slug => Apartment::Tenant.current).first!
+ end
def combine_lat_lng
if self.latitude.nil? || self.longitude.nil?
diff --git a/app/models/concerns/stif_codifligne_attributes_support.rb b/app/models/concerns/stif_codifligne_attributes_support.rb
index d4370e505..0cd2cccc4 100644
--- a/app/models/concerns/stif_codifligne_attributes_support.rb
+++ b/app/models/concerns/stif_codifligne_attributes_support.rb
@@ -16,6 +16,6 @@ module StifCodifligneAttributesSupport
end
def objectid
- Chouette::StifCodifligneObjectid.new read_attribute(:objectid).to_s
+ Chouette::StifCodifligneObjectid.new read_attribute(:objectid)
end
end
diff --git a/app/models/concerns/stif_reflex_attributes_support.rb b/app/models/concerns/stif_reflex_attributes_support.rb
index e6236a146..9dfd21f94 100644
--- a/app/models/concerns/stif_reflex_attributes_support.rb
+++ b/app/models/concerns/stif_reflex_attributes_support.rb
@@ -16,6 +16,6 @@ module StifReflexAttributesSupport
end
def objectid
- Chouette::StifReflexObjectid.new read_attribute(:objectid).to_s
+ Chouette::StifReflexObjectid.new read_attribute(:objectid)
end
end
diff --git a/spec/factories/chouette_access_points.rb b/spec/factories/chouette_access_points.rb
index 213323f56..38ad76363 100644
--- a/spec/factories/chouette_access_points.rb
+++ b/spec/factories/chouette_access_points.rb
@@ -5,7 +5,7 @@ FactoryGirl.define do
longitude {10.0 * rand}
sequence(:name) { |n| "AccessPoint #{n}" }
access_type "InOut"
- sequence(:objectid) { |n| "test:AccessPoint:#{n}:loc" }
+ sequence(:objectid) { |n| "FR:#{n}:ADL:#{n}:STIF" }
association :stop_area, :factory => :stop_area
end
diff --git a/spec/factories/chouette_lines.rb b/spec/factories/chouette_lines.rb
index e8d75fc67..423ab99f2 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| "organisation:Line:#{n}:LOC" }
+ sequence(:objectid) { |n| "STIF:CODIFLIGNE:Line:#{n}" }
sequence(:transport_mode) { |n| "bus" }
sequence(:number, 1)
diff --git a/spec/factories/chouette_stop_areas.rb b/spec/factories/chouette_stop_areas.rb
index 8e92b024b..8b64c227b 100644
--- a/spec/factories/chouette_stop_areas.rb
+++ b/spec/factories/chouette_stop_areas.rb
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :stop_area, :class => Chouette::StopArea do
- sequence(:objectid) { |n| "test:StopArea:#{n}" }
+ sequence(:objectid) { |n| "FR:#{n}:ZDE:#{n}:STIF" }
sequence(:name) { |n| "stop_area_#{n}" }
sequence(:registration_number) { |n| "test-#{n}" }
area_type { Chouette::StopArea.area_type.values.sample }
diff --git a/spec/models/chouette/access_point_spec.rb b/spec/models/chouette/access_point_spec.rb
index 0251e9491..e0f4b1501 100644
--- a/spec/models/chouette/access_point_spec.rb
+++ b/spec/models/chouette/access_point_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'
describe Chouette::AccessPoint, :type => :model do
+ subject { create(:access_point) }
describe '#objectid' do
subject { super().objectid }
@@ -109,7 +110,6 @@ describe Chouette::AccessPoint, :type => :model do
end
describe "#to_lat_lng" do
-
it "should return nil if latitude is nil" do
subject.latitude = nil
expect(subject.to_lat_lng).to be_nil
@@ -123,12 +123,13 @@ describe Chouette::AccessPoint, :type => :model do
end
describe "#geometry" do
+ let(:access_point) { create(:access_point) }
it "should be nil when to_lat_lng is nil" do
- allow(subject).to receive_messages :to_lat_lng => nil
- expect(subject.geometry).to be_nil
+ allow(access_point).to receive_messages :longitude => nil
+ allow(access_point).to receive_messages :latitude => nil
+ expect(access_point.geometry).to be_nil
end
-
end
describe "#generic_access_link_matrix" do
diff --git a/spec/models/chouette/stop_area_spec.rb b/spec/models/chouette/stop_area_spec.rb
index 293ae5202..a3a398bfb 100644
--- a/spec/models/chouette/stop_area_spec.rb
+++ b/spec/models/chouette/stop_area_spec.rb
@@ -1,9 +1,9 @@
require 'spec_helper'
describe Chouette::StopArea, :type => :model do
- # FIXME !!!!!!!!
+ subject { create(:stop_area) }
+
let!(:quay) { create :stop_area, :area_type => "zdep" }
- # let!(:boarding_position) { create :stop_area, :area_type => "BoardingPosition" }
let!(:commercial_stop_point) { create :stop_area, :area_type => "lda" }
let!(:stop_place) { create :stop_area, :area_type => "zdlp" }