diff options
| author | Xinhui | 2017-07-26 16:15:17 +0200 | 
|---|---|---|
| committer | Xinhui | 2017-07-27 16:35:12 +0200 | 
| commit | e6b04d1e7d95b80d22b1768247896956de6627ed (patch) | |
| tree | 9dd74393fa586f2063b1d84266d65cedb19bed9a | |
| parent | 870f75c2411a8a46c15a0766713df9a3611f2eaf (diff) | |
| download | chouette-core-e6b04d1e7d95b80d22b1768247896956de6627ed.tar.bz2 | |
Edit access point to use new StifReflexAttributesSupport
| -rw-r--r-- | app/models/chouette/access_point.rb | 7 | ||||
| -rw-r--r-- | lib/stif/reflex_synchronization.rb | 2 | ||||
| -rw-r--r-- | spec/factories/chouette_access_points.rb | 2 | ||||
| -rw-r--r-- | spec/models/chouette/access_point_spec.rb | 2 | 
4 files changed, 9 insertions, 4 deletions
| diff --git a/app/models/chouette/access_point.rb b/app/models/chouette/access_point.rb index da1f9524a..476f13c08 100644 --- a/app/models/chouette/access_point.rb +++ b/app/models/chouette/access_point.rb @@ -1,9 +1,10 @@  require 'geokit'  require 'geo_ruby' -class Chouette::AccessPoint < Chouette::TridentActiveRecord +class Chouette::AccessPoint < Chouette::ActiveRecord    # FIXME http://jira.codehaus.org/browse/JRUBY-6358    self.primary_key = "id" +  include StifReflexAttributesSupport    include Geokit::Mappable    include ProjectionFields @@ -29,6 +30,10 @@ class Chouette::AccessPoint < Chouette::TridentActiveRecord    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/lib/stif/reflex_synchronization.rb b/lib/stif/reflex_synchronization.rb index 675486265..63270a986 100644 --- a/lib/stif/reflex_synchronization.rb +++ b/lib/stif/reflex_synchronization.rb @@ -123,7 +123,7 @@ module Stif        end        def create_or_update_access_point entry, stop_area -        access = Chouette::AccessPoint.find_or_create_by(objectid: "dummy:AccessPoint:#{entry['id'].tr(':', '')}") +        access = Chouette::AccessPoint.find_or_create_by(objectid: entry['id'])          # Hack, on save object_version will be incremented by 1          entry['version']   = entry['version'].to_i + 1  if access.persisted?          access.access_type = self.access_point_access_type(entry) diff --git a/spec/factories/chouette_access_points.rb b/spec/factories/chouette_access_points.rb index 06d1da779..ef0247710 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}" } +    sequence(:objectid) { |n| "test:AccessPoint:#{n}:STIF" }      association :stop_area, :factory => :stop_area    end diff --git a/spec/models/chouette/access_point_spec.rb b/spec/models/chouette/access_point_spec.rb index 02b1621e3..0251e9491 100644 --- a/spec/models/chouette/access_point_spec.rb +++ b/spec/models/chouette/access_point_spec.rb @@ -4,7 +4,7 @@ describe Chouette::AccessPoint, :type => :model do    describe '#objectid' do      subject { super().objectid } -    it { is_expected.to be_kind_of(Chouette::ObjectId) } +    it { is_expected.to be_kind_of(Chouette::StifReflexObjectid) }    end    it { is_expected.to validate_presence_of :name } | 
