aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobertDober2017-04-11 17:26:11 +0200
committerRobertDober2017-04-11 21:01:45 +0200
commit839553dc9e40a8b4ef4020d08f64a06792152df7 (patch)
tree7452338890e97d7dec3d24646d76f75aec27214e
parent4a733e13aafd9cc6ff176892e853cd4f2cd13088 (diff)
parent90c62a1a73265056cdf998193395d455f5c4c0b6 (diff)
downloadchouette-core-839553dc9e40a8b4ef4020d08f64a06792152df7.tar.bz2
Merge branch 'master' of github.com:af83/stif-boiv
-rw-r--r--app/assets/javascripts/routing_constraint_zones.coffee21
-rw-r--r--app/controllers/route_stop_points_controller.rb18
-rw-r--r--app/controllers/routing_constraint_zones_controller.rb7
-rw-r--r--app/controllers/time_tables_controller.rb15
-rw-r--r--app/helpers/newapplication_helper.rb10
-rw-r--r--app/models/chouette/routing_constraint_zone.rb11
-rw-r--r--app/models/chouette/stop_point.rb2
-rw-r--r--app/views/routing_constraint_zones/_form.html.slim8
-rw-r--r--app/views/routing_constraint_zones/show.html.slim7
-rw-r--r--app/views/time_tables/index.html.slim12
-rw-r--r--config/locales/routing_constraint_zones.en.yml8
-rw-r--r--config/locales/routing_constraint_zones.fr.yml7
-rw-r--r--config/routes.rb1
-rw-r--r--db/migrate/20170405122823_rm_stop_areas_add_stop_points_to_routing_constraint_zone.rb6
-rw-r--r--db/schema.rb764
-rw-r--r--spec/controllers/route_stop_points_controller_spec.rb23
-rw-r--r--spec/factories/chouette_routing_constraint_zones.rb5
-rw-r--r--spec/features/lines_spec.rb8
-rw-r--r--spec/features/routes_spec.rb4
-rw-r--r--spec/models/chouette/routing_constraint_zone_spec.rb39
20 files changed, 544 insertions, 432 deletions
diff --git a/app/assets/javascripts/routing_constraint_zones.coffee b/app/assets/javascripts/routing_constraint_zones.coffee
new file mode 100644
index 000000000..bb7d8e9cd
--- /dev/null
+++ b/app/assets/javascripts/routing_constraint_zones.coffee
@@ -0,0 +1,21 @@
+fill_stop_points_options = ->
+ stop_point_select = $('#routing_constraint_zone_stop_point_ids')
+ stop_point_select.empty()
+ referential_id = document.location.pathname.match(/\d+/g)[0]
+ line_id = document.location.pathname.match(/\d+/g)[1]
+ route_id = $('#routing_constraint_zone_route_id').val()
+ $.ajax
+ url: "/referentials/#{referential_id}/lines/#{line_id}/routes/#{route_id}/stop_points"
+ dataType: 'json'
+ success: (data, textStatus, jqXHR) ->
+ for stop_point in data
+ stop_point_select.append "<option value='#{stop_point.id}'>#{stop_point.name}</option>"
+ error: (jqXHR, textStatus, errorThrown) ->
+ console.log textStatus
+ console.log errorThrown
+
+$ ->
+ if document.location.pathname.endsWith('new')
+ fill_stop_points_options()
+ $('#routing_constraint_zone_route_id').change(fill_stop_points_options)
+
diff --git a/app/controllers/route_stop_points_controller.rb b/app/controllers/route_stop_points_controller.rb
new file mode 100644
index 000000000..e12acb33b
--- /dev/null
+++ b/app/controllers/route_stop_points_controller.rb
@@ -0,0 +1,18 @@
+class RouteStopPointsController < ChouetteController
+ defaults resource_class: Chouette::StopPoint
+ actions :index
+ respond_to :json, only: :index
+
+ belongs_to :referential do
+ belongs_to :line, :parent_class => Chouette::Line do
+ belongs_to :route, :parent_class => Chouette::Route
+ end
+ end
+
+ def index
+ respond_to do |format|
+ format.json { render json: referential.lines.find(params[:line_id]).routes.find(params[:route_id]).stop_points.map { |sp| { id: sp.id, name: sp.name } } }
+ end
+ end
+end
+
diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb
index bc3dcdfd4..f2f74e801 100644
--- a/app/controllers/routing_constraint_zones_controller.rb
+++ b/app/controllers/routing_constraint_zones_controller.rb
@@ -3,6 +3,8 @@ class RoutingConstraintZonesController < ChouetteController
respond_to :html, :xml, :json
+ before_action :remove_empty_stop_point, only: [:create, :update]
+
belongs_to :referential do
belongs_to :line, parent_class: Chouette::Line
end
@@ -11,7 +13,10 @@ class RoutingConstraintZonesController < ChouetteController
private
def routing_constraint_zone_params
- params.require(:routing_constraint_zone).permit(:name, { stop_area_ids: [] }, :line_id, :route_id, :objectid, :object_version, :creator_id)
+ params.require(:routing_constraint_zone).permit(:name, { stop_point_ids: [] }, :line_id, :route_id, :objectid, :object_version, :creator_id)
end
+ def remove_empty_stop_point
+ params.require(:routing_constraint_zone)[:stop_point_ids].delete('')
+ end
end
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb
index cb7c96e03..eedfef07c 100644
--- a/app/controllers/time_tables_controller.rb
+++ b/app/controllers/time_tables_controller.rb
@@ -93,15 +93,14 @@ class TimeTablesController < ChouetteController
protected
def collection
- ransack_params = params[:q]
- # Hack to delete params can't be used by ransack
- tag_search = ransack_params["tag_search"] if ransack_params.present? && ransack_params["tag_search"].present?
- ransack_params.delete("tag_search") if ransack_params.present?
-
- selected_time_tables = tag_search ? select_time_tables.tagged_with(tag_search, :wild => true, :any => true) : select_time_tables
-
- @q = selected_time_tables.search(ransack_params)
+ scope = select_time_tables
+ if params[:q] && params[:q]["tag_search"]
+ tags = params[:q]["tag_search"].reject {|c| c.empty?}
+ params[:q].delete("tag_search")
+ scope = select_time_tables.tagged_with(tags, :wild => true, :any => true) if tags.any?
+ end
+ @q = scope.search(params[:q])
if sort_column && sort_direction
@time_tables ||= @q.result(:distinct => true).order("#{sort_column} #{sort_direction}")
else
diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb
index ca6ded5f6..42fca489f 100644
--- a/app/helpers/newapplication_helper.rb
+++ b/app/helpers/newapplication_helper.rb
@@ -51,12 +51,11 @@ module NewapplicationHelper
if attribute == 'name' or attribute == 'comment'
lnk = []
- unless item.class.to_s == 'Calendar' or item.class.to_s == 'Referential'
+ unless item.class == Calendar or item.class == Referential
if current_referential
lnk << current_referential
lnk << item.line if item.respond_to? :line
- lnk << item.route.line if item.class.to_s == 'Chouette::RoutingConstraintZone'
- lnk << item if item.class.to_s == 'Chouette::RoutingConstraintZone'
+ lnk << item.route.line if item.class == Chouette::RoutingConstraintZone
lnk << item if item.respond_to? :line_referential
lnk << item.stop_area if item.respond_to? :stop_area
lnk << item if item.respond_to? :stop_points or item.class.to_s == 'Chouette::TimeTable'
@@ -103,12 +102,11 @@ module NewapplicationHelper
polymorph_url << action
end
- unless item.class.to_s == 'Calendar' or item.class.to_s == 'Referential'
+ unless item.class == Calendar or item.class == Referential
if current_referential
polymorph_url << current_referential
polymorph_url << item.line if item.respond_to? :line
- polymorph_url << item.route.line if item.class.to_s == 'Chouette::RoutingConstraintZone'
- polymorph_url << item if item.class.to_s == 'Chouette::RoutingConstraintZone'
+ polymorph_url << item.route.line if item.class == Chouette::RoutingConstraintZone
polymorph_url << item if item.respond_to? :line_referential
polymorph_url << item.stop_area if item.respond_to? :stop_area
polymorph_url << item if item.respond_to? :stop_points or item.class.to_s == 'Chouette::TimeTable'
diff --git a/app/models/chouette/routing_constraint_zone.rb b/app/models/chouette/routing_constraint_zone.rb
index 2c8583ec1..d548ce048 100644
--- a/app/models/chouette/routing_constraint_zone.rb
+++ b/app/models/chouette/routing_constraint_zone.rb
@@ -1,9 +1,12 @@
class Chouette::RoutingConstraintZone < Chouette::TridentActiveRecord
belongs_to :route
- has_array_of :stop_areas, class_name: 'Chouette::StopArea'
+ has_array_of :stop_points, class_name: 'Chouette::StopPoint'
- validates_presence_of :name, :stop_area_ids, :route_id
- validates :stop_areas, length: { minimum: 2 }
+ validates_presence_of :name, :stop_point_ids, :route_id
+ validates :stop_point_ids, length: { minimum: 2, too_short: I18n.t('activerecord.errors.models.routing_constraint_zone.attributes.stop_points.not_enough_stop_points') }
+ validate :stop_points_belong_to_route
- self.primary_key = 'id'
+ def stop_points_belong_to_route
+ errors.add(:stop_points, I18n.t('activerecord.errors.models.routing_constraint_zone.attributes.stop_points.stop_points_not_from_route')) unless stop_points.all? { |sp| route.stop_points.include? sp }
+ end
end
diff --git a/app/models/chouette/stop_point.rb b/app/models/chouette/stop_point.rb
index 8a3262dd0..e0f947487 100644
--- a/app/models/chouette/stop_point.rb
+++ b/app/models/chouette/stop_point.rb
@@ -18,6 +18,8 @@ module Chouette
scope :default_order, -> { order("position") }
+ delegate :name, to: :stop_area
+
before_destroy :remove_dependent_journey_pattern_stop_points
def remove_dependent_journey_pattern_stop_points
route.journey_patterns.each do |jp|
diff --git a/app/views/routing_constraint_zones/_form.html.slim b/app/views/routing_constraint_zones/_form.html.slim
index f72dd1471..e07b21fec 100644
--- a/app/views/routing_constraint_zones/_form.html.slim
+++ b/app/views/routing_constraint_zones/_form.html.slim
@@ -4,13 +4,15 @@
= f.input :name
.row
.col-lg-6.col-sm-12
- = f.input :route_id, collection: @line.routes
+ = f.input :route_id, collection: @line.routes, include_blank: false
.row
.col-lg-6.col-sm-12
- / Temporarily limit the collection to 10 items... otherwise it kills RoR
- = f.input :stop_area_ids, as: :select, collection: Chouette::StopArea.limit(10), selected: @routing_constraint_zone.stop_area_ids, label: Chouette::StopArea.model_name.human.pluralize.capitalize, label_method: :name, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Sélection de arrêts', 'multiple': 'multiple', style: 'width: 100%' }
+ - stop_points_collection = @routing_constraint_zone.persisted? ? @routing_constraint_zone.route.stop_points : []
+ = f.input :stop_point_ids, id: 'stop_point_ids', as: :select, collection: stop_points_collection, selected: @routing_constraint_zone.stop_point_ids, label: Chouette::StopPoint.model_name.human.pluralize.capitalize, label_method: :name, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Sélection des arrêts sur séquence d\'arrêts', 'multiple': 'multiple', style: 'width: 100%' }
.row
.col-lg-12.text-right
= link_to 'Annuler', :back, class: 'btn btn-link'
= f.button :submit, class: 'btn btn-danger'
+
+
diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim
index 7b7b63623..351784ecc 100644
--- a/app/views/routing_constraint_zones/show.html.slim
+++ b/app/views/routing_constraint_zones/show.html.slim
@@ -9,10 +9,9 @@ p
= link_to @routing_constraint_zone.route.name, referential_line_route_path(@referential, @line, @routing_constraint_zone.route)
p
- label => "#{Chouette::StopArea.model_name.human.pluralize.capitalize} : "
+ label => "#{Chouette::StopPoint.model_name.human.pluralize.capitalize} : "
br
- - @routing_constraint_zone.stop_areas.each do |stop_area|
- = link_to stop_area.name, referential_stop_area_path(@referential, stop_area)
+ - @routing_constraint_zone.stop_points.each do |stop_point|
+ = link_to stop_point.name, referential_stop_area_path(@referential, stop_point.stop_area)
br
-
diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim
index 84ad539c2..65d0787e8 100644
--- a/app/views/time_tables/index.html.slim
+++ b/app/views/time_tables/index.html.slim
@@ -22,11 +22,11 @@
= f.label @time_tables.human_attribute_name(:tag_search), required: false, class: 'control-label'
= f.input :tag_search, as: :tags, collection: Chouette::TimeTable.tags_on(:tags).pluck(:name), label: false, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Indiquez une étiquette...' }, wrapper_html: { class: 'select2ed'}, include_blank: false
- / .form-group.togglable
- / = f.label @time_tables.human_attribute_name(:bounding_dates), required: false, class: 'control-label'
- / .filter_menu
- / = f.input :start_date_gteq, as: :date, label: t('simple_form.from'), wrapper_html: { class: 'date filter_menu-item' }
- / = f.input :end_date_lteq, as: :date, label: t('simple_form.to'), wrapper_html: { class: 'date filter_menu-item' }
+ .form-group.togglable
+ = f.label @time_tables.human_attribute_name(:bounding_dates), required: false, class: 'control-label'
+ .filter_menu
+ = f.input :start_date_gteq, as: :date, label: t('simple_form.from'), wrapper_html: { class: 'date filter_menu-item' }
+ = f.input :end_date_lteq, as: :date, label: t('simple_form.to'), wrapper_html: { class: 'date filter_menu-item' }
.actions
@@ -44,7 +44,7 @@
'table has-search'
= new_pagination @time_tables, 'pull-right'
-
+
- unless @time_tables.any?
.row.mt-xs
.col-lg-12
diff --git a/config/locales/routing_constraint_zones.en.yml b/config/locales/routing_constraint_zones.en.yml
index 7012a1493..6599989e8 100644
--- a/config/locales/routing_constraint_zones.en.yml
+++ b/config/locales/routing_constraint_zones.en.yml
@@ -9,6 +9,13 @@ en:
line: Line
created_at: Created at
updated_at: Updated at
+ errors:
+ models:
+ routing_constraint_zone:
+ attributes:
+ stop_points:
+ not_enough_stop_points: 'You should specify at least 2 stop points.'
+ stop_points_not_from_route: 'Stop point does not belong to the Route of this Routing constraint zone.'
routing_constraint_zones:
actions:
new: New routing constraint zone
@@ -21,3 +28,4 @@ en:
title: "Update routing constraint zone %{routing_constraint_zone}"
show:
title: "Routing constraint zone %{routing_constraint_zone}"
+
diff --git a/config/locales/routing_constraint_zones.fr.yml b/config/locales/routing_constraint_zones.fr.yml
index bb4d8bcd2..5b663e00c 100644
--- a/config/locales/routing_constraint_zones.fr.yml
+++ b/config/locales/routing_constraint_zones.fr.yml
@@ -9,6 +9,13 @@ fr:
line: Ligne
created_at: "Créé le"
updated_at: "Edité le"
+ errors:
+ models:
+ routing_constraint_zone:
+ attributes:
+ stop_points:
+ not_enough_stop_points: "Il faut mettre au moins deux arrêts sur séquence d'arrêts."
+ stop_points_not_from_route: "Arrêt sur séquence d'arrêts n'appartient pas à la Route de cette Zone de contrainte."
routing_constraint_zones:
actions:
new: Ajouter une zone de contrainte
diff --git a/config/routes.rb b/config/routes.rb
index cbdc5cc07..a8c332fb8 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -123,6 +123,7 @@ ChouetteIhm::Application.routes.draw do
end
resources :vehicle_journey_imports
resources :vehicle_journey_exports
+ resources :stop_points, only: :index, controller: 'route_stop_points'
end
resources :routing_constraint_zones
end
diff --git a/db/migrate/20170405122823_rm_stop_areas_add_stop_points_to_routing_constraint_zone.rb b/db/migrate/20170405122823_rm_stop_areas_add_stop_points_to_routing_constraint_zone.rb
new file mode 100644
index 000000000..67bc2623c
--- /dev/null
+++ b/db/migrate/20170405122823_rm_stop_areas_add_stop_points_to_routing_constraint_zone.rb
@@ -0,0 +1,6 @@
+class RmStopAreasAddStopPointsToRoutingConstraintZone < ActiveRecord::Migration
+ def change
+ remove_column :routing_constraint_zones, :stop_area_ids, :integer, array: true
+ add_column :routing_constraint_zones, :stop_point_ids, :bigint, array: true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 04da0f8b6..d0d1e88c6 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -18,15 +18,15 @@ ActiveRecord::Schema.define(version: 20170410134931) do
enable_extension "postgis"
enable_extension "hstore"
- create_table "access_links", force: true do |t|
+ create_table "access_links", id: :bigserial, force: :cascade do |t|
t.integer "access_point_id", limit: 8
t.integer "stop_area_id", limit: 8
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "comment", limit: nil
- t.decimal "link_distance", precision: 19, scale: 2
+ t.string "creator_id"
+ t.string "name"
+ t.string "comment"
+ t.decimal "link_distance", precision: 19, scale: 2
t.boolean "lift_availability"
t.boolean "mobility_restricted_suitability"
t.boolean "stairs_availability"
@@ -34,77 +34,77 @@ ActiveRecord::Schema.define(version: 20170410134931) do
t.time "frequent_traveller_duration"
t.time "occasional_traveller_duration"
t.time "mobility_restricted_traveller_duration"
- t.string "link_type", limit: nil
+ t.string "link_type"
t.integer "int_user_needs"
- t.string "link_orientation", limit: nil
+ t.string "link_orientation"
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "access_links", ["objectid"], :name => "access_links_objectid_key", :unique => true
+ add_index "access_links", ["objectid"], name: "access_links_objectid_key", unique: true, using: :btree
- create_table "access_points", force: true do |t|
- t.string "objectid", limit: nil
+ create_table "access_points", id: :bigserial, force: :cascade do |t|
+ t.string "objectid"
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "comment", limit: nil
- t.decimal "longitude", precision: 19, scale: 16
- t.decimal "latitude", precision: 19, scale: 16
- t.string "long_lat_type", limit: nil
- t.string "country_code", limit: nil
- t.string "street_name", limit: nil
- t.string "contained_in", limit: nil
+ t.string "creator_id"
+ t.string "name"
+ t.string "comment"
+ t.decimal "longitude", precision: 19, scale: 16
+ t.decimal "latitude", precision: 19, scale: 16
+ t.string "long_lat_type"
+ t.string "country_code"
+ t.string "street_name"
+ t.string "contained_in"
t.time "openning_time"
t.time "closing_time"
- t.string "access_type", limit: nil
+ t.string "access_type"
t.boolean "lift_availability"
t.boolean "mobility_restricted_suitability"
t.boolean "stairs_availability"
t.integer "stop_area_id", limit: 8
- t.string "zip_code", limit: nil
- t.string "city_name", limit: nil
+ t.string "zip_code"
+ t.string "city_name"
t.text "import_xml"
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "access_points", ["objectid"], :name => "access_points_objectid_key", :unique => true
+ add_index "access_points", ["objectid"], name: "access_points_objectid_key", unique: true, using: :btree
- create_table "api_keys", force: true do |t|
+ create_table "api_keys", id: :bigserial, force: :cascade do |t|
t.integer "referential_id", limit: 8
- t.string "token", limit: nil
- t.string "name", limit: nil
+ t.string "token"
+ t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
- create_table "calendars", force: true do |t|
- t.string "name", limit: nil
- t.string "short_name", limit: nil
- t.daterange "date_ranges", array: true
- t.date "dates", array: true
+ create_table "calendars", id: :bigserial, force: :cascade do |t|
+ t.string "name"
+ t.string "short_name"
+ t.daterange "date_ranges", array: true
+ t.date "dates", array: true
t.boolean "shared"
t.integer "organisation_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "calendars", ["organisation_id"], :name => "index_calendars_on_organisation_id"
- add_index "calendars", ["short_name"], :name => "index_calendars_on_short_name", :unique => true
+ add_index "calendars", ["organisation_id"], name: "index_calendars_on_organisation_id", using: :btree
+ add_index "calendars", ["short_name"], name: "index_calendars_on_short_name", unique: true, using: :btree
- create_table "clean_up_results", force: true do |t|
- t.string "message_key", limit: nil
+ create_table "clean_up_results", id: :bigserial, force: :cascade do |t|
+ t.string "message_key"
t.hstore "message_attributs"
t.integer "clean_up_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "clean_up_results", ["clean_up_id"], :name => "index_clean_up_results_on_clean_up_id"
+ add_index "clean_up_results", ["clean_up_id"], name: "index_clean_up_results_on_clean_up_id", using: :btree
- create_table "clean_ups", force: true do |t|
- t.string "status", limit: nil
+ create_table "clean_ups", id: :bigserial, force: :cascade do |t|
+ t.string "status"
t.datetime "started_at"
t.datetime "ended_at"
t.integer "referential_id", limit: 8
@@ -114,43 +114,43 @@ ActiveRecord::Schema.define(version: 20170410134931) do
t.datetime "end_date"
end
- add_index "clean_ups", ["referential_id"], :name => "index_clean_ups_on_referential_id"
+ add_index "clean_ups", ["referential_id"], name: "index_clean_ups_on_referential_id", using: :btree
- create_table "companies", force: true do |t|
- t.string "objectid", limit: nil, null: false
+ create_table "companies", id: :bigserial, force: :cascade do |t|
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "short_name", limit: nil
- t.string "organizational_unit", limit: nil
- t.string "operating_department_name", limit: nil
- t.string "code", limit: nil
- t.string "phone", limit: nil
- t.string "fax", limit: nil
- t.string "email", limit: nil
- t.string "registration_number", limit: nil
- t.string "url", limit: nil
- t.string "time_zone", limit: nil
+ t.string "creator_id"
+ t.string "name"
+ t.string "short_name"
+ t.string "organizational_unit"
+ t.string "operating_department_name"
+ t.string "code"
+ t.string "phone"
+ t.string "fax"
+ t.string "email"
+ t.string "registration_number"
+ t.string "url"
+ t.string "time_zone"
t.integer "line_referential_id", limit: 8
t.text "import_xml"
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "companies", ["line_referential_id"], :name => "index_companies_on_line_referential_id"
- add_index "companies", ["objectid"], :name => "companies_objectid_key", :unique => true
- add_index "companies", ["registration_number"], :name => "companies_registration_number_key"
+ add_index "companies", ["line_referential_id"], name: "index_companies_on_line_referential_id", using: :btree
+ add_index "companies", ["objectid"], name: "companies_objectid_key", unique: true, using: :btree
+ add_index "companies", ["registration_number"], name: "companies_registration_number_key", using: :btree
- create_table "connection_links", force: true do |t|
+ create_table "connection_links", id: :bigserial, force: :cascade do |t|
t.integer "departure_id", limit: 8
t.integer "arrival_id", limit: 8
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "comment", limit: nil
- t.decimal "link_distance", precision: 19, scale: 2
- t.string "link_type", limit: nil
+ t.string "creator_id"
+ t.string "name"
+ t.string "comment"
+ t.decimal "link_distance", precision: 19, scale: 2
+ t.string "link_type"
t.time "default_duration"
t.time "frequent_traveller_duration"
t.time "occasional_traveller_duration"
@@ -163,89 +163,89 @@ ActiveRecord::Schema.define(version: 20170410134931) do
t.datetime "updated_at"
end
- add_index "connection_links", ["objectid"], :name => "connection_links_objectid_key", :unique => true
+ add_index "connection_links", ["objectid"], name: "connection_links_objectid_key", unique: true, using: :btree
- create_table "exports", force: true do |t|
+ create_table "exports", id: :bigserial, force: :cascade do |t|
t.integer "referential_id", limit: 8
- t.string "status", limit: nil
- t.string "type", limit: nil
- t.string "options", limit: nil
+ t.string "status"
+ t.string "type"
+ t.string "options"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "references_type", limit: nil
- t.string "reference_ids", limit: nil
+ t.string "references_type"
+ t.string "reference_ids"
end
- add_index "exports", ["referential_id"], :name => "index_exports_on_referential_id"
+ add_index "exports", ["referential_id"], name: "index_exports_on_referential_id", using: :btree
- create_table "facilities", force: true do |t|
+ create_table "facilities", id: :bigserial, force: :cascade do |t|
t.integer "stop_area_id", limit: 8
t.integer "line_id", limit: 8
t.integer "connection_link_id", limit: 8
t.integer "stop_point_id", limit: 8
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
t.datetime "creation_time"
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "comment", limit: nil
- t.string "description", limit: nil
+ t.string "creator_id"
+ t.string "name"
+ t.string "comment"
+ t.string "description"
t.boolean "free_access"
- t.decimal "longitude", precision: 19, scale: 16
- t.decimal "latitude", precision: 19, scale: 16
- t.string "long_lat_type", limit: nil
- t.decimal "x", precision: 19, scale: 2
- t.decimal "y", precision: 19, scale: 2
- t.string "projection_type", limit: nil
- t.string "country_code", limit: nil
- t.string "street_name", limit: nil
- t.string "contained_in", limit: nil
+ t.decimal "longitude", precision: 19, scale: 16
+ t.decimal "latitude", precision: 19, scale: 16
+ t.string "long_lat_type"
+ t.decimal "x", precision: 19, scale: 2
+ t.decimal "y", precision: 19, scale: 2
+ t.string "projection_type"
+ t.string "country_code"
+ t.string "street_name"
+ t.string "contained_in"
end
- add_index "facilities", ["objectid"], :name => "facilities_objectid_key", :unique => true
+ add_index "facilities", ["objectid"], name: "facilities_objectid_key", unique: true, using: :btree
- create_table "facilities_features", id: false, force: true do |t|
+ create_table "facilities_features", id: false, force: :cascade do |t|
t.integer "facility_id", limit: 8
t.integer "choice_code"
end
- create_table "footnotes", force: true do |t|
+ create_table "footnotes", id: :bigserial, force: :cascade do |t|
t.integer "line_id", limit: 8
- t.string "code", limit: nil
- t.string "label", limit: nil
+ t.string "code"
+ t.string "label"
t.datetime "created_at"
t.datetime "updated_at"
end
- create_table "footnotes_vehicle_journeys", id: false, force: true do |t|
+ create_table "footnotes_vehicle_journeys", id: false, force: :cascade do |t|
t.integer "vehicle_journey_id", limit: 8
t.integer "footnote_id", limit: 8
end
- create_table "group_of_lines", force: true do |t|
- t.string "objectid", limit: nil, null: false
+ create_table "group_of_lines", id: :bigserial, force: :cascade do |t|
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "comment", limit: nil
- t.string "registration_number", limit: nil
+ t.string "creator_id"
+ t.string "name"
+ t.string "comment"
+ t.string "registration_number"
t.integer "line_referential_id", limit: 8
t.text "import_xml"
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "group_of_lines", ["line_referential_id"], :name => "index_group_of_lines_on_line_referential_id"
- add_index "group_of_lines", ["objectid"], :name => "group_of_lines_objectid_key", :unique => true
+ add_index "group_of_lines", ["line_referential_id"], name: "index_group_of_lines_on_line_referential_id", using: :btree
+ add_index "group_of_lines", ["objectid"], name: "group_of_lines_objectid_key", unique: true, using: :btree
- create_table "group_of_lines_lines", id: false, force: true do |t|
+ create_table "group_of_lines_lines", id: false, force: :cascade do |t|
t.integer "group_of_line_id", limit: 8
t.integer "line_id", limit: 8
end
- create_table "import_messages", force: true do |t|
+ create_table "import_messages", id: :bigserial, force: :cascade do |t|
t.integer "criticity"
- t.string "message_key", limit: nil
+ t.string "message_key"
t.hstore "message_attributs"
t.integer "import_id", limit: 8
t.integer "resource_id", limit: 8
@@ -254,42 +254,42 @@ ActiveRecord::Schema.define(version: 20170410134931) do
t.hstore "resource_attributes"
end
- add_index "import_messages", ["import_id"], :name => "index_import_messages_on_import_id"
- add_index "import_messages", ["resource_id"], :name => "index_import_messages_on_resource_id"
+ add_index "import_messages", ["import_id"], name: "index_import_messages_on_import_id", using: :btree
+ add_index "import_messages", ["resource_id"], name: "index_import_messages_on_resource_id", using: :btree
- create_table "import_resources", force: true do |t|
+ create_table "import_resources", id: :bigserial, force: :cascade do |t|
t.integer "import_id", limit: 8
- t.string "status", limit: nil
+ t.string "status"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "type", limit: nil
- t.string "reference", limit: nil
- t.string "name", limit: nil
+ t.string "type"
+ t.string "reference"
+ t.string "name"
t.hstore "metrics"
end
- add_index "import_resources", ["import_id"], :name => "index_import_resources_on_import_id"
+ add_index "import_resources", ["import_id"], name: "index_import_resources_on_import_id", using: :btree
- create_table "imports", force: true do |t|
- t.string "status", limit: nil
- t.string "current_step_id", limit: nil
+ create_table "imports", id: :bigserial, force: :cascade do |t|
+ t.string "status"
+ t.string "current_step_id"
t.float "current_step_progress"
t.integer "workbench_id", limit: 8
t.integer "referential_id", limit: 8
- t.string "name", limit: nil
+ t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "file", limit: nil
+ t.string "file"
t.datetime "started_at"
t.datetime "ended_at"
- t.string "token_download", limit: nil
- t.string "type", limit: nil
+ t.string "token_download"
+ t.string "type"
end
- add_index "imports", ["referential_id"], :name => "index_imports_on_referential_id"
- add_index "imports", ["workbench_id"], :name => "index_imports_on_workbench_id"
+ add_index "imports", ["referential_id"], name: "index_imports_on_referential_id", using: :btree
+ add_index "imports", ["workbench_id"], name: "index_imports_on_workbench_id", using: :btree
- create_table "journey_frequencies", force: true do |t|
+ create_table "journey_frequencies", id: :bigserial, force: :cascade do |t|
t.integer "vehicle_journey_id", limit: 8
t.time "scheduled_headway_interval", null: false
t.time "first_departure_time", null: false
@@ -300,10 +300,10 @@ ActiveRecord::Schema.define(version: 20170410134931) do
t.integer "timeband_id", limit: 8
end
- add_index "journey_frequencies", ["timeband_id"], :name => "index_journey_frequencies_on_timeband_id"
- add_index "journey_frequencies", ["vehicle_journey_id"], :name => "index_journey_frequencies_on_vehicle_journey_id"
+ add_index "journey_frequencies", ["timeband_id"], name: "index_journey_frequencies_on_timeband_id", using: :btree
+ add_index "journey_frequencies", ["vehicle_journey_id"], name: "index_journey_frequencies_on_vehicle_journey_id", using: :btree
- create_table "journey_pattern_sections", force: true do |t|
+ create_table "journey_pattern_sections", id: :bigserial, force: :cascade do |t|
t.integer "journey_pattern_id", limit: 8, null: false
t.integer "route_section_id", limit: 8, null: false
t.integer "rank", null: false
@@ -311,155 +311,155 @@ ActiveRecord::Schema.define(version: 20170410134931) do
t.datetime "updated_at"
end
- add_index "journey_pattern_sections", ["journey_pattern_id", "route_section_id", "rank"], :name => "index_jps_on_journey_pattern_id_and_route_section_id_and_rank", :unique => true
- add_index "journey_pattern_sections", ["journey_pattern_id"], :name => "index_journey_pattern_sections_on_journey_pattern_id"
- add_index "journey_pattern_sections", ["route_section_id"], :name => "index_journey_pattern_sections_on_route_section_id"
+ add_index "journey_pattern_sections", ["journey_pattern_id", "route_section_id", "rank"], name: "index_jps_on_journey_pattern_id_and_route_section_id_and_rank", unique: true, using: :btree
+ add_index "journey_pattern_sections", ["journey_pattern_id"], name: "index_journey_pattern_sections_on_journey_pattern_id", using: :btree
+ add_index "journey_pattern_sections", ["route_section_id"], name: "index_journey_pattern_sections_on_route_section_id", using: :btree
- create_table "journey_patterns", force: true do |t|
+ create_table "journey_patterns", id: :bigserial, force: :cascade do |t|
t.integer "route_id", limit: 8
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "comment", limit: nil
- t.string "registration_number", limit: nil
- t.string "published_name", limit: nil
+ t.string "creator_id"
+ t.string "name"
+ t.string "comment"
+ t.string "registration_number"
+ t.string "published_name"
t.integer "departure_stop_point_id", limit: 8
t.integer "arrival_stop_point_id", limit: 8
- t.integer "section_status", default: 0, null: false
+ t.integer "section_status", default: 0, null: false
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "journey_patterns", ["objectid"], :name => "journey_patterns_objectid_key", :unique => true
+ add_index "journey_patterns", ["objectid"], name: "journey_patterns_objectid_key", unique: true, using: :btree
- create_table "journey_patterns_stop_points", id: false, force: true do |t|
+ create_table "journey_patterns_stop_points", id: false, force: :cascade do |t|
t.integer "journey_pattern_id", limit: 8
t.integer "stop_point_id", limit: 8
end
- add_index "journey_patterns_stop_points", ["journey_pattern_id"], :name => "index_journey_pattern_id_on_journey_patterns_stop_points"
+ add_index "journey_patterns_stop_points", ["journey_pattern_id"], name: "index_journey_pattern_id_on_journey_patterns_stop_points", using: :btree
- create_table "line_referential_memberships", force: true do |t|
+ create_table "line_referential_memberships", id: :bigserial, force: :cascade do |t|
t.integer "organisation_id", limit: 8
t.integer "line_referential_id", limit: 8
t.boolean "owner"
end
- create_table "line_referential_sync_messages", force: true do |t|
+ create_table "line_referential_sync_messages", id: :bigserial, force: :cascade do |t|
t.integer "criticity"
- t.string "message_key", limit: nil
+ t.string "message_key"
t.hstore "message_attributs"
t.integer "line_referential_sync_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "line_referential_sync_messages", ["line_referential_sync_id"], :name => "line_referential_sync_id"
+ add_index "line_referential_sync_messages", ["line_referential_sync_id"], name: "line_referential_sync_id", using: :btree
- create_table "line_referential_syncs", force: true do |t|
+ create_table "line_referential_syncs", id: :bigserial, force: :cascade do |t|
t.integer "line_referential_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "started_at"
t.datetime "ended_at"
- t.string "status", limit: nil
+ t.string "status"
end
- add_index "line_referential_syncs", ["line_referential_id"], :name => "index_line_referential_syncs_on_line_referential_id"
+ add_index "line_referential_syncs", ["line_referential_id"], name: "index_line_referential_syncs_on_line_referential_id", using: :btree
- create_table "line_referentials", force: true do |t|
- t.string "name", limit: nil
+ create_table "line_referentials", id: :bigserial, force: :cascade do |t|
+ t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
- t.integer "sync_interval", default: 1
+ t.integer "sync_interval", default: 1
end
- create_table "lines", force: true do |t|
+ create_table "lines", id: :bigserial, force: :cascade do |t|
t.integer "network_id", limit: 8
t.integer "company_id", limit: 8
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "number", limit: nil
- t.string "published_name", limit: nil
- t.string "transport_mode", limit: nil
- t.string "registration_number", limit: nil
- t.string "comment", limit: nil
+ t.string "creator_id"
+ t.string "name"
+ t.string "number"
+ t.string "published_name"
+ t.string "transport_mode"
+ t.string "registration_number"
+ t.string "comment"
t.boolean "mobility_restricted_suitability"
t.integer "int_user_needs"
t.boolean "flexible_service"
- t.string "url", limit: nil
+ t.string "url"
t.string "color", limit: 6
t.string "text_color", limit: 6
- t.string "stable_id", limit: nil
+ t.string "stable_id"
t.integer "line_referential_id", limit: 8
- t.boolean "deactivated", default: false
+ t.boolean "deactivated", default: false
t.text "import_xml"
- t.string "transport_submode", limit: nil
- t.integer "secondary_company_ids", limit: 8, array: true
+ t.string "transport_submode"
+ t.integer "secondary_company_ids", limit: 8, array: true
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "lines", ["line_referential_id"], :name => "index_lines_on_line_referential_id"
- add_index "lines", ["objectid"], :name => "lines_objectid_key", :unique => true
- add_index "lines", ["registration_number"], :name => "lines_registration_number_key"
- add_index "lines", ["secondary_company_ids"], :name => "index_lines_on_secondary_company_ids"
+ add_index "lines", ["line_referential_id"], name: "index_lines_on_line_referential_id", using: :btree
+ add_index "lines", ["objectid"], name: "lines_objectid_key", unique: true, using: :btree
+ add_index "lines", ["registration_number"], name: "lines_registration_number_key", using: :btree
+ add_index "lines", ["secondary_company_ids"], name: "index_lines_on_secondary_company_ids", using: :gin
- create_table "networks", force: true do |t|
- t.string "objectid", limit: nil, null: false
+ create_table "networks", id: :bigserial, force: :cascade do |t|
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
+ t.string "creator_id"
t.date "version_date"
- t.string "description", limit: nil
- t.string "name", limit: nil
- t.string "registration_number", limit: nil
- t.string "source_name", limit: nil
- t.string "source_type", limit: nil
- t.string "source_identifier", limit: nil
- t.string "comment", limit: nil
+ t.string "description"
+ t.string "name"
+ t.string "registration_number"
+ t.string "source_name"
+ t.string "source_type"
+ t.string "source_identifier"
+ t.string "comment"
t.text "import_xml"
t.integer "line_referential_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "networks", ["line_referential_id"], :name => "index_networks_on_line_referential_id"
- add_index "networks", ["objectid"], :name => "networks_objectid_key", :unique => true
- add_index "networks", ["registration_number"], :name => "networks_registration_number_key"
+ add_index "networks", ["line_referential_id"], name: "index_networks_on_line_referential_id", using: :btree
+ add_index "networks", ["objectid"], name: "networks_objectid_key", unique: true, using: :btree
+ add_index "networks", ["registration_number"], name: "networks_registration_number_key", using: :btree
- create_table "organisations", force: true do |t|
- t.string "name", limit: nil
+ create_table "organisations", id: :bigserial, force: :cascade do |t|
+ t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "data_format", limit: nil, default: "neptune"
- t.string "code", limit: nil
+ t.string "data_format", default: "neptune"
+ t.string "code"
t.datetime "synced_at"
t.hstore "sso_attributes"
end
- add_index "organisations", ["code"], :name => "index_organisations_on_code", :unique => true
+ add_index "organisations", ["code"], name: "index_organisations_on_code", unique: true, using: :btree
- create_table "pt_links", force: true do |t|
+ create_table "pt_links", id: :bigserial, force: :cascade do |t|
t.integer "start_of_link_id", limit: 8
t.integer "end_of_link_id", limit: 8
t.integer "route_id", limit: 8
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "comment", limit: nil
- t.decimal "link_distance", precision: 19, scale: 2
+ t.string "creator_id"
+ t.string "name"
+ t.string "comment"
+ t.decimal "link_distance", precision: 19, scale: 2
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "pt_links", ["objectid"], :name => "pt_links_objectid_key", :unique => true
+ add_index "pt_links", ["objectid"], name: "pt_links_objectid_key", unique: true, using: :btree
- create_table "referential_clonings", force: true do |t|
- t.string "status", limit: nil
+ create_table "referential_clonings", id: :bigserial, force: :cascade do |t|
+ t.string "status"
t.datetime "started_at"
t.datetime "ended_at"
t.integer "source_referential_id", limit: 8
@@ -468,10 +468,10 @@ ActiveRecord::Schema.define(version: 20170410134931) do
t.datetime "updated_at"
end
- add_index "referential_clonings", ["source_referential_id"], :name => "index_referential_clonings_on_source_referential_id"
- add_index "referential_clonings", ["target_referential_id"], :name => "index_referential_clonings_on_target_referential_id"
+ add_index "referential_clonings", ["source_referential_id"], name: "index_referential_clonings_on_source_referential_id", using: :btree
+ add_index "referential_clonings", ["target_referential_id"], name: "index_referential_clonings_on_target_referential_id", using: :btree
- create_table "referential_metadata", force: true do |t|
+ create_table "referential_metadata", id: :bigserial, force: :cascade do |t|
t.integer "referential_id", limit: 8
t.integer "line_ids", limit: 8, array: true
t.integer "referential_source_id", limit: 8
@@ -480,227 +480,227 @@ ActiveRecord::Schema.define(version: 20170410134931) do
t.daterange "periodes", array: true
end
- add_index "referential_metadata", ["line_ids"], :name => "index_referential_metadata_on_line_ids"
- add_index "referential_metadata", ["referential_id"], :name => "index_referential_metadata_on_referential_id"
- add_index "referential_metadata", ["referential_source_id"], :name => "index_referential_metadata_on_referential_source_id"
+ add_index "referential_metadata", ["line_ids"], name: "index_referential_metadata_on_line_ids", using: :gin
+ add_index "referential_metadata", ["referential_id"], name: "index_referential_metadata_on_referential_id", using: :btree
+ add_index "referential_metadata", ["referential_source_id"], name: "index_referential_metadata_on_referential_source_id", using: :btree
- create_table "referentials", force: true do |t|
- t.string "name", limit: nil
- t.string "slug", limit: nil
+ create_table "referentials", id: :bigserial, force: :cascade do |t|
+ t.string "name"
+ t.string "slug"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "prefix", limit: nil
- t.string "projection_type", limit: nil
- t.string "time_zone", limit: nil
- t.string "bounds", limit: nil
+ t.string "prefix"
+ t.string "projection_type"
+ t.string "time_zone"
+ t.string "bounds"
t.integer "organisation_id", limit: 8
t.text "geographical_bounds"
t.integer "user_id", limit: 8
- t.string "user_name", limit: nil
- t.string "data_format", limit: nil
+ t.string "user_name"
+ t.string "data_format"
t.integer "line_referential_id", limit: 8
t.integer "stop_area_referential_id", limit: 8
t.integer "workbench_id", limit: 8
t.datetime "archived_at"
t.integer "created_from_id", limit: 8
- t.boolean "ready", default: false
+ t.boolean "ready", default: false
end
- add_index "referentials", ["created_from_id"], :name => "index_referentials_on_created_from_id"
+ add_index "referentials", ["created_from_id"], name: "index_referentials_on_created_from_id", using: :btree
- create_table "route_sections", force: true do |t|
+ create_table "route_sections", id: :bigserial, force: :cascade do |t|
t.integer "departure_id", limit: 8
t.integer "arrival_id", limit: 8
- t.spatial "input_geometry", limit: {:srid=>4326, :type=>"line_string"}
- t.spatial "processed_geometry", limit: {:srid=>4326, :type=>"line_string"}
- t.string "objectid", limit: nil, null: false
+ t.geometry "input_geometry", limit: {:srid=>4326, :type=>"line_string"}
+ t.geometry "processed_geometry", limit: {:srid=>4326, :type=>"line_string"}
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
+ t.string "creator_id"
t.float "distance"
t.boolean "no_processing"
t.datetime "created_at"
t.datetime "updated_at"
end
- create_table "routes", force: true do |t|
+ create_table "routes", id: :bigserial, force: :cascade do |t|
t.integer "line_id", limit: 8
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "comment", limit: nil
+ t.string "creator_id"
+ t.string "name"
+ t.string "comment"
t.integer "opposite_route_id", limit: 8
- t.string "published_name", limit: nil
- t.string "number", limit: nil
- t.string "direction", limit: nil
- t.string "wayback", limit: nil
+ t.string "published_name"
+ t.string "number"
+ t.string "direction"
+ t.string "wayback"
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "routes", ["objectid"], :name => "routes_objectid_key", :unique => true
+ add_index "routes", ["objectid"], name: "routes_objectid_key", unique: true, using: :btree
- create_table "routing_constraint_zones", force: true do |t|
- t.string "name", limit: nil
- t.integer "stop_area_ids", array: true
+ create_table "routing_constraint_zones", id: :bigserial, force: :cascade do |t|
+ t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
+ t.string "creator_id"
t.integer "route_id", limit: 8
+ t.integer "stop_point_ids", limit: 8, array: true
end
- create_table "routing_constraints_lines", id: false, force: true do |t|
+ create_table "routing_constraints_lines", id: false, force: :cascade do |t|
t.integer "stop_area_id", limit: 8
t.integer "line_id", limit: 8
end
- create_table "rule_parameter_sets", force: true do |t|
+ create_table "rule_parameter_sets", id: :bigserial, force: :cascade do |t|
t.text "parameters"
- t.string "name", limit: nil
+ t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "organisation_id", limit: 8
end
- create_table "stop_area_referential_memberships", force: true do |t|
+ create_table "stop_area_referential_memberships", id: :bigserial, force: :cascade do |t|
t.integer "organisation_id", limit: 8
t.integer "stop_area_referential_id", limit: 8
t.boolean "owner"
end
- create_table "stop_area_referential_sync_messages", force: true do |t|
+ create_table "stop_area_referential_sync_messages", id: :bigserial, force: :cascade do |t|
t.integer "criticity"
- t.string "message_key", limit: nil
+ t.string "message_key"
t.hstore "message_attributs"
t.integer "stop_area_referential_sync_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "stop_area_referential_sync_messages", ["stop_area_referential_sync_id"], :name => "stop_area_referential_sync_id"
+ add_index "stop_area_referential_sync_messages", ["stop_area_referential_sync_id"], name: "stop_area_referential_sync_id", using: :btree
- create_table "stop_area_referential_syncs", force: true do |t|
+ create_table "stop_area_referential_syncs", id: :bigserial, force: :cascade do |t|
t.integer "stop_area_referential_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "ended_at"
t.datetime "started_at"
- t.string "status", limit: nil
+ t.string "status"
end
- add_index "stop_area_referential_syncs", ["stop_area_referential_id"], :name => "index_stop_area_referential_syncs_on_stop_area_referential_id"
+ add_index "stop_area_referential_syncs", ["stop_area_referential_id"], name: "index_stop_area_referential_syncs_on_stop_area_referential_id", using: :btree
- create_table "stop_area_referentials", force: true do |t|
- t.string "name", limit: nil
+ create_table "stop_area_referentials", id: :bigserial, force: :cascade do |t|
+ t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
- create_table "stop_areas", force: true do |t|
+ create_table "stop_areas", id: :bigserial, force: :cascade do |t|
t.integer "parent_id", limit: 8
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.string "comment", limit: nil
- t.string "area_type", limit: nil
- t.string "registration_number", limit: nil
- t.string "nearest_topic_name", limit: nil
+ t.string "creator_id"
+ t.string "name"
+ t.string "comment"
+ t.string "area_type"
+ t.string "registration_number"
+ t.string "nearest_topic_name"
t.integer "fare_code"
- t.decimal "longitude", precision: 19, scale: 16
- t.decimal "latitude", precision: 19, scale: 16
- t.string "long_lat_type", limit: nil
- t.string "country_code", limit: nil
- t.string "street_name", limit: nil
+ t.decimal "longitude", precision: 19, scale: 16
+ t.decimal "latitude", precision: 19, scale: 16
+ t.string "long_lat_type"
+ t.string "country_code"
+ t.string "street_name"
t.boolean "mobility_restricted_suitability"
t.boolean "stairs_availability"
t.boolean "lift_availability"
t.integer "int_user_needs"
- t.string "zip_code", limit: nil
- t.string "city_name", limit: nil
- t.string "url", limit: nil
- t.string "time_zone", limit: nil
+ t.string "zip_code"
+ t.string "city_name"
+ t.string "url"
+ t.string "time_zone"
t.integer "stop_area_referential_id", limit: 8
- t.string "status", limit: nil
+ t.string "status"
t.text "import_xml"
t.datetime "deleted_at"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "stif_type", limit: nil
+ t.string "stif_type"
end
- add_index "stop_areas", ["name"], :name => "index_stop_areas_on_name"
- add_index "stop_areas", ["objectid"], :name => "stop_areas_objectid_key", :unique => true
- add_index "stop_areas", ["parent_id"], :name => "index_stop_areas_on_parent_id"
- add_index "stop_areas", ["stop_area_referential_id"], :name => "index_stop_areas_on_stop_area_referential_id"
+ add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree
+ add_index "stop_areas", ["objectid"], name: "stop_areas_objectid_key", unique: true, using: :btree
+ add_index "stop_areas", ["parent_id"], name: "index_stop_areas_on_parent_id", using: :btree
+ add_index "stop_areas", ["stop_area_referential_id"], name: "index_stop_areas_on_stop_area_referential_id", using: :btree
- create_table "stop_areas_stop_areas", id: false, force: true do |t|
+ create_table "stop_areas_stop_areas", id: false, force: :cascade do |t|
t.integer "child_id", limit: 8
t.integer "parent_id", limit: 8
end
- create_table "stop_points", force: true do |t|
+ create_table "stop_points", id: :bigserial, force: :cascade do |t|
t.integer "route_id", limit: 8
t.integer "stop_area_id", limit: 8
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
+ t.string "creator_id"
t.integer "position"
- t.string "for_boarding", limit: nil
- t.string "for_alighting", limit: nil
+ t.string "for_boarding"
+ t.string "for_alighting"
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "stop_points", ["objectid"], :name => "stop_points_objectid_key", :unique => true
+ add_index "stop_points", ["objectid"], name: "stop_points_objectid_key", unique: true, using: :btree
- create_table "taggings", force: true do |t|
+ create_table "taggings", id: :bigserial, force: :cascade do |t|
t.integer "tag_id", limit: 8
t.integer "taggable_id", limit: 8
- t.string "taggable_type", limit: nil
+ t.string "taggable_type"
t.integer "tagger_id", limit: 8
- t.string "tagger_type", limit: nil
+ t.string "tagger_type"
t.string "context", limit: 128
t.datetime "created_at"
end
- add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], :name => "taggings_idx", :unique => true
- add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
+ add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree
+ add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
- create_table "tags", force: true do |t|
- t.string "name", limit: nil
- t.integer "taggings_count", default: 0
+ create_table "tags", id: :bigserial, force: :cascade do |t|
+ t.string "name"
+ t.integer "taggings_count", default: 0
end
- add_index "tags", ["name"], :name => "index_tags_on_name", :unique => true
+ add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
- create_table "time_table_dates", force: true do |t|
+ create_table "time_table_dates", id: :bigserial, force: :cascade do |t|
t.integer "time_table_id", limit: 8, null: false
t.date "date"
t.integer "position", null: false
t.boolean "in_out"
end
- add_index "time_table_dates", ["time_table_id"], :name => "index_time_table_dates_on_time_table_id"
+ add_index "time_table_dates", ["time_table_id"], name: "index_time_table_dates_on_time_table_id", using: :btree
- create_table "time_table_periods", force: true do |t|
+ create_table "time_table_periods", id: :bigserial, force: :cascade do |t|
t.integer "time_table_id", limit: 8, null: false
t.date "period_start"
t.date "period_end"
t.integer "position", null: false
end
- add_index "time_table_periods", ["time_table_id"], :name => "index_time_table_periods_on_time_table_id"
+ add_index "time_table_periods", ["time_table_id"], name: "index_time_table_periods_on_time_table_id", using: :btree
- create_table "time_tables", force: true do |t|
- t.string "objectid", limit: nil, null: false
- t.integer "object_version", limit: 8, default: 1
- t.string "creator_id", limit: nil
- t.string "version", limit: nil
- t.string "comment", limit: nil
- t.integer "int_day_types", default: 0
+ create_table "time_tables", id: :bigserial, force: :cascade do |t|
+ t.string "objectid", null: false
+ t.integer "object_version", limit: 8, default: 1
+ t.string "creator_id"
+ t.string "version"
+ t.string "comment"
+ t.integer "int_day_types", default: 0
t.date "start_date"
t.date "end_date"
t.integer "calendar_id", limit: 8
@@ -709,111 +709,111 @@ ActiveRecord::Schema.define(version: 20170410134931) do
t.string "color"
end
- add_index "time_tables", ["calendar_id"], :name => "index_time_tables_on_calendar_id"
- add_index "time_tables", ["objectid"], :name => "time_tables_objectid_key", :unique => true
+ add_index "time_tables", ["calendar_id"], name: "index_time_tables_on_calendar_id", using: :btree
+ add_index "time_tables", ["objectid"], name: "time_tables_objectid_key", unique: true, using: :btree
- create_table "time_tables_vehicle_journeys", id: false, force: true do |t|
+ create_table "time_tables_vehicle_journeys", id: false, force: :cascade do |t|
t.integer "time_table_id", limit: 8
t.integer "vehicle_journey_id", limit: 8
end
- add_index "time_tables_vehicle_journeys", ["time_table_id"], :name => "index_time_tables_vehicle_journeys_on_time_table_id"
- add_index "time_tables_vehicle_journeys", ["vehicle_journey_id"], :name => "index_time_tables_vehicle_journeys_on_vehicle_journey_id"
+ add_index "time_tables_vehicle_journeys", ["time_table_id"], name: "index_time_tables_vehicle_journeys_on_time_table_id", using: :btree
+ add_index "time_tables_vehicle_journeys", ["vehicle_journey_id"], name: "index_time_tables_vehicle_journeys_on_vehicle_journey_id", using: :btree
- create_table "timebands", force: true do |t|
- t.string "objectid", limit: nil, null: false
+ create_table "timebands", id: :bigserial, force: :cascade do |t|
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "name", limit: nil
- t.time "start_time", null: false
- t.time "end_time", null: false
+ t.string "creator_id"
+ t.string "name"
+ t.time "start_time", null: false
+ t.time "end_time", null: false
t.datetime "created_at"
t.datetime "updated_at"
end
- create_table "users", force: true do |t|
- t.string "email", limit: nil, default: "", null: false
- t.string "encrypted_password", limit: nil, default: ""
- t.string "reset_password_token", limit: nil
+ create_table "users", id: :bigserial, force: :cascade do |t|
+ t.string "email", default: "", null: false
+ t.string "encrypted_password", default: ""
+ t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
- t.integer "sign_in_count", default: 0
+ t.integer "sign_in_count", default: 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
- t.string "current_sign_in_ip", limit: nil
- t.string "last_sign_in_ip", limit: nil
+ t.string "current_sign_in_ip"
+ t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "organisation_id", limit: 8
- t.string "name", limit: nil
- t.string "confirmation_token", limit: nil
+ t.string "name"
+ t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
- t.string "unconfirmed_email", limit: nil
- t.integer "failed_attempts", default: 0
- t.string "unlock_token", limit: nil
+ t.string "unconfirmed_email"
+ t.integer "failed_attempts", default: 0
+ t.string "unlock_token"
t.datetime "locked_at"
- t.string "authentication_token", limit: nil
- t.string "invitation_token", limit: nil
+ t.string "authentication_token"
+ t.string "invitation_token"
t.datetime "invitation_sent_at"
t.datetime "invitation_accepted_at"
t.integer "invitation_limit"
t.integer "invited_by_id", limit: 8
- t.string "invited_by_type", limit: nil
+ t.string "invited_by_type"
t.datetime "invitation_created_at"
- t.string "username", limit: nil
+ t.string "username"
t.datetime "synced_at"
- t.string "permissions", limit: nil, array: true
+ t.string "permissions", array: true
end
- add_index "users", ["email"], :name => "index_users_on_email", :unique => true
- add_index "users", ["invitation_token"], :name => "index_users_on_invitation_token", :unique => true
- add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
- add_index "users", ["username"], :name => "index_users_on_username", :unique => true
+ add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
+ add_index "users", ["invitation_token"], name: "index_users_on_invitation_token", unique: true, using: :btree
+ add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
+ add_index "users", ["username"], name: "index_users_on_username", unique: true, using: :btree
- create_table "vehicle_journey_at_stops", force: true do |t|
+ create_table "vehicle_journey_at_stops", id: :bigserial, force: :cascade do |t|
t.integer "vehicle_journey_id", limit: 8
t.integer "stop_point_id", limit: 8
- t.string "connecting_service_id", limit: nil
- t.string "boarding_alighting_possibility", limit: nil
+ t.string "connecting_service_id"
+ t.string "boarding_alighting_possibility"
t.time "arrival_time"
t.time "departure_time"
- t.string "for_boarding", limit: nil
- t.string "for_alighting", limit: nil
+ t.string "for_boarding"
+ t.string "for_alighting"
t.integer "departure_day_offset"
t.integer "arrival_day_offset"
end
- add_index "vehicle_journey_at_stops", ["stop_point_id"], :name => "index_vehicle_journey_at_stops_on_stop_pointid"
- add_index "vehicle_journey_at_stops", ["vehicle_journey_id"], :name => "index_vehicle_journey_at_stops_on_vehicle_journey_id"
+ add_index "vehicle_journey_at_stops", ["stop_point_id"], name: "index_vehicle_journey_at_stops_on_stop_pointid", using: :btree
+ add_index "vehicle_journey_at_stops", ["vehicle_journey_id"], name: "index_vehicle_journey_at_stops_on_vehicle_journey_id", using: :btree
- create_table "vehicle_journeys", force: true do |t|
+ create_table "vehicle_journeys", id: :bigserial, force: :cascade do |t|
t.integer "route_id", limit: 8
t.integer "journey_pattern_id", limit: 8
t.integer "company_id", limit: 8
- t.string "objectid", limit: nil, null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
- t.string "creator_id", limit: nil
- t.string "comment", limit: nil
- t.string "status_value", limit: nil
- t.string "transport_mode", limit: nil
- t.string "published_journey_name", limit: nil
- t.string "published_journey_identifier", limit: nil
- t.string "facility", limit: nil
- t.string "vehicle_type_identifier", limit: nil
+ t.string "creator_id"
+ t.string "comment"
+ t.string "status_value"
+ t.string "transport_mode"
+ t.string "published_journey_name"
+ t.string "published_journey_identifier"
+ t.string "facility"
+ t.string "vehicle_type_identifier"
t.integer "number", limit: 8
t.boolean "mobility_restricted_suitability"
t.boolean "flexible_service"
- t.integer "journey_category", default: 0, null: false
+ t.integer "journey_category", default: 0, null: false
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "vehicle_journeys", ["objectid"], :name => "vehicle_journeys_objectid_key", :unique => true
- add_index "vehicle_journeys", ["route_id"], :name => "index_vehicle_journeys_on_route_id"
+ add_index "vehicle_journeys", ["objectid"], name: "vehicle_journeys_objectid_key", unique: true, using: :btree
+ add_index "vehicle_journeys", ["route_id"], name: "index_vehicle_journeys_on_route_id", using: :btree
- create_table "workbenches", force: true do |t|
- t.string "name", limit: nil
+ create_table "workbenches", id: :bigserial, force: :cascade do |t|
+ t.string "name"
t.integer "organisation_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
@@ -821,49 +821,33 @@ ActiveRecord::Schema.define(version: 20170410134931) do
t.integer "stop_area_referential_id", limit: 8
end
- add_index "workbenches", ["line_referential_id"], :name => "index_workbenches_on_line_referential_id"
- add_index "workbenches", ["organisation_id"], :name => "index_workbenches_on_organisation_id"
- add_index "workbenches", ["stop_area_referential_id"], :name => "index_workbenches_on_stop_area_referential_id"
+ add_index "workbenches", ["line_referential_id"], name: "index_workbenches_on_line_referential_id", using: :btree
+ add_index "workbenches", ["organisation_id"], name: "index_workbenches_on_organisation_id", using: :btree
+ add_index "workbenches", ["stop_area_referential_id"], name: "index_workbenches_on_stop_area_referential_id", using: :btree
- Foreigner.load
add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey"
-
- add_foreign_key "group_of_lines_lines", "group_of_lines", name: "groupofline_group_fkey", dependent: :delete
-
- add_foreign_key "journey_frequencies", "timebands", name: "fk_rails_60bb6f7bd3", dependent: :nullify
- add_foreign_key "journey_frequencies", "vehicle_journeys", name: "fk_rails_d322c5d659", dependent: :nullify
-
- add_foreign_key "journey_pattern_sections", "journey_patterns", name: "fk_rails_73ae46b20f", dependent: :delete
- add_foreign_key "journey_pattern_sections", "route_sections", name: "fk_rails_0dbc726f14", dependent: :delete
-
- add_foreign_key "journey_patterns", "routes", name: "jp_route_fkey", dependent: :delete
- add_foreign_key "journey_patterns", "stop_points", name: "arrival_point_fkey", column: "arrival_stop_point_id", dependent: :nullify
- add_foreign_key "journey_patterns", "stop_points", name: "departure_point_fkey", column: "departure_stop_point_id", dependent: :nullify
-
- add_foreign_key "journey_patterns_stop_points", "journey_patterns", name: "jpsp_jp_fkey", dependent: :delete
- add_foreign_key "journey_patterns_stop_points", "stop_points", name: "jpsp_stoppoint_fkey", dependent: :delete
-
- add_foreign_key "route_sections", "stop_areas", name: "fk_rails_97b8dcfe1a", column: "departure_id"
- add_foreign_key "route_sections", "stop_areas", name: "fk_rails_df1612606f", column: "arrival_id"
-
- add_foreign_key "routes", "routes", name: "route_opposite_route_fkey", column: "opposite_route_id"
-
- add_foreign_key "stop_areas", "stop_areas", name: "area_parent_fkey", column: "parent_id", dependent: :nullify
-
- add_foreign_key "stop_areas_stop_areas", "stop_areas", name: "stoparea_child_fkey", column: "child_id", dependent: :delete
- add_foreign_key "stop_areas_stop_areas", "stop_areas", name: "stoparea_parent_fkey", column: "parent_id", dependent: :delete
-
- add_foreign_key "time_table_dates", "time_tables", name: "tm_date_fkey", dependent: :delete
-
- add_foreign_key "time_table_periods", "time_tables", name: "tm_period_fkey", dependent: :delete
-
- add_foreign_key "time_tables_vehicle_journeys", "time_tables", name: "vjtm_tm_fkey", dependent: :delete
- add_foreign_key "time_tables_vehicle_journeys", "vehicle_journeys", name: "vjtm_vj_fkey", dependent: :delete
-
- add_foreign_key "vehicle_journey_at_stops", "stop_points", name: "vjas_sp_fkey", dependent: :delete
- add_foreign_key "vehicle_journey_at_stops", "vehicle_journeys", name: "vjas_vj_fkey", dependent: :delete
-
- add_foreign_key "vehicle_journeys", "journey_patterns", name: "vj_jp_fkey", dependent: :delete
- add_foreign_key "vehicle_journeys", "routes", name: "vj_route_fkey", dependent: :delete
-
+ add_foreign_key "group_of_lines_lines", "group_of_lines", name: "groupofline_group_fkey", on_delete: :cascade
+ add_foreign_key "journey_frequencies", "timebands", on_delete: :nullify
+ add_foreign_key "journey_frequencies", "vehicle_journeys", on_delete: :nullify
+ add_foreign_key "journey_pattern_sections", "journey_patterns", on_delete: :cascade
+ add_foreign_key "journey_pattern_sections", "route_sections", on_delete: :cascade
+ add_foreign_key "journey_patterns", "routes", name: "jp_route_fkey", on_delete: :cascade
+ add_foreign_key "journey_patterns", "stop_points", column: "arrival_stop_point_id", name: "arrival_point_fkey", on_delete: :nullify
+ add_foreign_key "journey_patterns", "stop_points", column: "departure_stop_point_id", name: "departure_point_fkey", on_delete: :nullify
+ add_foreign_key "journey_patterns_stop_points", "journey_patterns", name: "jpsp_jp_fkey", on_delete: :cascade
+ add_foreign_key "journey_patterns_stop_points", "stop_points", name: "jpsp_stoppoint_fkey", on_delete: :cascade
+ add_foreign_key "route_sections", "stop_areas", column: "arrival_id"
+ add_foreign_key "route_sections", "stop_areas", column: "departure_id"
+ add_foreign_key "routes", "routes", column: "opposite_route_id", name: "route_opposite_route_fkey"
+ add_foreign_key "stop_areas", "stop_areas", column: "parent_id", name: "area_parent_fkey", on_delete: :nullify
+ add_foreign_key "stop_areas_stop_areas", "stop_areas", column: "child_id", name: "stoparea_child_fkey", on_delete: :cascade
+ add_foreign_key "stop_areas_stop_areas", "stop_areas", column: "parent_id", name: "stoparea_parent_fkey", on_delete: :cascade
+ add_foreign_key "time_table_dates", "time_tables", name: "tm_date_fkey", on_delete: :cascade
+ add_foreign_key "time_table_periods", "time_tables", name: "tm_period_fkey", on_delete: :cascade
+ add_foreign_key "time_tables_vehicle_journeys", "time_tables", name: "vjtm_tm_fkey", on_delete: :cascade
+ add_foreign_key "time_tables_vehicle_journeys", "vehicle_journeys", name: "vjtm_vj_fkey", on_delete: :cascade
+ add_foreign_key "vehicle_journey_at_stops", "stop_points", name: "vjas_sp_fkey", on_delete: :cascade
+ add_foreign_key "vehicle_journey_at_stops", "vehicle_journeys", name: "vjas_vj_fkey", on_delete: :cascade
+ add_foreign_key "vehicle_journeys", "journey_patterns", name: "vj_jp_fkey", on_delete: :cascade
+ add_foreign_key "vehicle_journeys", "routes", name: "vj_route_fkey", on_delete: :cascade
end
diff --git a/spec/controllers/route_stop_points_controller_spec.rb b/spec/controllers/route_stop_points_controller_spec.rb
new file mode 100644
index 000000000..2f5fa41c7
--- /dev/null
+++ b/spec/controllers/route_stop_points_controller_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+RSpec.describe RouteStopPointsController, type: :controller do
+ login_user
+
+ let(:referential) { Referential.first }
+ let!(:line) { create :line }
+ let!(:route) { create :route, line: line }
+
+ describe 'GET index' do
+ before(:each) { get :index, referential_id: referential.id, line_id: line.id, route_id: route.id, format: :json }
+
+ it 'returns HTTP success' do
+ expect(response).to be_success
+ end
+
+ it 'returns a JSON of stop areas' do
+ expect(response.body).to eq(route.stop_points.map { |sp| { id: sp.id, name: sp.name } }.to_json)
+ end
+ end
+end
+
+
diff --git a/spec/factories/chouette_routing_constraint_zones.rb b/spec/factories/chouette_routing_constraint_zones.rb
index 2f707e6a6..8ef2ddb43 100644
--- a/spec/factories/chouette_routing_constraint_zones.rb
+++ b/spec/factories/chouette_routing_constraint_zones.rb
@@ -1,7 +1,10 @@
FactoryGirl.define do
factory :routing_constraint_zone, class: Chouette::RoutingConstraintZone do
sequence(:name) { |n| "Routing constraint zone #{n}" }
- stop_area_ids { [create(:stop_area).id, create(:stop_area).id] }
association :route, factory: :route
+ after(:build) do |zone|
+ route = Chouette::Route.find(zone.route_id)
+ zone.stop_point_ids = route.stop_points.pluck(:id).first(2)
+ end
end
end
diff --git a/spec/features/lines_spec.rb b/spec/features/lines_spec.rb
index bbe3c757b..e7e1e601c 100644
--- a/spec/features/lines_spec.rb
+++ b/spec/features/lines_spec.rb
@@ -20,10 +20,10 @@ describe "Lines", :type => :feature do
end
it 'allows only R in CRUD' do
- expect(page).to have_content(I18n.t('actions.show'))
- expect(page).not_to have_content(I18n.t('actions.edit'))
- expect(page).not_to have_content(I18n.t('actions.destroy'))
- expect(page).not_to have_content(I18n.t('actions.add'))
+ expect(page).to have_link(I18n.t('actions.show'))
+ expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_path(referential, lines.first))
+ expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_path(referential, lines.first))
+ expect(page).not_to have_link(I18n.t('actions.add'), href: new_referential_line_path(referential))
end
context 'filtering' do
diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb
index 36d0e8f87..4b90a6ec6 100644
--- a/spec/features/routes_spec.rb
+++ b/spec/features/routes_spec.rb
@@ -102,7 +102,7 @@ describe "Routes", :type => :feature do
it 'does not show edit buttons for routes' do
@user.update_attribute(:permissions, [])
visit referential_line_path(referential, line)
- expect(page).not_to have_content(I18n.t('actions.edit'))
+ expect(page).not_to have_link(I18n.t('actions.edit'), href: edit_referential_line_route_path(referential, line, route))
end
end
@@ -136,7 +136,7 @@ describe "Routes", :type => :feature do
it 'does not show destroy buttons for routes' do
@user.update_attribute(:permissions, [])
visit referential_line_path(referential, line)
- expect(page).not_to have_content(I18n.t('actions.destroy'))
+ expect(page).not_to have_link(I18n.t('actions.destroy'), href: referential_line_route_path(referential, line, route))
end
end
end
diff --git a/spec/models/chouette/routing_constraint_zone_spec.rb b/spec/models/chouette/routing_constraint_zone_spec.rb
index f737872bf..c83942456 100644
--- a/spec/models/chouette/routing_constraint_zone_spec.rb
+++ b/spec/models/chouette/routing_constraint_zone_spec.rb
@@ -5,9 +5,42 @@ describe Chouette::RoutingConstraintZone, type: :model do
subject { create(:routing_constraint_zone) }
it { is_expected.to validate_presence_of :name }
- it { is_expected.to validate_presence_of :stop_area_ids }
- it { is_expected.to validate_presence_of :route_id }
# shoulda matcher to validate length of array ?
- xit { is_expected.to validate_length_of(:stop_area_ids).is_at_least(2) }
+ xit { is_expected.to validate_length_of(:stop_point_ids).is_at_least(2) }
+
+ describe 'validations' do
+ it 'validates the presence of route_id' do
+ routing_constraint_zone = create(:routing_constraint_zone)
+ expect {
+ routing_constraint_zone.update!(route_id: nil)
+ }.to raise_error
+ end
+
+ it 'validates the presence of stop_point_ids' do
+ routing_constraint_zone = create(:routing_constraint_zone)
+ expect {
+ routing_constraint_zone.update!(stop_point_ids: [])
+ }.to raise_error(ActiveRecord::RecordInvalid)
+ end
+
+ it 'validates that stop points belong to the route' do
+ routing_constraint_zone = create(:routing_constraint_zone)
+ route = create(:route)
+ expect {
+ routing_constraint_zone.update!(route_id: route.id)
+ }.to raise_error(ActiveRecord::RecordInvalid)
+ end
+ end
+
+ describe 'deleted stop areas' do
+ it 'does not have them in stop_area_ids' do
+ routing_constraint_zone = create(:routing_constraint_zone)
+ 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)
+ end
+ end
end