diff options
| author | Robert | 2017-06-09 17:25:52 +0200 |
|---|---|---|
| committer | Robert | 2017-06-09 17:25:52 +0200 |
| commit | 5d16bcae1f2174c07177227b84e2563930e1ec90 (patch) | |
| tree | 01a17a211612bf0ebeb3f4c77a9bd86fdd52064a | |
| parent | 29fbffa1928fc08b5e2392afdd98cc1e2094f023 (diff) | |
| parent | 680b4a76a959b7c362a03c98b2c68733bcb601e5 (diff) | |
| download | chouette-core-5d16bcae1f2174c07177227b84e2563930e1ec90.tar.bz2 | |
conflict resolved
35 files changed, 656 insertions, 1058 deletions
diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/components/CreateModal.js b/app/assets/javascripts/es6_browserified/journey_patterns/components/CreateModal.js index aa2d208df..0ed8660d5 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/components/CreateModal.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/components/CreateModal.js @@ -22,90 +22,91 @@ class CreateModal extends Component { } if(this.props.status.fetchSuccess == true) { return ( - <div className='row mt-md'> - <div className='col-lg-12 text-right'> - <button - type='button' - className='btn btn-outline-primary' - data-toggle='modal' - data-target='#NewJourneyPatternModal' - onClick={this.props.onOpenCreateModal} - > - Ajouter une mission - </button> + <div className="select_toolbox"> + <ul> + <li className='st_action'> + <button + type='button' + data-toggle='modal' + data-target='#NewJourneyPatternModal' + onClick={this.props.onOpenCreateModal} + > + <span className="fa fa-plus"></span> + </button> - <div className={ 'modal fade ' + ((this.props.modal.type == 'create') ? 'in' : '') } id='NewJourneyPatternModal'> - <div className='modal-container'> - <div className='modal-dialog'> - <div className='modal-content'> - <div className='modal-header'> - <h4 className='modal-title'>Ajouter une mission</h4> - </div> + <div className={ 'modal fade ' + ((this.props.modal.type == 'create') ? 'in' : '') } id='NewJourneyPatternModal'> + <div className='modal-container'> + <div className='modal-dialog'> + <div className='modal-content'> + <div className='modal-header'> + <h4 className='modal-title'>Ajouter une mission</h4> + </div> - {(this.props.modal.type == 'create') && ( - <form> - <div className='modal-body'> - <div className='form-group'> - <label className='control-label is-required'>Nom</label> - <input - type='text' - ref='name' - className='form-control' - onKeyDown={(e) => actions.resetValidation(e.currentTarget)} - required - /> - </div> - <div className='row'> - <div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'> - <div className='form-group'> - <label className='control-label is-required'>Nom public</label> - <input - type='text' - ref='published_name' - className='form-control' - onKeyDown={(e) => actions.resetValidation(e.currentTarget)} - required - /> - </div> + {(this.props.modal.type == 'create') && ( + <form> + <div className='modal-body'> + <div className='form-group'> + <label className='control-label is-required'>Nom</label> + <input + type='text' + ref='name' + className='form-control' + onKeyDown={(e) => actions.resetValidation(e.currentTarget)} + required + /> </div> - <div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'> - <div className='form-group'> - <label className='control-label is-required'>Code mission</label> - <input - type='text' - ref='registration_number' - className='form-control' - onKeyDown={(e) => actions.resetValidation(e.currentTarget)} - required - /> + <div className='row'> + <div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'> + <div className='form-group'> + <label className='control-label is-required'>Nom public</label> + <input + type='text' + ref='published_name' + className='form-control' + onKeyDown={(e) => actions.resetValidation(e.currentTarget)} + required + /> + </div> + </div> + <div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'> + <div className='form-group'> + <label className='control-label is-required'>Code mission</label> + <input + type='text' + ref='registration_number' + className='form-control' + onKeyDown={(e) => actions.resetValidation(e.currentTarget)} + required + /> + </div> </div> </div> </div> - </div> - <div className='modal-footer'> - <button - className='btn btn-link' - data-dismiss='modal' - type='button' - onClick={this.props.onModalClose} - > - Annuler - </button> - <button - className='btn btn-primary' - type='button' - onClick={this.handleSubmit.bind(this)} - > - Valider - </button> - </div> - </form> - )} + <div className='modal-footer'> + <button + className='btn btn-link' + data-dismiss='modal' + type='button' + onClick={this.props.onModalClose} + > + Annuler + </button> + <button + className='btn btn-primary' + type='button' + onClick={this.handleSubmit.bind(this)} + > + Valider + </button> + </div> + </form> + )} + </div> </div> </div> </div> - </div> - </div> + </li> + </ul> </div> ) } else { diff --git a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js index 41d247b21..0a6e7e1dc 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js +++ b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js @@ -201,8 +201,8 @@ const actions = { start = new Date(start) end = new Date(end) _.each(periods, (period, i) => { - if(index != i && !period.deleted){ - if((new Date(period.period_start) <= start && new Date(period.period_end) >= start) || (new Date(period.period_start) <= end && new Date(period.period_end) >= end)) + if(index !== i && !period.deleted){ + if((new Date(period.period_start) <= start && new Date(period.period_end) >= start) || (new Date(period.period_start) <= end && new Date(period.period_end) >= end) || (start >= new Date(period.period_start) && end <= new Date(period.period_end)) || (start <= new Date(period.period_start) && end >= new Date(period.period_end))) error = 'Les périodes ne peuvent pas se chevaucher' } }) diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js b/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js index c2229d991..40ae0eccf 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js +++ b/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js @@ -2,7 +2,7 @@ var React = require('react') var Component = require('react').Component var PropTypes = require('react').PropTypes -const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, journeyPatterns}) => ( +const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, timetable, metas}) => ( <div className={ 'modal fade ' + ((modal.type == 'confirm') ? 'in' : '') } id='ConfirmModal'> <div className='modal-container'> <div className='modal-dialog'> @@ -28,7 +28,7 @@ const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, journeyPat className='btn btn-primary' data-dismiss='modal' type='button' - onClick = {() => {onModalAccept(modal.confirmModal.callback, journeyPatterns)}} + onClick = {() => {onModalAccept(modal.confirmModal.callback, timetable, metas)}} > Valider </button> diff --git a/app/assets/javascripts/es6_browserified/time_tables/containers/ConfirmModal.js b/app/assets/javascripts/es6_browserified/time_tables/containers/ConfirmModal.js index 8095e1e7c..6282c1d1d 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/containers/ConfirmModal.js +++ b/app/assets/javascripts/es6_browserified/time_tables/containers/ConfirmModal.js @@ -5,13 +5,14 @@ var ConfirmModal = require('../components/ConfirmModal') const mapStateToProps = (state) => { return { modal: state.modal, - journeyPatterns: state.journeyPatterns + timetable: state.timetable, + metas: state.metas } } const mapDispatchToProps = (dispatch) => { return { - onModalAccept: (next, timetable, metas, state) =>{ + onModalAccept: (next, timetable, metas) =>{ dispatch(actions.fetchingApi()) actions.submitTimetable(dispatch, timetable, metas, next) }, diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js index 4f1e7a528..2ce084efd 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js +++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js @@ -12,6 +12,9 @@ const metas = (state = {}, action) => { color: action.json.color, calendar: action.json.calendar ? action.json.calendar : null }) + case 'RECEIVE_MONTH': + let dt = (typeof state.day_types === 'string') ? actions.strToArrayDayTypes(state.day_types) : state.day_types + return _.assign({}, state, {day_types: dt}) case 'INCLUDE_DATE_IN_PERIOD': case 'EXCLUDE_DATE_FROM_PERIOD': case 'DELETE_PERIOD': diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js index 660484c58..3d96fb7b7 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js +++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js @@ -5,8 +5,12 @@ const pagination = (state = {}, action) => { case 'RECEIVE_TIME_TABLES': return _.assign({}, state, { currentPage: action.json.current_periode_range, - periode_range: action.json.periode_range + periode_range: action.json.periode_range, + stateChanged: false }) + case 'RECEIVE_MONTH': + case 'RECEIVE_ERRORS': + return _.assign({}, state, {stateChanged: false}) case 'GO_TO_PREVIOUS_PAGE': case 'GO_TO_NEXT_PAGE': let nextPage = action.nextPage ? 1 : -1 @@ -22,7 +26,6 @@ const pagination = (state = {}, action) => { case 'VALIDATE_PERIOD_FORM': case 'UPDATE_COMMENT': case 'UPDATE_COLOR': - case 'UPDATE_DAY_TYPES': toggleOnConfirmModal('modal') return _.assign({}, state, {stateChanged: true}) default: diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js index ba27ca72c..97aa60526 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js @@ -8,10 +8,10 @@ var actions = require("./actions") var enableBatching = require('./batch').enableBatching // logger, DO NOT REMOVE -var applyMiddleware = require('redux').applyMiddleware -var createLogger = require('redux-logger') -var thunkMiddleware = require('redux-thunk').default -var promise = require('redux-promise') +// var applyMiddleware = require('redux').applyMiddleware +// var createLogger = require('redux-logger') +// var thunkMiddleware = require('redux-thunk').default +// var promise = require('redux-promise') var selectedJP = [] @@ -85,12 +85,12 @@ if (window.jpOrigin){ initialState.filters.queryString = actions.encodeParams(params) } -const loggerMiddleware = createLogger() +// const loggerMiddleware = createLogger() let store = createStore( enableBatching(vehicleJourneysApp), - initialState, - applyMiddleware(thunkMiddleware, promise, loggerMiddleware) + initialState + // applyMiddleware(thunkMiddleware, promise, loggerMiddleware) ) render( diff --git a/app/assets/stylesheets/components/_tables.sass b/app/assets/stylesheets/components/_tables.sass index 0cd91a1a8..e3a33e131 100644 --- a/app/assets/stylesheets/components/_tables.sass +++ b/app/assets/stylesheets/components/_tables.sass @@ -82,6 +82,66 @@ border-top: 2px solid $darkgrey margin-top: 15px + // Specific for tables displaying stop points + &.has-stoppoints + tbody + > tr > td:first-child + position: relative + padding-left: 25px + + &:before + content: '' + display: block + width: 10px + height: 10px + background-color: #fff + border: 2px solid $blue + border-radius: 50% + position: absolute + z-index: 5 + left: 5px + top: 50% + margin-top: -5px + + &:after + content: '' + display: block + width: 4px + margin: 0 3px + background-color: rgba($grey, 0.5) + position: absolute + z-index: 3 + top: 0 + left: 5px + bottom: 0 + + > tr:first-child > td:first-child + &:after + content: '' + top: 50% + + > tr:last-child > td:first-child + &:after + content: '' + bottom: 50% + + > tr:first-child > td:first-child, > tr:last-child > td:first-child + &:before + content: '•' + color: $blue + text-align: center + font-size: 28px + letter-spacing: 0 + text-indent: -0.01em + line-height: 12px + width: 15px + height: 15px + left: 2px + top: 50% + margin-top: -8px + + + // select_toolbox .select_toolbox padding: 10px diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb index f2f74e801..b5072f401 100644 --- a/app/controllers/routing_constraint_zones_controller.rb +++ b/app/controllers/routing_constraint_zones_controller.rb @@ -1,6 +1,7 @@ class RoutingConstraintZonesController < ChouetteController - defaults resource_class: Chouette::RoutingConstraintZone + include PolicyChecker + defaults resource_class: Chouette::RoutingConstraintZone respond_to :html, :xml, :json before_action :remove_empty_stop_point, only: [:create, :update] @@ -9,11 +10,50 @@ class RoutingConstraintZonesController < ChouetteController belongs_to :line, parent_class: Chouette::Line end - include PolicyChecker + def index + @routing_constraint_zones = collection + end + + def show + @routing_constraint_zone = collection.find(params[:id]) + end + + protected + + def collection + @q = resource.routing_constraint_zones.search(params[:q]) + + if sort_column && sort_direction + @routing_constraint_zones ||= @q.result(distinct: true).order(sort_column + ' ' + sort_direction) + else + @routing_constraint_zones ||= @q.result(distinct: true).order(:name) + end + @routing_constraint_zones = @routing_constraint_zones.paginate(page: params[:page], per_page: 10) + end private + def sort_column + (Chouette::RoutingConstraintZone.column_names).include?(params[:sort]) ? params[:sort] : 'name' + end + def sort_direction + %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' + end + + def resource + @referential = Referential.find params[:referential_id] + @line = @referential.lines.find params[:line_id] + end + def routing_constraint_zone_params - params.require(:routing_constraint_zone).permit(:name, { stop_point_ids: [] }, :line_id, :route_id, :objectid, :object_version, :creator_id) + params.require(:routing_constraint_zone).permit( + :name, + { stop_point_ids: [] }, + :line_id, + :route_id, + :objectid, + :object_version, + :creator_id + ) end def remove_empty_stop_point diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb index f03228d73..3d43e9fc7 100644 --- a/app/helpers/newapplication_helper.rb +++ b/app/helpers/newapplication_helper.rb @@ -16,7 +16,7 @@ module NewapplicationHelper end columns.map do |k, v| - if ["ID Codif", "Oid", "OiD", "ID Reflex", "Arrêt de départ", "Arrêt d'arrivée", "Période de validité englobante", "Période englobante", "Nombre de courses associées", "Journées d'application"].include? k + if ["ID Codif", "Oid", "OiD", "ID Reflex", "Arrêt de départ", "Arrêt d'arrivée", "Période de validité englobante", "Période englobante", "Nombre de courses associées", "Journées d'application", "Arrêts de l'itinéraire", "Arrêts inclus dans l'ITL"].include? k hcont << content_tag(:th, k) else hcont << content_tag(:th, sortable_columns(collection, k)) diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb index 2d329bcc6..151570f20 100644 --- a/app/models/chouette/time_table.rb +++ b/app/models/chouette/time_table.rb @@ -135,6 +135,10 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord [Chouette::TimeTable.maximum(:end_date)].compact.max end + def add_exclude_date(in_out, date) + self.dates.create!({in_out: in_out, date: date}) + end + def actualize self.dates.clear self.periods.clear diff --git a/app/models/chouette/time_table_date.rb b/app/models/chouette/time_table_date.rb index 4624ae88e..b881c9a5d 100644 --- a/app/models/chouette/time_table_date.rb +++ b/app/models/chouette/time_table_date.rb @@ -6,6 +6,8 @@ class Chouette::TimeTableDate < Chouette::ActiveRecord validates_presence_of :date validates_uniqueness_of :date, :scope => :time_table_id + scope :in_dates, -> { where(in_out: true) } + def self.model_name ActiveModel::Name.new Chouette::TimeTableDate, Chouette, "TimeTableDate" end diff --git a/app/models/clean_up.rb b/app/models/clean_up.rb index 457e90b65..a2b150ecc 100644 --- a/app/models/clean_up.rb +++ b/app/models/clean_up.rb @@ -15,25 +15,96 @@ class CleanUp < ActiveRecord::Base end def clean - result = {} - result['time_table_count'] = self.clean_time_tables - result['vehicle_journey_count'] = self.clean_vehicle_journeys - result['journey_pattern_count'] = self.clean_journey_patterns - result + {}.tap do |result| + result['time_table'] = send("destroy_time_tables_#{self.date_type}").try(:count) + result['time_table_date'] = send("destroy_time_tables_dates_#{self.date_type}").try(:count) + result['time_table_period'] = send("destroy_time_tables_periods_#{self.date_type}").try(:count) + self.overlapping_periods.each do |period| + exclude_dates_in_overlapping_period(period) + end + end + end + + def destroy_time_tables_between + time_tables = Chouette::TimeTable.where('end_date <= ? AND start_date >= ?', self.end_date, self.begin_date) + self.destroy_time_tables(time_tables) + end + + def destroy_time_tables_before + time_tables = Chouette::TimeTable.where('end_date <= ?', self.begin_date) + self.destroy_time_tables(time_tables) + end + + def destroy_time_tables_after + time_tables = Chouette::TimeTable.where('start_date >= ?', self.begin_date) + self.destroy_time_tables(time_tables) + end + + def destroy_time_table_dates_before + Chouette::TimeTableDate.in_dates.where('date <= ?', self.begin_date).destroy_all + end + + def destroy_time_tables_dates_after + Chouette::TimeTableDate.in_dates.where('date >= ?', self.begin_date).destroy_all + end + + def destroy_time_tables_dates_between + Chouette::TimeTableDate.in_dates.where('date >= ? AND date <= ?', self.begin_date, self.end_date).destroy_all end - def clean_time_tables - Chouette::TimeTable.validity_out_between?(begin_date, end_date).delete_all + def destroy_time_tables_periods_before + Chouette::TimeTablePeriod.where('period_end <= ?', self.begin_date).destroy_all end - def clean_vehicle_journeys - ids = Chouette::VehicleJourney.includes(:time_tables).where(:time_tables => {id: nil}).pluck(:id) - Chouette::VehicleJourney.where(id: ids).delete_all + def destroy_time_tables_periods_after + Chouette::TimeTablePeriod.where('period_start >= ?', self.begin_date).destroy_all end - def clean_journey_patterns - ids = Chouette::JourneyPattern.includes(:vehicle_journeys).where(:vehicle_journeys => {id: nil}).pluck(:id) - Chouette::JourneyPattern.where(id: ids).delete_all + def destroy_time_tables_periods_between + Chouette::TimeTablePeriod.where('period_start >= ? AND period_end <= ?', self.begin_date, self.end_date).destroy_all + end + + def overlapping_periods + self.end_date = self.begin_date if self.date_type != 'between' + Chouette::TimeTablePeriod.where('(period_start, period_end) OVERLAPS (?, ?)', self.begin_date, self.end_date) + end + + def exclude_dates_in_overlapping_period(period) + days_in_period = period.period_start..period.period_end + day_out = period.time_table.dates.where(in_out: false).map(&:date) + # check if day is greater or less then cleanup date + if date_type != 'between' + operator = date_type == 'after' ? '>' : '<' + to_exclude_days = days_in_period.map do |day| + day if day.public_send(operator, self.begin_date) + end + else + days_in_cleanup_periode = (self.begin_date..self.end_date) + to_exclude_days = days_in_period & days_in_cleanup_periode + end + + to_exclude_days.to_a.compact.each do |day| + # we ensure day is not already an exclude date + if !day_out.include?(day) + self.add_exclude_date(period.time_table, day) + end + end + end + + def add_exclude_date(time_table, day) + day_in = time_table.dates.where(in_out: true).map(&:date) + unless day_in.include?(day) + time_table.add_exclude_date(false, day) + else + time_table.dates.where(date: day).take.update_attribute(:in_out, false) + end + end + + def destroy_time_tables(time_tables) + time_tables.each do |time_table| + time_table.vehicle_journeys.map(&:destroy) + end + time_tables.destroy_all end aasm column: :status do @@ -61,11 +132,11 @@ class CleanUp < ActiveRecord::Base def log_successful message_attributs update_attribute(:ended_at, Time.now) - CleanUpResult.create(clean_up: self, message_key: :successfull, message_attributs: message_attributs) + CleanUpResult.create(destroy_up: self, message_key: :successfull, message_attributs: message_attributs) end def log_failed message_attributs update_attribute(:ended_at, Time.now) - CleanUpResult.create(clean_up: self, message_key: :failed, message_attributs: message_attributs) + CleanUpResult.create(destroy_up: self, message_key: :failed, message_attributs: message_attributs) end end diff --git a/app/views/referential_lines/index.js.slim b/app/views/referential_lines/index.js.slim deleted file mode 100644 index 0165fb077..000000000 --- a/app/views/referential_lines/index.js.slim +++ /dev/null @@ -1 +0,0 @@ -| $('#lines').html("#{escape_javascript(render('lines'))}");
\ No newline at end of file diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index 1e24f0f15..db99381d3 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -1,26 +1,23 @@ / PageHeader = pageheader 'map-marker', @line.name, - 'Lorem ipsum dolor sit amet', + '', t('last_update', time: l(@line.updated_at, format: :short)) do / Below is secundary actions & optional contents .row .col-lg-12.text-right.mb-sm - / = link_to t('lines.actions.show_network'), [@referential, @line.network], class: 'btn btn-primary' - / = link_to t('lines.actions.show_company'), [@referential, @line.company], class: 'btn btn-primary' - = link_to @line.human_attribute_name(:footnotes), referential_line_footnotes_path(@referential, @line), class: 'btn btn-primary' - = link_to Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr), referential_line_routing_constraint_zones_path(@referential, @line), class: 'btn btn-primary disabled' + = link_to t('routing_constraint_zones.index.title'), referential_line_routing_constraint_zones_path(@referential, @line), class: 'btn btn-primary' - if policy(Chouette::Line).create? && @referential.organisation == current_organisation - = link_to t('lines.actions.new'), new_referential_line_path(@referential), class: 'btn btn-primary' + = link_to t('actions.new'), new_referential_line_path(@referential), class: 'btn btn-primary' - if policy(@line).update? - = link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), class: 'btn btn-primary' + = link_to t('actions.edit'), edit_referential_line_path(@referential, @line), class: 'btn btn-primary' - if policy(@line).destroy? = link_to referential_line_path(@referential, @line), method: :delete, data: {confirm: t('lines.actions.destroy_confirm')}, class: 'btn btn-primary' do span.fa.fa-trash - span = t('lines.actions.destroy') + span = t('actions.destroy') - if !@line.hub_restricted? || (@line.hub_restricted? && @line.routes.size < 2) - if policy(Chouette::Route).create? && @referential.organisation == current_organisation diff --git a/app/views/routing_constraint_zones/_filters.html.slim b/app/views/routing_constraint_zones/_filters.html.slim new file mode 100644 index 000000000..18ef40d61 --- /dev/null +++ b/app/views/routing_constraint_zones/_filters.html.slim @@ -0,0 +1,16 @@ += search_form_for @q, url: referential_line_routing_constraint_zones_path(@referential, @line), class: 'form form-filter' do |f| + .ffg-row + .input-group.search_bar + = f.search_field :name_or_objectid_cont, class: 'form-control', placeholder: "Indiquez un nom d'ITL ou un OiD..." + span.input-group-btn + button.btn.btn-default#search-btn type='submit' + span.fa.fa-search + + .ffg-row + .form-group + = f.label 'Itinéraire associé', required: false, class: 'control-label' + = f.input :route_id, as: :select, collection: @line.routing_constraint_zones.pluck(:route_id), label: false, label_method: lambda {|r| @line.routing_constraint_zones.find_by(route_id: r).route_name}, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Indiquez un itinéraire...' }, wrapper_html: { class: 'select2ed'} + + .actions + = link_to 'Effacer', referential_line_routing_constraint_zones_path(@referential, @line), class: 'btn btn-link' + = f.submit 'Filtrer', class: 'btn btn-default' diff --git a/app/views/routing_constraint_zones/_form.html.slim b/app/views/routing_constraint_zones/_form.html.slim index b1c77a44b..082e8f7f8 100644 --- a/app/views/routing_constraint_zones/_form.html.slim +++ b/app/views/routing_constraint_zones/_form.html.slim @@ -1,19 +1,14 @@ -= simple_form_for [@referential, @line, @routing_constraint_zone] do |f| - .row - .col-lg-6.col-sm-12 - = f.input :name - .row - .col-lg-6.col-sm-12 - = f.input :route_id, collection: @line.routes.select { |route| route.stop_points.count > 2 }, include_blank: false - .row - .col-lg-6.col-sm-12 - - stop_points_collection = @routing_constraint_zone.persisted? ? @routing_constraint_zone.route.stop_points : [] - = f.input :stop_point_ids, as: :select, collection: stop_points_collection, selected: @routing_constraint_zone.stop_point_ids, label: Chouette::StopPoint.model_name.human.pluralize.capitalize, label_method: :name, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Sélection des arrêts sur séquence d\'arrêts', 'multiple': 'multiple', style: 'width: 100%' } += simple_form_for [@referential, @line, @routing_constraint_zone], html: {class: 'form-horizontal', id: 'itl_form'}, wrapper: :horizontal_form do |form| .row - .col-lg-12.text-right - = link_to 'Annuler', :back, class: 'btn btn-link' - = f.button :submit, class: 'btn btn-danger' + .col-lg-12 + = form.input :name + + = form.input :route_id, collection: @line.routes.select { |route| route.stop_points.count > 2 }, include_blank: false + + - stop_points_collection = @routing_constraint_zone.persisted? ? @routing_constraint_zone.route.stop_points : [] + = form.input :stop_point_ids, as: :select, collection: stop_points_collection, selected: @routing_constraint_zone.stop_point_ids, label: Chouette::StopPoint.model_name.human.pluralize.capitalize, label_method: :name, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Sélection des arrêts sur séquence d\'arrêts', 'multiple': 'multiple', style: 'width: 100%' } + = form.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'itl_form' -= hidden_field_tag 'stop_point_ids', @routing_constraint_zone.stop_point_ids.to_s, id: 'stop_point_ids' + = hidden_field_tag 'stop_point_ids', @routing_constraint_zone.stop_point_ids.to_s, id: 'stop_point_ids' diff --git a/app/views/routing_constraint_zones/edit.html.slim b/app/views/routing_constraint_zones/edit.html.slim index fcb0d08a8..d81a347e0 100644 --- a/app/views/routing_constraint_zones/edit.html.slim +++ b/app/views/routing_constraint_zones/edit.html.slim @@ -1,5 +1,12 @@ -= title_tag t('.title', routing_constraint_zone: @routing_constraint_zone.name) +/ PageHeader += pageheader 'map-marker', + t('.title'), + '', + t('last_update', time: l(@routing_constraint_zone.updated_at, format: :short)) -.row - .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2 - == render 'form' +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + == render 'form' diff --git a/app/views/routing_constraint_zones/index.html.slim b/app/views/routing_constraint_zones/index.html.slim index 620b0f7db..248efedb4 100644 --- a/app/views/routing_constraint_zones/index.html.slim +++ b/app/views/routing_constraint_zones/index.html.slim @@ -1,11 +1,30 @@ -= title_tag Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr) +/ PageHeader += pageheader 'map-marker', + t('routing_constraint_zones.index.title'), + '', + '', + ((policy(Chouette::RoutingConstraintZone).create? && @referential.organisation == current_organisation) ? link_to(t('actions.new'), new_referential_line_routing_constraint_zone_path(@referential, @line), class: 'btn btn-primary') : '') -- if policy(Chouette::RoutingConstraintZone).create? && @referential.organisation == current_organisation - = link_to t('routing_constraint_zones.actions.new'), new_referential_line_routing_constraint_zone_path(@referential, @line) +/ PageContent +.page_content + .container-fluid + - if params[:q].present? or @routing_constraint_zones.any? + .row + .col-lg-12 + = render 'filters' -- if @routing_constraint_zones.any? - = table_builder @routing_constraint_zones, - { objectid: 'objectid', name: 'name', route: 'route_name', stop_points_count: 'stop_points_count' }, - [:show, :edit, :delete], - [], - 'table table-bordered' + - if @routing_constraint_zones.any? + .row + .col-lg-12 + = table_builder @routing_constraint_zones, + { 'Oid' => Proc.new { |n| n.try(:objectid).try(:local_id) }, + :name => 'name', :stop_points_count => 'stop_points_count', + :route => 'route_name' }, + [:show, :edit, :delete], + [], + 'table has-filter has-search' + + - unless @routing_constraint_zones.any? + .row.mt-xs + .col-lg-12 + = replacement_msg t('routing_constraint_zones.search_no_results') diff --git a/app/views/routing_constraint_zones/new.html.slim b/app/views/routing_constraint_zones/new.html.slim index fcb0d08a8..f6ae62825 100644 --- a/app/views/routing_constraint_zones/new.html.slim +++ b/app/views/routing_constraint_zones/new.html.slim @@ -1,5 +1,10 @@ -= title_tag t('.title', routing_constraint_zone: @routing_constraint_zone.name) +/ PageHeader += pageheader 'map-marker', + t('.title') -.row - .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2 - == render 'form' +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + == render 'form' diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim index 351784ecc..f0c244387 100644 --- a/app/views/routing_constraint_zones/show.html.slim +++ b/app/views/routing_constraint_zones/show.html.slim @@ -1,17 +1,35 @@ -= title_tag @routing_constraint_zone.name +/ PageHeader += pageheader 'map-marker', + @routing_constraint_zone.name, + '', + t('last_update', time: l(@routing_constraint_zone.updated_at, format: :short)) do -p - label => "#{@routing_constraint_zone.human_attribute_name(:name)} : " - = @routing_constraint_zone.name + / Below is secundary actions & optional contents + .row + .col-lg-12.text-right.mb-sm + - if policy(@routing_constraint_zone).update? + = link_to t('actions.edit'), edit_referential_line_routing_constraint_zone_path(@referential, @line, @routing_constraint_zone), class: 'btn btn-primary' -p - label => "#{Chouette::Route.model_name.human.capitalize} : " - = link_to @routing_constraint_zone.route.name, referential_line_route_path(@referential, @line, @routing_constraint_zone.route) + - if policy(@routing_constraint_zone).destroy? + = link_to referential_line_routing_constraint_zone_path(@referential, @line, @routing_constraint_zone), method: :delete, data: {confirm: t('routing_constraint_zones.actions.destroy_confirm')}, class: 'btn btn-primary' do + span.fa.fa-trash + span = t('actions.destroy') -p - label => "#{Chouette::StopPoint.model_name.human.pluralize.capitalize} : " - br - - @routing_constraint_zone.stop_points.each do |stop_point| - = link_to stop_point.name, referential_stop_area_path(@referential, stop_point.stop_area) - br +/ PageContent +.page_content + .container-fluid + .row + .col-lg-6.col-md-6.col-sm-12.col-xs-12 + = definition_list t('metadatas'), + { @routing_constraint_zone.human_attribute_name(:name) => @routing_constraint_zone.try(:name), + @routing_constraint_zone.human_attribute_name(:route) => link_to(@routing_constraint_zone.try(:route_name), [@referential, @line, @routing_constraint_zone.route]), + @routing_constraint_zone.human_attribute_name(:line) => link_to(@line.name, [@referential, @line])} + .row + .col-lg-12 + = table_builder @routing_constraint_zone.route.stop_points, + { "Arrêts de l'itinéraire" => 'name', + "Arrêts inclus dans l'ITL" => Proc.new{ |rsp| (@routing_constraint_zone.stop_points.collect{|c| c.name}.include? rsp.name) ? 'Oui' : 'Non' } }, + [], + [], + 'table has-stoppoints' diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim index c17f96c85..402b09b98 100644 --- a/app/views/time_tables/index.html.slim +++ b/app/views/time_tables/index.html.slim @@ -20,7 +20,7 @@ "Nombre de courses associées" => Proc.new{ |tt| tt.vehicle_journeys.count }, "Journées d'application" => Proc.new{ |tt| (%w(monday tuesday wednesday thursday friday saturday sunday).collect{|d| tt.send(d) ? t("calendars.days.#{d}") : '' }).reject{|a| a.empty?}.join(', ').html_safe }, :calendar => Proc.new{ |tt| tt.calendar ? tt.calendar.try(:name) : '-' }, :updated_at => Proc.new {|tt| l(tt.updated_at, format: :short)} }, - [:show, :edit, :duplicate, :delete], + [:show, :edit, :duplicate, :actualize, :delete], [], 'table has-search' diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim index 1c5984a7d..2e71ebb9e 100644 --- a/app/views/time_tables/show.html.slim +++ b/app/views/time_tables/show.html.slim @@ -4,6 +4,7 @@ = pageheader 'map-marker', @time_table.comment, '', + t('last_update', time: l(@time_table.updated_at, format: :short)), (policy(@time_table).edit? ? link_to(t('actions.edit'), edit_referential_time_table_path(@referential, @time_table), class: 'btn btn-default') : '') / Below is secundary actions & optional contents (filters, ...) diff --git a/config/locales/actions.en.yml b/config/locales/actions.en.yml index 6e2dd3aa2..fe4d3d4e5 100644 --- a/config/locales/actions.en.yml +++ b/config/locales/actions.en.yml @@ -5,6 +5,7 @@ en: delete: "Delete" search: "Search" add: "Add new" + new: "Add new" show: "See" archive: "Archive" unarchive: "Unarchive" diff --git a/config/locales/actions.fr.yml b/config/locales/actions.fr.yml index 8f2fc90f8..ae0537ebb 100644 --- a/config/locales/actions.fr.yml +++ b/config/locales/actions.fr.yml @@ -6,6 +6,7 @@ fr: search: "Chercher" submit: "Valider" add: 'Ajouter' + new: 'Ajouter' show: 'Consulter' archive: 'Conserver' unarchive: 'Déconserver' diff --git a/config/locales/routing_constraint_zones.en.yml b/config/locales/routing_constraint_zones.en.yml index 2d4412dba..8e9dbfb02 100644 --- a/config/locales/routing_constraint_zones.en.yml +++ b/config/locales/routing_constraint_zones.en.yml @@ -11,7 +11,7 @@ en: updated_at: Updated at objectid: Object ID stop_points_count: Number of stop points - route: Route + route: Associated route errors: models: routing_constraint_zone: @@ -21,6 +21,7 @@ en: stop_points_not_from_route: 'Stop point does not belong to the Route of this Routing constraint zone.' all_stop_points_selected: 'All stop points from route cannot be selected.' routing_constraint_zones: + search_no_results: "No ITL matches your query" actions: new: New routing constraint zone edit: Edit this routing constraint zone @@ -32,4 +33,5 @@ en: title: "Update routing constraint zone %{routing_constraint_zone}" show: title: "Routing constraint zone %{routing_constraint_zone}" - + index: + title: "Interdictions of local trafficous" diff --git a/config/locales/routing_constraint_zones.fr.yml b/config/locales/routing_constraint_zones.fr.yml index 36dcf9301..3e207fac0 100644 --- a/config/locales/routing_constraint_zones.fr.yml +++ b/config/locales/routing_constraint_zones.fr.yml @@ -6,12 +6,12 @@ fr: routing_constraint_zone: name: Nom stop_areas: Arrêts - line: Ligne + line: Ligne associée created_at: "Créé le" updated_at: "Edité le" objectid: Object ID stop_points_count: Nombre d'arrêts - route: Itinéraire + route: Itinéraire associé errors: models: routing_constraint_zone: @@ -21,14 +21,14 @@ fr: stop_points_not_from_route: "Arrêt sur séquence d'arrêts n'appartient pas à la Route de cette Zone de contrainte." all_stop_points_selected: "Une zone de contrainte ne peut pas couvrir tous les arrêts d'une ligne." routing_constraint_zones: + search_no_results: "Aucune ITL ne correspond à votre recherche" actions: - new: Ajouter une zone de contrainte - edit: Editer cette zone de contrainte - destroy: Supprimer cette zone de contrainte destroy_confirm: Etes vous sûr de supprimer cette zone de contrainte ? new: - title: Ajouter une zone de contrainte + title: Ajouter un ITL edit: title: "Editer la zone de contrainte %{routing_constraint_zone}" show: title: "Zone de contrainte %{routing_constraint_zone}" + index: + title: "Interdictions de traffic local" diff --git a/db/migrate/20170607141031_change_begin_date_from_clean_ups.rb b/db/migrate/20170607141031_change_begin_date_from_clean_ups.rb new file mode 100644 index 000000000..850616b18 --- /dev/null +++ b/db/migrate/20170607141031_change_begin_date_from_clean_ups.rb @@ -0,0 +1,9 @@ +class ChangeBeginDateFromCleanUps < ActiveRecord::Migration + def up + change_column :clean_ups, :begin_date, :date + end + + def down + change_column :clean_ups, :begin_date, :datetime + end +end diff --git a/db/migrate/20170607141317_change_end_date_from_clean_ups.rb b/db/migrate/20170607141317_change_end_date_from_clean_ups.rb new file mode 100644 index 000000000..e47197ff1 --- /dev/null +++ b/db/migrate/20170607141317_change_end_date_from_clean_ups.rb @@ -0,0 +1,9 @@ +class ChangeEndDateFromCleanUps < ActiveRecord::Migration + def up + change_column :clean_ups, :end_date, :date + end + + def down + change_column :clean_ups, :end_date, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb deleted file mode 100644 index 1aa092fa8..000000000 --- a/db/schema.rb +++ /dev/null @@ -1,857 +0,0 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema.define(version: 20170605135126) do - - # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" - enable_extension "postgis" - enable_extension "hstore" - - create_table "access_links", id: :bigserial, force: :cascade do |t| - t.integer "access_point_id", limit: 8 - t.integer "stop_area_id", limit: 8 - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.string "comment" - t.decimal "link_distance", precision: 19, scale: 2 - t.boolean "lift_availability" - t.boolean "mobility_restricted_suitability" - t.boolean "stairs_availability" - t.time "default_duration" - t.time "frequent_traveller_duration" - t.time "occasional_traveller_duration" - t.time "mobility_restricted_traveller_duration" - t.string "link_type" - t.integer "int_user_needs" - t.string "link_orientation" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "access_links", ["objectid"], name: "access_links_objectid_key", unique: true, using: :btree - - create_table "access_points", id: :bigserial, force: :cascade do |t| - t.string "objectid" - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.string "comment" - t.decimal "longitude", precision: 19, scale: 16 - t.decimal "latitude", precision: 19, scale: 16 - t.string "long_lat_type" - t.string "country_code" - t.string "street_name" - t.string "contained_in" - t.time "openning_time" - t.time "closing_time" - t.string "access_type" - t.boolean "lift_availability" - t.boolean "mobility_restricted_suitability" - t.boolean "stairs_availability" - t.integer "stop_area_id", limit: 8 - t.string "zip_code" - t.string "city_name" - t.text "import_xml" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "access_points", ["objectid"], name: "access_points_objectid_key", unique: true, using: :btree - - create_table "api_keys", id: :bigserial, force: :cascade do |t| - t.integer "referential_id", limit: 8 - t.string "token" - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "calendars", id: :bigserial, force: :cascade do |t| - t.string "name" - t.string "short_name" - t.daterange "date_ranges", array: true - t.date "dates", array: true - t.boolean "shared", default: false - t.integer "organisation_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "calendars", ["organisation_id"], name: "index_calendars_on_organisation_id", using: :btree - add_index "calendars", ["short_name"], name: "index_calendars_on_short_name", unique: true, using: :btree - - create_table "clean_up_results", id: :bigserial, force: :cascade do |t| - t.string "message_key" - t.hstore "message_attributs" - t.integer "clean_up_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "clean_up_results", ["clean_up_id"], name: "index_clean_up_results_on_clean_up_id", using: :btree - - create_table "clean_ups", id: :bigserial, force: :cascade do |t| - t.string "status" - t.datetime "started_at" - t.datetime "ended_at" - t.integer "referential_id", limit: 8 - t.datetime "begin_date" - t.datetime "created_at" - t.datetime "updated_at" - t.datetime "end_date" - t.string "date_type" - end - - add_index "clean_ups", ["referential_id"], name: "index_clean_ups_on_referential_id", using: :btree - - create_table "companies", id: :bigserial, force: :cascade do |t| - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.string "short_name" - t.string "organizational_unit" - t.string "operating_department_name" - t.string "code" - t.string "phone" - t.string "fax" - t.string "email" - t.string "registration_number" - t.string "url" - t.string "time_zone" - t.integer "line_referential_id", limit: 8 - t.text "import_xml" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "companies", ["line_referential_id"], name: "index_companies_on_line_referential_id", using: :btree - add_index "companies", ["objectid"], name: "companies_objectid_key", unique: true, using: :btree - add_index "companies", ["registration_number"], name: "companies_registration_number_key", using: :btree - - create_table "connection_links", id: :bigserial, force: :cascade do |t| - t.integer "departure_id", limit: 8 - t.integer "arrival_id", limit: 8 - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.string "comment" - t.decimal "link_distance", precision: 19, scale: 2 - t.string "link_type" - t.time "default_duration" - t.time "frequent_traveller_duration" - t.time "occasional_traveller_duration" - t.time "mobility_restricted_traveller_duration" - t.boolean "mobility_restricted_suitability" - t.boolean "stairs_availability" - t.boolean "lift_availability" - t.integer "int_user_needs" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "connection_links", ["objectid"], name: "connection_links_objectid_key", unique: true, using: :btree - - create_table "exports", id: :bigserial, force: :cascade do |t| - t.integer "referential_id", limit: 8 - t.string "status" - t.string "type" - t.string "options" - t.datetime "created_at" - t.datetime "updated_at" - t.string "references_type" - t.string "reference_ids" - end - - add_index "exports", ["referential_id"], name: "index_exports_on_referential_id", using: :btree - - create_table "facilities", id: :bigserial, force: :cascade do |t| - t.integer "stop_area_id", limit: 8 - t.integer "line_id", limit: 8 - t.integer "connection_link_id", limit: 8 - t.integer "stop_point_id", limit: 8 - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.datetime "creation_time" - t.string "creator_id" - t.string "name" - t.string "comment" - t.string "description" - t.boolean "free_access" - t.decimal "longitude", precision: 19, scale: 16 - t.decimal "latitude", precision: 19, scale: 16 - t.string "long_lat_type" - t.decimal "x", precision: 19, scale: 2 - t.decimal "y", precision: 19, scale: 2 - t.string "projection_type" - t.string "country_code" - t.string "street_name" - t.string "contained_in" - end - - add_index "facilities", ["objectid"], name: "facilities_objectid_key", unique: true, using: :btree - - create_table "facilities_features", id: false, force: :cascade do |t| - t.integer "facility_id", limit: 8 - t.integer "choice_code" - end - - create_table "footnotes", id: :bigserial, force: :cascade do |t| - t.integer "line_id", limit: 8 - t.string "code" - t.string "label" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "footnotes_vehicle_journeys", id: false, force: :cascade do |t| - t.integer "vehicle_journey_id", limit: 8 - t.integer "footnote_id", limit: 8 - end - - create_table "group_of_lines", id: :bigserial, force: :cascade do |t| - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.string "comment" - t.string "registration_number" - t.integer "line_referential_id", limit: 8 - t.text "import_xml" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "group_of_lines", ["line_referential_id"], name: "index_group_of_lines_on_line_referential_id", using: :btree - add_index "group_of_lines", ["objectid"], name: "group_of_lines_objectid_key", unique: true, using: :btree - - create_table "group_of_lines_lines", id: false, force: :cascade do |t| - t.integer "group_of_line_id", limit: 8 - t.integer "line_id", limit: 8 - end - - create_table "import_messages", id: :bigserial, force: :cascade do |t| - t.integer "criticity" - t.string "message_key" - t.hstore "message_attributs" - t.integer "import_id", limit: 8 - t.integer "resource_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - t.hstore "resource_attributes" - end - - add_index "import_messages", ["import_id"], name: "index_import_messages_on_import_id", using: :btree - add_index "import_messages", ["resource_id"], name: "index_import_messages_on_resource_id", using: :btree - - create_table "import_resources", id: :bigserial, force: :cascade do |t| - t.integer "import_id", limit: 8 - t.string "status" - t.datetime "created_at" - t.datetime "updated_at" - t.string "type" - t.string "reference" - t.string "name" - t.hstore "metrics" - end - - add_index "import_resources", ["import_id"], name: "index_import_resources_on_import_id", using: :btree - - create_table "imports", id: :bigserial, force: :cascade do |t| - t.string "status" - t.string "current_step_id" - t.float "current_step_progress" - t.integer "workbench_id", limit: 8 - t.integer "referential_id", limit: 8 - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - t.string "file" - t.datetime "started_at" - t.datetime "ended_at" - t.string "token_download" - t.string "type" - end - - add_index "imports", ["referential_id"], name: "index_imports_on_referential_id", using: :btree - add_index "imports", ["workbench_id"], name: "index_imports_on_workbench_id", using: :btree - - create_table "journey_frequencies", id: :bigserial, force: :cascade do |t| - t.integer "vehicle_journey_id", limit: 8 - t.time "scheduled_headway_interval", null: false - t.time "first_departure_time", null: false - t.time "last_departure_time" - t.boolean "exact_time", default: false - t.datetime "created_at" - t.datetime "updated_at" - t.integer "timeband_id", limit: 8 - end - - 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 - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.string "comment" - t.string "registration_number" - t.string "published_name" - t.integer "departure_stop_point_id", limit: 8 - t.integer "arrival_stop_point_id", limit: 8 - t.integer "section_status", default: 0, null: false - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "journey_patterns", ["objectid"], name: "journey_patterns_objectid_key", unique: true, using: :btree - - create_table "journey_patterns_stop_points", id: false, force: :cascade do |t| - t.integer "journey_pattern_id", limit: 8 - t.integer "stop_point_id", limit: 8 - end - - add_index "journey_patterns_stop_points", ["journey_pattern_id"], name: "index_journey_pattern_id_on_journey_patterns_stop_points", using: :btree - - create_table "line_referential_memberships", id: :bigserial, force: :cascade do |t| - t.integer "organisation_id", limit: 8 - t.integer "line_referential_id", limit: 8 - t.boolean "owner" - end - - create_table "line_referential_sync_messages", id: :bigserial, force: :cascade do |t| - t.integer "criticity" - t.string "message_key" - t.hstore "message_attributs" - t.integer "line_referential_sync_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "line_referential_sync_messages", ["line_referential_sync_id"], name: "line_referential_sync_id", using: :btree - - create_table "line_referential_syncs", id: :bigserial, force: :cascade do |t| - t.integer "line_referential_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - t.datetime "started_at" - t.datetime "ended_at" - t.string "status" - end - - add_index "line_referential_syncs", ["line_referential_id"], name: "index_line_referential_syncs_on_line_referential_id", using: :btree - - create_table "line_referentials", id: :bigserial, force: :cascade do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "sync_interval", default: 1 - end - - create_table "lines", id: :bigserial, force: :cascade do |t| - t.integer "network_id", limit: 8 - t.integer "company_id", limit: 8 - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.string "number" - t.string "published_name" - t.string "transport_mode" - t.string "registration_number" - t.string "comment" - t.boolean "mobility_restricted_suitability" - t.integer "int_user_needs" - t.boolean "flexible_service" - t.string "url" - t.string "color", limit: 6 - t.string "text_color", limit: 6 - t.string "stable_id" - t.integer "line_referential_id", limit: 8 - t.boolean "deactivated", default: false - t.text "import_xml" - t.string "transport_submode" - t.integer "secondary_company_ids", limit: 8, array: true - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "seasonal" - end - - add_index "lines", ["line_referential_id"], name: "index_lines_on_line_referential_id", using: :btree - add_index "lines", ["objectid"], name: "lines_objectid_key", unique: true, using: :btree - add_index "lines", ["registration_number"], name: "lines_registration_number_key", using: :btree - add_index "lines", ["secondary_company_ids"], name: "index_lines_on_secondary_company_ids", using: :gin - - create_table "networks", id: :bigserial, force: :cascade do |t| - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.date "version_date" - t.string "description" - t.string "name" - t.string "registration_number" - t.string "source_name" - t.string "source_type" - t.string "source_identifier" - t.string "comment" - t.text "import_xml" - t.integer "line_referential_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "networks", ["line_referential_id"], name: "index_networks_on_line_referential_id", using: :btree - add_index "networks", ["objectid"], name: "networks_objectid_key", unique: true, using: :btree - add_index "networks", ["registration_number"], name: "networks_registration_number_key", using: :btree - - create_table "organisations", id: :bigserial, force: :cascade do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - t.string "data_format", default: "neptune" - t.string "code" - t.datetime "synced_at" - t.hstore "sso_attributes" - end - - add_index "organisations", ["code"], name: "index_organisations_on_code", unique: true, using: :btree - - create_table "pt_links", id: :bigserial, force: :cascade do |t| - t.integer "start_of_link_id", limit: 8 - t.integer "end_of_link_id", limit: 8 - t.integer "route_id", limit: 8 - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.string "comment" - t.decimal "link_distance", precision: 19, scale: 2 - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "pt_links", ["objectid"], name: "pt_links_objectid_key", unique: true, using: :btree - - create_table "referential_clonings", id: :bigserial, force: :cascade do |t| - t.string "status" - t.datetime "started_at" - t.datetime "ended_at" - t.integer "source_referential_id", limit: 8 - t.integer "target_referential_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "referential_clonings", ["source_referential_id"], name: "index_referential_clonings_on_source_referential_id", using: :btree - add_index "referential_clonings", ["target_referential_id"], name: "index_referential_clonings_on_target_referential_id", using: :btree - - create_table "referential_metadata", id: :bigserial, force: :cascade do |t| - t.integer "referential_id", limit: 8 - t.integer "line_ids", limit: 8, array: true - t.integer "referential_source_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - t.daterange "periodes", array: true - end - - add_index "referential_metadata", ["line_ids"], name: "index_referential_metadata_on_line_ids", using: :gin - add_index "referential_metadata", ["referential_id"], name: "index_referential_metadata_on_referential_id", using: :btree - add_index "referential_metadata", ["referential_source_id"], name: "index_referential_metadata_on_referential_source_id", using: :btree - - create_table "referentials", id: :bigserial, force: :cascade do |t| - t.string "name" - t.string "slug" - t.datetime "created_at" - t.datetime "updated_at" - t.string "prefix" - t.string "projection_type" - t.string "time_zone" - t.string "bounds" - t.integer "organisation_id", limit: 8 - t.text "geographical_bounds" - t.integer "user_id", limit: 8 - t.string "user_name" - t.string "data_format" - t.integer "line_referential_id", limit: 8 - t.integer "stop_area_referential_id", limit: 8 - t.integer "workbench_id", limit: 8 - t.datetime "archived_at" - t.integer "created_from_id", limit: 8 - t.boolean "ready", default: false - end - - add_index "referentials", ["created_from_id"], name: "index_referentials_on_created_from_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 - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.string "comment" - t.integer "opposite_route_id", limit: 8 - t.string "published_name" - t.string "number" - t.string "direction" - t.string "wayback" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "routes", ["objectid"], name: "routes_objectid_key", unique: true, using: :btree - - create_table "routing_constraint_zones", id: :bigserial, force: :cascade do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.integer "route_id", limit: 8 - t.integer "stop_point_ids", limit: 8, array: true - end - - create_table "routing_constraints_lines", id: false, force: :cascade do |t| - t.integer "stop_area_id", limit: 8 - t.integer "line_id", limit: 8 - end - - create_table "rule_parameter_sets", id: :bigserial, force: :cascade do |t| - t.text "parameters" - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "organisation_id", limit: 8 - end - - create_table "stop_area_referential_memberships", id: :bigserial, force: :cascade do |t| - t.integer "organisation_id", limit: 8 - t.integer "stop_area_referential_id", limit: 8 - t.boolean "owner" - end - - create_table "stop_area_referential_sync_messages", id: :bigserial, force: :cascade do |t| - t.integer "criticity" - t.string "message_key" - t.hstore "message_attributs" - t.integer "stop_area_referential_sync_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "stop_area_referential_sync_messages", ["stop_area_referential_sync_id"], name: "stop_area_referential_sync_id", using: :btree - - create_table "stop_area_referential_syncs", id: :bigserial, force: :cascade do |t| - t.integer "stop_area_referential_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - t.datetime "ended_at" - t.datetime "started_at" - t.string "status" - end - - add_index "stop_area_referential_syncs", ["stop_area_referential_id"], name: "index_stop_area_referential_syncs_on_stop_area_referential_id", using: :btree - - create_table "stop_area_referentials", id: :bigserial, force: :cascade do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "stop_areas", id: :bigserial, force: :cascade do |t| - t.integer "parent_id", limit: 8 - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.string "comment" - t.string "area_type" - t.string "registration_number" - t.string "nearest_topic_name" - t.integer "fare_code" - t.decimal "longitude", precision: 19, scale: 16 - t.decimal "latitude", precision: 19, scale: 16 - t.string "long_lat_type" - t.string "country_code" - t.string "street_name" - t.boolean "mobility_restricted_suitability" - t.boolean "stairs_availability" - t.boolean "lift_availability" - t.integer "int_user_needs" - t.string "zip_code" - t.string "city_name" - t.string "url" - t.string "time_zone" - t.integer "stop_area_referential_id", limit: 8 - t.string "status" - t.text "import_xml" - t.datetime "deleted_at" - t.datetime "created_at" - t.datetime "updated_at" - t.string "stif_type" - end - - add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree - add_index "stop_areas", ["objectid"], name: "stop_areas_objectid_key", unique: true, using: :btree - add_index "stop_areas", ["parent_id"], name: "index_stop_areas_on_parent_id", using: :btree - add_index "stop_areas", ["stop_area_referential_id"], name: "index_stop_areas_on_stop_area_referential_id", using: :btree - - create_table "stop_areas_stop_areas", id: false, force: :cascade do |t| - t.integer "child_id", limit: 8 - t.integer "parent_id", limit: 8 - end - - create_table "stop_points", id: :bigserial, force: :cascade do |t| - t.integer "route_id", limit: 8 - t.integer "stop_area_id", limit: 8 - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.integer "position" - t.string "for_boarding" - t.string "for_alighting" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "stop_points", ["objectid"], name: "stop_points_objectid_key", unique: true, using: :btree - - create_table "taggings", id: :bigserial, force: :cascade do |t| - t.integer "tag_id", limit: 8 - t.integer "taggable_id", limit: 8 - t.string "taggable_type" - t.integer "tagger_id", limit: 8 - t.string "tagger_type" - t.string "context", limit: 128 - t.datetime "created_at" - end - - add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree - add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree - - create_table "tags", id: :bigserial, force: :cascade do |t| - t.string "name" - t.integer "taggings_count", default: 0 - end - - add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree - - create_table "time_table_dates", id: :bigserial, force: :cascade do |t| - t.integer "time_table_id", limit: 8, null: false - t.date "date" - t.integer "position", null: false - t.boolean "in_out" - end - - add_index "time_table_dates", ["time_table_id"], name: "index_time_table_dates_on_time_table_id", using: :btree - - create_table "time_table_periods", id: :bigserial, force: :cascade do |t| - t.integer "time_table_id", limit: 8, null: false - t.date "period_start" - t.date "period_end" - t.integer "position", null: false - end - - add_index "time_table_periods", ["time_table_id"], name: "index_time_table_periods_on_time_table_id", using: :btree - - create_table "time_tables", id: :bigserial, force: :cascade do |t| - t.string "objectid", null: false - t.integer "object_version", limit: 8, default: 1 - t.string "creator_id" - t.string "version" - t.string "comment" - t.integer "int_day_types", default: 0 - t.date "start_date" - t.date "end_date" - t.integer "calendar_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - t.string "color" - t.integer "created_from_id" - end - - add_index "time_tables", ["calendar_id"], name: "index_time_tables_on_calendar_id", using: :btree - add_index "time_tables", ["created_from_id"], name: "index_time_tables_on_created_from_id", using: :btree - add_index "time_tables", ["objectid"], name: "time_tables_objectid_key", unique: true, using: :btree - - create_table "time_tables_vehicle_journeys", id: false, force: :cascade do |t| - t.integer "time_table_id", limit: 8 - t.integer "vehicle_journey_id", limit: 8 - end - - add_index "time_tables_vehicle_journeys", ["time_table_id"], name: "index_time_tables_vehicle_journeys_on_time_table_id", using: :btree - add_index "time_tables_vehicle_journeys", ["vehicle_journey_id"], name: "index_time_tables_vehicle_journeys_on_vehicle_journey_id", using: :btree - - create_table "timebands", id: :bigserial, force: :cascade do |t| - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "name" - t.time "start_time", null: false - t.time "end_time", null: false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "users", id: :bigserial, force: :cascade do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "" - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0 - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "organisation_id", limit: 8 - t.string "name" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.integer "failed_attempts", default: 0 - t.string "unlock_token" - t.datetime "locked_at" - t.string "authentication_token" - t.string "invitation_token" - t.datetime "invitation_sent_at" - t.datetime "invitation_accepted_at" - t.integer "invitation_limit" - t.integer "invited_by_id", limit: 8 - t.string "invited_by_type" - t.datetime "invitation_created_at" - t.string "username" - t.datetime "synced_at" - t.string "permissions", array: true - end - - add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree - add_index "users", ["invitation_token"], name: "index_users_on_invitation_token", unique: true, using: :btree - add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree - add_index "users", ["username"], name: "index_users_on_username", unique: true, using: :btree - - create_table "vehicle_journey_at_stops", id: :bigserial, force: :cascade do |t| - t.integer "vehicle_journey_id", limit: 8 - t.integer "stop_point_id", limit: 8 - t.string "connecting_service_id" - t.string "boarding_alighting_possibility" - t.time "arrival_time" - t.time "departure_time" - t.string "for_boarding" - t.string "for_alighting" - t.integer "departure_day_offset", default: 0 - t.integer "arrival_day_offset", default: 0 - end - - add_index "vehicle_journey_at_stops", ["stop_point_id"], name: "index_vehicle_journey_at_stops_on_stop_pointid", using: :btree - add_index "vehicle_journey_at_stops", ["vehicle_journey_id"], name: "index_vehicle_journey_at_stops_on_vehicle_journey_id", using: :btree - - create_table "vehicle_journeys", id: :bigserial, force: :cascade do |t| - t.integer "route_id", limit: 8 - t.integer "journey_pattern_id", limit: 8 - t.integer "company_id", limit: 8 - t.string "objectid", null: false - t.integer "object_version", limit: 8 - t.string "creator_id" - t.string "comment" - t.string "status_value" - t.string "transport_mode" - t.string "published_journey_name" - t.string "published_journey_identifier" - t.string "facility" - t.string "vehicle_type_identifier" - t.integer "number", limit: 8 - t.boolean "mobility_restricted_suitability" - t.boolean "flexible_service" - t.integer "journey_category", default: 0, null: false - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "vehicle_journeys", ["objectid"], name: "vehicle_journeys_objectid_key", unique: true, using: :btree - add_index "vehicle_journeys", ["route_id"], name: "index_vehicle_journeys_on_route_id", using: :btree - - create_table "workbenches", id: :bigserial, force: :cascade do |t| - t.string "name" - t.integer "organisation_id", limit: 8 - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line_referential_id", limit: 8 - t.integer "stop_area_referential_id", limit: 8 - end - - add_index "workbenches", ["line_referential_id"], name: "index_workbenches_on_line_referential_id", using: :btree - add_index "workbenches", ["organisation_id"], name: "index_workbenches_on_organisation_id", using: :btree - add_index "workbenches", ["stop_area_referential_id"], name: "index_workbenches_on_stop_area_referential_id", using: :btree - - add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey" - add_foreign_key "group_of_lines_lines", "group_of_lines", name: "groupofline_group_fkey", on_delete: :cascade - add_foreign_key "journey_frequencies", "timebands", on_delete: :nullify - add_foreign_key "journey_frequencies", "vehicle_journeys", on_delete: :nullify - add_foreign_key "journey_pattern_sections", "journey_patterns", on_delete: :cascade - add_foreign_key "journey_pattern_sections", "route_sections", on_delete: :cascade - add_foreign_key "journey_patterns", "routes", name: "jp_route_fkey", on_delete: :cascade - add_foreign_key "journey_patterns", "stop_points", column: "arrival_stop_point_id", name: "arrival_point_fkey", on_delete: :nullify - add_foreign_key "journey_patterns", "stop_points", column: "departure_stop_point_id", name: "departure_point_fkey", on_delete: :nullify - add_foreign_key "journey_patterns_stop_points", "journey_patterns", name: "jpsp_jp_fkey", on_delete: :cascade - add_foreign_key "journey_patterns_stop_points", "stop_points", name: "jpsp_stoppoint_fkey", on_delete: :cascade - add_foreign_key "route_sections", "stop_areas", column: "arrival_id" - add_foreign_key "route_sections", "stop_areas", column: "departure_id" - add_foreign_key "routes", "routes", column: "opposite_route_id", name: "route_opposite_route_fkey" - add_foreign_key "stop_areas", "stop_areas", column: "parent_id", name: "area_parent_fkey", on_delete: :nullify - add_foreign_key "stop_areas_stop_areas", "stop_areas", column: "child_id", name: "stoparea_child_fkey", on_delete: :cascade - add_foreign_key "stop_areas_stop_areas", "stop_areas", column: "parent_id", name: "stoparea_parent_fkey", on_delete: :cascade - add_foreign_key "time_table_dates", "time_tables", name: "tm_date_fkey", on_delete: :cascade - add_foreign_key "time_table_periods", "time_tables", name: "tm_period_fkey", on_delete: :cascade - add_foreign_key "time_tables_vehicle_journeys", "time_tables", name: "vjtm_tm_fkey", on_delete: :cascade - add_foreign_key "time_tables_vehicle_journeys", "vehicle_journeys", name: "vjtm_vj_fkey", on_delete: :cascade - add_foreign_key "vehicle_journey_at_stops", "stop_points", name: "vjas_sp_fkey", on_delete: :cascade - add_foreign_key "vehicle_journey_at_stops", "vehicle_journeys", name: "vjas_vj_fkey", on_delete: :cascade - add_foreign_key "vehicle_journeys", "journey_patterns", name: "vj_jp_fkey", on_delete: :cascade - add_foreign_key "vehicle_journeys", "routes", name: "vj_route_fkey", on_delete: :cascade -end diff --git a/spec/factories/chouette_time_table.rb b/spec/factories/chouette_time_table.rb index f462349cf..6480df79d 100644 --- a/spec/factories/chouette_time_table.rb +++ b/spec/factories/chouette_time_table.rb @@ -1,6 +1,7 @@ FactoryGirl.define do factory :time_table_date, :class => Chouette::TimeTableDate do + association :time_table, :factory => :time_table end factory :time_table_period, :class => Chouette::TimeTablePeriod do diff --git a/spec/factories/clean_ups.rb b/spec/factories/clean_ups.rb index 41165ac16..d3746c3b2 100644 --- a/spec/factories/clean_ups.rb +++ b/spec/factories/clean_ups.rb @@ -1,15 +1,6 @@ FactoryGirl.define do factory :clean_up do - status "MyString" -started_at "2016-11-14 14:45:18" -ended_at "2016-11-14 14:45:18" -referential nil -keep_lines false -keep_stops false -keep_companies false -keep_networks false -keep_group_of_lines false -expected_date "2016-11-14 14:45:18" + begin_date { Date.today} + end_date { Date.today + 1.month } end - end diff --git a/spec/features/routing_constraint_zones_spec.rb b/spec/features/routing_constraint_zones_spec.rb index 9e8c7dad4..b116b38bd 100644 --- a/spec/features/routing_constraint_zones_spec.rb +++ b/spec/features/routing_constraint_zones_spec.rb @@ -20,7 +20,7 @@ describe 'RoutingConstraintZones', type: :feature do context 'user has permission to create routing_constraint_zones' do it 'shows a create link for routing_constraint_zones' do - expect(page).to have_content(I18n.t('routing_constraint_zones.actions.new')) + expect(page).to have_content(I18n.t('actions.new')) end end @@ -28,7 +28,7 @@ describe 'RoutingConstraintZones', type: :feature do it 'does not show a create link for routing_constraint_zones' do @user.update_attribute(:permissions, []) visit referential_line_routing_constraint_zones_path(referential, line) - expect(page).not_to have_content(I18n.t('routing_constraint_zones.actions.new')) + expect(page).not_to have_content(I18n.t('actions.new')) end end diff --git a/spec/javascripts/time_table/reducers/pagination_spec.js b/spec/javascripts/time_table/reducers/pagination_spec.js index 740ded3ac..5da58427e 100644 --- a/spec/javascripts/time_table/reducers/pagination_spec.js +++ b/spec/javascripts/time_table/reducers/pagination_spec.js @@ -118,11 +118,4 @@ describe('pagination reducer', () => { }) ).toEqual(Object.assign({}, state, {stateChanged: true})) }) - it('should handle UPDATE_DAY_TYPES', () => { - expect( - paginationReducer(state, { - type: 'UPDATE_DAY_TYPES' - }) - ).toEqual(Object.assign({}, state, {stateChanged: true})) - }) }) diff --git a/spec/models/clean_up_spec.rb b/spec/models/clean_up_spec.rb index c22d32eaa..b4cf5e1af 100644 --- a/spec/models/clean_up_spec.rb +++ b/spec/models/clean_up_spec.rb @@ -1,21 +1,227 @@ require 'rails_helper' RSpec.describe CleanUp, :type => :model do - let(:cleaner) { CleanUp.new } it { should validate_presence_of(:begin_date) } it { should validate_presence_of(:date_type) } it { should belong_to(:referential) } - it 'should delete vehiclejourneys without timetables' do - create_list(:vehicle_journey, 2) - create_list(:vehicle_journey, 2, time_tables:[create(:time_table)]) - expect(cleaner.clean_vehicle_journeys).to eq 2 + context '#exclude_dates_in_overlapping_period with :before date_type' do + let(:time_table) { create(:time_table) } + let(:period) { time_table.periods[0] } + let(:cleaner) { create(:clean_up, date_type: :before) } + + it 'should add exclude date into period for overlapping period' do + days_in_period = (period.period_start..period.period_end).count + cleaner.begin_date = period.period_end + + expect { cleaner.exclude_dates_in_overlapping_period(period) }.to change { + time_table.dates.where(in_out: false).count + }.by(days_in_period - 1) + end + + it 'should not add exclude date if no overlapping found' do + cleaner.begin_date = period.period_start + expect { cleaner.exclude_dates_in_overlapping_period(period) }.to_not change { + time_table.dates.where(in_out: false).count + } + end + end + + context '#exclude_dates_in_overlapping_period with :after date_type' do + let(:time_table) { create(:time_table) } + let(:period) { time_table.periods[0] } + let(:cleaner) { create(:clean_up, date_type: :after) } + + it 'should add exclude date into period for overlapping period' do + days_in_period = (period.period_start..period.period_end).count + cleaner.begin_date = period.period_start + 1.day + expect { cleaner.exclude_dates_in_overlapping_period(period) }.to change { + time_table.dates.where(in_out: false).count + }.by(days_in_period - 2) + end + + it 'should not add exclude date if no overlapping found' do + cleaner.begin_date = period.period_end + expect { cleaner.exclude_dates_in_overlapping_period(period) }.to_not change { + time_table.dates.where(in_out: false).count + } + end + end + + context '#exclude_dates_in_overlapping_period with :between date_type' do + let(:time_table) { create(:time_table) } + let(:period) { time_table.periods[0] } + let(:cleaner) { create(:clean_up, date_type: :between, begin_date: period.period_start + 3.day, end_date: period.period_end) } + + it 'should add exclude date into period for overlapping period' do + expected_day_out = (cleaner.begin_date..cleaner.end_date).count + expect { cleaner.exclude_dates_in_overlapping_period(period) }.to change { + time_table.dates.where(in_out: false).count + }.by(expected_day_out) + end + + it 'should not add exclude date if no overlapping found' do + cleaner.begin_date = period.period_end + 1.day + cleaner.end_date = cleaner.begin_date + 1.day + + expect { cleaner.exclude_dates_in_overlapping_period(period) }.to_not change { + time_table.dates.where(in_out: false).count + } + end + end + + context '#overlapping_periods' do + let(:cleaner) { create(:clean_up, date_type: :before, end_date: nil) } + let(:time_table) { create(:time_table) } + + it 'should detect overlapping periods' do + cleaner.begin_date = time_table.periods[0].period_start + expect(cleaner.overlapping_periods).to include(time_table.periods[0]) + end + + it 'should not return none overlapping periods' do + cleaner.begin_date = time_table.periods[0].period_start - 1.day + expect(cleaner.overlapping_periods).to_not include(time_table.periods[0]) + end + end + + context '#clean' do + let(:cleaner) { create(:clean_up, date_type: :before) } + + it 'should call destroy_time_tables_before' do + cleaner.date_type = :before + expect(cleaner).to receive(:destroy_time_tables_before) + expect(cleaner).to receive(:destroy_time_tables_dates_before) + expect(cleaner).to receive(:destroy_time_tables_periods_before) + cleaner.clean + end + + it 'should call destroy_time_tables_after' do + cleaner.date_type = :after + expect(cleaner).to receive(:destroy_time_tables_after) + expect(cleaner).to receive(:destroy_time_tables_dates_after) + expect(cleaner).to receive(:destroy_time_tables_periods_after) + cleaner.clean + end + + it 'should call destroy_time_tables_between' do + cleaner.date_type = :between + expect(cleaner).to receive(:destroy_time_tables_between) + expect(cleaner).to receive(:destroy_time_tables_dates_between) + expect(cleaner).to receive(:destroy_time_tables_periods_between) + cleaner.clean + end + end + + context '#destroy_time_tables_dates_between' do + let!(:time_table) { create(:time_table) } + let(:cleaner) { create(:clean_up, date_type: :between) } + + before do + time_table.periods.clear + time_table.save + cleaner.begin_date = time_table.start_date + cleaner.end_date = time_table.end_date + end + + it 'should destroy record' do + expect{ cleaner.destroy_time_tables_dates_between }.to change { + Chouette::TimeTableDate.count + }.by(-time_table.dates.count) + end + + it 'should not destroy record not in range' do + cleaner.begin_date = time_table.end_date + 1.day + cleaner.end_date = cleaner.begin_date + 1.day + + expect{ cleaner.destroy_time_tables_dates_between }.to_not change { + Chouette::TimeTableDate.count + } + end + end + + context '#destroy_time_tables_dates_after' do + let!(:time_table_date) { create(:time_table_date, date: Date.yesterday, in_out: true) } + let(:cleaner) { create(:clean_up, date_type: :after, begin_date: time_table_date.date) } + + it 'should destroy record' do + count = Chouette::TimeTableDate.where('date >= ?', cleaner.begin_date).count + expect{ cleaner.destroy_time_tables_dates_after }.to change { + Chouette::TimeTableDate.count + }.by(-count) + end + end + + context '#destroy_time_tables_between' do + let!(:time_table) { create(:time_table ) } + let(:cleaner) { create(:clean_up, date_type: :after, begin_date: time_table.start_date, end_date: time_table.end_date) } + + it 'should destroy time_tables with validity period in purge range' do + expect{ cleaner.destroy_time_tables_between }.to change { + Chouette::TimeTable.count + }.by(-1) + end + + it 'should not destroy time_tables if not totaly inside purge range' do + cleaner.begin_date = time_table.start_date + 1.day + expect{ cleaner.destroy_time_tables_between }.to_not change { + Chouette::TimeTable.count + } + end + end + + context '#destroy_time_tables_after' do + let!(:time_table) { create(:time_table ) } + let(:cleaner) { create(:clean_up, date_type: :after, begin_date: time_table.start_date) } + + it 'should destroy time_tables with start_date >= purge begin_date' do + expect{ cleaner.destroy_time_tables_after }.to change { + Chouette::TimeTable.count + }.by(-1) + end + + it 'should not destroy time_tables with start_date < purge begin date' do + cleaner.begin_date = time_table.end_date + expect{ cleaner.destroy_time_tables_after }.to_not change { + Chouette::TimeTable.count + } + end end - it 'should delete journeypatterns without vehicle journeys' do - create_list(:journey_pattern, 2) - create_list(:vehicle_journey, 2, journey_pattern: create(:journey_pattern)) - expect(cleaner.clean_journey_patterns).to eq 2 + context '#destroy_time_tables' do + let!(:time_table) { create(:time_table) } + let(:cleaner) { create(:clean_up, date_type: :before) } + + it 'should destroy all time_tables' do + expect{cleaner.destroy_time_tables(Chouette::TimeTable.all)}.to change { + Chouette::TimeTable.count + }.by(-1) + end + + it 'should destroy associated vehicle_journeys' do + create(:vehicle_journey, time_tables: [time_table]) + expect{cleaner.destroy_time_tables(Chouette::TimeTable.all)}.to change { + Chouette::VehicleJourney.count + }.by(-1) + end + end + + context '#destroy_time_tables_before' do + let!(:time_table) { create(:time_table ) } + let(:cleaner) { create(:clean_up, date_type: :before, begin_date: time_table.end_date) } + + it 'should destroy time_tables with end_date <= purge begin_date' do + expect{ cleaner.destroy_time_tables_before }.to change { + Chouette::TimeTable.count + }.by(-1) + end + + it 'should not destroy time_tables with end_date > purge begin date' do + cleaner.begin_date = Date.today + expect{ cleaner.destroy_time_tables_before }.to_not change { + Chouette::TimeTable.count + } + end end end |
