aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/api/v1/compliance_check_sets_controller.rb14
-rw-r--r--app/controllers/compliance_control_blocks_controller.rb1
-rw-r--r--app/controllers/compliance_control_sets_controller.rb1
-rw-r--r--app/controllers/compliance_controls_controller.rb1
-rw-r--r--app/controllers/route_sections_controller.rb70
-rw-r--r--app/controllers/route_sections_selectors_controller.rb47
-rw-r--r--app/controllers/routes_controller.rb3
-rw-r--r--app/decorators/compliance_control_decorator.rb36
-rw-r--r--app/decorators/compliance_control_set_decorator.rb23
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/helpers/compliance_control_sets_helper.rb34
-rw-r--r--app/helpers/route_section_selectors_helper.rb23
-rw-r--r--app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js2
-rw-r--r--app/maps/design/route_section_selector_style_map.rb73
-rw-r--r--app/maps/design/route_section_style_map.rb66
-rw-r--r--app/maps/route_section_map.rb66
-rw-r--r--app/maps/route_section_selector_map.rb116
-rw-r--r--app/models/chouette/journey_pattern.rb7
-rw-r--r--app/models/chouette/route.rb31
-rw-r--r--app/models/compliance_check_set.rb36
-rw-r--r--app/models/referential.rb4
-rw-r--r--app/models/route_section_search.rb33
-rw-r--r--app/models/route_sections_selector.rb101
-rw-r--r--app/policies/compliance_control_block_policy.rb20
-rw-r--r--app/policies/compliance_control_policy.rb10
-rw-r--r--app/policies/compliance_control_set_policy.rb16
-rw-r--r--app/views/api/v1/compliance_check_sets/validated.rabl11
-rw-r--r--app/views/compliance_control_sets/show.html.slim17
-rw-r--r--app/views/help/route_sections.textile92
-rw-r--r--app/views/help/toc.textile1
-rw-r--r--app/views/journey_patterns/show.html.slim6
-rw-r--r--app/views/route_sections/_form.html.slim21
-rw-r--r--app/views/route_sections/edit.html.slim6
-rw-r--r--app/views/route_sections/index.html.slim49
-rw-r--r--app/views/route_sections/new.html.slim4
-rw-r--r--app/views/route_sections/show.html.slim27
-rw-r--r--app/views/route_sections/show.kml.slim6
-rw-r--r--app/views/route_sections_selectors/_selection.js.slim21
-rw-r--r--app/views/route_sections_selectors/edit.html.slim34
-rw-r--r--app/views/shared/_header.html.slim5
-rw-r--r--config/breadcrumbs.rb11
-rw-r--r--config/initializers/route_section.rb3
-rw-r--r--config/locales/compliance_control_sets.en.yml2
-rw-r--r--config/locales/compliance_controls.en.yml6
-rw-r--r--config/locales/compliance_controls.fr.yml6
-rw-r--r--config/locales/journey_patterns.en.yml1
-rw-r--r--config/locales/journey_patterns.fr.yml1
-rw-r--r--config/locales/referentials.en.yml1
-rw-r--r--config/locales/referentials.fr.yml1
-rw-r--r--config/locales/route_sections.en.yml50
-rw-r--r--config/locales/route_sections.fr.yml50
-rw-r--r--config/locales/routes.en.yml1
-rw-r--r--config/locales/routes.fr.yml1
-rw-r--r--config/routes.rb13
-rw-r--r--db/migrate/20170307155042_set_updated_at.rb2
-rw-r--r--db/migrate/20171109101358_drop_table_journey_pattern_sections.rb5
-rw-r--r--db/migrate/20171109101514_drop_table_route_sections.rb5
-rw-r--r--db/migrate/20171110114408_change_foreign_keys_to_bigint_2.rb20
-rw-r--r--db/migrate/20171110130416_change_foreign_keys_to_bigint_3.rb5
-rw-r--r--db/migrate/20171113101005_change_type_to_resource_type_from_compliance_check_resources.rb5
-rw-r--r--db/schema.rb100
-rw-r--r--lib/osrm_route_section_processor.rb42
-rw-r--r--lib/stif/permission_translator.rb4
-rw-r--r--lib/tasks/route_sections.rake17
-rw-r--r--spec/controllers/api/v1/compliance_check_sets_controller_spec.rb37
-rw-r--r--spec/controllers/routes_controller_spec.rb4
-rw-r--r--spec/factories/chouette_route_sections.rb6
-rw-r--r--spec/models/chouette/route/route_duplication_spec.rb9
-rw-r--r--spec/models/chouette/route_section_spec.rb93
-rw-r--r--spec/models/compliance_check_set_spec.rb77
-rw-r--r--spec/models/route_sections_selector_spec.rb43
-rw-r--r--spec/policies/compliance_control_block_policy_spec.rb19
-rw-r--r--spec/policies/compliance_control_policy_spec.rb19
-rw-r--r--spec/policies/compliance_control_set_policy_spec.rb23
-rw-r--r--spec/support/permissions.rb4
-rw-r--r--spec/support/pundit/shared_examples.rb20
76 files changed, 477 insertions, 1365 deletions
diff --git a/app/controllers/api/v1/compliance_check_sets_controller.rb b/app/controllers/api/v1/compliance_check_sets_controller.rb
new file mode 100644
index 000000000..acb38c834
--- /dev/null
+++ b/app/controllers/api/v1/compliance_check_sets_controller.rb
@@ -0,0 +1,14 @@
+class Api::V1::ComplianceCheckSetsController < Api::V1::IbooController
+ def validated
+ @compliance_check_set = ComplianceCheckSet.find(params[:id])
+
+ if @compliance_check_set.update_status
+ render :validated
+ else
+ render json: {
+ status: "error",
+ messages: @compliance_check_set.errors.full_messages
+ }
+ end
+ end
+end
diff --git a/app/controllers/compliance_control_blocks_controller.rb b/app/controllers/compliance_control_blocks_controller.rb
index 996f8a464..f53a1e04a 100644
--- a/app/controllers/compliance_control_blocks_controller.rb
+++ b/app/controllers/compliance_control_blocks_controller.rb
@@ -1,4 +1,5 @@
class ComplianceControlBlocksController < InheritedResources::Base
+ include PolicyChecker
defaults resource_class: ComplianceControlBlock
belongs_to :compliance_control_set
actions :all, :except => [:show, :index]
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index 956f26112..5c78d09e3 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -1,4 +1,5 @@
class ComplianceControlSetsController < InheritedResources::Base
+ include PolicyChecker
defaults resource_class: ComplianceControlSet
include RansackDateFilter
before_action only: [:index] { set_date_time_params("updated_at", DateTime) }
diff --git a/app/controllers/compliance_controls_controller.rb b/app/controllers/compliance_controls_controller.rb
index 816d8897b..5a9c0b671 100644
--- a/app/controllers/compliance_controls_controller.rb
+++ b/app/controllers/compliance_controls_controller.rb
@@ -1,4 +1,5 @@
class ComplianceControlsController < InheritedResources::Base
+ include PolicyChecker
defaults resource_class: ComplianceControl
belongs_to :compliance_control_set
actions :all, :except => [:index]
diff --git a/app/controllers/route_sections_controller.rb b/app/controllers/route_sections_controller.rb
deleted file mode 100644
index 03d6cf176..000000000
--- a/app/controllers/route_sections_controller.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-class RouteSectionsController < ChouetteController
-
- defaults :resource_class => Chouette::RouteSection
-
- respond_to :html
- respond_to :kml, :only => :show
-
- belongs_to :referential
-
- before_action :save_return_to_path, only: [:edit, :create_to_edit]
-
- helper_method :search
-
- def new
- @stop_areas = referential.stop_areas.with_geometry.order :name
- new!
- end
-
- def show
- @map = RouteSectionMap.new(resource).with_helpers(self)
- show!
- end
-
- def edit
- @map = RouteSectionMap.new(resource, true).with_helpers(self)
- edit!
- end
-
- def update
- update! { session.delete(:return_to) }
- end
-
- def create
- create! { session.delete(:return_to) }
- end
-
- def create_to_edit
- route_section = Chouette::RouteSection.create(route_section_params)
- if route_section.id
- redirect_to edit_referential_route_section_path(referential, route_section)
- else
- flash[:alert] = I18n.t('route_sections.unable_to_contact_server')
- redirect_to :back
- end
- end
-
- protected
-
- def save_return_to_path
- session[:return_to] = params[:return_to] if params[:return_to]
- end
-
- def collection
- # if q = params[:q]
- # @route_sections ||= Chouette::RouteSection.joins(:departure, :arrival).where(departure: {name: "#{q}"}).or.where(arrival: {name: "#{q}"})
- # end
- @route_sections ||= search.collection.includes(:departure, :arrival).paginate page: params[:page]
- end
-
- def search
- @search ||= RouteSectionSearch.new(params[:route_section_search])
- end
-
- private
-
- def route_section_params
- params.require(:route_section).permit(:departure_id, :arrival_id, :editable_geometry, :no_processing)
- end
-
-end
diff --git a/app/controllers/route_sections_selectors_controller.rb b/app/controllers/route_sections_selectors_controller.rb
deleted file mode 100644
index b5b5ebd48..000000000
--- a/app/controllers/route_sections_selectors_controller.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-class RouteSectionsSelectorsController < ChouetteController
-
- # singleton option makes association_chain crazy
- #defaults singleton: true
-
- respond_to :html, only: [ :edit, :update ]
- respond_to :js, only: :section
-
- belongs_to :referential do
- belongs_to :line, :parent_class => Chouette::Line do
- belongs_to :route, :parent_class => Chouette::Route do
- belongs_to :journey_pattern, parent_class: Chouette::JourneyPattern
- end
- end
- end
-
- def edit
- @map = RouteSectionSelectorMap.new(resource).with_helpers(self)
- end
-
- def update
- update!
- parent.control_route_sections
- end
-
- def selection
- parent
-
- @route_section = referential.route_sections.find params[:route_section_id].to_i
- render partial: 'selection', format: 'js'
- end
-
- private
-
- def resource
- @route_sections_selector ||= RouteSectionsSelector.new parent
- end
-
- def build_resource
- @route_sections_selector ||= RouteSectionsSelector.new parent, *resource_params
- end
-
- def route_section_selector_params
- params.require(:route_section_selector).permit()
- end
-
-end
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 93f30f4d5..1a6c82484 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -68,7 +68,8 @@ class RoutesController < ChouetteController
def duplicate
route = Chouette::Route.find(params[:id]).duplicate
- redirect_to edit_referential_line_route_path(@referential, route.line, route)
+ flash[:notice] = t('routes.duplicate.success')
+ redirect_to referential_line_path(@referential, route.line)
end
protected
diff --git a/app/decorators/compliance_control_decorator.rb b/app/decorators/compliance_control_decorator.rb
index e70ff5350..f56e80417 100644
--- a/app/decorators/compliance_control_decorator.rb
+++ b/app/decorators/compliance_control_decorator.rb
@@ -2,33 +2,29 @@ class ComplianceControlDecorator < Draper::Decorator
delegate_all
def action_links
+ policy = h.policy(object)
links = []
- # if h.policy(object).destroy?
- links << Link.new(
- content: h.destroy_link_content,
- href: h.compliance_control_set_compliance_control_path(object.compliance_control_set.id, object.id),
- method: :delete,
- data: { confirm: h.t('compliance_control_sets.actions.destroy_confirm') }
- )
- # end
-
- # if h.policy(object).edit?
- links << Link.new(
- content: h.t('compliance_control_sets.actions.edit'),
- href: h.edit_compliance_control_set_compliance_control_path(object.compliance_control_set.id, object.id)
- )
- # end
-
-
- # if h.policy(object).show?
links << Link.new(
content: h.t('compliance_control_sets.actions.show'),
href: h.compliance_control_set_compliance_control_path(object.compliance_control_set.id, object.id)
)
- # end
+ if policy.edit?
+ links << Link.new(
+ content: h.t('compliance_controls.actions.edit'),
+ href: h.edit_compliance_control_set_compliance_control_path(object.compliance_control_set.id, object.id)
+ )
+ end
+
+ if policy.destroy?
+ links << Link.new(
+ content: h.destroy_link_content,
+ href: h.compliance_control_set_compliance_control_path(object.compliance_control_set.id, object.id),
+ method: :delete,
+ data: { confirm: h.t('compliance_controls.actions.destroy_confirm') }
+ )
+ end
links
end
-
end
diff --git a/app/decorators/compliance_control_set_decorator.rb b/app/decorators/compliance_control_set_decorator.rb
index 7515316ce..73d65d54a 100644
--- a/app/decorators/compliance_control_set_decorator.rb
+++ b/app/decorators/compliance_control_set_decorator.rb
@@ -2,30 +2,31 @@ class ComplianceControlSetDecorator < Draper::Decorator
delegate_all
def action_links
+ policy = h.policy(object)
links = []
- # if policy.clone?
+ if policy.edit?
+ links << Link.new(
+ content: h.t('compliance_control_sets.actions.edit'),
+ href: h.edit_compliance_control_set_path(object.id)
+ )
+ end
+
+ if policy.clone?
links << Link.new(
content: h.t('actions.clone'),
href: h.clone_compliance_control_set_path(object.id)
)
- # end
+ end
- # if h.policy(object).destroy?
+ if policy.destroy?
links << Link.new(
content: h.destroy_link_content,
href: h.compliance_control_set_path(object.id),
method: :delete,
data: { confirm: h.t('compliance_control_sets.actions.destroy_confirm') }
)
- # end
-
- # if h.policy(object).edit?
- links << Link.new(
- content: h.t('compliance_control_sets.actions.edit'),
- href: h.edit_compliance_control_set_path(object.id)
- )
- # end
+ end
links
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 5edb8c3bf..9f2e2765f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -73,8 +73,6 @@ module ApplicationHelper
"time_tables"
when path.include?("/timebands")
"timebands"
- when path.include?("/route_sections")
- "route_sections"
when path.include?("/rule_parameter_set")
"parametersets"
when path.include?("/import_tasks")
diff --git a/app/helpers/compliance_control_sets_helper.rb b/app/helpers/compliance_control_sets_helper.rb
index 6ba4bed4f..bb2a72623 100644
--- a/app/helpers/compliance_control_sets_helper.rb
+++ b/app/helpers/compliance_control_sets_helper.rb
@@ -4,4 +4,36 @@ module ComplianceControlSetsHelper
[current_organisation, Organisation.find_by_name("STIF")].uniq
end
-end
+ def flotted_links ccs_id = @compliance_control_set
+ links = [new_control(ccs_id), new_block(ccs_id)]
+ unless links.all? &:nil?
+ content_tag :div, class: 'select_toolbox' do
+ content_tag :ul do
+ links.collect {|link| concat content_tag(:li, link, class: 'st_action with_text') unless link.nil?}
+ end
+ end
+ end
+ end
+
+ def new_control ccs_id
+ if policy(ComplianceControl).create?
+ link_to select_type_compliance_control_set_compliance_controls_path(ccs_id) do
+ concat content_tag :span, nil, class: 'fa fa-plus'
+ concat content_tag :span, t('compliance_control_sets.actions.add_compliance_control')
+ end
+ else
+ nil
+ end
+ end
+
+ def new_block ccs_id
+ if policy(ComplianceControlBlock).create?
+ link_to new_compliance_control_set_compliance_control_block_path(ccs_id) do
+ concat content_tag :span, nil, class: 'fa fa-plus'
+ concat content_tag :span,t('compliance_control_sets.actions.add_compliance_control_block')
+ end
+ else
+ nil
+ end
+ end
+end \ No newline at end of file
diff --git a/app/helpers/route_section_selectors_helper.rb b/app/helpers/route_section_selectors_helper.rb
deleted file mode 100644
index 1be30066b..000000000
--- a/app/helpers/route_section_selectors_helper.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-module RouteSectionSelectorsHelper
-
- def link_to_edit_route_section(route_section)
- classes = [ 'edit-route-section' ]
- link ='#'
-
- if route_section.present?
- return_to = edit_referential_line_route_journey_pattern_route_sections_selector_path(@referential, @line, @route, @journey_pattern)
- link = edit_referential_route_section_path(@referential, route_section, return_to: return_to)
- else
- classes << 'disabled'
- end
-
- link_to "Edit", link, class: classes, title: t('route_sections_selectors.edit.route_section.edit')
- end
-
- def link_to_create_route_section(departure, arrival)
- return_to = edit_referential_line_route_journey_pattern_route_sections_selector_path(@referential, @line, @route, @journey_pattern)
- link_to t('route_sections_selectors.edit.route_section.new'),
- create_to_edit_referential_route_sections_path(@referential, route_section: {departure_id:departure.id, arrival_id: arrival.id}, return_to: return_to)
- end
-
-end
diff --git a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js
index 175106ac5..ebfbed9eb 100644
--- a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js
@@ -34,7 +34,7 @@ export default class ShiftVehicleJourney extends Component {
<li className='st_action'>
<button
type='button'
- disabled={(actions.getSelected(this.props.vehicleJourneys).length > 1 || this.props.disabled)}
+ disabled={(actions.getSelected(this.props.vehicleJourneys).length != 1 || this.props.disabled)}
data-toggle='modal'
data-target='#ShiftVehicleJourneyModal'
onClick={this.props.onOpenShiftModal}
diff --git a/app/maps/design/route_section_selector_style_map.rb b/app/maps/design/route_section_selector_style_map.rb
deleted file mode 100644
index 12f192ec8..000000000
--- a/app/maps/design/route_section_selector_style_map.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-class Design::RouteSectionSelectorStyleMap < Design::GenericStyleMap
- attr_accessor :style
-
- def initialize(helpers, options = {})
- @helpers = helpers
- @style = options[:style].present? ? default_style.merge(options[:style]) : default_style
- end
-
- def select_style
- {
- fillColor: "blue",
- graphicName: "square",
- rotation: 90,
- strokeColor: "#00dd00",
- pointRadius: 15,
- graphicZIndex: 100
- }
- end
-
- def highlight_style
- {
- fillColor: "orange",
- graphicName: "square",
- rotation: 90,
- strokeColor: "#dd0000",
- pointRadius: 15,
- graphicZIndex: 200
- }
- end
-
- def default_style
- {
- label: "${label}",
- fontColor: "black",
- fontSize: "11px",
- fontWeight: "bold",
- labelAlign: "ct",
- labelXOffset: 0,
- labelYOffset: -15,
- strokeColor: "#0000dd",
- strokeOpacity: 1,
- strokeWidth: 3,
- strokeLineCap: "round",
- strokeDashstyle: "solid",
- externalGraphic: @helpers.assets_path_patch( "map/${positionType}.png"),
- graphicWidth: 12,
- graphicHeight: 12,
- graphicOpacity: 1,
- graphicXOffset: -6,
- graphicYOffset: -6,
- display: true,
- fillColor: "red",
- graphicName: "square",
- rotation: 90,
- graphicZIndex: 10
- }
- end
-
- def context
- {
- label: :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} ",
- positionType: :" function(feature) { if (feature.attributes.iconCode != undefined) {return feature.attributes.iconCode;} else { return '';} } "
- }
- end
-
- def style_map
- OpenLayers::StyleMap.new(
- default: OpenLayers::Style.new(style, { context: context}),
- select: OpenLayers::Style.new(style.merge(select_style), { context: context }),
- highlight: OpenLayers::Style.new(style.merge( highlight_style), { context: context }))
- end
-
-end
diff --git a/app/maps/design/route_section_style_map.rb b/app/maps/design/route_section_style_map.rb
deleted file mode 100644
index dbd292412..000000000
--- a/app/maps/design/route_section_style_map.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-class Design::RouteSectionStyleMap < Design::GenericStyleMap
- attr_accessor :style
-
- def initialize(helpers, options = {})
- @helpers= helpers
- @style = options[:style].present? ? default_style.merge(options[:style]) : default_style
- end
-
- def select_style
- {
- fillColor:"blue",
- graphicName:"circle",
- rotation:90,
- :strokeColor => "red",
- pointerEvents: "visiblePainted"
- }
- end
-
- def highlight_style
- {
- fillColor:"lightblue",
- graphicName:"circle",
- rotation:90,
- :strokeColor => "#dd0000"
- }
- end
-
- def default_style
-
- {
- :fontColor => "black",
- :fontSize => "11px",
- :fontWeight => "bold",
- :labelAlign => "cm",
- :labelXOffset => 0,
- :labelYOffset => -15,
- :strokeColor => "green",
- :strokeOpacity => 1,
- :strokeWidth => 4,
- :strokeLineCap => "round",
- :strokeLineJoin => "round",
- :strokeDashstyle => "solid",
- :lineCap => "round",
- :lineJoin => "round",
- :dashstyle => "solid",
- :graphicWidth => 12,
- :graphicHeight => 12,
- :graphicOpacity => 1,
- :graphicXOffset => -6,
- :graphicYOffset => -6,
- :display => true,
- fillOpacity: 0.8,
- fillColor: "#ffffff",
- graphicName: "circle",
- pointRadius: 7,
- pointerEvents: "visiblePainted",
- rotation: 90
- }
-
- end
-
- def style_map
- OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style), :select => OpenLayers::Style.new(style.merge( select_style)), :highlight => OpenLayers::Style.new(style.merge( highlight_style)))
- end
-
-end
diff --git a/app/maps/route_section_map.rb b/app/maps/route_section_map.rb
deleted file mode 100644
index de4d5e746..000000000
--- a/app/maps/route_section_map.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-class RouteSectionMap < ApplicationMap
-
- attr_reader :route_section
-
- attr_accessor :editable
- alias_method :editable?, :editable
-
- def initialize(route_section, editable = false)
- @route_section = route_section
- @editable = editable
- end
-
- def customize_map(map, page)
- # layers order seems to matter for ModifyFeature control
- route_section.stop_areas.each do |stop_area|
- layer = "stop_area_#{stop_area.id}".to_sym
- page.assign layer.to_s, kml_layer(stop_area, :styleMap => Design::StopAreasStyleMap.new(helpers).style_map)
- page << map.add_layer(layer)
- page << map.add_control( hover_control_display_name(layer) )
- end
-
- geometry_options = {}.tap do |options|
- options[:mode] = :editable if editable?
- end
- geometry_uneditable_kml_layer = kml_layer(route_section, :styleMap => Design::RouteSectionSelectorStyleMap.new(helpers).style_map)
- page << map.add_layer(geometry_uneditable_kml_layer)
-
- if route_section.input_geometry
- geometry_editable_layer = kml_layer(route_section, geometry_options, {}) # , :styleMap => Design::LineStyleMap.new(style: nil).style_map)
- else
- points = route_section.stop_areas.map{|point| OpenLayers::Geometry::Point.new(point.longitude, point.latitude).transform("EPSG:4326", "EPSG:900913")}
- geometry_editable_layer = OpenLayers::Layer::Vector.new("user_geometry", {:projection => projection("EPSG:4326"), :styleMap => Design::RouteSectionStyleMap.new(helpers).style_map})
- geometry_editable_features = OpenLayers::Feature::Vector.new(OpenLayers::Geometry::LineString.new(points))
- page.assign :geometry_editable_features, geometry_editable_features
- end
-
- if editable
- page.assign :user_geometry, geometry_editable_layer
-
- page << "user_geometry.addFeatures([geometry_editable_features])" if geometry_editable_features
-
- page << map.add_layer(:user_geometry)
-
- page.assign :modify_feature, OpenLayers::Control::ModifyFeature.new(:user_geometry, autoActivate: true)
- page << map.add_control( :modify_feature )
- else
- page << map.add_layer(geometry_editable_layer)
- end
-
- page << map.zoom_to_extent(bounds.to_google.to_openlayers) if bounds
- end
-
- def bounds
- @bounds ||=
- if route_section.geometry.present?
- route_section.geometry.bounds
- elsif route_section.stop_areas.present?
- GeoRuby::SimpleFeatures::Point.bounds route_section.stop_areas.collect(&:geometry)
- end
- end
-
- def ready?
- bounds.present?
- end
-
-end
diff --git a/app/maps/route_section_selector_map.rb b/app/maps/route_section_selector_map.rb
deleted file mode 100644
index 7287c4d8a..000000000
--- a/app/maps/route_section_selector_map.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-class RouteSectionSelectorMap < ApplicationMap
-
- attr_reader :route_section_selector, :style
-
- def initialize(route_section_selector, style = nil)
- @route_section_selector = route_section_selector
- @style = nil
- end
-
- def customize_map(map, page)
- layer = kml_layer([route_section_selector.itinerary.referential, route_section_selector.itinerary.route.line, route_section_selector.itinerary.route, route_section_selector.itinerary],
- { rendererOptions: { zIndexing: true }, styleMap: Design::JourneyPatternStyleMap.new(helpers).style_map })
- page.assign 'journeyPatternLayer', layer
-
- page << map.add_layer(:journeyPatternLayer)
- page << map.add_control(hover_control_display_name(:journeyPatternLayer))
-
- route_section_geometry = OpenLayers::Layer::Vector.new('Route Section Geometry',
- { projection: projection('EPSG:900913'),
- rendererOptions: { zIndexing: true },
- styleMap: Design::RouteSectionSelectorStyleMap.new(helpers).style_map})
-
- route_section_layer_points = []
- route_section_selector.sections.reject{|s| s.candidates.length==0}.each do |section|
- section.candidates.each do |candidate|
- geometry = candidate.processed_geometry
- route_section_layer_points << ["#{candidate.id}"] + clean_route_section_line(geometry)
- end
- end
-
- page.assign :route_section_layer_points, route_section_layer_points
- page << <<EOF
- var route_section_layers;
- route_section_layers = route_section_layer_points.map(function(elt, index) {
- var route_section_id = elt[0];
- elt.splice(0, 1);
- var points = elt.map( function(e,i) {
- return OpenLayers.Projection.transform(new OpenLayers.Geometry.Point(e[0], e[1]), "EPSG:4326", "EPSG:900913" );
- })
- return new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(points), {id: route_section_id, name: ""});
- })
-EOF
- page.assign :route_section_geometry, route_section_geometry
- page << 'route_section_geometry.addFeatures(route_section_layers)'
- page << map.add_layer(:route_section_geometry)
-
- page << <<EOF
- function selected(feature) {
- RouteSectionMap.onSelectedFeature(feature);
- }
- function unselected(feature) {
- RouteSectionMap.onUnselectedFeature(feature);
- }
-
- highlightControl = new OpenLayers.Control.SelectFeature([route_section_geometry],
- {
- clickout: true,
- toggle: false,
- multiple:false,
- hover:true,
- highlightOnly:true,
- eventListeners:{
- featurehighlighted: function (event) {
- event.feature.layer.drawFeature(
- event.feature,
- 'highlight'
- );
- },
- featureunhighlighted: function (event) {
- event.feature.layer.drawFeature(
- event.feature,
- 'default'
- );
- }
- }
- }
- );
- selectControl = new OpenLayers.Control.SelectFeature([route_section_geometry],
- {
- onSelect:selected,
- onUnselect:unselected
- }
- );
- map.addControl(highlightControl);
- map.addControl(selectControl);
- highlightControl.activate();
- selectControl.activate();
-EOF
-
- #page.assign :select_feature, OpenLayers::Control::SelectFeature.new(:route_section_geometry, {onSelect: selected, onUnselect: unselected})
- #page << map.add_control( :select_feature )
-
-
- page << map.zoom_to_extent(bounds.to_google.to_openlayers) if bounds
-
- end
-
- def clean_route_section_line(line)
- point_array = line.to_s.scan(/-?\d+[.]\d+\s-?\d+[.]\d+/)
- point_array.map do |point|
- point = point.scan(/-?\d+[.]\d+/)
- lat = point[0].to_f
- lng = point[1].to_f
- [lat, lng]
- end
-
- end
-
- def ready?
- bounds.present?
- end
-
- def bounds
- @bounds ||= GeoRuby::SimpleFeatures::Point.bounds(route_section_selector.itinerary.route.stop_areas.collect(&:geometry).compact)
- end
-end
diff --git a/app/models/chouette/journey_pattern.rb b/app/models/chouette/journey_pattern.rb
index fb30ab69e..5058c95dc 100644
--- a/app/models/chouette/journey_pattern.rb
+++ b/app/models/chouette/journey_pattern.rb
@@ -148,6 +148,7 @@ module Chouette
vjas.destroy
end
end
+<<<<<<< HEAD
def control_route_sections
stop_area_ids = self.stop_points.map(&:stop_area_id)
@@ -183,4 +184,8 @@ module Chouette
end
end
end
-end \ No newline at end of file
+end
+=======
+ end
+end
+>>>>>>> master
diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb
index 6794ba3e4..be86b5b04 100644
--- a/app/models/chouette/route.rb
+++ b/app/models/chouette/route.rb
@@ -76,20 +76,19 @@ module Chouette
validates :wayback, inclusion: { in: self.wayback.values }
- after_commit :journey_patterns_control_route_sections
-
- def duplicate
- overrides = {
- 'opposite_route_id' => nil
- }
- keys_for_create = attributes.keys - %w{id objectid created_at updated_at}
- atts_for_create = attributes
- .slice(*keys_for_create)
- .merge(overrides)
- new_route = self.class.create!(atts_for_create)
- duplicate_stop_points(for_route: new_route)
- new_route
- end
+ def duplicate
+ overrides = {
+ 'opposite_route_id' => nil,
+ 'name' => I18n.t('activerecord.copy', name: self.name)
+ }
+ keys_for_create = attributes.keys - %w{id objectid created_at updated_at}
+ atts_for_create = attributes
+ .slice(*keys_for_create)
+ .merge(overrides)
+ new_route = self.class.create!(atts_for_create)
+ duplicate_stop_points(for_route: new_route)
+ new_route
+ end
def duplicate_stop_points(for_route:)
stop_points.each(&duplicate_stop_point(for_route: for_route))
@@ -192,9 +191,13 @@ module Chouette
protected
+<<<<<<< HEAD
def self.vehicle_journeys_timeless(stop_point_id)
all( :conditions => ['vehicle_journeys.id NOT IN (?)', Chouette::VehicleJourneyAtStop.where(stop_point_id: stop_point_id).pluck(:vehicle_journey_id)] )
end
+=======
+ protected
+>>>>>>> master
end
end \ No newline at end of file
diff --git a/app/models/compliance_check_set.rb b/app/models/compliance_check_set.rb
index 536afc705..80e499b74 100644
--- a/app/models/compliance_check_set.rb
+++ b/app/models/compliance_check_set.rb
@@ -18,4 +18,40 @@ class ComplianceCheckSet < ActiveRecord::Base
where('created_at BETWEEN :begin AND :end', begin: period_range.begin, end: period_range.end)
end
+ def update_status
+ statuses = compliance_check_resources.map do |resource|
+ case resource.status
+ when 'ERROR'
+ return update(status: 'failed')
+ when 'WARNING'
+ return update(status: 'warning')
+ else
+ resource.status
+ end
+ end
+
+ if statuses_ok_or_ignored?(statuses)
+ return update(status: 'successful')
+ end
+
+ true
+ end
+
+ private
+
+ def statuses_ok_or_ignored?(statuses)
+ uniform_statuses = statuses.uniq
+
+ (
+ # All statuses OK
+ uniform_statuses.length == 1 &&
+ uniform_statuses.first == 'OK'
+ ) ||
+ (
+ # Statuses OK or IGNORED
+ uniform_statuses.length == 2 &&
+ uniform_statuses.include?('OK') &&
+ uniform_statuses.include?('IGNORED')
+ )
+ end
end
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 8003d342f..fa6bcbcf1 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -126,10 +126,6 @@ class Referential < ActiveRecord::Base
Chouette::VehicleJourneyFrequency.all
end
- def route_sections
- Chouette::RouteSection.all
- end
-
def routing_constraint_zones
Chouette::RoutingConstraintZone.all
end
diff --git a/app/models/route_section_search.rb b/app/models/route_section_search.rb
deleted file mode 100644
index bf53cdf05..000000000
--- a/app/models/route_section_search.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-class RouteSectionSearch
- include ActiveModel::Conversion
- extend ActiveModel::Naming
-
- attr_accessor :departure_name, :arrival_name, :line_id
- attr_accessor :scope
-
- def scope
- scope ||= Chouette::RouteSection
- end
-
- def initialize(attributes = {})
- attributes.each { |k,v| send "#{k}=", v } if attributes
- end
-
- def collection
- collection = scope
-
- [:departure, :arrival].each do |endpoint|
- endpoint_name = send "#{endpoint}_name"
- collection = collection.by_endpoint_name(endpoint, endpoint_name) if endpoint_name.present?
- end
-
- collection = collection.by_line_id(line_id) if line_id.present?
-
- collection
- end
-
- def persisted?
- false
- end
-
-end
diff --git a/app/models/route_sections_selector.rb b/app/models/route_sections_selector.rb
deleted file mode 100644
index 0db09ed25..000000000
--- a/app/models/route_sections_selector.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-class RouteSectionsSelector
- extend ActiveModel::Naming
- include ActiveModel::Conversion
-
- include ActiveModel::Validations
-
- attr_reader :itinerary
-
- def initialize(journey_pattern, attributes = {})
- @itinerary = journey_pattern
-
- self.attributes = attributes
- end
-
- def attributes=(attributes)
- attributes.each { |k,v| send "#{k}=", v }
- end
-
- def update_attributes(attributes)
- self.attributes = attributes
- save
- end
-
- delegate :stop_points, to: :itinerary
-
- def sections
- @sections ||= create_sections
- end
-
- def create_sections
- [].tap do |sections|
- stop_points.each_cons(2).each_with_index do |(departure, arrival), index|
- journey_pattern_section = Chouette::JourneyPatternSection.find_by(journey_pattern: @itinerary, rank: index)
-
- if journey_pattern_section
- route_section = journey_pattern_section ? journey_pattern_section.route_section : nil
- else
- route_section = Chouette::RouteSection.find_by(departure: departure.stop_area, arrival: arrival.stop_area)
- end
-
- sections << Section.new(departure.stop_area, arrival.stop_area, index, route_section)
- end
- end
- end
-
- def sections_attributes=(attributes)
- # Process the attributes hash
- attributes.each do |index, section_attributes|
- sections[index.to_i].attributes = section_attributes
- end
- end
-
- def save
- sections.each do |s|
- Chouette::JourneyPatternSection.update_by_journey_pattern_rank(itinerary.id, s.route_section_id, s.rank)
- end
- end
-
- class Section
- extend ActiveModel::Translation
-
- attr_accessor :departure, :arrival, :rank, :route_section_id
-
- def initialize(departure, arrival, rank, route_section = nil)
- @departure, @arrival, @rank = departure, arrival, rank
-
- self.route_section = route_section
- end
-
- def route_section=(route_section)
- @route_section = route_section
- @route_section_id = route_section.respond_to?(:id) ? route_section.id : nil
- end
-
- def route_section
- @route_section ||= candidates.find_by id: route_section_id
- end
-
- def persisted?
- false
- end
-
- def candidates
- @candidates ||= Chouette::RouteSection.where(departure: departure, arrival: arrival)
- end
-
- def create_candidate
- Chouette::RouteSection.create(departure: departure, arrival: arrival)
- end
-
- def attributes=(attributes)
- attributes.each { |k,v| send "#{k}=", v }
- end
-
- def valid?
- route_section.present?
- end
-
- end
-
-end
diff --git a/app/policies/compliance_control_block_policy.rb b/app/policies/compliance_control_block_policy.rb
new file mode 100644
index 000000000..acbc1853f
--- /dev/null
+++ b/app/policies/compliance_control_block_policy.rb
@@ -0,0 +1,20 @@
+class ComplianceControlBlockPolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
+ end
+ end
+
+ def destroy?
+ user.has_permission?('compliance_control_blocks.destroy')
+ end
+
+ def create?
+ user.has_permission?('compliance_control_blocks.create')
+ end
+
+ def update?
+ user.has_permission?('compliance_control_blocks.update')
+ end
+
+end
diff --git a/app/policies/compliance_control_policy.rb b/app/policies/compliance_control_policy.rb
index 09250f013..a09760128 100644
--- a/app/policies/compliance_control_policy.rb
+++ b/app/policies/compliance_control_policy.rb
@@ -6,17 +6,15 @@ class ComplianceControlPolicy < ApplicationPolicy
end
def destroy?
- # user.has_permission?('compliance_controls.destroy')
- true
+ user.has_permission?('compliance_controls.destroy')
end
def create?
- # user.has_permission?('compliance_controls.create')
- true
+ user.has_permission?('compliance_controls.create')
end
def update?
- # user.has_permission?('compliance_controls.update')
- true
+ user.has_permission?('compliance_controls.update')
end
+
end
diff --git a/app/policies/compliance_control_set_policy.rb b/app/policies/compliance_control_set_policy.rb
index 12b829aa4..011f6c0c7 100644
--- a/app/policies/compliance_control_set_policy.rb
+++ b/app/policies/compliance_control_set_policy.rb
@@ -4,4 +4,20 @@ class ComplianceControlSetPolicy < ApplicationPolicy
scope
end
end
+
+ def destroy?
+ user.has_permission?('compliance_control_sets.destroy')
+ end
+
+ def create?
+ user.has_permission?('compliance_control_sets.create')
+ end
+
+ def update?
+ user.has_permission?('compliance_control_sets.update')
+ end
+
+ def clone?
+ create?
+ end
end
diff --git a/app/views/api/v1/compliance_check_sets/validated.rabl b/app/views/api/v1/compliance_check_sets/validated.rabl
new file mode 100644
index 000000000..1368a8014
--- /dev/null
+++ b/app/views/api/v1/compliance_check_sets/validated.rabl
@@ -0,0 +1,11 @@
+object @compliance_check_set
+
+attributes(
+ :id,
+ :referential_id,
+ :name,
+ :creator,
+ :status,
+ :started_at,
+ :ended_at
+)
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index d086c07c8..2bd663578 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -77,8 +77,8 @@
.span.fa.fa-cog
ul.dropdown-menu
li
- = link_to t('compliance_control_sets.actions.edit'), edit_compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id)
- = link_to t('compliance_control_sets.actions.destroy'), compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id), :method => :delete, :data => {:confirm => t('compliance_control_sets.actions.destroy_confirm')}
+ = link_to t('compliance_control_sets.actions.edit'), edit_compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id) if policy(ComplianceControlBlock).update? if policy(ComplianceControlBlock).update?
+ = link_to t('compliance_control_sets.actions.destroy'), compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id), :method => :delete, :data => {:confirm => t('compliance_control_sets.actions.destroy_confirm')} if policy(ComplianceControlBlock).destroy?
.row
.col-lg-12
.select_table
@@ -108,15 +108,4 @@
cls: 'table has-filter has-search',
model: ComplianceControl
- .select_toolbox
- ul
- li.st_action.with_text
- = link_to select_type_compliance_control_set_compliance_controls_path(@compliance_control_set.id)
- span.fa.fa-plus
- span
- = t('compliance_control_sets.actions.add_compliance_control')
- li.st_action.with_text
- = link_to new_compliance_control_set_compliance_control_block_path(@compliance_control_set.id)
- span.fa.fa-plus
- span
- = t('compliance_control_sets.actions.add_compliance_control_block')
+ = flotted_links(@compliance_control_set.id) \ No newline at end of file
diff --git a/app/views/help/route_sections.textile b/app/views/help/route_sections.textile
deleted file mode 100644
index 4cd6bf93f..000000000
--- a/app/views/help/route_sections.textile
+++ /dev/null
@@ -1,92 +0,0 @@
----
-layout: default
-title: Tracés
----
-
-CHOUETTE permet d'éditer le tracé de ligne sur la cartographie. Le tracé est defini au niveau de la "mission":/journey_patterns . Chaque trajet entre deux arrêts est défini séparément.
-
-Les tracés définis entre deux arrêts pour une mission peuvent être récupérés pour une autre mission. Il est possible de définir autant de tracés entre deux arrêts que nécessaire.
-
-L'application dispose d'un moteur de recherche d'itinéraire qui établi un trajet par défaut. Il peut également être utilisé pour faciliter le tracé manuel, l'utilisateur plaçant les principaux points de son tracé, le moteur se chargeant de les relier en suivant les voiries (et en tenant compte des sens de circulation).
-
-Il est à noter que seul le format GTFS sait gérer les tracés aussi bien en import et en export.
-
-h3. Création d'un nouveau tracé
-
-h4. Accès à l'interface de tracé
-
-Créer un nouveau tracé se fait dans le menu d'une mission. Un lien de modification du tracé est disponible dans le menu latéral. Tant que le tracé n'est pas entièrement défini, le lien apparaît en orange avec un panneau d'alerte.
-
-!2016-01-08_163438.png!
-
-p=. Accès à la modification d'un tracé
-
-La page de modification d'un tracé liste toutes les sections de la mission. Il s'agit du trajet entre deux arrêts de la mission. Le tracé est entièrement défini à partir du moment où toutes les sections bénéficient d'un tracé.
-
-Pour chaque section, un menu déroulant liste les tracés disponibles avec la distance et éventuellement le nombre de _via_. Lorsque seule la distance est visible, cela signifie que le tracé a été généré automatiquement par le calculateur d'itinéraire. Si des vias sont indiqués, cela signifie que le tracé a été établi à partir de points définis par l'utilisateur.
-
-!2016-01-08_163715.png!
-
-p=. Liste des tracés
-
-Pour créer un tracé sur une section n'en disposant pas encore, il convient de cliquer sur _Ajouter une alternative_. A ce stade, le pictogramme en forme de crayon est grisé puisqu'il n'existe pas encore de tracé à modifier.
-
-h4. Choix du traitement de la géométrie
-
-Après avoir cliqué le lien d'ajout d'une alternative, la cartographie s'affiche avec le trajet proposé automatiquement par le calculateur d'itinéraire en bleu et une ligne droite entre les deux arrêts en vert. Côté menu, les poitns de départ et d'arrivée sont indiqués sur le côté et un menu déroulant permet de choisir le traitement de la géométrie. Deux options sont possibles :
-
-* Standard : Le calculateur d'itinéraire recherche le trajet le plus court en respectant le cas échéant les points définis par l'utilisateur.
-* Pas de traitement : le calculateur n'est pas utilsé, le parcours correspondra très exactement au tracé fait manuellement par l'utilisateur.
-
-h4. Création du tracé
-
-Lors de la création d'un nouveau tracé, la ligne bleue correspondant à la proposition du calculateur ne peut pas être éditée. Si le tracé calculé par défaut convient, il suffit de le valider sans éditer le moindre point.
-
-Dans le cas contraire, il est possible de cliquer sur la ligne verte qui change alors de couleur pour devenir rouge. Chaque extrémité est marquée par un pictogramme rond de couleur verte qui signale une étape du tracé. Au centre du tracé se trouve un point identique mais semi-transparent que l'on peut faire glisser sur la carte pour raffiner le tracé. Chaque posistionnement du point fait automatiquement apparaître un nouveau point éditable de chaque côté de la section, ce qui permet de dessiner un tracé de plus en plus précis.
-
-Il est recommandé de commencer son tracé sur les grosses étapes puis de raffiner le trajet en replaçant les points et en créant de nouvelles étapes afin d'avoir le prochain point du tracé à portée de souris.
-
-Le traitement de la géométrie permet de ne pas tracer le trajet dans le moindre détail. Il suffit de placer quelques points significatifs et de valider en conservant _standard_ comme traitement de géométrie pour que le trajet soit calculé en passant par les points définis. Attention, le calculateur cherche une solution en fonction des voiries auxquelles sont associés les points placés. Si l'un d'entre-eux est effectivement associé à une mauvaise voirie, le calculateur risque de faire faire de gros détours pour satisfaire la demande. En conséquence il est déconseillé de placer les points directement sur les carrefous pour éviter que le point soit associé à une voirie non désirée.
-
-Dans le cas d'un tracé entièrement défini à la main, il convient de choisir _pas de traitement_ dans le menu de traitement de la géométrie.
-
-Finalier la sélection des tracés se fait en cliquant sur le bouton _modifier le parcours_ en bas de la page.
-
-!2016-01-08_165558.png!
-
-p=. Placement des points d'un tracé.
-
-h3. Modifier un tracé
-
-Une fois le tracé créé, il est possible de sélectionner un autre tracé ou de modifier un tracé. Le menu déroulant sur la liste des sections permet de sélectionner le tracé que l'on va retenir, soit pour l'affecter, soit pour le modifier.
-!2016-01-08_170524.png!
-
-p=. Séléction d'un tracé
-
-Dès lors qu'un tracé a été créé, il est possible de le modifier. Il suffit pour cela de cliquer sur le pictogramme représentant un crayon. Sur la page d'édition du tracé, il s'affiche dans une couleur violette. Double cliquer sur le tracé permet de le faire passer en mode édition. Il redevient bleu avec des cercles organges déplaçables correspondants à chacun des points du parcours. Lorsqu'on édite les points du tracé, le tracé intial reste visible en dessous en bleu.
-
-!2016-01-08_175148.png!
-
-p=. Tracé à modifier
-
-!2016-01-08_175340.png!
-
-p=. Tracé en mode édition
-
-Modifier le tracé se fait en déplaçant les points qui le composent. Si le traitement de la géométrie est paramété en _Standard_, un nouveau trajet est calculé en fonction des modifications apportées au tracé. Dans le cas inverse, le tracé est modifié en fonction de ce qui a été tracé par l'utilisateur.
-
-Il est également possible de visualiser et de modifier un tracé en passant par le sous-menu _Sections de parcours_ du menu _données_.
-
-h3. Supprimer un tracé
-
-La suppresion des tracés se fait dans un sous-menu spécifique du menu _données_. Il dispose de champs de recherche qui permettent de retrouver les sections à éditer pour les consulter, les modifier et les supprimer.
-
-!2016-01-08_180432.png!
-
-p=. gestion des tracés par section.
-
-La supression se fait en cliquant sur le pictogramme poubelle dans le tableau ou dans la page de détail de la section de parcours après avoir cliqué sur le bouton _Voir_.
-
-!2016-01-08_180930.png!
-
-p=. Visualisation, modification et suppresion de tracé
diff --git a/app/views/help/toc.textile b/app/views/help/toc.textile
index 9a80cb84e..9772ca1b6 100644
--- a/app/views/help/toc.textile
+++ b/app/views/help/toc.textile
@@ -30,7 +30,6 @@ h3. Sommaire
## "Courses en fréquence":timebands.textile
## "Correspondances":connection_links
## "Calendrier":time_tables
-## "Tracés":route_sections
# Imports
## "Imports":imports
## "Formats d'import":import_formats
diff --git a/app/views/journey_patterns/show.html.slim b/app/views/journey_patterns/show.html.slim
index 823252480..a77536130 100644
--- a/app/views/journey_patterns/show.html.slim
+++ b/app/views/journey_patterns/show.html.slim
@@ -39,12 +39,6 @@ h3.journey_pattern_stop_points = t('.stop_points')
- if policy(@journey_pattern).destroy?
= link_to t('journey_patterns.actions.destroy'), referential_line_route_journey_pattern_path(@referential, @line, @route, @journey_pattern), :method => :delete, :data => {:confirm => t('journey_patterns.actions.destroy_confirm')}, class: 'remove'
li
- = link_to edit_referential_line_route_journey_pattern_route_sections_selector_path(@referential, @line, @route, @journey_pattern), class: "edit#{' control-shape' if @journey_pattern.control?}" do
- = t('journey_patterns.actions.edit_route_sections')
- - if @journey_pattern.control?
- i.fa.fa-exclamation-triangle
-
- li
= link_to t('journey_patterns.journey_pattern.vehicle_journey_at_stops'), referential_line_route_vehicle_journeys_path(@referential, @line, @route, :q => {:journey_pattern_id_eq => @journey_pattern.id, :journey_pattern_object_id => @journey_pattern.objectid}), class: 'clock'
= creation_tag(@journey_pattern)
diff --git a/app/views/route_sections/_form.html.slim b/app/views/route_sections/_form.html.slim
deleted file mode 100644
index 51e4fdcf6..000000000
--- a/app/views/route_sections/_form.html.slim
+++ /dev/null
@@ -1,21 +0,0 @@
-= semantic_form_for [@referential, @route_section] do |form|
- = form.inputs do
- - if @route_section.new_record?
- = form.input :departure, as: :select, collection: @stop_areas, include_blank: false
- = form.input :arrival, as: :select, collection: @stop_areas, include_blank: false
- - else
- li.input.optional
- label.label = @route_section.human_attribute_name('departure')
- = @route_section.departure.name
-
- li.input.optional
- label.label = @route_section.human_attribute_name('arrival')
- = @route_section.arrival.name
-
- = form.input :editable_geometry, as: :hidden
-
- = form.input :no_processing, label: t('.no_processing'), as: :select, collection: { t('.standard_processor') => false, t('.no_processor') => true }, include_blank: false
-
- = form.actions do
- = form.action :submit, as: :button, label: t('.submit')
- = form.action :cancel, as: :link \ No newline at end of file
diff --git a/app/views/route_sections/edit.html.slim b/app/views/route_sections/edit.html.slim
deleted file mode 100644
index 7c95def73..000000000
--- a/app/views/route_sections/edit.html.slim
+++ /dev/null
@@ -1,6 +0,0 @@
-- breadcrumb :referential_route_section, @referential, @route_section
-
-= title_tag t('route_sections.edit.title')
-
-= @map.to_html if @map
-== render 'form'
diff --git a/app/views/route_sections/index.html.slim b/app/views/route_sections/index.html.slim
deleted file mode 100644
index c459af73c..000000000
--- a/app/views/route_sections/index.html.slim
+++ /dev/null
@@ -1,49 +0,0 @@
-- breadcrumb :referential_route_sections, @referential
-= title_tag t('.title')
-
-= form_for search, url: referential_route_sections_path(@referential), method: :get, class: 'form-inline' do |form|
- .panel.panel-default
- .panel-heading
- .col-md-6
- = form.text_field :departure_name, class: 'form-control', placeholder: Chouette::RouteSection.human_attribute_name(:departure)
-
- .input-group.col-md-6
- = form.text_field :arrival_name, class: 'form-control', placeholder: Chouette::RouteSection.human_attribute_name(:arrival)
-
- .input-group-btn
- button.btn.btn-default type="submit"
- i.fa.fa-search
-
- .panel-body
- .col-md-4
- = form.select :line_id, @referential.lines.order(:name).pluck(:name, :id), { include_blank: t('.all_lines')}, class: 'form-control'
-
-table.table.table-hover.table-striped
- thead
- tr
- th = Chouette::RouteSection.human_attribute_name :departure
- th = Chouette::RouteSection.human_attribute_name :arrival
- th.distance = Chouette::RouteSection.human_attribute_name :distance
- th.points = Chouette::RouteSection.human_attribute_name :points
- th.points = Chouette::RouteSection.human_attribute_name :quantity
- th.actions
-
- tbody
- - @route_sections.each do |route_section|
- tr
- td
- = route_section.departure.name
- = link_to content_tag(:i, "", class: "fa fa-external-link"), referential_stop_area_path(@referential, route_section.departure)
- td
- = route_section.arrival.name
- = link_to content_tag(:i, "", class: "fa fa-external-link"), referential_stop_area_path(@referential, route_section.arrival)
- td.distance = route_section.distance.to_i if route_section.distance
- td.points = route_section.via_count if route_section.via_count > 0
- td.journey_patterns = route_section.journey_pattern_sections.count(:journey_pattern_id, distinct: true)
- td.actions
- = link_to t('.actions.show'), referential_route_section_path(@referential, route_section), class: 'view'
- = link_to t('.actions.edit'), edit_referential_route_section_path(@referential, route_section), class: 'edit'
- = link_to t('.actions.destroy'), referential_route_section_path(@referential, route_section), method: :delete, data: { confirm: t('route_sections.actions.destroy_confirm') }, class: 'remove'
-
-.pagination
- = will_paginate @route_sections, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer
diff --git a/app/views/route_sections/new.html.slim b/app/views/route_sections/new.html.slim
deleted file mode 100644
index 79f4cda2b..000000000
--- a/app/views/route_sections/new.html.slim
+++ /dev/null
@@ -1,4 +0,0 @@
-- breadcrumb :referential_route_sections, @referential
-= title_tag t('route_sections.new.title')
-
-== render 'form'
diff --git a/app/views/route_sections/show.html.slim b/app/views/route_sections/show.html.slim
deleted file mode 100644
index afd0ed0d6..000000000
--- a/app/views/route_sections/show.html.slim
+++ /dev/null
@@ -1,27 +0,0 @@
-- breadcrumb :referential_route_section, @referential, @route_section
-= title_tag t('.title')
-
-.route_section
- = @map.to_html
-
- .summary
- p
- label = "#{@route_section.human_attribute_name('departure')} : "
- = @route_section.departure.name
-
- p
- label = "#{@route_section.human_attribute_name('arrival')} : "
- = @route_section.arrival.name
-
- p
- label = "#{@route_section.human_attribute_name('distance')} : "
- = "#{@route_section.distance.round}m" if @route_section.distance
-
-- content_for :sidebar do
- ul.actions
- li
- = link_to t('route_sections.actions.edit'), edit_referential_route_section_path(@referential, @route_section), class: 'edit'
- li
- = link_to t('route_sections.actions.destroy'), referential_route_section_path(@referential, @route_section), :method => :delete, :data => {:confirm => t('route_sections.actions.destroy_confirm')}, class: 'remove'
-
- = creation_tag(@route_section)
diff --git a/app/views/route_sections/show.kml.slim b/app/views/route_sections/show.kml.slim
deleted file mode 100644
index 9dbb4957b..000000000
--- a/app/views/route_sections/show.kml.slim
+++ /dev/null
@@ -1,6 +0,0 @@
-doctype XML
-
-kml xmlns="http://www.opengis.net/kml/2.2"
- document
- placemark id="route-section-#{@route_section.id}"
- = @route_section.geometry(params[:mode]).kml_representation.html_safe \ No newline at end of file
diff --git a/app/views/route_sections_selectors/_selection.js.slim b/app/views/route_sections_selectors/_selection.js.slim
deleted file mode 100644
index 6b5489171..000000000
--- a/app/views/route_sections_selectors/_selection.js.slim
+++ /dev/null
@@ -1,21 +0,0 @@
-div
- span.departure
- label = "#{@route_section.human_attribute_name('departure')} : "
- = link_to @route_section.departure.name, referential_stop_area_path(@referential, @route_section.departure)
-
- span.arrival
- label = "#{@route_section.human_attribute_name('arrival')} : "
- = link_to @route_section.arrival.name, referential_stop_area_path(@referential, @route_section.arrival)
-
- span.distance
- label = "#{@route_section.human_attribute_name('distance')} : "
- = "#{@route_section.distance.to_i} m" if @route_section.distance > 0
-
- - if @route_section.via_count > 0
- span.via_count
- label = "#{@route_section.human_attribute_name('via_count')} : "
- = @route_section.via_count if @route_section.via_count > 0
-
- span.actions
- = link_to_edit_route_section @route_section
- = link_to_create_route_section @route_section.departure, @route_section.arrival \ No newline at end of file
diff --git a/app/views/route_sections_selectors/edit.html.slim b/app/views/route_sections_selectors/edit.html.slim
deleted file mode 100644
index 9dcee8af3..000000000
--- a/app/views/route_sections_selectors/edit.html.slim
+++ /dev/null
@@ -1,34 +0,0 @@
-= title_tag t('.title', journey_pattern: journey_name(@journey_pattern))
-
-.large-map
- = @map.to_html(no_fullscreen: true)
-
-= semantic_form_for resource, url: referential_line_route_journey_pattern_route_sections_selector_path(@referential, @line, @route, @journey_pattern), method: :put do |form|
- h3 = t('.selection.title')
-
- #map-selection style="display: none;"
- div
-
- #empty-map-selection
- = t('.no_selection')
-
- h3 = t('.form.title')
-
- table.table.table-hover.table-striped
- tbody
- = form.fields_for :sections do |section_form|
- tr
- td = link_to section_form.object.departure.name, referential_stop_area_path(@referential, section_form.object.departure)
- td.route_section
- - if section_form.object.candidates.present?
- = section_form.input :route_section_id, as: :select, label: false, collection: section_form.object.candidates, include_blank: t('.no_selection')
- - else
- = t('.no_candidate')
-
- td.action
- = link_to_edit_route_section section_form.object.route_section
- = link_to_create_route_section section_form.object.departure, section_form.object.arrival
-
- = form.actions do
- = form.action :submit, as: :button, label: t('.submit')
- = form.action :cancel, as: :link, url: referential_line_route_journey_pattern_path(@referential, @line, @route, @journey_pattern) \ No newline at end of file
diff --git a/app/views/shared/_header.html.slim b/app/views/shared/_header.html.slim
index 33aee09a4..afe802b49 100644
--- a/app/views/shared/_header.html.slim
+++ b/app/views/shared/_header.html.slim
@@ -82,11 +82,6 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
= Referential.human_attribute_name("time_tables")
li
- = link_to referential_route_sections_path(@referential) do
- span.badge.pull-right = @referential.route_sections.size
- = Referential.human_attribute_name("route_sections")
-
- li
= link_to referential_timebands_path(@referential) do
span.badge.pull-right = @referential.timebands.size
= Referential.human_attribute_name("timebands")
diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb
index 4883ec7a2..0cabf9c6b 100644
--- a/config/breadcrumbs.rb
+++ b/config/breadcrumbs.rb
@@ -41,17 +41,6 @@ crumb :referential_group_of_line do |referential, group_of_line|
parent :referential_group_of_lines, referential
end
-crumb :referential_route_sections do |referential|
- link I18n.t('route_sections.index.title'), referential_route_sections_path(referential)
- parent :referential, referential
-end
-
-crumb :referential_route_section do |referential, route_section|
- link breadcrumb_name(route_section.departure), referential_route_section_path(referential, route_section)
- parent :referential_route_sections, referential
-end
-
-
crumb :time_tables do |referential|
link I18n.t('time_tables.index.title'), referential_time_tables_path(referential)
parent :referential, referential
diff --git a/config/initializers/route_section.rb b/config/initializers/route_section.rb
deleted file mode 100644
index dadea36ee..000000000
--- a/config/initializers/route_section.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-Rails.application.config.to_prepare do
- Chouette::RouteSection.processor = OsrmRouteSectionProcessor.new
-end
diff --git a/config/locales/compliance_control_sets.en.yml b/config/locales/compliance_control_sets.en.yml
index 7361edacf..10c4f5e9a 100644
--- a/config/locales/compliance_control_sets.en.yml
+++ b/config/locales/compliance_control_sets.en.yml
@@ -17,7 +17,7 @@ en:
destroy: Destroy
add_compliance_control: Compliance Control
add_compliance_control_block: Compliance Control Block
- destroy_confirm: Are you sur ?
+ destroy_confirm: Are you sure ?
filters:
name: 'Enter name ...'
search_no_results: 'No compliance control set found'
diff --git a/config/locales/compliance_controls.en.yml b/config/locales/compliance_controls.en.yml
index abf1c8f82..9615bbf69 100644
--- a/config/locales/compliance_controls.en.yml
+++ b/config/locales/compliance_controls.en.yml
@@ -30,6 +30,12 @@ en:
title: "Update compliance control"
metas:
no_prerequisite: "None"
+ actions:
+ new: Add
+ edit: Edit
+ show: Show
+ destroy: Destroy
+ destroy_confirm: Are you sure ?
route_control/zdl_stop_area:
messages:
3_route_1: "The route with %{source_objectid} objectid connect the stop points %{target_0_label} (%{target_0_objectid}) and %{target_1_label} (%{target_1_objectid}) which belong to the same ZDL"
diff --git a/config/locales/compliance_controls.fr.yml b/config/locales/compliance_controls.fr.yml
index acb7a6383..e23f879f5 100644
--- a/config/locales/compliance_controls.fr.yml
+++ b/config/locales/compliance_controls.fr.yml
@@ -29,6 +29,12 @@ fr:
title: "Sélectionner un type de contrôle"
metas:
no_prerequisite: "Aucun"
+ actions:
+ new: Ajouter
+ edit: Editer
+ show: Consulter
+ destroy: Supprimer
+ destroy_confirm: Etes vous sûr de supprimer ce contrôle ?
route_control/zdl_stop_area:
messages:
3_route_1: "L'itinéraire %{source_objectid} dessert successivement les arrêts %{target_0_label} (%{target_0_objectid}) et %{target_1_label} (%{target_1_objectid}) de la même zone de lieu"
diff --git a/config/locales/journey_patterns.en.yml b/config/locales/journey_patterns.en.yml
index 494e700b9..effac5569 100644
--- a/config/locales/journey_patterns.en.yml
+++ b/config/locales/journey_patterns.en.yml
@@ -10,7 +10,6 @@ en:
edit: "Edit this journey pattern"
destroy: "Remove this journey pattern"
destroy_confirm: A"re you sure you want destroy this journey pattern ?"
- edit_route_sections: "Update route sections"
edit_journey_patterns_collection: "Edit journey patterns"
new:
title: "Add a new journey pattern"
diff --git a/config/locales/journey_patterns.fr.yml b/config/locales/journey_patterns.fr.yml
index 24f182168..23c43e2a7 100644
--- a/config/locales/journey_patterns.fr.yml
+++ b/config/locales/journey_patterns.fr.yml
@@ -10,7 +10,6 @@ fr:
edit: "Editer cette mission"
destroy: "Supprimer cette mission"
destroy_confirm: "Etes vous sûr de vouloir détruire cette mission ?"
- edit_route_sections: "Editer les sections de parcours"
edit_journey_patterns_collection: "Editer les missions"
new:
title: "Ajouter une mission"
diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml
index 8c58e53ee..a2c6fcf59 100644
--- a/config/locales/referentials.en.yml
+++ b/config/locales/referentials.en.yml
@@ -78,7 +78,6 @@ en:
access_points: "Access Points"
time_tables: "Time tables"
connection_links: "Connection links"
- route_sections: "Route sections"
quays: "quays"
boarding_positions: "boarding positions"
commercial_stops: "commercial stops"
diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml
index 5b028233c..e132c959d 100644
--- a/config/locales/referentials.fr.yml
+++ b/config/locales/referentials.fr.yml
@@ -78,7 +78,6 @@ fr:
access_points: "points d'accès"
time_tables: "Calendriers"
connection_links: "Correspondances"
- route_sections: "Sections de parcours"
quays: "quais"
boarding_positions: "points d'embarquement"
commercial_stops: "arrêts commerciaux"
diff --git a/config/locales/route_sections.en.yml b/config/locales/route_sections.en.yml
deleted file mode 100644
index 7f4a56fc4..000000000
--- a/config/locales/route_sections.en.yml
+++ /dev/null
@@ -1,50 +0,0 @@
-en:
- route_sections:
- new:
- title: "Add a new section"
- show:
- title: "Show this section"
- edit:
- title: "Edit this section"
- form:
- no_processing: "Geometry processing"
- standard_processor: "Standard"
- no_processor: "No treatment"
- submit: "Submit"
- index:
- title: "Sections course"
- all_lines: "All lines"
- actions:
- show: "Show"
- edit: "Edit"
- destroy: "Delete"
- destroy_confirm: "Are you sure you want to delete this route section?"
- actions:
- edit: "Edit this section"
- destroy: "Delete this section"
- destroy_confirm: "Are you sure you want to delete this route section?"
- unable_to_contact_server: 'Unable to contact OSRM server, please try again later.'
- route_sections_selectors:
- edit:
- title: "Changing the course of the mission %{journey_pattern}"
- route_section:
- edit: "Edit this section"
- new: "Add alternative"
- no_candidate: "No known path"
- no_selection: "No selection"
- selection:
- title: "Selected section"
- form:
- title: "Full course"
- submit: "Change the route"
- activerecord:
- models:
- route_section: "Section course"
- attributes:
- route_section:
- departure: "Departure point"
- arrival: "Arrival point"
- points: "Via"
- distance: "Distance"
- created_at: Created at
- updated_at: Updated at
diff --git a/config/locales/route_sections.fr.yml b/config/locales/route_sections.fr.yml
deleted file mode 100644
index 852d47a57..000000000
--- a/config/locales/route_sections.fr.yml
+++ /dev/null
@@ -1,50 +0,0 @@
-fr:
- route_sections:
- new:
- title: "Ajouter une section"
- show:
- title: "Détails d'une Section de parcours"
- edit:
- title: "Editer une Section de parcours"
- form:
- no_processing: "Traitement de la géométrie"
- standard_processor: "Standard"
- no_processor: "Pas de traitement"
- submit: "Valider"
- index:
- title: "Sections de parcours"
- all_lines: "Tous les lignes"
- actions:
- show: "Voir"
- edit: "Editer"
- destroy: "Supprimer"
- destroy_confirm: "Etes vous sûr de vouloir supprimer cette section de parcours ?"
- actions:
- edit: "Editer cette section"
- destroy: "Supprimer cette section"
- destroy_confirm: "Etes vous sûr de vouloir supprimer cette section de parcours ?"
- unable_to_contact_server: "Le serveur OSRM n'est pas disponible pour le moment, merci de réessayer dans quelques instants."
- route_sections_selectors:
- edit:
- title: "Edition du parcours de la mission %{journey_pattern}"
- route_section:
- edit: "Editer cette section"
- new: "Ajouter une alternative"
- no_candidate: "Aucun parcours connu"
- no_selection: "Aucune selection"
- selection:
- title: "Section sélectionnée"
- form:
- title: "Parcours complet"
- submit: "Editer le parcours"
- activerecord:
- models:
- route_section: "Section du parcours"
- attributes:
- route_section:
- departure: "Arrêt de départ"
- arrival: "Arrêt d'arrivée"
- points: "Via"
- distance: "Distance"
- created_at: "Créé le"
- updated_at: "Edité le"
diff --git a/config/locales/routes.en.yml b/config/locales/routes.en.yml
index 4437b62b9..ba4f76daa 100644
--- a/config/locales/routes.en.yml
+++ b/config/locales/routes.en.yml
@@ -55,6 +55,7 @@ en:
for_alighting: "Alighting"
duplicate:
title: "Duplicate route"
+ success: "Route cloned with success"
route:
no_journey_pattern: "No Journey pattern"
opposite: "Opposite route"
diff --git a/config/locales/routes.fr.yml b/config/locales/routes.fr.yml
index 31838f1a7..3bcc33320 100644
--- a/config/locales/routes.fr.yml
+++ b/config/locales/routes.fr.yml
@@ -55,6 +55,7 @@ fr:
for_alighting: "Descente"
duplicate:
title: "Dupliquer l'itinéraire"
+ success: "itinéraire dupliqué avec succès"
route:
no_journey_pattern: "Pas de mission"
wayback:
diff --git a/config/routes.rb b/config/routes.rb
index 2f332b2c9..27db66c2c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -63,6 +63,9 @@ ChouetteIhm::Application.routes.draw do
resources :stop_areas, only: [:index, :show]
resources :time_tables, only: [:index, :show]
resources :vehicle_journeys, only: :show
+ patch 'compliance_check_sets/:id',
+ to: 'compliance_check_sets#validated',
+ as: 'compliance_check_set'
end
end
@@ -106,7 +109,6 @@ ChouetteIhm::Application.routes.draw do
get :select_compliance_control_set
post :validate, on: :member
resources :autocomplete_time_tables, only: [:index]
- resources :autocomplete_route_sections
resources :autocomplete_timebands
resources :group_of_lines, controller: "referential_group_of_lines" do
collection do
@@ -138,9 +140,6 @@ ChouetteIhm::Application.routes.draw do
resource :journey_patterns_collection, :only => [:show, :update]
resources :journey_patterns do
get 'new_vehicle_journey', on: :member
- resource :route_sections_selector, path: 'sections' do
- post 'selection'
- end
end
resource :vehicle_journeys_collection, :only => [:show, :update]
resources :vehicle_journeys, :vehicle_journey_frequencies do
@@ -214,12 +213,6 @@ ChouetteIhm::Application.routes.draw do
end
end
resources :clean_ups
-
- resources :route_sections do
- collection do
- get 'create_to_edit'
- end
- end
end
root :to => "dashboards#show"
diff --git a/db/migrate/20170307155042_set_updated_at.rb b/db/migrate/20170307155042_set_updated_at.rb
index 84ffd8211..16bfda3d9 100644
--- a/db/migrate/20170307155042_set_updated_at.rb
+++ b/db/migrate/20170307155042_set_updated_at.rb
@@ -1,6 +1,6 @@
class SetUpdatedAt < ActiveRecord::Migration
def up
- models = %w(VehicleJourney Timeband TimeTable StopPoint StopArea RoutingConstraintZone Route RouteSection PtLink Network Line
+ models = %w(VehicleJourney Timeband TimeTable StopPoint StopArea RoutingConstraintZone Route PtLink Network Line
JourneyPattern GroupOfLine ConnectionLink Company AccessPoint AccessLink)
models.each do |table|
diff --git a/db/migrate/20171109101358_drop_table_journey_pattern_sections.rb b/db/migrate/20171109101358_drop_table_journey_pattern_sections.rb
new file mode 100644
index 000000000..a7bb482a5
--- /dev/null
+++ b/db/migrate/20171109101358_drop_table_journey_pattern_sections.rb
@@ -0,0 +1,5 @@
+class DropTableJourneyPatternSections < ActiveRecord::Migration
+ def change
+ drop_table :journey_pattern_sections
+ end
+end
diff --git a/db/migrate/20171109101514_drop_table_route_sections.rb b/db/migrate/20171109101514_drop_table_route_sections.rb
new file mode 100644
index 000000000..c009ed8ec
--- /dev/null
+++ b/db/migrate/20171109101514_drop_table_route_sections.rb
@@ -0,0 +1,5 @@
+class DropTableRouteSections < ActiveRecord::Migration
+ def change
+ drop_table :route_sections
+ end
+end
diff --git a/db/migrate/20171110114408_change_foreign_keys_to_bigint_2.rb b/db/migrate/20171110114408_change_foreign_keys_to_bigint_2.rb
new file mode 100644
index 000000000..3bd4525ff
--- /dev/null
+++ b/db/migrate/20171110114408_change_foreign_keys_to_bigint_2.rb
@@ -0,0 +1,20 @@
+class ChangeForeignKeysToBigint2 < ActiveRecord::Migration
+ def change
+ change_column :api_keys, :organisation_id, :bigint
+ change_column :compliance_check_blocks, :compliance_check_set_id, :bigint
+ change_column :compliance_check_messages, :compliance_check_id, :bigint
+ change_column :compliance_check_messages, :compliance_check_resource_id, :bigint
+ change_column :compliance_check_messages, :compliance_check_set_id, :bigint
+ change_column :compliance_check_sets, :referential_id, :bigint
+ change_column :compliance_check_sets, :compliance_control_set_id, :bigint
+ change_column :compliance_check_sets, :workbench_id, :bigint
+ change_column :compliance_check_sets, :parent_id, :bigint
+ change_column :compliance_checks, :compliance_check_set_id, :bigint
+ change_column :compliance_checks, :compliance_check_block_id, :bigint
+ change_column :compliance_control_blocks, :compliance_control_set_id, :bigint
+ change_column :compliance_control_sets, :organisation_id, :bigint
+ change_column :compliance_controls, :compliance_control_set_id, :bigint
+ change_column :compliance_controls, :compliance_control_block_id, :bigint
+ change_column :time_tables, :created_from_id, :bigint
+ end
+end
diff --git a/db/migrate/20171110130416_change_foreign_keys_to_bigint_3.rb b/db/migrate/20171110130416_change_foreign_keys_to_bigint_3.rb
new file mode 100644
index 000000000..bfe1b4be2
--- /dev/null
+++ b/db/migrate/20171110130416_change_foreign_keys_to_bigint_3.rb
@@ -0,0 +1,5 @@
+class ChangeForeignKeysToBigint3 < ActiveRecord::Migration
+ def change
+ change_column :compliance_check_resources, :compliance_check_set_id, :bigint
+ end
+end
diff --git a/db/migrate/20171113101005_change_type_to_resource_type_from_compliance_check_resources.rb b/db/migrate/20171113101005_change_type_to_resource_type_from_compliance_check_resources.rb
new file mode 100644
index 000000000..6d1aaa883
--- /dev/null
+++ b/db/migrate/20171113101005_change_type_to_resource_type_from_compliance_check_resources.rb
@@ -0,0 +1,5 @@
+class ChangeTypeToResourceTypeFromComplianceCheckResources < ActiveRecord::Migration
+ def change
+ rename_column :compliance_check_resources, :type, :resource_type
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index cd5fb8627..a992eb32b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20171109101605) do
+ActiveRecord::Schema.define(version: 20171113101005) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -77,7 +77,7 @@ ActiveRecord::Schema.define(version: 20171109101605) do
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
- t.integer "organisation_id"
+ t.integer "organisation_id", limit: 8
end
add_index "api_keys", ["organisation_id"], name: "index_api_keys_on_organisation_id", using: :btree
@@ -148,23 +148,23 @@ ActiveRecord::Schema.define(version: 20171109101605) do
create_table "compliance_check_blocks", id: :bigserial, force: :cascade do |t|
t.string "name"
t.hstore "condition_attributes"
- t.integer "compliance_check_set_id"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.integer "compliance_check_set_id", limit: 8
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
add_index "compliance_check_blocks", ["compliance_check_set_id"], name: "index_compliance_check_blocks_on_compliance_check_set_id", using: :btree
create_table "compliance_check_messages", id: :bigserial, force: :cascade do |t|
- t.integer "compliance_check_id"
- t.integer "compliance_check_resource_id"
+ t.integer "compliance_check_id", limit: 8
+ t.integer "compliance_check_resource_id", limit: 8
t.string "message_key"
t.hstore "message_attributes"
t.hstore "resource_attributes"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "status"
- t.integer "compliance_check_set_id"
+ t.integer "compliance_check_set_id", limit: 8
end
add_index "compliance_check_messages", ["compliance_check_id"], name: "index_compliance_check_messages_on_compliance_check_id", using: :btree
@@ -174,26 +174,26 @@ ActiveRecord::Schema.define(version: 20171109101605) do
create_table "compliance_check_resources", id: :bigserial, force: :cascade do |t|
t.string "status"
t.string "name"
- t.string "type"
+ t.string "resource_type"
t.string "reference"
t.hstore "metrics"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.integer "compliance_check_set_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "compliance_check_set_id", limit: 8
end
add_index "compliance_check_resources", ["compliance_check_set_id"], name: "index_compliance_check_resources_on_compliance_check_set_id", using: :btree
create_table "compliance_check_sets", id: :bigserial, force: :cascade do |t|
- t.integer "referential_id"
- t.integer "compliance_control_set_id"
- t.integer "workbench_id"
+ t.integer "referential_id", limit: 8
+ t.integer "compliance_control_set_id", limit: 8
+ t.integer "workbench_id", limit: 8
t.string "creator"
t.string "status"
- t.integer "parent_id"
+ t.integer "parent_id", limit: 8
t.string "parent_type"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "current_step_id"
t.float "current_step_progress"
t.string "name"
@@ -207,16 +207,16 @@ ActiveRecord::Schema.define(version: 20171109101605) do
add_index "compliance_check_sets", ["workbench_id"], name: "index_compliance_check_sets_on_workbench_id", using: :btree
create_table "compliance_checks", id: :bigserial, force: :cascade do |t|
- t.integer "compliance_check_set_id"
- t.integer "compliance_check_block_id"
+ t.integer "compliance_check_set_id", limit: 8
+ t.integer "compliance_check_block_id", limit: 8
t.string "type"
t.hstore "control_attributes"
t.string "name"
t.string "code"
t.string "criticity"
t.text "comment"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "origin_code"
end
@@ -226,34 +226,34 @@ ActiveRecord::Schema.define(version: 20171109101605) do
create_table "compliance_control_blocks", id: :bigserial, force: :cascade do |t|
t.string "name"
t.hstore "condition_attributes"
- t.integer "compliance_control_set_id"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.integer "compliance_control_set_id", limit: 8
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
add_index "compliance_control_blocks", ["compliance_control_set_id"], name: "index_compliance_control_blocks_on_compliance_control_set_id", using: :btree
create_table "compliance_control_sets", id: :bigserial, force: :cascade do |t|
t.string "name"
- t.integer "organisation_id"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.integer "organisation_id", limit: 8
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
add_index "compliance_control_sets", ["organisation_id"], name: "index_compliance_control_sets_on_organisation_id", using: :btree
create_table "compliance_controls", id: :bigserial, force: :cascade do |t|
- t.integer "compliance_control_set_id"
+ t.integer "compliance_control_set_id", limit: 8
t.string "type"
t.hstore "control_attributes"
t.string "name"
t.string "code"
t.string "criticity"
t.text "comment"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "origin_code"
- t.integer "compliance_control_block_id"
+ t.integer "compliance_control_block_id", limit: 8
end
add_index "compliance_controls", ["code", "compliance_control_set_id"], name: "index_compliance_controls_on_code_and_compliance_control_set_id", unique: true, using: :btree
@@ -431,18 +431,6 @@ ActiveRecord::Schema.define(version: 20171109101605) do
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", 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
- t.datetime "created_at"
- 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, 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", id: :bigserial, force: :cascade do |t|
t.integer "route_id", limit: 8
t.string "objectid", null: false
@@ -654,20 +642,6 @@ ActiveRecord::Schema.define(version: 20171109101605) do
add_index "referentials", ["created_from_id"], name: "index_referentials_on_created_from_id", using: :btree
add_index "referentials", ["referential_suite_id"], name: "index_referentials_on_referential_suite_id", using: :btree
- create_table "route_sections", id: :bigserial, force: :cascade do |t|
- t.integer "departure_id", limit: 8
- t.integer "arrival_id", limit: 8
- 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"
- t.float "distance"
- t.boolean "no_processing"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
create_table "routes", id: :bigserial, force: :cascade do |t|
t.integer "line_id", limit: 8
t.string "objectid", null: false
@@ -864,7 +838,7 @@ ActiveRecord::Schema.define(version: 20171109101605) do
t.datetime "created_at"
t.datetime "updated_at"
t.string "color"
- t.integer "created_from_id"
+ t.integer "created_from_id", limit: 8
t.string "checksum"
t.text "checksum_source"
t.string "data_source_ref"
@@ -1013,16 +987,12 @@ ActiveRecord::Schema.define(version: 20171109101605) do
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 "referentials", "referential_suites"
- 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
diff --git a/lib/osrm_route_section_processor.rb b/lib/osrm_route_section_processor.rb
deleted file mode 100644
index e9f92def0..000000000
--- a/lib/osrm_route_section_processor.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'open-uri'
-
-class OsrmRouteSectionProcessor
-
- def call(route_section)
- osrm_endpoint = Rails.application.secrets.osrm_endpoint
-
- points_string = (route_section.input_geometry || route_section.default_geometry).points.map do |point|
- "loc=#{point.y.to_f},#{point.x.to_f}"
- end.join
-
- Rails.logger.info "Invoke #{osrm_endpoint} for RouteSection StopArea:#{route_section.departure.id} -> StopArea:#{route_section.arrival.id}"
-
- response = open "#{osrm_endpoint}/viaroute?#{points_string}instructions=false"
- return nil unless response
-
- geometry = JSON.parse(response.read.to_s)['route_geometry']
- if geometry
- decoded_geometry = Polylines::Decoder.decode_polyline(geometry, 1e6).map do |point|
- GeoRuby::SimpleFeatures::Point.from_x_y(point[1], point[0], 4326)
- end
-
- GeoRuby::SimpleFeatures::LineString.from_points(decoded_geometry).try(:to_rgeo) if decoded_geometry.many?
- end
- rescue OpenURI::HTTPError => e
- Rails.logger.error "#{osrm_endpoint} failed: #{e}"
- nil
- rescue IOError => e
- Rails.logger.error "#{osrm_endpoint} failed: #{e}"
- nil
- end
-
- def self.create_all
- Chouette::JourneyPattern.find_each do |journey_pattern|
- selector = RouteSectionsSelector.new(journey_pattern)
- selector.sections.each do |section|
- section.create_candidate unless section.candidates.present?
- end
- end
- end
-
-end
diff --git a/lib/stif/permission_translator.rb b/lib/stif/permission_translator.rb
index 121e89694..2d267bc7b 100644
--- a/lib/stif/permission_translator.rb
+++ b/lib/stif/permission_translator.rb
@@ -29,8 +29,8 @@ module Stif
vehicle_journeys
api_keys
compliance_controls
- compliance_controls_sets
- compliance_controls_blocks
+ compliance_control_sets
+ compliance_control_blocks
compliance_check_sets
]
end
diff --git a/lib/tasks/route_sections.rake b/lib/tasks/route_sections.rake
deleted file mode 100644
index d48ddbba4..000000000
--- a/lib/tasks/route_sections.rake
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace :route_sections do
-
- def find_referential(id_or_slug)
- if id_or_slug.to_s =~ /\A\d+\Z/
- Referential.find id_or_slug.to_i
- else
- Referential.find_by slug: id_or_slug
- end
- end
-
- desc "Generate all RouteSections for a given Referential"
- task :create_all, [:referential] => [:environment] do |t, args|
- find_referential(args[:referential]).switch
- OsrmRouteSectionProcessor.create_all
- end
-
-end
diff --git a/spec/controllers/api/v1/compliance_check_sets_controller_spec.rb b/spec/controllers/api/v1/compliance_check_sets_controller_spec.rb
new file mode 100644
index 000000000..1c3784807
--- /dev/null
+++ b/spec/controllers/api/v1/compliance_check_sets_controller_spec.rb
@@ -0,0 +1,37 @@
+RSpec.describe Api::V1::ComplianceCheckSetsController, type: :controller do
+ include_context 'iboo authenticated api user'
+
+ describe "POST #validate" do
+ let(:check_set) { create(:compliance_check_set) }
+
+ it "calls #update_status on the ComplianceCheckSet" do
+ expect_any_instance_of(ComplianceCheckSet).to receive(:update_status)
+
+ patch :validated, id: check_set.id
+ end
+
+ context "responds with" do
+ render_views
+
+ it "object JSON on #update_status true" do
+ allow_any_instance_of(
+ ComplianceCheckSet
+ ).to receive(:update_status).and_return(true)
+
+ patch :validated, id: check_set.id
+
+ expect(JSON.parse(response.body)['id']).to eq(check_set.id)
+ end
+
+ it "error JSON on #update_status false" do
+ allow_any_instance_of(
+ ComplianceCheckSet
+ ).to receive(:update_status).and_return(false)
+
+ patch :validated, id: check_set.id
+
+ expect(response.body).to include('error')
+ end
+ end
+ end
+end
diff --git a/spec/controllers/routes_controller_spec.rb b/spec/controllers/routes_controller_spec.rb
index 42064b5ea..c5e0cdf20 100644
--- a/spec/controllers/routes_controller_spec.rb
+++ b/spec/controllers/routes_controller_spec.rb
@@ -87,8 +87,8 @@ RSpec.describe RoutesController, type: :controller do
id: route.id
end.to change { Chouette::Route.count }.by(1)
- expect(Chouette::Route.last.name).to eq(route.name)
- expect(Chouette::Route.last.published_name).to eq(route.published_name)
+ expect(Route.last.name).to eq( I18n.t('activerecord.copy', name: route.name))
+ expect(Route.last.published_name).to eq(route.published_name)
end
end
end
diff --git a/spec/factories/chouette_route_sections.rb b/spec/factories/chouette_route_sections.rb
deleted file mode 100644
index d5e2cf69d..000000000
--- a/spec/factories/chouette_route_sections.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-FactoryGirl.define do
- factory :route_section, :class => Chouette::RouteSection do
- association :departure, :factory => :stop_area
- association :arrival, :factory => :stop_area
- end
-end
diff --git a/spec/models/chouette/route/route_duplication_spec.rb b/spec/models/chouette/route/route_duplication_spec.rb
index b8a8c1b35..ee45b5005 100644
--- a/spec/models/chouette/route/route_duplication_spec.rb
+++ b/spec/models/chouette/route/route_duplication_spec.rb
@@ -1,8 +1,3 @@
-# From Chouette import what we need ™
-# Route = Chouette::Route
-# StopArea = Chouette::StopArea
-# StopPoint = Chouette::StopPoint
-
RSpec.describe Chouette::Route do
let!( :route ){ create :route }
@@ -11,7 +6,7 @@ RSpec.describe Chouette::Route do
describe 'properties' do
it 'same attribute values' do
route.duplicate
- expect( values_for_create(Chouette::Route.last, except: %w{objectid}) ).to eq( values_for_create( route, except: %w{objectid} ) )
+ expect( values_for_create(Chouette::Route.last, except: %w{objectid name checksum checksum_source}) ).to eq( values_for_create( route, except: %w{objectid name checksum checksum_source} ) )
end
it 'and others cannot' do
expect{ route.duplicate name: 'YAN', line_id: 42 }.to raise_error(ArgumentError)
@@ -38,7 +33,7 @@ RSpec.describe Chouette::Route do
let( :second_duplicate ){ first_duplicate.reload.duplicate }
it 'the required attributes' do
- expect( values_for_create(first_duplicate, except: %w{objectid}) ).to eq( values_for_create( second_duplicate, except: %w{objectid} ) )
+ expect( values_for_create(first_duplicate, except: %w{objectid name checksum checksum_source}) ).to eq( values_for_create( second_duplicate, except: %w{objectid name checksum checksum_source} ) )
end
it 'the stop areas' do
diff --git a/spec/models/chouette/route_section_spec.rb b/spec/models/chouette/route_section_spec.rb
deleted file mode 100644
index f064d38ea..000000000
--- a/spec/models/chouette/route_section_spec.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-# require 'spec_helper'
-#
-# RSpec.describe Chouette::RouteSection, :type => :model do
-#
-# subject { create :route_section }
-#
-# it { should validate_presence_of(:departure) }
-# it { should validate_presence_of(:arrival) }
-#
-# describe "#default_geometry" do
-#
-# it "should return nil when departure isn't defined" do
-# subject.departure = nil
-# expect(subject.default_geometry).to be_nil
-# end
-#
-# it "should return nil when arrival isn't defined" do
-# subject.arrival = nil
-# expect(subject.default_geometry).to be_nil
-# end
-#
-# it "should return nil when departure has no geometry" do
-# subject.departure.stub :geometry
-# expect(subject.default_geometry).to be_nil
-# end
-#
-# it "should return nil when arrival has no geometry" do
-# subject.arrival.stub :geometry
-# expect(subject.default_geometry).to be_nil
-# end
-#
-# it "should use departure geometry as first point" do
-# expect(subject.default_geometry.first).to eq(subject.departure.geometry)
-# end
-#
-# end
-#
-# describe "#process_geometry" do
-#
-# let(:sample_geometry) { line_string("0 0,1 1").to_rgeo }
-#
-# context "without processor" do
-#
-# it "should use the input geometry" do
-# subject.input_geometry = sample_geometry
-# subject.process_geometry
-# expect(subject.processed_geometry).to eq(subject.input_geometry)
-# end
-#
-# it "should use the default geometry when no input is defined" do
-# subject.input_geometry = nil
-# subject.process_geometry
-# expect(subject.processed_geometry).to eq(subject.default_geometry.to_rgeo)
-# end
-#
-# end
-#
-# # context "with a processor" do
-# #
-# # it "should use the processor result" do
-# # subject.processor = Proc.new { |s| sample_geometry }
-# # subject.process_geometry
-# # subject.processor = nil
-# # expect(subject.processed_geometry).to eq(sample_geometry)
-# # end
-# # end
-# end
-#
-# describe "#distance" do
-#
-# context "with simple line" do
-# let(:sample_geometry) { line_string("2.329534 48.842397,2.325725 48.855839").to_rgeo }
-# it "should return the right distance" do
-# subject.input_geometry = sample_geometry
-# subject.process_geometry
-# expect(subject.distance).to eq(sample_geometry.to_georuby.spherical_distance)
-# end
-# end
-#
-# context "with complex line" do
-# let(:sample_geometry) { line_string("2.329561 48.842397, 2.329351 48.843119, 2.329152 48.843801, 2.3289820000000003 48.844426,2.3287960000000005 48.845059,2.3286540000000007 48.845575,2.3283130000000005 48.846748,2.3281220000000005 48.847404999999995,2.3279330000000003 48.848088,2.3278860000000003 48.848245999999996,2.3273240000000004 48.850142999999996,2.3273030000000006 48.850218999999996,2.3271630000000005 48.850745999999994,2.3270140000000006 48.85130999999999,2.3269350000000006 48.85142799999999,2.3268640000000005 48.85153599999999,2.3268290000000005 48.85161099999999,2.3267490000000004 48.85180999999999,2.3267700000000002 48.852053999999995,2.326759 48.852216999999996,2.326687 48.852427999999996,2.3266620000000002 48.852512,2.3264280000000004 48.853286,2.3264050000000003 48.853362,2.3263710000000004 48.853483,2.326125 48.854343,2.3259980000000002 48.854727,2.325737 48.855833999999994").to_rgeo }
-# it "should return the right distance" do
-# subject.input_geometry = sample_geometry
-# subject.process_geometry
-# expect(subject.distance).to eq(sample_geometry.to_georuby.spherical_distance)
-# end
-# end
-#
-# end
-#
-#
-#
-# end
diff --git a/spec/models/compliance_check_set_spec.rb b/spec/models/compliance_check_set_spec.rb
index 8afea5b3e..0159d1c6b 100644
--- a/spec/models/compliance_check_set_spec.rb
+++ b/spec/models/compliance_check_set_spec.rb
@@ -12,4 +12,81 @@ RSpec.describe ComplianceCheckSet, type: :model do
it { should have_many :compliance_checks }
it { should have_many :compliance_check_blocks }
+
+ describe "#update_status" do
+ it "updates :status to successful when all resources are OK" do
+ check_set = create(:compliance_check_set)
+ create_list(
+ :compliance_check_resource,
+ 2,
+ compliance_check_set: check_set,
+ status: 'OK'
+ )
+
+ check_set.update_status
+
+ expect(check_set.status).to eq('successful')
+ end
+
+ it "updates :status to failed when one resource is ERROR" do
+ check_set = create(:compliance_check_set)
+ create(
+ :compliance_check_resource,
+ compliance_check_set: check_set,
+ status: 'ERROR'
+ )
+ create(
+ :compliance_check_resource,
+ compliance_check_set: check_set,
+ status: 'OK'
+ )
+
+ updated = check_set.update_status
+
+ expect(updated).to be true
+ expect(check_set.status).to eq('failed')
+ end
+
+ it "updates :status to warning when one resource is WARNING" do
+ check_set = create(:compliance_check_set)
+ create(
+ :compliance_check_resource,
+ compliance_check_set: check_set,
+ status: 'WARNING'
+ )
+ create(
+ :compliance_check_resource,
+ compliance_check_set: check_set,
+ status: 'OK'
+ )
+
+ check_set.update_status
+
+ expect(check_set.status).to eq('warning')
+ end
+
+ it "updates :status to successful when resources are IGNORED" do
+ check_set = create(:compliance_check_set)
+ create(
+ :compliance_check_resource,
+ compliance_check_set: check_set,
+ status: 'IGNORED'
+ )
+ create(
+ :compliance_check_resource,
+ compliance_check_set: check_set,
+ status: 'OK'
+ )
+
+ check_set.update_status
+
+ expect(check_set.status).to eq('successful')
+ end
+
+ it "returns true when the status did not get updated" do
+ check_set = create(:compliance_check_set)
+
+ expect(check_set.update_status).to be true
+ end
+ end
end
diff --git a/spec/models/route_sections_selector_spec.rb b/spec/models/route_sections_selector_spec.rb
deleted file mode 100644
index 19863c315..000000000
--- a/spec/models/route_sections_selector_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# require 'spec_helper'
-#
-# describe RouteSectionsSelector, :type => :model do
-#
-# let(:stop_points) { create_list :stop_point, 5 }
-# let(:itinerary) { double stop_points: stop_points, route_sections: [] }
-#
-# subject { RouteSectionsSelector.new itinerary }
-#
-# describe "#sections" do
-#
-# it "should create a Section between each StopPoint" do
-# expect(subject.sections.size).to eq(stop_points.size - 1)
-# end
-#
-# end
-#
-# end
-#
-# describe RouteSectionsSelector::Section, :type => :model do
-#
-# let(:departure) { create :stop_point }
-# let(:arrival) { create :stop_point }
-#
-# subject { RouteSectionsSelector::Section.new departure, arrival }
-#
-# let(:route_sections) do
-# create_list :route_section, 5,
-# departure: departure.stop_area,
-# arrival: arrival.stop_area
-# end
-#
-# describe "#candidates" do
-# it "should return an empty array when no RouteSection exists" do
-# expect(subject.candidates).to be_empty
-# end
-#
-# it "should return the RouteSections with the same departure/arrival StopAreas" do
-# expect(subject.candidates).to match_array(route_sections)
-# end
-# end
-#
-# end
diff --git a/spec/policies/compliance_control_block_policy_spec.rb b/spec/policies/compliance_control_block_policy_spec.rb
new file mode 100644
index 000000000..02c4ae08d
--- /dev/null
+++ b/spec/policies/compliance_control_block_policy_spec.rb
@@ -0,0 +1,19 @@
+require 'rails_helper'
+
+RSpec.describe ComplianceControlBlockPolicy do
+
+ let( :record ){ build_stubbed :compliance_control_block }
+ before { stub_policy_scope(record) }
+
+ permissions :create? do
+ it_behaves_like 'permitted policy outside referential', 'compliance_control_blocks.create'
+ end
+
+ permissions :update? do
+ it_behaves_like 'permitted policy outside referential', 'compliance_control_blocks.update'
+ end
+
+ permissions :destroy? do
+ it_behaves_like 'permitted policy outside referential', 'compliance_control_blocks.destroy'
+ end
+end
diff --git a/spec/policies/compliance_control_policy_spec.rb b/spec/policies/compliance_control_policy_spec.rb
index d7c80143d..c66fa8f93 100644
--- a/spec/policies/compliance_control_policy_spec.rb
+++ b/spec/policies/compliance_control_policy_spec.rb
@@ -2,27 +2,18 @@ require 'rails_helper'
RSpec.describe ComplianceControlPolicy do
- let(:user) { User.new }
-
- subject { described_class }
-
- permissions ".scope" do
- pending "add some examples to (or delete) #{__FILE__}"
- end
-
- permissions :show? do
- pending "add some examples to (or delete) #{__FILE__}"
- end
+ let( :record ){ build_stubbed :compliance_control }
+ before { stub_policy_scope(record) }
permissions :create? do
- pending "add some examples to (or delete) #{__FILE__}"
+ it_behaves_like 'permitted policy outside referential', 'compliance_controls.create'
end
permissions :update? do
- pending "add some examples to (or delete) #{__FILE__}"
+ it_behaves_like 'permitted policy outside referential', 'compliance_controls.update'
end
permissions :destroy? do
- pending "add some examples to (or delete) #{__FILE__}"
+ it_behaves_like 'permitted policy outside referential', 'compliance_controls.destroy'
end
end
diff --git a/spec/policies/compliance_control_set_policy_spec.rb b/spec/policies/compliance_control_set_policy_spec.rb
new file mode 100644
index 000000000..9b89338d6
--- /dev/null
+++ b/spec/policies/compliance_control_set_policy_spec.rb
@@ -0,0 +1,23 @@
+require 'rails_helper'
+
+RSpec.describe ComplianceControlSetPolicy do
+
+ let( :record ){ build_stubbed :compliance_control_set }
+ before { stub_policy_scope(record) }
+
+ permissions :create? do
+ it_behaves_like 'permitted policy outside referential', 'compliance_control_sets.create'
+ end
+
+ permissions :update? do
+ it_behaves_like 'permitted policy outside referential', 'compliance_control_sets.update'
+ end
+
+ permissions :clone? do
+ it_behaves_like 'permitted policy outside referential', 'compliance_control_sets.create'
+ end
+
+ permissions :destroy? do
+ it_behaves_like 'permitted policy outside referential', 'compliance_control_sets.destroy'
+ end
+end
diff --git a/spec/support/permissions.rb b/spec/support/permissions.rb
index 7d09e16cb..dde530871 100644
--- a/spec/support/permissions.rb
+++ b/spec/support/permissions.rb
@@ -26,8 +26,8 @@ module Support
vehicle_journeys
api_keys
compliance_controls
- compliance_controls_sets
- compliance_controls_blocks
+ compliance_control_sets
+ compliance_control_blocks
compliance_check_sets
]
end
diff --git a/spec/support/pundit/shared_examples.rb b/spec/support/pundit/shared_examples.rb
index 49c6845da..49f915626 100644
--- a/spec/support/pundit/shared_examples.rb
+++ b/spec/support/pundit/shared_examples.rb
@@ -129,3 +129,23 @@ RSpec.shared_examples 'permitted policy' do
end
end
end
+
+RSpec.shared_examples 'permitted policy outside referential' do
+ | permission |
+
+ context 'permission absent → ' do
+ it "denies user" do
+ expect_it.not_to permit(user_context, record)
+ end
+ end
+
+ context 'permission present → ' do
+ before do
+ add_permissions(permission, to_user: user)
+ end
+
+ it 'allows user' do
+ expect_it.to permit(user_context, record)
+ end
+ end
+end \ No newline at end of file