diff options
| author | Robert Dober | 2017-10-31 19:18:56 +0100 | 
|---|---|---|
| committer | GitHub | 2017-10-31 19:18:56 +0100 | 
| commit | 13553712a18435f16f449a6d0c6a2ade24038797 (patch) | |
| tree | 5e3577a7d8c69f8cbc93ede730d00404b3cd6b24 | |
| parent | b3c941878c8b2224449e7e185d9ea5c7537f0c69 (diff) | |
| parent | 3b0b05930e14992ffab6429e0319f07bc9c6e560 (diff) | |
| download | chouette-core-13553712a18435f16f449a6d0c6a2ade24038797.tar.bz2 | |
Merge pull request #105 from af83/4774-compliance_control_sets-filters
4774 compliance control sets filters
| -rw-r--r-- | app/controllers/compliance_control_sets_controller.rb | 8 | ||||
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 1 | ||||
| -rw-r--r-- | app/helpers/compliance_control_blocks_helper.rb | 2 | ||||
| -rw-r--r-- | app/helpers/compliance_controls_helper.rb | 11 | ||||
| -rw-r--r-- | app/helpers/table_builder_helper.rb | 24 | ||||
| -rw-r--r-- | app/models/compliance_control.rb | 72 | ||||
| -rw-r--r-- | app/views/compliance_control_sets/show.html.slim | 94 | ||||
| -rw-r--r-- | app/views/compliance_controls/_filters.html.slim | 46 | ||||
| -rw-r--r-- | app/views/layouts/navigation/_main_nav_left.html.slim | 21 | ||||
| -rw-r--r-- | config/locales/compliance_controls.en.yml | 13 | ||||
| -rw-r--r-- | config/locales/compliance_controls.fr.yml | 17 | ||||
| -rw-r--r-- | config/routes.rb | 1 | ||||
| -rw-r--r-- | spec/features/compliance_control_sets_spec.rb | 82 | ||||
| -rw-r--r-- | spec/features/connection_links_spec.rb | 2 | ||||
| -rw-r--r-- | spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb | 17 | ||||
| -rw-r--r-- | spec/models/compliance_control_spec.rb | 4 | 
16 files changed, 312 insertions, 103 deletions
| diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb index 570204065..b45e85d49 100644 --- a/app/controllers/compliance_control_sets_controller.rb +++ b/app/controllers/compliance_control_sets_controller.rb @@ -17,8 +17,12 @@ class ComplianceControlSetsController < InheritedResources::Base    def show      show! do |format|        format.html { +        @q_controls_form        = @compliance_control_set.compliance_controls.ransack(params[:q])          @compliance_control_set = @compliance_control_set.decorate -        @compliance_controls_without_block = decorate_compliance_controls(@compliance_control_set.compliance_controls.where(compliance_control_block_id: nil)) +        @compliance_controls    = +          decorate_compliance_controls( @q_controls_form.result) +            .group_by(&:compliance_control_block) +        @indirect_compliance_controls = @compliance_controls.delete nil        }      end    end @@ -54,4 +58,4 @@ class ComplianceControlSetsController < InheritedResources::Base    def compliance_control_set_params      params.require(:compliance_control_set).permit(:name, :id)    end -end
\ No newline at end of file +end diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 0c9f3067a..1d6f88068 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*-  class StopAreasController < InheritedResources::Base    include ApplicationHelper diff --git a/app/helpers/compliance_control_blocks_helper.rb b/app/helpers/compliance_control_blocks_helper.rb index 5c279b33a..311e6fb46 100644 --- a/app/helpers/compliance_control_blocks_helper.rb +++ b/app/helpers/compliance_control_blocks_helper.rb @@ -7,4 +7,4 @@ module ComplianceControlBlocksHelper        "[" + t("enumerize.transport_mode.#{transport_mode}") + "]" + "[" + t("enumerize.transport_submode.#{transport_submode}") + "]"      end    end -end
\ No newline at end of file +end diff --git a/app/helpers/compliance_controls_helper.rb b/app/helpers/compliance_controls_helper.rb new file mode 100644 index 000000000..ba0c538c9 --- /dev/null +++ b/app/helpers/compliance_controls_helper.rb @@ -0,0 +1,11 @@ +module ComplianceControlsHelper +  def subclass_selection_list +    ComplianceControl.subclass_patterns.map(&method(:make_subclass_selection_item)) +  end + + +  def make_subclass_selection_item(key_pattern) +    key, pattern = key_pattern +    [t("compliance_controls.filters.subclasses.#{key}"), "-#{pattern}-"] +  end +end  diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb index 95f53a90d..37f01ce0d 100644 --- a/app/helpers/table_builder_helper.rb +++ b/app/helpers/table_builder_helper.rb @@ -83,17 +83,21 @@ module TableBuilderHelper      cls: '',      # A set of content, over the th line... -    overhead: [] +    overhead: [], + +    # Possibility to override the result of collection.model +    model: nil +    )      content_tag :table, -      thead(collection, columns, sortable, selectable, links.any?, overhead) + +      thead(collection, columns, sortable, selectable, links.any?, overhead, model || collection.model) +          tbody(collection, columns, selectable, links, overhead),        class: cls    end    private -  def thead(collection, columns, sortable, selectable, has_links, overhead) +  def thead(collection, columns, sortable, selectable, has_links, overhead, model )      content_tag :thead do        # Inserts overhead content if any specified        over_head = '' @@ -121,7 +125,7 @@ module TableBuilderHelper              hcont << content_tag(:th, build_column_header(                column,                sortable, -              collection.model, +              model,                params,                params[:sort],                params[:direction] @@ -137,7 +141,7 @@ module TableBuilderHelper                  hcont << content_tag(:th, build_column_header(                    column,                    sortable, -                  collection.model, +                  model,                    params,                    params[:sort],                    params[:direction] @@ -147,7 +151,7 @@ module TableBuilderHelper                  hcont << content_tag(:th, build_column_header(                    column,                    sortable, -                  collection.model, +                  model,                    params,                    params[:sort],                    params[:direction] @@ -160,7 +164,7 @@ module TableBuilderHelper                hcont << content_tag(:th, build_column_header(                  column,                  sortable, -                collection.model, +                model,                  params,                  params[:sort],                  params[:direction] @@ -299,14 +303,14 @@ module TableBuilderHelper    def build_column_header(      column,      table_is_sortable, -    collection_model, +    model,      params,      sort_on,      sort_direction    )      if !table_is_sortable || !column.sortable -      return column.header_label(collection_model) +      return column.header_label(model)      end      direction = @@ -331,7 +335,7 @@ module TableBuilderHelper        arrow_icons = content_tag :span, arrow_up + arrow_down, class: 'orderers'        ( -        column.header_label(collection_model) + +        column.header_label(model) +          arrow_icons        ).html_safe      end diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb index 08efa7e9a..49fb6513f 100644 --- a/app/models/compliance_control.rb +++ b/app/models/compliance_control.rb @@ -1,29 +1,7 @@  class ComplianceControl < ActiveRecord::Base -  extend Enumerize -  belongs_to :compliance_control_set -  belongs_to :compliance_control_block - -  enumerize :criticity, in: %i(warning error), scope: true, default: :warning -  hstore_accessor :control_attributes, {} - -  validates :criticity, presence: true -  validates :name, presence: true -  validates :code, presence: true, uniqueness: { scope: :compliance_control_set } -  validates :origin_code, presence: true -  validates :compliance_control_set, presence: true - -  validate def coherent_control_set -    return true if compliance_control_block_id.nil? -    ids = [compliance_control_block.compliance_control_set_id, compliance_control_set_id] -    return true if ids.first == ids.last -    names = ids.map{|id| ComplianceControlSet.find(id).name} -    errors.add(:coherent_control_set, -               I18n.t('compliance_controls.errors.incoherent_control_sets', -                      indirect_set_name: names.first, -                      direct_set_name: names.last)) -  end    class << self +    def criticities; %i(warning error) end      def default_code; "" end      def dynamic_attributes        hstore_metadata_for_control_attributes.keys @@ -33,6 +11,17 @@ class ComplianceControl < ActiveRecord::Base        ComplianceControlPolicy      end +    def subclass_patterns +      {  +        generic: 'Generic', +        journey_pattern: 'JourneyPattern', +        line: 'Line', +        route: 'Route', +        routing_constraint_zone: 'RoutingConstraint', +        vehicle_journey: 'VehicleJourney' +      } +    end +      def inherited(child)        child.instance_eval do          def model_name @@ -43,12 +32,37 @@ class ComplianceControl < ActiveRecord::Base      end    end -  def initialize(attributes = {}) -    super -    self.name ||= I18n.t("activerecord.models.#{self.class.name.underscore}.one") -    self.code ||= self.class.default_code -    self.origin_code ||= self.class.default_code -  end +  extend Enumerize +  belongs_to :compliance_control_set +  belongs_to :compliance_control_block + +  enumerize :criticity, in: criticities, scope: true, default: :warning +  hstore_accessor :control_attributes, {} + +  validates :criticity, presence: true +  validates :name, presence: true +  validates :code, presence: true, uniqueness: { scope: :compliance_control_set } +  validates :origin_code, presence: true +  validates :compliance_control_set, presence: true + +  validate def coherent_control_set +  return true if compliance_control_block_id.nil? +  ids = [compliance_control_block.compliance_control_set_id, compliance_control_set_id] +  return true if ids.first == ids.last +  names = ids.map{|id| ComplianceControlSet.find(id).name} +  errors.add(:coherent_control_set, +             I18n.t('compliance_controls.errors.incoherent_control_sets', +                    indirect_set_name: names.first, +                    direct_set_name: names.last)) +end + + +def initialize(attributes = {}) +  super +  self.name ||= I18n.t("activerecord.models.#{self.class.name.underscore}.one") +  self.code ||= self.class.default_code +  self.origin_code ||= self.class.default_code +end  end diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim index cf236feb8..294df6a53 100644 --- a/app/views/compliance_control_sets/show.html.slim +++ b/app/views/compliance_control_sets/show.html.slim @@ -24,54 +24,21 @@        .col-lg-6.col-md-6.col-sm-12.col-xs-12          = definition_list t('metadatas'),              ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name +  - if params[:q].present? or @compliance_controls.any? +    .row +      .col-lg-12 +        = render '/compliance_controls/filters' +      .row        .col-lg-12          h2            = transport_mode("", "") -      .row -        .col-lg-12 -          .select_table -            = table_builder_2 @compliance_controls_without_block, -                    [ \ -                TableBuilderHelper::Column.new( \ -                  key: :code, \ -                  attribute: 'code' \ -                ), \ -                TableBuilderHelper::Column.new( \ -                  key: :name, \ -                  attribute: 'name', \ -                  link_to: lambda do |compliance_control| \ -                      compliance_control_set_compliance_control_path(@compliance_control_set, compliance_control) \ -                    end \ -                ), \ -                TableBuilderHelper::Column.new( \ -                  key: :criticity, \ -                  attribute: 'criticity' \ -                ), \ -                TableBuilderHelper::Column.new( \ -                  key: :comment, \ -                  attribute: 'comment' \ -                ), \ -              ], -              sortable: true, -              cls: 'table has-filter has-search' -    - @compliance_control_set.compliance_control_blocks.each do |block| -      .row -        .col-lg-12 -          h2 -            = transport_mode(block.transport_mode, block.transport_submode) -            .btn-group -              .btn.dropdown-toggle{ data-toggle="dropdown" } -                .span.fa.fa-cog -              ul.dropdown-menu -                li -                  = link_to t('compliance_control_sets.actions.edit'), edit_compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id) -                  = link_to t('compliance_control_sets.actions.destroy'), compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id), :method => :delete, :data => {:confirm =>  t('compliance_control_sets.actions.destroy_confirm')} +      - if @indirect_compliance_controls.try(:any?)          .row            .col-lg-12              .select_table -              = table_builder_2 ModelDecorator.decorate(block.compliance_controls, with: ComplianceControlDecorator), +              = table_builder_2 @indirect_compliance_controls,                        [ \                    TableBuilderHelper::Column.new( \                      key: :code, \ @@ -94,7 +61,52 @@                    ), \                  ],                  sortable: true, -                cls: 'table has-filter has-search' +                cls: 'table has-filter has-search', +                model: ComplianceControl + +    - @compliance_controls.each do |block, compliance_controls| + +      - if compliance_controls.try(:any?) +        .row +          .col-lg-12 +            h2 +              = transport_mode(block.transport_mode, block.transport_submode) +              .btn-group +                .btn.dropdown-toggle{ data-toggle="dropdown" } +                  .span.fa.fa-cog +                ul.dropdown-menu +                  li +                    = link_to t('compliance_control_sets.actions.edit'), edit_compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id) +                    = link_to t('compliance_control_sets.actions.destroy'), compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id), :method => :delete, :data => {:confirm =>  t('compliance_control_sets.actions.destroy_confirm')} +          .row +            .col-lg-12 +              .select_table +                = table_builder_2 compliance_controls, +                        [ \ +                    TableBuilderHelper::Column.new( \ +                      key: :code, \ +                      attribute: 'code' \ +                    ), \ +                    TableBuilderHelper::Column.new( \ +                      key: :name, \ +                      attribute: 'name', \ +                      link_to: lambda do |compliance_control| \ +                          compliance_control_set_compliance_control_path(@compliance_control_set, compliance_control) \ +                        end \ +                    ), \ +                    TableBuilderHelper::Column.new( \ +                      key: :criticity, \ +                      attribute: 'criticity' \ +                    ), \ +                    TableBuilderHelper::Column.new( \ +                      key: :comment, \ +                      attribute: 'comment' \ +                    ), \ +                  ], +                  sortable: true, +                  cls: 'table has-filter has-search', +                  model: ComplianceControl +      .select_toolbox        ul          li.st_action.with_text diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim new file mode 100644 index 000000000..c729190a0 --- /dev/null +++ b/app/views/compliance_controls/_filters.html.slim @@ -0,0 +1,46 @@ += search_form_for @q_controls_form, +  url: compliance_control_set_path(@compliance_control_set), +  builder: SimpleForm::FormBuilder, +  class: 'form form-filter' do |f| + +  .ffg-row +    .input-group.search_bar +      = f.search_field :name_cont, +        class: 'form-control', +        placeholder: t('compliance_controls.filters.name') +      span.input-group-btn +        button.btn.btn-default type='submit' +          span.fa.fa-search + +  .ffg-row +    .form-group.togglable#compliance_control_block-filter +      = f.label t('activerecord.models.compliance_control_block.one'), required: false, class: 'control-label' +      = f.input :compliance_control_block_id_eq_any, +        collection: @compliance_control_set.compliance_control_blocks, +        as: :check_boxes, +        label: false, +        label_method: lambda {|w| ("<span>#{transport_mode(w.transport_mode, w.transport_submode)}</span>").html_safe}, +        required: false, +        wrapper_html: {class: 'checkbox_list'} +    .form-group.togglable#subclass-filter +      = f.label t('compliance_controls.filters.subclass'), required: false, class: 'control-label' +      = f.input :origin_code_cont_any, +        collection: subclass_selection_list, +        as: :check_boxes, +        label: false, +        label_method: lambda {|w| ("<span>#{w.first}</span>").html_safe}, +        required: false, +        wrapper_html: {class: 'checkbox_list'} +    .form-group.togglable#severity-filter +      = f.label t('compliance_controls.filters.criticity'), required: false, class: 'control-label' +      = f.input :criticity_eq_any, +        collection: ComplianceControl.criticities, +        as: :check_boxes, +        label: false, +        label_method: lambda {|w| ("<span>#{w}</span>").html_safe}, +        required: false, +        wrapper_html: {class: 'checkbox_list'} + +  .actions +    = link_to t('actions.erase'), @compliance_control_set, class: 'btn btn-link' +    = f.submit t('actions.filter'), class: 'btn btn-default', id: 'compliance_control_set_compliance_controls_filter_btn' diff --git a/app/views/layouts/navigation/_main_nav_left.html.slim b/app/views/layouts/navigation/_main_nav_left.html.slim index 062c9383c..837b9cb73 100644 --- a/app/views/layouts/navigation/_main_nav_left.html.slim +++ b/app/views/layouts/navigation/_main_nav_left.html.slim @@ -31,16 +31,17 @@          #miTwo.panel-collapse.collapse            .list-group -            = link_to workbench_path(current_offer_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do -              span Jeux de données -            = link_to workbench_imports_path(current_offer_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do -              span Import -            = link_to calendars_path, class: 'list-group-item' do -              span Modèles de calendrier -            = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do -              span Rapport de contrôle -            = link_to compliance_control_sets_path, class: 'list-group-item' do -              span Jeux de contrôle +            - if current_user +              = link_to workbench_path(current_offer_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do +                span Jeux de données +              = link_to workbench_imports_path(current_offer_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do +                span Import +              = link_to calendars_path, class: 'list-group-item' do +                span Modèles de calendrier +              = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do +                span Rapport de contrôle +              = link_to compliance_control_sets_path, class: 'list-group-item' do +                span Jeux de contrôle        .menu-item.panel          .panel-heading diff --git a/config/locales/compliance_controls.en.yml b/config/locales/compliance_controls.en.yml index 887bc2009..41971d9e9 100644 --- a/config/locales/compliance_controls.en.yml +++ b/config/locales/compliance_controls.en.yml @@ -2,6 +2,17 @@ en:    compliance_controls:      clone:        prefix: 'Copy of' +    filters: +      criticity: Severity +      name: "Search by a control's name or code" +      subclass: Object +      subclasses: +        generic: 'Generic' +        journey_pattern: 'JourneyPattern' +        line: 'Line' +        route: 'Route' +        routing_constraint_zone: 'RoutingConstraint' +        vehicle_journey: 'VehicleJourney'      min_max_values: "the minimum (%{min}) is not supposed to be greater than the maximum (%{max})"      errors:        incoherent_control_sets: "Impossible to assign a control to a set (id: %{direct_set_name}) differing from the one of its group (id: %{indirect_set_name})" @@ -179,4 +190,4 @@ en:          compliance_control_block: "Control Block"          minimum: "Minimum"          maximum: "Maximum" -        target: "Target"
\ No newline at end of file +        target: "Target" diff --git a/config/locales/compliance_controls.fr.yml b/config/locales/compliance_controls.fr.yml index 2feb201bf..3fa83a147 100644 --- a/config/locales/compliance_controls.fr.yml +++ b/config/locales/compliance_controls.fr.yml @@ -2,6 +2,17 @@ fr:    compliance_controls:      clone:        prefix: 'Copie de' +    filters: +      criticity: Criticité +      name: "Chercher le nom ou code d'un contrôl" +      subclass: Objet   +      subclasses: +        generic: 'Généric' +        journey_pattern: 'JourneyPattern' +        line: 'Ligne' +        route: 'Itinéraire' +        routing_constraint_zone: 'ITL' +        vehicle_journey: 'Course'      min_max_values: "la valeur de minimum (%{min}) ne doit pas être superieur à la valuer du maximum (%{max})"      errors:        incoherent_control_sets: "Le contrôle ne peut pas être associé à un jeu de contrôle (id: %{direct_set_name}) différent de celui de son groupe (id: %{indirect_set_name})" @@ -119,7 +130,7 @@ fr:    activerecord:      models:        compliance_control: -        one: "controle" +        one: "contrôle"          other: "contrôles"        route_control/zdl_stop_area:          one: "Deux arrêts d’une même ZDL ne peuvent pas se succéder dans un itinéraire" @@ -130,7 +141,7 @@ fr:        route_control/duplicates:          one: "Détection de double définition d'itinéraire"        route_control/opposite_route_terminus: -        one: "Vérification des terminus de l'itinéraire inverse" +       one: "Vérification des terminus de l'itinéraire inverse"        route_control/minimum_length:          one: "Un itinéraire doit contenir au moins 2 arrêts"        route_control/omnibus_journey_pattern: @@ -179,4 +190,4 @@ fr:          compliance_control_block: "Groupe de contrôle"          minimum: "Minimum"          maximum: "Maximum" -        target: "Cible"
\ No newline at end of file +        target: "Cible" diff --git a/config/routes.rb b/config/routes.rb index b105e77d6..27c3c3044 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,6 +74,7 @@ ChouetteIhm::Application.routes.draw do    resources :api_keys, :only => [:edit, :update, :new, :create, :destroy]    resources :compliance_control_sets do +    get :simple, on: :member      get :clone, on: :member      resources :compliance_controls, except: :index do        get :select_type, on: :collection diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb new file mode 100644 index 000000000..500d4ce6f --- /dev/null +++ b/spec/features/compliance_control_sets_spec.rb @@ -0,0 +1,82 @@ +RSpec.describe "ComplianceControlSets", type: :feature do + +  login_user + +  # We setup a control_set with two blocks and one direct control (meaning that it is not attached to a block) +  # Then we add one control to the first block and two controls to the second block +  let( :control_set ){ create :compliance_control_set, organisation: organisation } +  let( :controls ){ control_set.compliance_controls } + +  let(:blox){ +    2.times.map{ | _ | create :compliance_control_block, compliance_control_set: control_set } +  } + +  before do +    blox.first.update transport_mode: 'bus', transport_submode: 'bus' +    blox.second.update transport_mode: 'train', transport_submode: 'train' + +    make_control +    make_control blox.first, severity: :error +    make_control blox.second, times: 2 +  end + +  describe 'show' do +    before do +      visit compliance_control_set_path( control_set ) +    end + +    it 'we can see the controls inside their blocks' do +      controls.each do | control | +        expect( page ).to have_content(control.code) +      end +    end + +    it 'we can apply a severity filter' do +      controls.take(2).each do | control | +        control.update criticity: 'error' +      end +      check('error') +      click_on('Filtrer') +      controls.each do | control | +        if control.criticity == 'error' +          expect( page ).to have_content(control.code) +        else +          expect( page ).not_to have_content(control.code) +        end +      end +    end + +    it 'we can apply a subclass filter' do +      controls.first.update(origin_code: 'x-Route-y') +      controls.second.update(origin_code: 'x-Line-y') + +      within('#subclass-filter') do +        check('Itinéraire') +        check('Ligne') +      end +      click_on('Filtrer') +      controls.each do | control | +        if control.origin_code[/-Generic-/] +          expect( page ).not_to have_content(control.code) +        else +          expect( page ).to have_content(control.code) +        end +      end +    end + +  end + +  def make_control ccblock=nil, times: 1, severity: :warning +    times.times do +      make_one_control ccblock, severity +    end +  end + +  def make_one_control ccblock, severity +      create( :generic_attribute_control_min_max, +        code: random_string, +        compliance_control_block: ccblock, +        compliance_control_set: control_set) +  end + +end diff --git a/spec/features/connection_links_spec.rb b/spec/features/connection_links_spec.rb index 7272242fe..2f6283dcd 100644 --- a/spec/features/connection_links_spec.rb +++ b/spec/features/connection_links_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe "ConnectionLinks", :type => :feature do +RSpec.describe "ConnectionLinks", type: :feature do    login_user    let!(:connection_links) { Array.new(2) { create(:connection_link) } } diff --git a/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb b/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb new file mode 100644 index 000000000..868eca984 --- /dev/null +++ b/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb @@ -0,0 +1,17 @@ +RSpec.describe ComplianceControl do +  let( :subject ){ described_class.subclass_patterns } + +  context 'subclass_patterns' do +    it 'are correctly defined' do +      expect_it.to eq( +        generic: 'Generic', +        journey_pattern: 'JourneyPattern', +        line: 'Line', +        route: 'Route', +        routing_constraint_zone: 'RoutingConstraint', +        vehicle_journey: 'VehicleJourney' +      ) +    end +  end + +end diff --git a/spec/models/compliance_control_spec.rb b/spec/models/compliance_control_spec.rb index db73dab21..4267459ea 100644 --- a/spec/models/compliance_control_spec.rb +++ b/spec/models/compliance_control_spec.rb @@ -4,10 +4,6 @@ RSpec.describe ComplianceControl, type: :model do      let(:compliance_control) { build_stubbed :compliance_control } -    it 'should have a valid factory' do -      expect(compliance_control).to be_valid -    end -      it { should belong_to :compliance_control_set }      it { should belong_to :compliance_control_block } | 
