diff options
32 files changed, 173 insertions, 168 deletions
| diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js b/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js index 34689070d..825e7bb7d 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js @@ -90,7 +90,7 @@ const actions = {    resetValidation: (target) => {      $(target).parent().removeClass('has-error').children('.help-block').remove()    }, -  humanOID : (oid) => oid.split(':')[2], +  humanOID : (oid) => oid.split(':')[2].split("-").pop(),    validateFields : (fields) => {      const test = [] diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js index de87c14af..2e2e06514 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js @@ -269,7 +269,7 @@ const actions = {      type: 'RECEIVE_TOTAL_COUNT',      total    }), -  humanOID: (oid) => oid.split(':')[2], +  humanOID: (oid) => oid.split(':')[2].split("-").pop(),    fetchVehicleJourneys : (dispatch, currentPage, nextPage, queryString) => {      if(currentPage == undefined){        currentPage = 1 diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/MissionSelect2.js index 922a1e5ee..2f49e9980 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/MissionSelect2.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/MissionSelect2.js @@ -2,6 +2,7 @@ var _ = require('lodash')  var React = require('react')  var PropTypes = require('react').PropTypes  var Select2 = require('react-select2') +var humanOID = require('../../../actions').humanOID  // get JSON full path  var origin = window.location.origin @@ -34,7 +35,7 @@ class BSelect4 extends React.Component{              delay: '500',              data: function(params) {                return { -                q: {published_name_cont_or_short_id_or_registration_number_cont: params.term}, +                q: {published_name_or_objectid_or_registration_number_cont: params.term},                };              },              processResults: function(data, params) { @@ -43,7 +44,7 @@ class BSelect4 extends React.Component{                    item => _.assign(                      {},                      item, -                    { text: "<strong>" + item.published_name + " - " + item.short_id + "</strong><br/><small>" + item.registration_number + "</small>" } +                    { text: "<strong>" + item.published_name + " - " + humanOID(item.object_id) + "</strong><br/><small>" + item.registration_number + "</small>" }                    )                  )                }; diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/TimetableSelect2.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/TimetableSelect2.js index 5157300ba..2248175ab 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/TimetableSelect2.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/TimetableSelect2.js @@ -2,7 +2,7 @@ var _ = require('lodash')  var React = require('react')  var PropTypes = require('react').PropTypes  var Select2 = require('react-select2') -var actions = require('../../../actions') +var humanOID = require('../../../actions').humanOID  // get JSON full path  var origin = window.location.origin @@ -48,7 +48,7 @@ class BSelect4 extends React.Component{                    item => _.assign(                      {},                      item, -                    {text: '<strong>' + "<span class='fa fa-circle' style='color:" + (item.color ? item.color : '#4B4B4B') + "'></span> " + item.comment + ' - ' + item.short_id + '</strong><br/><small>' + (item.day_types ? item.day_types.match(/[A-Z]?[a-z]+/g).join(', ') : "") + '</small>'} +                    {text: '<strong>' + "<span class='fa fa-circle' style='color:" + (item.color ? item.color : '#4B4B4B') + "'></span> " + item.comment + ' - ' + humanOID(item.objectid) + '</strong><br/><small>' + (item.day_types ? item.day_types.match(/[A-Z]?[a-z]+/g).join(', ') : "") + '</small>'}                    )                  )                }; diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/VJSelect2.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/VJSelect2.js index cc2ee4b9e..b9678ea9a 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/VJSelect2.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/select2s/VJSelect2.js @@ -2,6 +2,7 @@ var _ = require('lodash')  var React = require('react')  var PropTypes = require('react').PropTypes  var Select2 = require('react-select2') +var humanOID = require('../../../actions').humanOID  // get JSON full path  var origin = window.location.origin @@ -12,10 +13,6 @@ class BSelect4b extends React.Component{    constructor(props) {      super(props)    } -  humanOID(oid) { -    var a = oid.split(':') -    return a[a.length - 1] -  }    render() {      return ( @@ -46,7 +43,7 @@ class BSelect4b extends React.Component{                    item => _.assign(                      {},                      item, -                    { id: item.objectid, text: _.last(_.split(item.objectid, ':')) } +                    { id: item.objectid, text: humanOID(item.objectid) }                    )                  )                }; diff --git a/app/controllers/api_keys_controller.rb b/app/controllers/api_keys_controller.rb index 7059cf52e..03e5ef237 100644 --- a/app/controllers/api_keys_controller.rb +++ b/app/controllers/api_keys_controller.rb @@ -3,19 +3,27 @@ class ApiKeysController < BreadcrumbController    def create      @api_key = Api::V1::ApiKey.new(api_key_params.merge(organisation: current_organisation)) -    create! { organisation_api_keys_path } -  end - -  def index -    @api_keys = decorate_api_keys(current_organisation.api_keys.paginate(page: params[:page])) +    create! do |format| +      format.html { +        redirect_to workbenches_path +      } +    end    end    def update -    update! { organisation_api_key_path(resource) } +    update! do |format| +      format.html { +        redirect_to workbenches_path +      } +    end    end    def destroy -    destroy! { organisation_api_keys_path } +    destroy! do |format| +      format.html { +        redirect_to workbenches_path +      } +    end    end    private diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb index 1da64991d..ec0bbbb18 100644 --- a/app/controllers/referential_lines_controller.rb +++ b/app/controllers/referential_lines_controller.rb @@ -11,7 +11,7 @@ class ReferentialLinesController < ChouetteController    belongs_to :referential    def show -    @routes = resource.routes +    @routes = resource.routes.order(:objectid)      case sort_route_column      when "stop_points", "journey_patterns" diff --git a/app/decorators/route_decorator.rb b/app/decorators/route_decorator.rb index 46cb6cd5f..510c941a3 100644 --- a/app/decorators/route_decorator.rb +++ b/app/decorators/route_decorator.rb @@ -45,28 +45,28 @@ class RouteDecorator < Draper::Decorator        )      ) -    if h.policy(object).destroy? +    if h.policy(object).duplicate?        links << Link.new( -        content: h.destroy_link_content, -        href: h.referential_line_route_path( +        content: h.t('routes.duplicate.title'), +        href: h.duplicate_referential_line_route_path(            context[:referential],            context[:line],            object          ), -        method: :delete, -        data: { confirm: h.t('routes.actions.destroy_confirm') } +        method: :post        )      end -    if h.policy(object).duplicate? +    if h.policy(object).destroy?        links << Link.new( -        content: h.t('routes.duplicate.title'), -        href: h.duplicate_referential_line_route_path( +        content: h.destroy_link_content, +        href: h.referential_line_route_path(            context[:referential],            context[:line],            object          ), -        method: :post +        method: :delete, +        data: { confirm: h.t('routes.actions.destroy_confirm') }        )      end diff --git a/app/models/chouette/netex_object_id.rb b/app/models/chouette/netex_object_id.rb index 07d862992..441004c1e 100644 --- a/app/models/chouette/netex_object_id.rb +++ b/app/models/chouette/netex_object_id.rb @@ -5,7 +5,7 @@ class Chouette::NetexObjectId < String    end    alias_method :objectid?, :valid? -  @@format = /^([A-Za-z_]+):([0-9A-Za-z_]+):([A-Za-z]+):([0-9A-Za-z_-]+)$/  +  @@format = /^([A-Za-z_]+):([0-9A-Za-z_]+):([A-Za-z]+):([0-9A-Za-z_-]+)$/    cattr_reader :format    def parts @@ -27,7 +27,7 @@ class Chouette::NetexObjectId < String    def local_id      parts.try(:fourth)    end -   +    def self.create(provider_id, system_id, object_type, local_id)      new [provider_id, system_id, object_type, local_id].join(":")    end diff --git a/app/models/chouette/object_id.rb b/app/models/chouette/object_id.rb index 4f58048e1..0b122c91b 100644 --- a/app/models/chouette/object_id.rb +++ b/app/models/chouette/object_id.rb @@ -5,7 +5,7 @@ class Chouette::ObjectId < String    end    alias_method :objectid?, :valid? -  @@format = /^([0-9A-Za-z_]+):([A-Za-z]+):([0-9A-Za-z_-]+)$/  +  @@format = /^([0-9A-Za-z_]+):([A-Za-z]+):([0-9A-Za-z_-]+)$/    cattr_reader :format    def parts @@ -23,7 +23,7 @@ class Chouette::ObjectId < String    def local_id      parts.try(:third)    end -   +    def self.create(system_id, object_type, local_id)      new [system_id, object_type, local_id].join(":")    end diff --git a/app/models/chouette/stif_netex_objectid.rb b/app/models/chouette/stif_netex_objectid.rb index 3b11691d9..a0a91668a 100644 --- a/app/models/chouette/stif_netex_objectid.rb +++ b/app/models/chouette/stif_netex_objectid.rb @@ -26,6 +26,10 @@ class Chouette::StifNetexObjectid < String      parts.try(:fourth)    end +  def short_id +    local_id.try(:split, "-").try(:[], -1) +  end +    def self.create(provider_id, object_type, local_id, boiv_id)      new [provider_id, object_type, local_id, boiv_id].join(":")    end diff --git a/app/views/api_keys/_api_key.html.slim b/app/views/api_keys/_api_key.html.slim deleted file mode 100644 index 4cb07ef83..000000000 --- a/app/views/api_keys/_api_key.html.slim +++ /dev/null @@ -1,18 +0,0 @@ -#index_item.panel.panel-default.api_key -  .panel-heading -    .panel-title.clearfix -      span.pull-right -        = link_to edit_referential_api_key_path(@referential, api_key), class: "btn btn-default btn-sm" do -          span.fa.fa-pencil - -        = link_to referential_api_key_path(@referential, api_key), :method => :delete, :data => {:confirm =>  t('api_keys.actions.destroy_confirm')}, class: "btn btn-danger btn-sm" do -          span.fa.fa-trash-o - -      h5 -        = link_to([@referential, api_key], class: "preview", :title => "#{Chouette::StopArea.model_name.human.capitalize} #{api_key.name}") do -          span.name = truncate(api_key.name, :length => 20) - -  .panel-body -    p = "#{api_key.class.human_attribute_name('token')} #{truncate(api_key.token, :length => 20)}" -     -    p = "#{api_key.class.human_attribute_name('updated_at')} #{l(api_key.updated_at)}"
\ No newline at end of file diff --git a/app/views/api_keys/_form.html.slim b/app/views/api_keys/_form.html.slim index f3ebf3fe1..94a3ae57e 100644 --- a/app/views/api_keys/_form.html.slim +++ b/app/views/api_keys/_form.html.slim @@ -1,7 +1,9 @@ -= simple_form_for @api_key, url: action_url do |f| -    = f.input :name -    - unless @api_key.new_record? -      = f.input :token, :input_html => { readonly: true } += simple_form_for @api_key, html: {class: 'form-horizontal', id: 'api_key_form'}, wrapper: :horizontal_form do |f| +  .row +    .col-lg-12 +      = f.input :name +      - unless @api_key.new_record? +        = f.input :token, :input_html => { readonly: true } -    = f.association :referential -    = f.button :submit, 'submit', class: 'btn-primary' +      / = f.association :referential +      = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'api_key_form' diff --git a/app/views/api_keys/edit.html.slim b/app/views/api_keys/edit.html.slim index e47deddf7..b1bd1858d 100644 --- a/app/views/api_keys/edit.html.slim +++ b/app/views/api_keys/edit.html.slim @@ -1,2 +1,18 @@ -= title_tag t('api_keys.edit.title') -== render partial: 'form', locals: {action_url: organisation_api_key_path} +/ PageHeader += pageheader 'Clé d\'API', +             t('api_keys.edit.title'), +             'Lorem ipsum dolor sit amet', +             t('last_update', time: l(@api_key.updated_at, format: :short)), +             '' + +  / Below is secundary actions & optional contents (filters, ...) +  .row.mb-sm +    .col-lg-12.text-right +      = ( policy(@api_key).destroy? ? link_to(t('actions.destroy'), api_key_path(@api_key), :method => :delete, class: 'btn btn-default') : '' ) + +/ 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/api_keys/index.html.slim b/app/views/api_keys/index.html.slim deleted file mode 100644 index 9757b8955..000000000 --- a/app/views/api_keys/index.html.slim +++ /dev/null @@ -1,27 +0,0 @@ -- header_params = ['map-marker', -                   t('.title'), -                   ''] -- header_params << link_to(t('actions.add'), new_organisation_api_key_path, class: 'btn btn-default')  if policy(Api::V1::ApiKey).create? -= pageheader(*header_params) do - - -- if @api_keys.any? -  .row -    .col-lg-12 -      = table_builder_2 @api_keys, -        [ \ -          TableBuilderHelper::Column.new( \ -            key: :name, \ -            attribute: 'name', \ -            link_to: lambda do |api_key| \ -              organisation_api_key_path(api_key) \ -            end \ -          ), \ -          TableBuilderHelper::Column.new( \ -            key: :token, \ -            attribute: 'token' \ -          ), \ -        ], -        cls: 'table has-search' - -      = new_pagination @api_keys, 'pull-right' diff --git a/app/views/api_keys/new.html.slim b/app/views/api_keys/new.html.slim index 291c9f8a6..9acb08a94 100644 --- a/app/views/api_keys/new.html.slim +++ b/app/views/api_keys/new.html.slim @@ -1,2 +1,12 @@ -= title_tag t('api_keys.new.title') -== render partial: 'form', locals: {action_url: organisation_api_keys_path} +/ PageHeader += pageheader 'Clé d\'API', +             t('api_keys.new.title'), +             'Lorem ipsum dolor sit amet', +             '' + +/ 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/api_keys/show.html.slim b/app/views/api_keys/show.html.slim deleted file mode 100644 index de30ac125..000000000 --- a/app/views/api_keys/show.html.slim +++ /dev/null @@ -1,17 +0,0 @@ -= title_tag t('api_keys.show.title') - -.api_keys_show -  .summary -    p -      label = "#{@api_key.class.human_attribute_name('name')} : " -      = @api_key.name - -    p -      label = "#{@api_key.class.human_attribute_name('token')} : " -      = @api_key.token - -- content_for :sidebar do -  ul.actions -    li = link_to t('api_keys.actions.edit'), edit_organisation_api_key_path(@api_key), class: "edit" -    li = link_to t('api_keys.actions.destroy'), organisation_api_key_path(@api_key), :method => :delete,  :data => {:confirm =>  t('api_keys.actions.destroy_confirm')}, class: "remove" -    br diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index cbce7a7d5..6e59d83b3 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -46,7 +46,7 @@                  [ \                    TableBuilderHelper::Column.new( \                      name: 'ID', \ -                    attribute: Proc.new { |n| n.objectid.local_id }, \ +                    attribute: Proc.new { |n| n.objectid.short_id }, \                      sortable: false \                    ), \                    TableBuilderHelper::Column.new( \ diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim index a21b5ec8a..e2681d215 100644 --- a/app/views/routes/show.html.slim +++ b/app/views/routes/show.html.slim @@ -21,7 +21,7 @@      .row        .col-lg-6.col-md-6.col-sm-12.col-xs-12          = definition_list t('metadatas'), -          { t('id_codif') => @route.try(:objectid).try(:local_id), +          { t('objectid') => @route.objectid.short_id,              t('activerecord.attributes.route.published_name') => (@route.published_name ? @route.published_name : '-'),              @route.human_attribute_name(:wayback) => (@route.wayback ? @route.wayback_text : '-' ),              @route.human_attribute_name(:opposite_route) => (@route.opposite_route ? @route.opposite_route.name : '-') } @@ -29,7 +29,7 @@        - if @route_sp.any?          .col-lg-6.col-md-6.col-sm-12.col-xs-12            #route_map.map.mb-lg -       +      .row        .col-lg-12          - if @route_sp.any? diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim index a1b9c4e09..b984f95c8 100644 --- a/app/views/time_tables/index.html.slim +++ b/app/views/time_tables/index.html.slim @@ -18,7 +18,7 @@              [ \                TableBuilderHelper::Column.new( \                  name: 'ID', \ -                attribute: Proc.new { |n| n.objectid.local_id }, \ +                attribute: Proc.new { |n| n.objectid.short_id}, \                  sortable: false \                ), \                TableBuilderHelper::Column.new( \ @@ -69,4 +69,4 @@  = javascript_tag do    | window.I18n = #{(I18n.backend.send(:translations).to_json).html_safe}; -= javascript_include_tag 'filters/timetable.js' += javascript_include_tag 'filters/time_table.js' diff --git a/app/views/workbenches/index.html.slim b/app/views/workbenches/index.html.slim index 6140c4f8c..d35ed8121 100644 --- a/app/views/workbenches/index.html.slim +++ b/app/views/workbenches/index.html.slim @@ -2,6 +2,13 @@  = pageheader 'tableau-de-bord',               t('.title', organisation: current_organisation.name) +  / Below is secundary actions & optional contents (filters, ...) +  .row.mb-sm +   .col-lg-12.text-right +     - if policy(Api::V1::ApiKey).create? +       = link_to t('actions.create_api_key'), new_api_key_path, class: 'btn btn-primary' + +  / PageContent  .page_content    .container-fluid @@ -27,6 +34,19 @@            .panel-body              em.small.text-muted = t('.offers.no_content') +        .panel.panel-default +          .panel-heading +            h3.panel-title +              = t('.offers.api_keys') +              span.badge.ml-xs = current_organisation.api_keys.count if current_organisation.api_keys.any? +          - if current_organisation.api_keys.any? +            - current_organisation.api_keys.each do |api_key| +              .list-group +                = policy(api_key).edit? ? link_to( "#{api_key.name} : #{api_key.token}", edit_api_key_path(api_key), class: 'list-group-item') : "#{api_key.name} : #{api_key.token}" +          - else +            .panel-body +              em.small.text-muted = t('.offers.no_content') +        .col-lg-6.col-md-6.col-sm-6.col-xs-12          .panel.panel-default            .panel-heading diff --git a/config/locales/actions.en.yml b/config/locales/actions.en.yml index 36b76d01c..8dea51ca3 100644 --- a/config/locales/actions.en.yml +++ b/config/locales/actions.en.yml @@ -19,6 +19,7 @@ en:      import: 'Import'      filter: 'Filter'      erase: 'Erase' +    create_api_key: "Create an API key"    or: "or"    cancel: "Cancel"    search_hint: "Type in a search term" diff --git a/config/locales/actions.fr.yml b/config/locales/actions.fr.yml index f581142c7..01fc06326 100644 --- a/config/locales/actions.fr.yml +++ b/config/locales/actions.fr.yml @@ -19,6 +19,7 @@ fr:      import: 'Importer'      filter: 'Filtrer'      erase: 'Effacer' +    create_api_key: "Créer une clé d'API"    or: "ou"    cancel: "Annuler"    search_hint: "Entrez un texte à rechercher" diff --git a/config/locales/workbenches.fr.yml b/config/locales/workbenches.fr.yml index 85c5259b8..559593492 100644 --- a/config/locales/workbenches.fr.yml +++ b/config/locales/workbenches.fr.yml @@ -6,6 +6,7 @@ fr:          title: "Offres de transport"          organisation: "Offres de mon organisation"          idf: "Offres IDF" +        api_keys: "Clés d'API"          referentials: "Jeux de données"          calendars: "Calendriers"          see: "Voir la liste" @@ -13,4 +14,4 @@ fr:      referential_count:        zero: "Aucun jeu de données à l'heure actuelle"        one: "1 jeu de données à l'heure actuelle" -      other: "#{count} jeux de données à l'heure actuelle"  +      other: "#{count} jeux de données à l'heure actuelle" diff --git a/config/routes.rb b/config/routes.rb index 8f8989cab..0f1b22e44 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -63,11 +63,12 @@ ChouetteIhm::Application.routes.draw do    end    resource :organisation, :only => [:show, :edit, :update] do -    resources :api_keys      resources :users      resources :rule_parameter_sets    end +  resources :api_keys, :only => [:edit, :update, :new, :create, :destroy] +    resources :stop_area_referentials, :only => [:show] do      post :sync, on: :member      resources :stop_areas diff --git a/db/migrate/20131029115820_create_compliance_check_results.rb b/db/migrate/20131029115820_create_compliance_check_results.rb new file mode 100644 index 000000000..7f5c8e436 --- /dev/null +++ b/db/migrate/20131029115820_create_compliance_check_results.rb @@ -0,0 +1,23 @@ +class CreateComplianceCheckResults < ActiveRecord::Migration +  def up +    unless table_exists? :compliance_check_results +      create_table :compliance_check_results do |t| +        t.belongs_to :compliance_check_task , :null => :no ,:limit => 8 +        t.string :rule_code      # rule code value +        t.string :severity      # warning, error, improvement +        t.string :status      # NA, OK, NOK +        t.integer :violation_count # number of violation occurences +        t.text :detail # detail of violation location +        t.timestamps +      end +      add_foreign_key :compliance_check_results, :compliance_check_tasks, :on_delete => :cascade +    end +  end + +  def down +    if table_exists? :compliance_check_results +      execute "drop table compliance_check_results" +      # drop_table :compliance_check_results +    end +  end +end diff --git a/db/migrate/20170906092619_create_compliance_check_results.rb b/db/migrate/20170906092619_create_new_compliance_check_results.rb index e917d384e..a22800a8f 100644 --- a/db/migrate/20170906092619_create_compliance_check_results.rb +++ b/db/migrate/20170906092619_create_new_compliance_check_results.rb @@ -1,5 +1,6 @@ -class CreateComplianceCheckResults < ActiveRecord::Migration +class CreateNewComplianceCheckResults < ActiveRecord::Migration    def change +    drop_table :compliance_check_results if table_exists? :compliance_check_results      create_table :compliance_check_results do |t|        t.references :compliance_check, index: true, foreign_key: true        t.references :compliance_check_resource, index: true, foreign_key: true diff --git a/db/seeds.rb b/db/seeds.rb index 6e7f59c54..d31a35cfc 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,72 +1,38 @@  # coding: utf-8  # This file should contain all the record creation needed to seed the database with its default values.  # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -#   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) -#   Mayor.create(:name => 'Emanuel', :city => cities.first) -Organisation.where(code: nil).destroy_all +stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex") +line_referential = LineReferential.find_or_create_by!(name: "CodifLigne") +# Organisations  stif = Organisation.find_or_create_by!(code: "STIF") do |org|    org.name = 'STIF'  end +operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation| +  organisation.name = "Transporteur A" +end +# Member +line_referential.add_member stif, owner: true +line_referential.add_member operator + +stop_area_referential.add_member stif, owner: true +stop_area_referential.add_member operator + +# Users  stif.users.find_or_create_by!(username: "admin") do |user|    user.email = 'stif-boiv@af83.com'    user.password = "secret"    user.name = "STIF Administrateur" -  user.permissions = User.all_permissions -end - -operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation| -  organisation.name = "Transporteur A"  end  operator.users.find_or_create_by!(username: "transporteur") do |user|    user.email = 'stif-boiv+transporteur@af83.com'    user.password = "secret"    user.name = "Martin Lejeune" -  user.permissions = User.all_permissions -end - -stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex") do |referential| -  referential.add_member stif, owner: true -  referential.add_member operator -end - -10.times do |n| -  stop_area_referential.stop_areas.find_or_create_by! name: "Test #{n}", area_type: "zdep", objectid: "StopArea: #{n}" -end - -line_referential = LineReferential.find_or_create_by!(name: "CodifLigne") do |referential| -  referential.add_member stif, owner: true -  referential.add_member operator -end - -10.times do |n| -  line_referential.lines.find_or_create_by! name: "Test #{n}" do |l| -    l.objectid = "Chouette:Dummy:Line:00" + n.to_s -  end  end  # Include all Lines in organisation functional_scope  stif.update sso_attributes: { functional_scope: line_referential.lines.pluck(:objectid) }  operator.update sso_attributes: { functional_scope: line_referential.lines.limit(3).pluck(:objectid) } - -workbench = Workbench.find_by(name: "Gestion de l'offre") -workbench.update_attributes(line_referential: line_referential, -                            stop_area_referential: stop_area_referential) - -[["parissudest201604", "Paris Sud-Est Avril 2016"], - ["parissudest201605", "Paris Sud-Est Mai 2016"]].each do |slug, name| -  operator.referentials.find_or_create_by!(slug: slug) do |referential| -    referential.name      = name -    referential.prefix    = slug -    referential.workbench = workbench -  end -end - -# Clone last referential -# Referential.new_from(Referential.last) diff --git a/lib/stif/permission_translator.rb b/lib/stif/permission_translator.rb index afe69756e..47ab2840f 100644 --- a/lib/stif/permission_translator.rb +++ b/lib/stif/permission_translator.rb @@ -23,6 +23,7 @@ module Stif           referentials routes routing_constraint_zones           time_tables           vehicle_journeys +         api_keys        ]      end diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake index 90e47560e..7fe289ed6 100644 --- a/lib/tasks/ci.rake +++ b/lib/tasks/ci.rake @@ -2,7 +2,7 @@ namespace :ci do    desc "Prepare CI build"    task :setup do      cp "config/database/jenkins.yml", "config/database.yml" -    sh "RAILS_ENV=test rake db:migrate" +    sh "RAILS_ENV=test rake db:drop db:create db:migrate"      sh "npm --production --no-progress install"    end @@ -19,7 +19,11 @@ namespace :ci do    end    def deploy_env -    git_branch.in?(deploy_envs) ? git_branch : "dev" +    if git_branch == "master" +      "dev" +    elsif git_branch.in?(deploy_envs) +      git_branch +    end    end    desc "Check security aspects" @@ -37,7 +41,11 @@ namespace :ci do    desc "Deploy after CI"    task :deploy do -    sh "cap #{deploy_env} deploy:migrations" +    if deploy_env +      sh "cap #{deploy_env} deploy:migrations" +    else +      puts "No deploy for branch #{git_branch}" +    end    end    desc "Clean test files" diff --git a/spec/lib/stif/permission_translator_spec.rb b/spec/lib/stif/permission_translator_spec.rb index 1af21364c..9675382e6 100644 --- a/spec/lib/stif/permission_translator_spec.rb +++ b/spec/lib/stif/permission_translator_spec.rb @@ -1,3 +1,4 @@ +# coding: utf-8  RSpec.describe Stif::PermissionTranslator do    context "No SSO Permissions" do @@ -15,15 +16,15 @@ RSpec.describe Stif::PermissionTranslator do    context "SSO Permission boiv:edit-offer →" do      it "all permissions" do -      expect( described_class.translate(%w{boiv:edit-offer}) ).to eq(Support::Permissions.all_permissions) +      expect( described_class.translate(%w{boiv:edit-offer}) ).to match_array(Support::Permissions.all_permissions)      end      it "all permissions, no doubletons" do -      expect( described_class.translate(%w{boiv:edit-offer boiv:read-offer}) ).to eq(Support::Permissions.all_permissions) +      expect( described_class.translate(%w{boiv:edit-offer boiv:read-offer}) ).to match_array(Support::Permissions.all_permissions)      end      it "all permissions, input order agnostic" do -      expect( described_class.translate(%w{boiv:read-offer boiv:edit-offer}) ).to eq(Support::Permissions.all_permissions) +      expect( described_class.translate(%w{boiv:read-offer boiv:edit-offer}) ).to match_array(Support::Permissions.all_permissions)      end    end @@ -39,7 +40,7 @@ RSpec.describe Stif::PermissionTranslator do      it "does not add garbage or doubletons for boiv:edit-offer level" do        expect(          described_class.translate(%w{xxx boiv:read-offer lines.delete boiv:edit-offer footnotes.update}) -      ).to eq(Support::Permissions.all_permissions) +      ).to match_array(Support::Permissions.all_permissions)      end    end  end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6176babea..6b37b9fa8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,7 @@  # This file is copied to spec/ when you run 'rails generate rspec:install' -require 'simplecov'  unless ENV['NO_RCOV'] +  require 'simplecov' +    if ENV['JOB_NAME']      require 'simplecov-rcov'      SimpleCov.formatters = [ @@ -8,8 +9,12 @@ unless ENV['NO_RCOV']        SimpleCov::Formatter::RcovFormatter      ]    end +    SimpleCov.start 'rails' do      add_filter 'vendor' +    add_filter 'app/exporters/chouette/hub' +    add_filter 'app/maps' +    add_filter 'lib/ievkit'    end  end | 
