diff options
| author | Zog | 2018-05-28 16:32:33 +0200 |
|---|---|---|
| committer | Zog | 2018-05-29 10:19:14 +0200 |
| commit | 1f66366e62357942f1bf0cdefb9c6e656bf3066a (patch) | |
| tree | 470fbda42eed63c78698611e5d085bf6724c8d73 | |
| parent | 376c297b18bdf29abd1b70b60a05c04beacde633 (diff) | |
| download | chouette-core-1f66366e62357942f1bf0cdefb9c6e656bf3066a.tar.bz2 | |
Refs #7185; Fix specs
| -rw-r--r-- | app/helpers/stop_area_copies_helper.rb | 8 | ||||
| -rw-r--r-- | db/migrate/20170307155042_set_updated_at.rb | 2 | ||||
| -rw-r--r-- | db/migrate/20180330124436_add_metadata_to_other_models.rb | 3 | ||||
| -rw-r--r-- | lib/stif/reflex_synchronization.rb | 35 | ||||
| -rw-r--r-- | spec/controllers/vehicle_journey_frequencies_controller_spec.rb | 5 | ||||
| -rw-r--r-- | spec/models/ninoxe_extension_spec.rb | 28 | ||||
| -rw-r--r-- | spec/models/stop_area_copy_spec.rb | 38 | ||||
| -rw-r--r-- | spec/tasks/reflex_rake_spec.rb | 7 |
8 files changed, 2 insertions, 124 deletions
diff --git a/app/helpers/stop_area_copies_helper.rb b/app/helpers/stop_area_copies_helper.rb deleted file mode 100644 index 023a9d750..000000000 --- a/app/helpers/stop_area_copies_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -module StopAreaCopiesHelper - - def label_stop_area_types(*stop_area_types) - stop_area_types - .flatten - .zip_map { |stop_area_type| t("area_types.label.#{stop_area_type}") } - end -end diff --git a/db/migrate/20170307155042_set_updated_at.rb b/db/migrate/20170307155042_set_updated_at.rb index 6280ba9a8..d805a468f 100644 --- a/db/migrate/20170307155042_set_updated_at.rb +++ b/db/migrate/20170307155042_set_updated_at.rb @@ -1,7 +1,7 @@ class SetUpdatedAt < ActiveRecord::Migration def up models = %w(VehicleJourney TimeTable StopPoint StopArea RoutingConstraintZone Route PtLink Network Line - JourneyPattern GroupOfLine ConnectionLink Company AccessPoint AccessLink) + JourneyPattern GroupOfLine Company) models.each do |table| "Chouette::#{table}".constantize.where(updated_at: nil).update_all('updated_at = created_at') diff --git a/db/migrate/20180330124436_add_metadata_to_other_models.rb b/db/migrate/20180330124436_add_metadata_to_other_models.rb index be031de0c..a3ee89a90 100644 --- a/db/migrate/20180330124436_add_metadata_to_other_models.rb +++ b/db/migrate/20180330124436_add_metadata_to_other_models.rb @@ -3,10 +3,7 @@ class AddMetadataToOtherModels < ActiveRecord::Migration [ Api::V1::ApiKey, Calendar, - Chouette::AccessLink, - Chouette::AccessPoint, Chouette::Company, - Chouette::ConnectionLink, Chouette::GroupOfLine, Chouette::JourneyPattern, Chouette::Line, diff --git a/lib/stif/reflex_synchronization.rb b/lib/stif/reflex_synchronization.rb index 508d28b40..9b16584d0 100644 --- a/lib/stif/reflex_synchronization.rb +++ b/lib/stif/reflex_synchronization.rb @@ -120,34 +120,6 @@ module Stif end end - def access_point_access_type entry - if entry['IsEntry'] == 'true' && entry['IsExit'] == 'true' - 'in_out' - elsif entry['IsEntry'] == 'true' - 'in' - elsif entry['IsExit'] == 'true' - 'out' - end - end - - def create_or_update_access_point entry, stop_area - 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) - access.stop_area = stop_area - { - :name => 'Name', - :object_version => 'version', - :zip_code => 'PostalRegion', - :city_name => 'Town' - }.each do |k, v| access[k] = entry[v] end - if entry['gml:pos'] - access['longitude'] = entry['gml:pos'][:lng] - access['latitude'] = entry['gml:pos'][:lat] - end - save_if_valid(access) if access.changed? - end def create_or_update_stop_area entry stop = Chouette::StopArea.find_or_create_by(objectid: entry['id'], stop_area_referential: self.defaut_referential ) @@ -177,12 +149,7 @@ module Stif increment_counts prop, 1 save_if_valid(stop) end - # Create AccessPoint from StopPlaceEntrance - if entry[:stop_place_entrances] - entry[:stop_place_entrances].each do |entrance| - self.create_or_update_access_point entrance, stop - end - end + stop end end diff --git a/spec/controllers/vehicle_journey_frequencies_controller_spec.rb b/spec/controllers/vehicle_journey_frequencies_controller_spec.rb deleted file mode 100644 index 61636e334..000000000 --- a/spec/controllers/vehicle_journey_frequencies_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -RSpec.describe VehicleJourneyFrequenciesController, :type => :controller do - -end diff --git a/spec/models/ninoxe_extension_spec.rb b/spec/models/ninoxe_extension_spec.rb index 016e10496..aff283139 100644 --- a/spec/models/ninoxe_extension_spec.rb +++ b/spec/models/ninoxe_extension_spec.rb @@ -28,31 +28,3 @@ describe Chouette::StopArea do # end end - -describe Chouette::AccessPoint do - # check override methods - - subject {create(:access_point)} - - it "should return referential projection" do - subject.referential.projection_type='27572' - expect(subject.projection).to eq(subject.referential.projection_type) - end - - it "should return projection coordinates when referential has projection" do - subject.latitude = 45 - subject.longitude = 0 - subject.referential.projection_type='27572' - expect(subject.projection_x).not_to be_nil - expect(subject.projection_y).not_to be_nil - end - - it "should return nil projection coordinates when referential has no projection" do - subject.latitude = 45 - subject.longitude = 0 - subject.referential.projection_type=nil - expect(subject.projection_x).to be_nil - expect(subject.projection_y).to be_nil - end - -end diff --git a/spec/models/stop_area_copy_spec.rb b/spec/models/stop_area_copy_spec.rb deleted file mode 100644 index a00271077..000000000 --- a/spec/models/stop_area_copy_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -require 'spec_helper' - -describe StopAreaCopy, :type => :model do - - subject { StopAreaCopy.new(:source_id => 1, :hierarchy => "child", :area_type => "Quay") } - - describe ".save" do - # Fixme #1627 - # it "should create a child for source" do - # source = create(:stop_area, :area_type => "CommercialStopPoint", :name => "test1", - # :registration_number => "123456", :city_name => "dummy", :zip_code => "12345") - # source.save - # subject.source_id = source.id - # subject.hierarchy = "child" - # subject.area_type = "Quay" - # subject.save - - # source.reload - # expect(source.children.length).to eq(1) - # expect(source.children[0].name).to eq("test1") - # end - - # it "should create a parent for source" do - # source = create(:stop_area, :area_type => "CommercialStopPoint", :name => "test2", - # :registration_number => "123456", :city_name => "dummy", :zip_code => "12345") - # source.save - # subject.source_id = source.id - # subject.hierarchy = "parent" - # subject.area_type = "StopPlace" - # subject.save - # source.reload - # expect(source.parent).not_to be_nil - # expect(source.parent.name).to eq('test2') - # end - end - -end diff --git a/spec/tasks/reflex_rake_spec.rb b/spec/tasks/reflex_rake_spec.rb index 6ece223d2..a995e691f 100644 --- a/spec/tasks/reflex_rake_spec.rb +++ b/spec/tasks/reflex_rake_spec.rb @@ -15,12 +15,6 @@ describe 'reflex:sync' do it 'should create stopArea on successfull request' do expect(Chouette::StopArea.count).to eq 6 - expect(Chouette::AccessPoint.count).to eq 2 - end - - it 'should convert StopPlaceEntrance to AccessPoint' do - access = Chouette::AccessPoint.find_by(name: 'Montgeron Crosne - Rue Du Moulin De Senlis') - expect(access.stop_area.name).to eq 'First stopPlace children' end it 'should store object_status on stif_type attribute' do @@ -50,7 +44,6 @@ describe 'reflex:sync' do it 'should not create duplicate stop_area' do expect(Chouette::StopArea.count).to eq 6 - expect(Chouette::AccessPoint.count).to eq 2 end it 'should flag deleted_at for missing element from last sync' do |
