aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/compliance_check_sets_controller.rb31
-rw-r--r--app/controllers/compliance_checks_controller.rb2
-rw-r--r--app/controllers/compliance_control_sets_controller.rb21
-rw-r--r--app/decorators/compliance_check_decorator.rb8
-rw-r--r--app/helpers/compliance_check_blocks_helper.rb3
-rw-r--r--app/helpers/compliance_check_sets_helper.rb16
-rw-r--r--app/helpers/compliance_control_blocks_helper.rb2
-rw-r--r--app/helpers/transport_mode_helper.rb16
-rw-r--r--app/models/compliance_check_block.rb8
-rw-r--r--app/models/compliance_control_block.rb4
-rw-r--r--app/models/concerns/stif_transport_mode_enumerations.rb25
-rw-r--r--app/models/concerns/stif_transport_submode_enumerations.rb36
-rw-r--r--app/models/line_referential.rb2
-rw-r--r--app/models/organisation.rb1
-rw-r--r--app/views/compliance_check_sets/executed.html.slim84
-rw-r--r--app/views/compliance_check_sets/show.html.slim12
-rw-r--r--app/views/compliance_checks/_filters.html.slim47
-rw-r--r--app/views/compliance_control_sets/show.html.slim117
-rw-r--r--app/views/compliance_controls/_filters.html.slim3
-rw-r--r--app/views/lines/_filters.html.slim4
-rw-r--r--config/locales/compliance_check_blocks.en.yml8
-rw-r--r--config/locales/compliance_check_blocks.fr.yml7
-rw-r--r--config/locales/compliance_check_sets.en.yml31
-rw-r--r--config/locales/compliance_check_sets.fr.yml28
-rw-r--r--config/locales/compliance_checks.en.yml8
-rw-r--r--config/locales/compliance_checks.fr.yml11
-rw-r--r--config/routes.rb1
-rw-r--r--spec/controllers/compliance_check_sets_controller_spec.rb4
-rw-r--r--spec/factories/compliance_control_blocks.rb3
-rw-r--r--spec/features/compliance_check_sets_spec.rb110
-rw-r--r--spec/features/compliance_control_sets_spec.rb16
-rw-r--r--spec/models/compliance_check_block_spec.rb17
-rw-r--r--spec/models/compliance_control_block_spec.rb17
-rw-r--r--spec/models/line_referential_spec.rb9
-rw-r--r--spec/support/breadcrumb_features.rb15
35 files changed, 572 insertions, 155 deletions
diff --git a/app/controllers/compliance_check_sets_controller.rb b/app/controllers/compliance_check_sets_controller.rb
index 95dcfbf05..175c22191 100644
--- a/app/controllers/compliance_check_sets_controller.rb
+++ b/app/controllers/compliance_check_sets_controller.rb
@@ -18,4 +18,35 @@ class ComplianceCheckSetsController < InheritedResources::Base
}
end
end
+
+ def executed
+ show! do |format|
+ # But now nobody is aware anymore that `format.html` passes a parameter into the block
+ format.html { executed_for_html }
+ end
+ end
+
+
+ private
+
+ # Action Implementation
+ # ---------------------
+
+ def executed_for_html
+ @q_checks_form = @compliance_check_set.compliance_checks.ransack(params[:q])
+ @compliance_check_set = @compliance_check_set.decorate
+ compliance_checks =
+ decorate_compliance_checks( @q_checks_form.result)
+ .group_by(&:compliance_check_block)
+ @direct_compliance_checks = compliance_checks.delete nil
+ @blocks_to_compliance_checks_map = compliance_checks
+ end
+
+ # Decoration
+ # ----------
+ def decorate_compliance_checks(compliance_checks)
+ ModelDecorator.decorate(
+ compliance_checks,
+ with: ComplianceCheckDecorator)
+ end
end
diff --git a/app/controllers/compliance_checks_controller.rb b/app/controllers/compliance_checks_controller.rb
index 07438cf99..81749e292 100644
--- a/app/controllers/compliance_checks_controller.rb
+++ b/app/controllers/compliance_checks_controller.rb
@@ -1,4 +1,4 @@
-class ComplianceChecksController < ChouetteController
+class ComplianceChecksController < InheritedResources::Base
end
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index 5c78d09e3..83a345c6f 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -17,17 +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 =
- decorate_compliance_controls( @q_controls_form.result)
- .group_by(&:compliance_control_block)
- @indirect_compliance_controls = @compliance_controls.delete nil
- }
+ # But now nobody is aware anymore that `format.html` passes a parameter into the block
+ format.html { show_for_html }
end
end
+
def clone
ComplianceControlSetCloner.new.copy(params[:id], current_organisation.id)
flash[:notice] = I18n.t("compliance_control_sets.errors.operation_in_progress")
@@ -59,4 +54,14 @@ class ComplianceControlSetsController < InheritedResources::Base
def compliance_control_set_params
params.require(:compliance_control_set).permit(:name, :id)
end
+
+ def show_for_html
+ @q_controls_form = @compliance_control_set.compliance_controls.ransack(params[:q])
+ @compliance_control_set = @compliance_control_set.decorate
+ compliance_controls =
+ decorate_compliance_controls( @q_controls_form.result)
+ .group_by(&:compliance_control_block)
+ @direct_compliance_controls = compliance_controls.delete nil
+ @blocks_to_compliance_controls_map = compliance_controls
+ end
end
diff --git a/app/decorators/compliance_check_decorator.rb b/app/decorators/compliance_check_decorator.rb
new file mode 100644
index 000000000..5431f5796
--- /dev/null
+++ b/app/decorators/compliance_check_decorator.rb
@@ -0,0 +1,8 @@
+class ComplianceCheckDecorator < Draper::Decorator
+ delegate_all
+
+ def action_links
+ []
+ end
+
+end
diff --git a/app/helpers/compliance_check_blocks_helper.rb b/app/helpers/compliance_check_blocks_helper.rb
new file mode 100644
index 000000000..b4d858b07
--- /dev/null
+++ b/app/helpers/compliance_check_blocks_helper.rb
@@ -0,0 +1,3 @@
+module ComplianceCheckBlocksHelper
+ include TransportModeHelper
+end
diff --git a/app/helpers/compliance_check_sets_helper.rb b/app/helpers/compliance_check_sets_helper.rb
new file mode 100644
index 000000000..fc7165fed
--- /dev/null
+++ b/app/helpers/compliance_check_sets_helper.rb
@@ -0,0 +1,16 @@
+module ComplianceCheckSetsHelper
+ def compliance_check_set_path(compliance_check_set)
+ workbench_compliance_check_set_path(compliance_check_set.workbench, compliance_check_set)
+ end
+
+ def executed_compliance_check_set_path(compliance_check_set)
+ executed_workbench_compliance_check_set_path(compliance_check_set.workbench, compliance_check_set)
+ end
+
+ def compliance_check_path(compliance_check)
+ workbench_compliance_check_set_compliance_check_path(
+ compliance_check.compliance_check_set.workbench,
+ compliance_check.compliance_check_set,
+ compliance_check)
+ end
+end
diff --git a/app/helpers/compliance_control_blocks_helper.rb b/app/helpers/compliance_control_blocks_helper.rb
index 311e6fb46..b53ac17ae 100644
--- a/app/helpers/compliance_control_blocks_helper.rb
+++ b/app/helpers/compliance_control_blocks_helper.rb
@@ -1,5 +1,5 @@
module ComplianceControlBlocksHelper
- def transport_mode(transport_mode, transport_submode)
+ def compliance_transport_mode(transport_mode, transport_submode)
return "[Tous les modes de transport]" if transport_mode == ""
if transport_submode == ""
"[" + t("enumerize.transport_mode.#{transport_mode}") + "]"
diff --git a/app/helpers/transport_mode_helper.rb b/app/helpers/transport_mode_helper.rb
new file mode 100644
index 000000000..7a486fc2d
--- /dev/null
+++ b/app/helpers/transport_mode_helper.rb
@@ -0,0 +1,16 @@
+module TransportModeHelper
+ def transport_mode_text(transport_modable=nil)
+ mode = transport_modable.try(:transport_mode)
+ return "[Tous les modes de transport]" if mode.blank?
+
+ submode = transport_modable.try(:transport_submode)
+ [translated_mode_name(:mode, mode), translated_mode_name(:submode, submode)].join
+ end
+
+ private
+ def translated_mode_name mode_type, value
+ return "" if value.blank?
+ "[#{I18n.t("enumerize.transport_#{mode_type}.#{value}")}]"
+ end
+
+end
diff --git a/app/models/compliance_check_block.rb b/app/models/compliance_check_block.rb
index ee60a8bb1..05240b428 100644
--- a/app/models/compliance_check_block.rb
+++ b/app/models/compliance_check_block.rb
@@ -1,5 +1,13 @@
class ComplianceCheckBlock < ActiveRecord::Base
+ include StifTransportModeEnumerations
+ include StifTransportSubmodeEnumerations
+
belongs_to :compliance_check_set
has_many :compliance_checks
+
+ hstore_accessor :condition_attributes,
+ transport_mode: :string,
+ transport_submode: :string
+
end
diff --git a/app/models/compliance_control_block.rb b/app/models/compliance_control_block.rb
index 5721c00f4..cfcdfd1a6 100644
--- a/app/models/compliance_control_block.rb
+++ b/app/models/compliance_control_block.rb
@@ -1,6 +1,6 @@
class ComplianceControlBlock < ActiveRecord::Base
- extend StifTransportModeEnumerations
- extend StifTransportSubmodeEnumerations
+ include StifTransportModeEnumerations
+ include StifTransportSubmodeEnumerations
belongs_to :compliance_control_set
has_many :compliance_controls, dependent: :destroy
diff --git a/app/models/concerns/stif_transport_mode_enumerations.rb b/app/models/concerns/stif_transport_mode_enumerations.rb
index c2d38c2c6..74621dfc5 100644
--- a/app/models/concerns/stif_transport_mode_enumerations.rb
+++ b/app/models/concerns/stif_transport_mode_enumerations.rb
@@ -1,19 +1,18 @@
module StifTransportModeEnumerations
extend ActiveSupport::Concern
- extend Enumerize
- extend self
- enumerize :transport_mode, in: %w(bus
- metro
- rail
- tram
- funicular)
-
- def transport_modes
- StifTransportModeEnumerations.transport_mode.values
+ class << self
+ def transport_modes
+ %w(bus metro rail tram funicular)
+ end
+ def sorted_transport_modes
+ transport_modes.sort_by{|m| I18n.t("enumerize.transport_mode.#{m}").parameterize }
+ end
end
-
- def sorted_transport_modes
- self.transport_modes.sort_by{|m| I18n.t("enumerize.transport_mode.#{m}").parameterize }
+
+ included do
+ extend Enumerize
+ enumerize :transport_mode, in: StifTransportModeEnumerations.transport_modes
end
+
end
diff --git a/app/models/concerns/stif_transport_submode_enumerations.rb b/app/models/concerns/stif_transport_submode_enumerations.rb
index cf314badd..eb3e56eac 100644
--- a/app/models/concerns/stif_transport_submode_enumerations.rb
+++ b/app/models/concerns/stif_transport_submode_enumerations.rb
@@ -1,24 +1,28 @@
module StifTransportSubmodeEnumerations
extend ActiveSupport::Concern
- extend Enumerize
- extend self
- enumerize :transport_submode, in: %w(demandAndResponseBus
- nightBus
- airportLinkBus
- highFrequencyBus
- expressBus
- railShuttle
- suburbanRailway
- regionalRail
- interregionalRail
-)
+ class << self
+ def transport_submodes
+ %w(
+ demandAndResponseBus
+ nightBus
+ airportLinkBus
+ highFrequencyBus
+ expressBus
+ railShuttle
+ suburbanRailway
+ regionalRail
+ interregionalRail)
+ end
- def transport_submodes
- StifTransportSubmodeEnumerations.transport_submode.values
+ def sorted_transport_submodes
+ transport_submodes.sort_by{|m| I18n.t("enumerize.transport_submode.#{m}").parameterize }
+ end
end
- def sorted_transport_submodes
- self.transport_submodes.sort_by{|m| I18n.t("enumerize.transport_submode.#{m}").parameterize }
+ included do
+ extend Enumerize
+ enumerize :transport_submode, in: StifTransportSubmodeEnumerations.transport_submodes
end
+
end
diff --git a/app/models/line_referential.rb b/app/models/line_referential.rb
index 8bc6adec3..7ab892b53 100644
--- a/app/models/line_referential.rb
+++ b/app/models/line_referential.rb
@@ -1,5 +1,5 @@
class LineReferential < ActiveRecord::Base
- extend StifTransportModeEnumerations
+ include StifTransportModeEnumerations
has_many :line_referential_memberships
has_many :organisations, through: :line_referential_memberships
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index b0c0692da..f6fba2d67 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -55,6 +55,7 @@ class Organisation < ActiveRecord::Base
organisation_referential = referentials.find_by id: referential_id
return organisation_referential if organisation_referential
+ # TODO: Replace each with find
workbenches.each do |workbench|
workbench_referential = workbench.all_referentials.find_by id: referential_id
return workbench_referential if workbench_referential
diff --git a/app/views/compliance_check_sets/executed.html.slim b/app/views/compliance_check_sets/executed.html.slim
new file mode 100644
index 000000000..bb055272d
--- /dev/null
+++ b/app/views/compliance_check_sets/executed.html.slim
@@ -0,0 +1,84 @@
+- breadcrumb :compliance_check_set, @workbench, @compliance_check_set
+/ PageHeader
+= pageheader 'jeux-de-donnees',
+ t('compliance_check_sets.executed.title', name: @compliance_check_set.name)
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-6.col-md-6.col-sm-12.col-xs-12
+ = definition_list t('metadatas'),
+ ComplianceCheckSet.human_attribute_name(:name) => @compliance_check_set.name
+
+ - if params[:q].present? || @blocks_to_compliance_checks_map.any? || @direct_compliance_checks
+ .row
+ .col-lg-12
+ = render '/compliance_checks/filters'
+
+ - if @direct_compliance_checks.try(:any?)
+ .row
+ .col-lg-12
+ h2
+ = transport_mode_text()
+ .row
+ .col-lg-12
+ = table_builder_2 @direct_compliance_checks,
+ [ \
+ TableBuilderHelper::Column.new( \
+ key: :code, \
+ attribute: 'code' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :name, \
+ attribute: 'name', \
+ link_to: lambda do |compliance_check| \
+ compliance_check_path(compliance_check) \
+ end \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :criticity, \
+ attribute: 'criticity' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :comment, \
+ attribute: 'comment' \
+ ), \
+ ],
+ sortable: true,
+ cls: 'table has-filter has-search',
+ model: ComplianceCheck
+
+ - @blocks_to_compliance_checks_map.each do |block, compliance_checks|
+
+ - if compliance_checks.try(:any?)
+ .row
+ .col-lg-12
+ h2
+ = transport_mode_text(block)
+ .row
+ .col-lg-12
+ = table_builder_2 compliance_checks,
+ [ \
+ TableBuilderHelper::Column.new( \
+ key: :code, \
+ attribute: 'code' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :name, \
+ attribute: 'name', \
+ link_to: lambda do |compliance_check| \
+ compliance_check_path(compliance_check) \
+ end \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :criticity, \
+ attribute: 'criticity' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :comment, \
+ attribute: 'comment' \
+ ), \
+ ],
+ sortable: true,
+ cls: 'table has-filter has-search',
+ model: ComplianceCheck
diff --git a/app/views/compliance_check_sets/show.html.slim b/app/views/compliance_check_sets/show.html.slim
deleted file mode 100644
index eefa5363f..000000000
--- a/app/views/compliance_check_sets/show.html.slim
+++ /dev/null
@@ -1,12 +0,0 @@
-- breadcrumb :compliance_check_set, @workbench, @compliance_check_set
-/ PageHeader
-= pageheader 'jeux-de-donnees',
- @compliance_check_set.referential.name
-/ PageContent
-.page_content
- .container-fluid
- .row
- .col-lg-6.col-md-6.col-sm-12.col-xs-12
- = definition_list t('metadatas'),
- ComplianceCheckSet.human_attribute_name(:id) => @compliance_check_set.referential.id,
- ComplianceCheckSet.human_attribute_name(:name) => @compliance_check_set.referential.name
diff --git a/app/views/compliance_checks/_filters.html.slim b/app/views/compliance_checks/_filters.html.slim
new file mode 100644
index 000000000..0d747da27
--- /dev/null
+++ b/app/views/compliance_checks/_filters.html.slim
@@ -0,0 +1,47 @@
+/ Compliance Check Filter
+= search_form_for @q_checks_form,
+ url: executed_compliance_check_set_path(@compliance_check_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_checks.filters.name')
+ span.input-group-btn
+ button.btn.btn-default type='submit'
+ span.fa.fa-search
+
+ .ffg-row
+ .form-group.togglable#compliance_check_block-filter
+ = f.label t('activerecord.models.compliance_check_block.one'), required: false, class: 'control-label'
+ = f.input :compliance_check_block_id_eq_any,
+ collection: @compliance_check_set.compliance_check_blocks,
+ as: :check_boxes,
+ label: false,
+ label_method: lambda {|w| ("<span>#{transport_mode_text(w)}</span>").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
+ .form-group.togglable#subclass-filter
+ = f.label t('compliance_checks.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_checks.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'), executed_compliance_check_set_path(@compliance_check_set), class: 'btn btn-link'
+ = f.submit t('actions.filter'), class: 'btn btn-default', id: 'compliance_check_set_compliance_checks_filter_btn'
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index 2bd663578..71b71f842 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -1,8 +1,7 @@
- breadcrumb :compliance_control_set, @compliance_control_set
/ PageHeader
= pageheader 'jeux-de-controle',
- t('compliance_control_sets.show.title', name: @compliance_control_set.name),
- 'Lorem ipsum dolor sit amet'
+ t('compliance_control_sets.show.title', name: @compliance_control_set.name)
/ Below is secondary actions & optional contents (filters, ...)
.row.mb-sm
@@ -25,21 +24,65 @@
= definition_list t('metadatas'),
ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name,
I18n.t('activerecord.attributes.compliance_control_set.owner_jdc') => @compliance_control_set.organisation.name
- - if params[:q].present? or @compliance_controls.any?
+
+ - if params[:q].present? || @blocks_to_compliance_controls_map.any? || @direct_compliance_controls
.row
.col-lg-12
= render '/compliance_controls/filters'
- .row
- .col-lg-12
- h2
- = transport_mode("", "")
- - if @indirect_compliance_controls.try(:any?)
+ - if @direct_compliance_controls.try(:any?)
+ .row
+ .col-lg-12
+ h2
+ = transport_mode_text()
+ .row
+ .col-lg-12
+ .select_table
+ = table_builder_2 @direct_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
+
+ - @blocks_to_compliance_controls_map.each do |block, compliance_controls|
+
+ - if compliance_controls.try(:any?)
+ .row
+ .col-lg-12
+ h2
+ = transport_mode_text(block)
+ .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 @indirect_compliance_controls,
+ = table_builder_2 compliance_controls,
[ \
TableBuilderHelper::Column.new( \
key: :code, \
@@ -65,47 +108,15 @@
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) if policy(ComplianceControlBlock).update? if policy(ComplianceControlBlock).update?
- = link_to t('compliance_control_sets.actions.destroy'), compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id), :method => :delete, :data => {:confirm => t('compliance_control_sets.actions.destroy_confirm')} if policy(ComplianceControlBlock).destroy?
- .row
- .col-lg-12
- .select_table
- = 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
-
- = flotted_links(@compliance_control_set.id) \ No newline at end of file
+ .select_toolbox
+ ul
+ li.st_action.with_text
+ = link_to select_type_compliance_control_set_compliance_controls_path(@compliance_control_set.id)
+ span.fa.fa-plus
+ span
+ = t('compliance_control_sets.actions.add_compliance_control')
+ li.st_action.with_text
+ = link_to new_compliance_control_set_compliance_control_block_path(@compliance_control_set.id)
+ span.fa.fa-plus
+ span
+ = t('compliance_control_sets.actions.add_compliance_control_block')
diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim
index c729190a0..d38da5d2d 100644
--- a/app/views/compliance_controls/_filters.html.slim
+++ b/app/views/compliance_controls/_filters.html.slim
@@ -1,3 +1,4 @@
+/ Compliance Control Filter
= search_form_for @q_controls_form,
url: compliance_control_set_path(@compliance_control_set),
builder: SimpleForm::FormBuilder,
@@ -19,7 +20,7 @@
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},
+ label_method: lambda {|w| ("<span>#{transport_mode_text(w)}</span>").html_safe},
required: false,
wrapper_html: {class: 'checkbox_list'}
.form-group.togglable#subclass-filter
diff --git a/app/views/lines/_filters.html.slim b/app/views/lines/_filters.html.slim
index 7662c41b5..58f8f2431 100644
--- a/app/views/lines/_filters.html.slim
+++ b/app/views/lines/_filters.html.slim
@@ -17,11 +17,11 @@
.form-group.togglable
= f.label Chouette::Line.human_attribute_name(:transport_mode), required: false, class: 'control-label'
- = f.input :transport_mode_eq_any, collection: Chouette::Line.sorted_transport_modes, as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + t("enumerize.transport_mode.#{l}") + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}
+ = f.input :transport_mode_eq_any, collection: StifTransportModeEnumerations.sorted_transport_modes, as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + t("enumerize.transport_mode.#{l}") + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}
.form-group.togglable
= f.label Chouette::Line.human_attribute_name(:transport_submode), required: false, class: 'control-label'
- = f.input :transport_submode_eq_any, collection: Chouette::Line.sorted_transport_submodes, as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + t("enumerize.transport_submode.#{l}") + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}
+ = f.input :transport_submode_eq_any, collection: StifTransportSubmodeEnumerations.sorted_transport_submodes, as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + t("enumerize.transport_submode.#{l}") + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}
.actions
= link_to 'Effacer', @workbench, class: 'btn btn-link'
diff --git a/config/locales/compliance_check_blocks.en.yml b/config/locales/compliance_check_blocks.en.yml
new file mode 100644
index 000000000..a20fb483e
--- /dev/null
+++ b/config/locales/compliance_check_blocks.en.yml
@@ -0,0 +1,8 @@
+en:
+ activerecord:
+ models:
+ compliance_check_block:
+ zero: Control blocks
+ one: Control block
+ other: Control blocks
+
diff --git a/config/locales/compliance_check_blocks.fr.yml b/config/locales/compliance_check_blocks.fr.yml
new file mode 100644
index 000000000..3d385aff6
--- /dev/null
+++ b/config/locales/compliance_check_blocks.fr.yml
@@ -0,0 +1,7 @@
+fr:
+ activerecord:
+ models:
+ compliance_check_block:
+ zero: "Groupe de contrôle"
+ one: "Groupe de contrôle"
+ other: "Groupes de contrôles"
diff --git a/config/locales/compliance_check_sets.en.yml b/config/locales/compliance_check_sets.en.yml
index 89c142a49..5aa6f9740 100644
--- a/config/locales/compliance_check_sets.en.yml
+++ b/config/locales/compliance_check_sets.en.yml
@@ -1,9 +1,5 @@
en:
compliance_check_sets:
- index:
- title: Control reports
- new: Creating a Control Report
- edit: Update a Control Report
actions:
new: Add a control report
edit: Edit a control report
@@ -12,12 +8,25 @@ en:
filters:
name: Specify a control report name...
error_period_filter: End date must be greater than or equal to begin date
+ index:
+ title: Compliance control set
+ new: New compliance control set
+ new_control: Creating a Control
+ select_types: Control Type Selection
+ edit: Edit compliance control set
search_no_results: No control reports match your search
+ executed:
+ title: Executed control report %{name}
activerecord:
- attributes:
- compliance_check_set:
- ref: réf
- creation_date: Created at
- associated_object: Associated object
- assigned_to: Assigned to
- compliance_control_set: Compliance control set
+ attributes:
+ compliance_check_set:
+ ref: ref
+ creation_date: Created at
+ associated_object: Associated object
+ assigned_to: Assigned to
+ compliance_control_set: Compliance control set
+ name: Name
+ models:
+ compliance_check_block:
+ one: compliance_control_set
+ other: compliance_control_sets
diff --git a/config/locales/compliance_check_sets.fr.yml b/config/locales/compliance_check_sets.fr.yml
index 8c21f33fd..8ad5af904 100644
--- a/config/locales/compliance_check_sets.fr.yml
+++ b/config/locales/compliance_check_sets.fr.yml
@@ -1,9 +1,5 @@
fr:
compliance_check_sets:
- index:
- title: Rapports de contrôle
- new: Création d'un rapport de contrôle
- edit: Édition d'un rapport de contrôle
actions:
new: Ajouter
edit: Editer
@@ -12,12 +8,22 @@ fr:
filters:
name: Indiquez un nom d'un objet associé...
error_period_filter: La date de fin doit être supérieure ou égale à la date de début0
+ index:
+ title: "Liste des jeux de contrôles"
search_no_results: Aucun rapport de contrôle ne correspond à votre recherche
+ executed:
+ title: Jeu de contrôles exécutés %{name}
activerecord:
- attributes:
- compliance_check_set:
- ref: réf
- creation_date: Date et heure de création
- associated_object: Objet associé
- assigned_to: Affectation
- compliance_control_set: jeu de contrôle
+ attributes:
+ compliance_check_set:
+ ref: réf
+ creation_date: Date et heure de création
+ associated_object: Objet associé
+ assigned_to: Affectation
+ compliance_control_set: jeu de contrôle
+ name: Nom
+ models:
+ compliance_check_block:
+ zero: "Groupe de contrôle"
+ one: "Groupe de contrôle"
+ other: "Groupes de contrôles"
diff --git a/config/locales/compliance_checks.en.yml b/config/locales/compliance_checks.en.yml
index 7f3e317be..177c87852 100644
--- a/config/locales/compliance_checks.en.yml
+++ b/config/locales/compliance_checks.en.yml
@@ -1,2 +1,10 @@
en:
+ activerecord:
+ attributes:
+ compliance_check:
+ code: Code
compliance_checks:
+ filters:
+ subclass: Object
+ criticity: Severity
+ name: Name
diff --git a/config/locales/compliance_checks.fr.yml b/config/locales/compliance_checks.fr.yml
index 421574cbd..d11d37003 100644
--- a/config/locales/compliance_checks.fr.yml
+++ b/config/locales/compliance_checks.fr.yml
@@ -1,3 +1,14 @@
fr:
+ activerecord:
+ attributes:
+ compliance_check:
+ code: Code
+ name: Nom
+ criticity: Criticité
+ comment: Commentaire
compliance_checks:
+ filters:
+ subclass: Objet
+ criticity: Criticité
+ name: Nom
diff --git a/config/routes.rb b/config/routes.rb
index 8221dfe1a..8ea8168bf 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,6 +12,7 @@ ChouetteIhm::Application.routes.draw do
end
end
resources :compliance_check_sets, only: [:index, :show] do
+ get :executed, on: :member
resources :compliance_checks, only: [:show]
end
end
diff --git a/spec/controllers/compliance_check_sets_controller_spec.rb b/spec/controllers/compliance_check_sets_controller_spec.rb
index 804b0a658..3ddb1dad1 100644
--- a/spec/controllers/compliance_check_sets_controller_spec.rb
+++ b/spec/controllers/compliance_check_sets_controller_spec.rb
@@ -5,9 +5,9 @@ RSpec.describe ComplianceCheckSetsController, type: :controller do
let(:compliance_check_set) { create :compliance_check_set }
- describe "GET show" do
+ describe "GET executed" do
it 'should be successful' do
- get :show, workbench_id: compliance_check_set.workbench.id, id: compliance_check_set.id
+ get :executed, workbench_id: compliance_check_set.workbench.id, id: compliance_check_set.id
expect(response).to be_success
end
end
diff --git a/spec/factories/compliance_control_blocks.rb b/spec/factories/compliance_control_blocks.rb
index 4785d8419..94773d4b3 100644
--- a/spec/factories/compliance_control_blocks.rb
+++ b/spec/factories/compliance_control_blocks.rb
@@ -1,7 +1,8 @@
FactoryGirl.define do
factory :compliance_control_block do
sequence(:name) { |n| "Compliance control block #{n}" }
- transport_mode "air"
+ transport_mode StifTransportModeEnumerations.transport_modes.first
+ transport_submode StifTransportSubmodeEnumerations.transport_submodes.first
association :compliance_control_set
end
end
diff --git a/spec/features/compliance_check_sets_spec.rb b/spec/features/compliance_check_sets_spec.rb
new file mode 100644
index 000000000..7ba64b6b8
--- /dev/null
+++ b/spec/features/compliance_check_sets_spec.rb
@@ -0,0 +1,110 @@
+require 'rails_helper'
+
+RSpec.describe "ComplianceCheckSets", type: :feature do
+
+ include ComplianceCheckSetsHelper
+ include TransportModeHelper
+
+ 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( :compliance_check_set ){ create :compliance_check_set, name: random_string }
+ let(:blox){[
+ create( :compliance_check_block,
+ compliance_check_set: compliance_check_set, transport_mode: 'bus', transport_submode: 'demandAndResponseBus'),
+ create( :compliance_check_block,
+ compliance_check_set: compliance_check_set, transport_mode: 'rail', transport_submode: 'suburbanRailway')
+ ]}
+ let!(:direct_checks){ make_check(nil, times: 2) + make_check(nil, severity: :error) }
+ let!(:indirect_checks){ blox.flat_map{ |block| make_check(block) } }
+ let( :all_checks ){ direct_checks + indirect_checks }
+
+
+ context 'executed' do
+
+ before do
+ visit(executed_compliance_check_set_path(compliance_check_set))
+ end
+
+ it 'we can see the expected content' do
+ # Breadcrumbs
+ expect_breadcrumb_links "Accueil", "Gestion de l'offre", "Liste des jeux de contrôles"
+
+ # Headline
+ expect( page ).to have_content("Jeu de contrôles exécutés #{compliance_check_set.name}")
+
+ # Information Definition List
+ expect( page.first('.dl-term') ).to have_content("Nom")
+ expect( page.first('.dl-def') ).to have_content(compliance_check_set.name)
+
+ # Filters
+ within( 'form.form-filter' ) do
+ expect( page ).to have_content("Groupe de contrôle")
+ expect( page ).to have_content("Objet")
+ expect( page ).to have_content("Criticité")
+ end
+
+ # Checks
+ # Direct Children
+ within(:xpath, xpath_for_div_of_block) do
+ direct_checks.each do | direct_check |
+ expect( page ).to have_content( direct_check.code )
+ expect( page ).to have_content( direct_check.name )
+ expect( page ).to have_content( direct_check.criticity )
+ expect( page ).to have_content( direct_check.comment )
+ end
+
+ end
+ # Indirect Children
+ compliance_check_set.compliance_check_blocks.each do | block |
+ within(:xpath, xpath_for_div_of_block(block)) do
+ block.compliance_checks.each do | check |
+ expect( page ).to have_content( check.code )
+ expect( page ).to have_content( check.name )
+ expect( page ).to have_content( check.criticity )
+ expect( page ).to have_content( check.comment )
+ end
+ end
+ end
+ end
+
+ it 'can filter the results and remove the filter' do
+ # Filter
+ check('error')
+ click_on('Filtrer')
+ all_checks.each do | check |
+ if check.criticity == 'error'
+ expect( page ).to have_content(check.code)
+ else
+ expect( page ).not_to have_content(check.code)
+ end
+ end
+
+ # Remove filter
+ click_on('Effacer')
+ all_checks.each do | check |
+ expect( page ).to have_content(check.code)
+ end
+
+ end
+ end
+
+ def make_check ccblock=nil, times: 1, severity: :warning
+ times.times.map do
+ make_one_check ccblock, severity
+ end
+ end
+
+ def make_one_check ccblock, severity
+ create( :compliance_check,
+ code: random_string,
+ compliance_check_block: ccblock,
+ compliance_check_set: compliance_check_set,
+ criticity: severity)
+ end
+
+ def xpath_for_div_of_block(block = nil)
+ %{.//div[@class="col-lg-12"]/h2[contains(text(),"#{transport_mode_text(block)}")]/../../..}
+ end
+end
diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb
index 500d4ce6f..bcb989cdc 100644
--- a/spec/features/compliance_control_sets_spec.rb
+++ b/spec/features/compliance_control_sets_spec.rb
@@ -25,7 +25,18 @@ RSpec.describe "ComplianceControlSets", type: :feature do
visit compliance_control_set_path( control_set )
end
- it 'we can see the controls inside their blocks' do
+ it 'we can see the expected content' do
+ # Breadcrumb
+ expect_breadcrumb_links "Accueil", "Liste des jeux de contrôles"
+
+ # Headline
+ expect( page ).to have_content("Consulter le jeu de contrôles #{control_set.name}")
+
+ # Information Definition List
+ expect( page.first('.dl-term') ).to have_content("Nom")
+ expect( page.first('.dl-def') ).to have_content(control_set.name)
+
+ # Children
controls.each do | control |
expect( page ).to have_content(control.code)
end
@@ -76,7 +87,8 @@ RSpec.describe "ComplianceControlSets", type: :feature do
create( :generic_attribute_control_min_max,
code: random_string,
compliance_control_block: ccblock,
- compliance_control_set: control_set)
+ compliance_control_set: control_set,
+ criticity: severity)
end
end
diff --git a/spec/models/compliance_check_block_spec.rb b/spec/models/compliance_check_block_spec.rb
index a3d98d459..0629a645d 100644
--- a/spec/models/compliance_check_block_spec.rb
+++ b/spec/models/compliance_check_block_spec.rb
@@ -1,10 +1,17 @@
-require 'rails_helper'
-
RSpec.describe ComplianceCheckBlock, type: :model do
- it 'should have a valid factory' do
- expect(FactoryGirl.build(:compliance_check_block)).to be_valid
- end
it { should belong_to :compliance_check_set }
it { should have_many :compliance_checks }
+
+ it { should allow_values(*%w{bus metro rail tram funicular}).for(:transport_mode) }
+ it { should_not allow_values(*%w{bs mtro ril tramm Funicular}).for(:transport_mode) }
+
+
+ it { should allow_values( *%w{ demandAndResponseBus nightBus airportLinkBus highFrequencyBus expressBus
+ railShuttle suburbanRailway regionalRail interregionalRail })
+ .for(:transport_submode) }
+
+ it { should_not allow_values( *%w{ demandResponseBus nightus irportLinkBus highrequencyBus expressBUs
+ Shuttle suburban regioalRail interregion4lRail })
+ .for(:transport_submode) }
end
diff --git a/spec/models/compliance_control_block_spec.rb b/spec/models/compliance_control_block_spec.rb
index c7440a5eb..4abe0ed9c 100644
--- a/spec/models/compliance_control_block_spec.rb
+++ b/spec/models/compliance_control_block_spec.rb
@@ -1,13 +1,20 @@
require 'rails_helper'
RSpec.describe ComplianceControlBlock, type: :model do
- subject { create(:compliance_control_block) }
-
- it 'should have a valid factory' do
- expect(FactoryGirl.build(:compliance_control_block)).to be_valid
- end
it { should belong_to :compliance_control_set }
it { should have_many(:compliance_controls).dependent(:destroy) }
it { should validate_presence_of(:transport_mode) }
+
+ it { should allow_values(*%w{bus metro rail tram funicular}).for(:transport_mode) }
+ it { should_not allow_values(*%w{bs mtro ril tramm Funicular}).for(:transport_mode) }
+
+
+ it { should allow_values( *%w{ demandAndResponseBus nightBus airportLinkBus highFrequencyBus expressBus
+ railShuttle suburbanRailway regionalRail interregionalRail })
+ .for(:transport_submode) }
+
+ it { should_not allow_values( *%w{ demandResponseBus nightus irportLinkBus highrequencyBus expressBUs
+ Shuttle suburban regioalRail interregion4lRail })
+ .for(:transport_submode) }
end
diff --git a/spec/models/line_referential_spec.rb b/spec/models/line_referential_spec.rb
index 8c6cb018b..8f8714f8f 100644
--- a/spec/models/line_referential_spec.rb
+++ b/spec/models/line_referential_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-RSpec.describe LineReferential, :type => :model do
+RSpec.describe LineReferential, type: :model do
it 'should have a valid factory' do
expect(FactoryGirl.build(:line_referential)).to be_valid
end
@@ -10,9 +8,4 @@ RSpec.describe LineReferential, :type => :model do
it { is_expected.to have_many(:workbenches) }
it { should validate_presence_of(:sync_interval) }
- describe "#transport_modes" do
- it 'returns a list of all transport modes' do
- expect(FactoryGirl.create(:line_referential).class.transport_modes).to match_array(StifTransportModeEnumerations.transport_modes )
- end
- end
end
diff --git a/spec/support/breadcrumb_features.rb b/spec/support/breadcrumb_features.rb
new file mode 100644
index 000000000..36bfce19c
--- /dev/null
+++ b/spec/support/breadcrumb_features.rb
@@ -0,0 +1,15 @@
+module BreadcrumbFeatures
+ def expect_breadcrumb_links *link_names
+ within('.breadcrumbs') do
+ all('a').zip( link_names ).each do | link_element, link_content |
+ within(link_element) do | |
+ expect(page).to have_content(link_content)
+ end
+ end
+ end
+ end
+end
+
+RSpec.configure do | conf |
+ conf.include BreadcrumbFeatures, type: :feature
+end