aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/compliance_check_sets_controller.rb30
-rw-r--r--app/controllers/compliance_control_sets_controller.rb25
-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.rb12
-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/organisation.rb1
-rw-r--r--app/views/compliance_check_sets/show.html.slim54
-rw-r--r--app/views/compliance_checks/_filters.html.slim47
-rw-r--r--app/views/compliance_control_sets/show.html.slim17
-rw-r--r--app/views/compliance_controls/_filters.html.slim3
-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.yml30
-rw-r--r--config/locales/compliance_check_sets.fr.yml30
-rw-r--r--config/locales/compliance_checks.en.yml8
-rw-r--r--config/locales/compliance_checks.fr.yml11
-rw-r--r--db/schema.rb75
-rw-r--r--spec/features/compliance_ckeck_sets_spec.rb78
-rw-r--r--spec/features/compliance_control_sets_spec.rb16
-rw-r--r--spec/models/compliance_check_block_spec.rb5
-rw-r--r--spec/models/compliance_control_block_spec.rb19
-rw-r--r--spec/support/breadcrumb_features.rb15
25 files changed, 456 insertions, 72 deletions
diff --git a/app/controllers/compliance_check_sets_controller.rb b/app/controllers/compliance_check_sets_controller.rb
index 95dcfbf05..56d1b9f1f 100644
--- a/app/controllers/compliance_check_sets_controller.rb
+++ b/app/controllers/compliance_check_sets_controller.rb
@@ -18,4 +18,34 @@ class ComplianceCheckSetsController < InheritedResources::Base
}
end
end
+
+ def show
+ show!(&method(:implement_show))
+ end
+
+
+ private
+
+ # Action Implementation
+ # ---------------------
+ def implement_show format
+ format.html(&method(:implement_show_for_html))
+ end
+
+ def implement_show_for_html _mime_response
+ @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
+ end
+
+ # Decoration
+ # ----------
+ def decorate_compliance_checks(compliance_checks)
+ ModelDecorator.decorate(
+ compliance_checks,
+ with: ComplianceCheckDecorator)
+ end
end
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index 5c78d09e3..65aa1e81f 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -16,18 +16,10 @@ class ComplianceControlSetsController < InheritedResources::Base
end
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
- }
- end
+ show!(&method(:implement_show))
end
+
def clone
ComplianceControlSetCloner.new.copy(params[:id], current_organisation.id)
flash[:notice] = I18n.t("compliance_control_sets.errors.operation_in_progress")
@@ -59,4 +51,17 @@ class ComplianceControlSetsController < InheritedResources::Base
def compliance_control_set_params
params.require(:compliance_control_set).permit(:name, :id)
end
+
+ def implement_show format
+ format.html(&method(:implement_show_for_html))
+ end
+
+ def implement_show_for_html _mime_response
+ @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
+ end
end
diff --git a/app/decorators/compliance_check_decorator.rb b/app/decorators/compliance_check_decorator.rb
new file mode 100644
index 000000000..09984aa2e
--- /dev/null
+++ b/app/decorators/compliance_check_decorator.rb
@@ -0,0 +1,8 @@
+class ComplianceCheckDecorator < Draper::Decorator
+ delegate_all
+
+ def action_links
+ 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..349ecae87
--- /dev/null
+++ b/app/helpers/compliance_check_sets_helper.rb
@@ -0,0 +1,12 @@
+module ComplianceCheckSetsHelper
+ def compliance_check_set_path(compliance_check_set)
+ 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..b61057205
--- /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?
+ "[#{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..eb4654756 100644
--- a/app/models/compliance_check_block.rb
+++ b/app/models/compliance_check_block.rb
@@ -1,5 +1,13 @@
class ComplianceCheckBlock < ActiveRecord::Base
+ extend StifTransportModeEnumerations
+ extend 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/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/show.html.slim b/app/views/compliance_check_sets/show.html.slim
index eefa5363f..4052707da 100644
--- a/app/views/compliance_check_sets/show.html.slim
+++ b/app/views/compliance_check_sets/show.html.slim
@@ -1,12 +1,60 @@
- breadcrumb :compliance_check_set, @workbench, @compliance_check_set
/ PageHeader
= pageheader 'jeux-de-donnees',
- @compliance_check_set.referential.name
+ t('compliance_check_sets.show.title', name: @compliance_check_set.name),
+ 'Lorem ipsum dolor sit amet'
/ 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
+ ComplianceCheckSet.human_attribute_name(:name) => @compliance_check_set.name
+
+ - if params[:q].present? || @compliance_checks.any? || @direct_compliance_checks
+ .row
+ .col-lg-12
+ h2
+ = render '/compliance_checks/filters'
+
+ - if @direct_compliance_checks.try(:any?)
+ .row
+ .col-lg-12
+ h2
+ = transport_mode_text()
+ .row
+ .col-lg-12
+ .select_table
+ = 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
+
+ - @compliance_checks.each do |block, compliance_checks|
+
+ - if compliance_checks.try(:any?)
+ .row
+ .col-lg-12
+ h2
+ = transport_mode_text(block)
diff --git a/app/views/compliance_checks/_filters.html.slim b/app/views/compliance_checks/_filters.html.slim
new file mode 100644
index 000000000..189e3d787
--- /dev/null
+++ b/app/views/compliance_checks/_filters.html.slim
@@ -0,0 +1,47 @@
+/ Compliance Check Filter
+= search_form_for @q_checks_form,
+ url: 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'), @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..12be42ea6 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -25,21 +25,22 @@
= 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? || @compliance_controls.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 @indirect_compliance_controls,
+ = table_builder_2 @direct_compliance_controls,
[ \
TableBuilderHelper::Column.new( \
key: :code, \
@@ -71,7 +72,7 @@
.row
.col-lg-12
h2
- = transport_mode(block.transport_mode, block.transport_submode)
+ = transport_mode_text(block)
.btn-group
.btn.dropdown-toggle{ data-toggle="dropdown" }
.span.fa.fa-cog
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/config/locales/compliance_check_blocks.en.yml b/config/locales/compliance_check_blocks.en.yml
new file mode 100644
index 000000000..9278823dc
--- /dev/null
+++ b/config/locales/compliance_check_blocks.en.yml
@@ -0,0 +1,8 @@
+en:
+ activerecord:
+ models:
+ compliance_check_block:
+ zero: "Control report groups"
+ one: "Control report group"
+ many: "Control report groups"
+
diff --git a/config/locales/compliance_check_blocks.fr.yml b/config/locales/compliance_check_blocks.fr.yml
new file mode 100644
index 000000000..2ead24b2f
--- /dev/null
+++ b/config/locales/compliance_check_blocks.fr.yml
@@ -0,0 +1,7 @@
+fr:
+ activerecord:
+ models:
+ compliance_check_block:
+ zero: "Groupe de rapport de contrôle"
+ one: "Groupe de rapport de contrôle"
+ many: "Groupes de rapport de contrôle"
diff --git a/config/locales/compliance_check_sets.en.yml b/config/locales/compliance_check_sets.en.yml
index 89c142a49..0088cc6cc 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,24 @@ en:
filters:
name: Specify a control report name...
error_period_filter: End date must be greater than or equal to begin date
+ index:
+ title: Control reports
+ new: Creating a Control Report
+ edit: Update a Control Report
search_no_results: No control reports match your search
+ show:
+ title: 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: réf
+ creation_date: Created at
+ associated_object: Associated object
+ assigned_to: Assigned to
+ compliance_control_set: Compliance control set
+ name: Name
+ models:
+ compliance_check_block:
+ zero: "Control report groups"
+ one: "Control report group"
+ many: "Control report groups"
diff --git a/config/locales/compliance_check_sets.fr.yml b/config/locales/compliance_check_sets.fr.yml
index 8c21f33fd..edf16d460 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,24 @@ 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: Rapports de contrôle
+ new: Création d'un rapport de contrôle
+ edit: Édition d'un rapport de contrôle
search_no_results: Aucun rapport de contrôle ne correspond à votre recherche
+ show:
+ title: Rapport de contrôle %{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 rapport de contrôle"
+ one: "Groupe de rapport de contrôle"
+ many: "Groupes de rapport de contrôle"
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..009c0a7e2 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: Objét
+ criticity: Criticité
+ name: Nom
diff --git a/db/schema.rb b/db/schema.rb
index af6a51f7a..735e3405b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -284,6 +284,22 @@ ActiveRecord::Schema.define(version: 20171114102438) do
add_index "connection_links", ["objectid"], name: "connection_links_objectid_key", unique: true, using: :btree
+ create_table "delayed_jobs", id: :bigserial, force: :cascade do |t|
+ t.integer "priority", default: 0
+ t.integer "attempts", default: 0
+ t.text "handler"
+ t.text "last_error"
+ t.datetime "run_at"
+ t.datetime "locked_at"
+ t.datetime "failed_at"
+ t.string "locked_by", limit: 255
+ t.string "queue", limit: 255
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
+
create_table "exports", id: :bigserial, force: :cascade do |t|
t.integer "referential_id", limit: 8
t.string "status"
@@ -405,12 +421,12 @@ ActiveRecord::Schema.define(version: 20171114102438) do
t.datetime "started_at"
t.datetime "ended_at"
t.string "token_download"
- t.string "type"
+ t.string "type", limit: 255
t.integer "parent_id", limit: 8
t.string "parent_type"
+ t.integer "current_step", default: 0
+ t.integer "total_steps", default: 0
t.datetime "notified_parent_at"
- t.integer "current_step", default: 0
- t.integer "total_steps", default: 0
t.string "creator"
end
@@ -431,6 +447,18 @@ ActiveRecord::Schema.define(version: 20171114102438) do
add_index "journey_frequencies", ["timeband_id"], name: "index_journey_frequencies_on_timeband_id", using: :btree
add_index "journey_frequencies", ["vehicle_journey_id"], name: "index_journey_frequencies_on_vehicle_journey_id", using: :btree
+ create_table "journey_pattern_sections", id: :bigserial, force: :cascade do |t|
+ t.integer "journey_pattern_id", limit: 8, null: false
+ t.integer "route_section_id", limit: 8, null: false
+ t.integer "rank", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "journey_pattern_sections", ["journey_pattern_id", "route_section_id", "rank"], name: "index_jps_on_journey_pattern_id_and_route_section_id_and_rank", unique: true, using: :btree
+ add_index "journey_pattern_sections", ["journey_pattern_id"], name: "index_journey_pattern_sections_on_journey_pattern_id", using: :btree
+ add_index "journey_pattern_sections", ["route_section_id"], name: "index_journey_pattern_sections_on_route_section_id", using: :btree
+
create_table "journey_patterns", id: :bigserial, force: :cascade do |t|
t.integer "route_id", limit: 8
t.string "objectid", null: false
@@ -550,6 +578,11 @@ ActiveRecord::Schema.define(version: 20171114102438) do
add_index "networks", ["objectid"], name: "networks_objectid_key", unique: true, using: :btree
add_index "networks", ["registration_number"], name: "networks_registration_number_key", using: :btree
+ create_table "object_id_factories", id: :bigserial, force: :cascade do |t|
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "organisations", id: :bigserial, force: :cascade do |t|
t.string "name"
t.datetime "created_at"
@@ -640,6 +673,20 @@ ActiveRecord::Schema.define(version: 20171114102438) do
add_index "referentials", ["created_from_id"], name: "index_referentials_on_created_from_id", using: :btree
add_index "referentials", ["referential_suite_id"], name: "index_referentials_on_referential_suite_id", using: :btree
+ create_table "route_sections", id: :bigserial, force: :cascade do |t|
+ t.integer "departure_id", limit: 8
+ t.integer "arrival_id", limit: 8
+ t.geometry "input_geometry", limit: {:srid=>4326, :type=>"line_string"}
+ t.geometry "processed_geometry", limit: {:srid=>4326, :type=>"line_string"}
+ t.string "objectid", null: false
+ t.integer "object_version", limit: 8
+ t.string "creator_id"
+ t.float "distance"
+ t.boolean "no_processing"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "routes", id: :bigserial, force: :cascade do |t|
t.integer "line_id", limit: 8
t.string "objectid", null: false
@@ -716,7 +763,7 @@ ActiveRecord::Schema.define(version: 20171114102438) do
create_table "stop_areas", id: :bigserial, force: :cascade do |t|
t.integer "parent_id", limit: 8
- t.string "objectid", null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
t.string "creator_id"
t.string "name"
@@ -725,8 +772,8 @@ ActiveRecord::Schema.define(version: 20171114102438) do
t.string "registration_number"
t.string "nearest_topic_name"
t.integer "fare_code"
- t.decimal "longitude", precision: 19, scale: 16
- t.decimal "latitude", precision: 19, scale: 16
+ t.decimal "longitude", precision: 19, scale: 16
+ t.decimal "latitude", precision: 19, scale: 16
t.string "long_lat_type"
t.string "country_code"
t.string "street_name"
@@ -744,7 +791,7 @@ ActiveRecord::Schema.define(version: 20171114102438) do
t.datetime "deleted_at"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "stif_type"
+ t.string "stif_type", limit: 255
end
add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree
@@ -815,12 +862,12 @@ ActiveRecord::Schema.define(version: 20171114102438) do
add_index "time_table_periods", ["time_table_id"], name: "index_time_table_periods_on_time_table_id", using: :btree
create_table "time_tables", id: :bigserial, force: :cascade do |t|
- t.string "objectid", null: false
- t.integer "object_version", limit: 8, default: 1
+ t.string "objectid", null: false
+ t.integer "object_version", limit: 8, default: 1
t.string "creator_id"
t.string "version"
t.string "comment"
- t.integer "int_day_types", default: 0
+ t.integer "int_day_types", default: 0
t.date "start_date"
t.date "end_date"
t.integer "calendar_id", limit: 8
@@ -973,14 +1020,22 @@ ActiveRecord::Schema.define(version: 20171114102438) do
add_foreign_key "compliance_controls", "compliance_control_blocks"
add_foreign_key "compliance_controls", "compliance_control_sets"
add_foreign_key "group_of_lines_lines", "group_of_lines", name: "groupofline_group_fkey", on_delete: :cascade
+ add_foreign_key "journey_frequencies", "timebands", name: "journey_frequencies_timeband_id_fk", on_delete: :nullify
add_foreign_key "journey_frequencies", "timebands", on_delete: :nullify
+ add_foreign_key "journey_frequencies", "vehicle_journeys", name: "journey_frequencies_vehicle_journey_id_fk", on_delete: :nullify
add_foreign_key "journey_frequencies", "vehicle_journeys", on_delete: :nullify
+ add_foreign_key "journey_pattern_sections", "journey_patterns", name: "journey_pattern_sections_journey_pattern_id_fk", on_delete: :cascade
+ add_foreign_key "journey_pattern_sections", "journey_patterns", on_delete: :cascade
+ add_foreign_key "journey_pattern_sections", "route_sections", name: "journey_pattern_sections_route_section_id_fk", on_delete: :cascade
+ add_foreign_key "journey_pattern_sections", "route_sections", on_delete: :cascade
add_foreign_key "journey_patterns", "routes", name: "jp_route_fkey", on_delete: :cascade
add_foreign_key "journey_patterns", "stop_points", column: "arrival_stop_point_id", name: "arrival_point_fkey", on_delete: :nullify
add_foreign_key "journey_patterns", "stop_points", column: "departure_stop_point_id", name: "departure_point_fkey", on_delete: :nullify
add_foreign_key "journey_patterns_stop_points", "journey_patterns", name: "jpsp_jp_fkey", on_delete: :cascade
add_foreign_key "journey_patterns_stop_points", "stop_points", name: "jpsp_stoppoint_fkey", on_delete: :cascade
add_foreign_key "referentials", "referential_suites"
+ add_foreign_key "route_sections", "stop_areas", column: "arrival_id"
+ add_foreign_key "route_sections", "stop_areas", column: "departure_id"
add_foreign_key "routes", "routes", column: "opposite_route_id", name: "route_opposite_route_fkey"
add_foreign_key "stop_areas", "stop_areas", column: "parent_id", name: "area_parent_fkey", on_delete: :nullify
add_foreign_key "stop_areas_stop_areas", "stop_areas", column: "child_id", name: "stoparea_child_fkey", on_delete: :cascade
diff --git a/spec/features/compliance_ckeck_sets_spec.rb b/spec/features/compliance_ckeck_sets_spec.rb
index a4a6b2fda..17902ed3f 100644
--- a/spec/features/compliance_ckeck_sets_spec.rb
+++ b/spec/features/compliance_ckeck_sets_spec.rb
@@ -1,14 +1,86 @@
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 }
+ let( :compliance_check_set ){ create :compliance_check_set, name: random_string }
+ let(:blox){
+ 2.times.map{ | _ | create :compliance_check_block, compliance_check_set: compliance_check_set }
+ }
+ let!(:direct_checks){ make_check(nil, times: 2) + make_check(nil, severity: :error) }
+ let!(:indirect_checks){ blox.map{ |block| make_check(block) } }
context 'show' do
- it 'can visit the page' do
- visit(workbench_compliance_check_set_path(compliance_check_set.workbench, compliance_check_set))
+
+ before do
+ blox.first.update transport_mode: 'bus', transport_submode: 'demandAndResponseBus'
+ blox.second.update transport_mode: 'train', transport_submode: 'suburbanRailway'
+ visit(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", " Rapports de contrôle"
+
+ # Headline
+ expect( page ).to have_content("Rapport de contrôle #{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 rapport de contrôle")
+ expect( page ).to have_content("Objét")
+ 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.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
+ end
+
+ def make_check ccblock=nil, times: 1, severity: :error
+ 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..845056fac 100644
--- a/spec/models/compliance_check_block_spec.rb
+++ b/spec/models/compliance_check_block_spec.rb
@@ -1,9 +1,4 @@
-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 }
diff --git a/spec/models/compliance_control_block_spec.rb b/spec/models/compliance_control_block_spec.rb
index c7440a5eb..6566baac0 100644
--- a/spec/models/compliance_control_block_spec.rb
+++ b/spec/models/compliance_control_block_spec.rb
@@ -1,13 +1,18 @@
-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) }
+
+ xit { should allow_values(*%w{bus metro rail tram funicular}).for(:transport_mode) }
+ xit { should_not allow_values(*%w{bs mtro ril tramm Funicular}).for(:transport_mode) }
+
+
+ xit { should allow_values( *%w{ demandAndResponseBus nightBus airportLinkBus highFrequencyBus expressBus
+ railShuttle suburbanRailway regionalRail interregionalRail })
+ .for(:transport_submode) }
+
+ xit { should_not allow_values( *%w{ demandResponseBus nightus irportLinkBus highrequencyBus expressBUs
+ Shuttle suburban regioalRail interregion4lRail })
+ .for(:transport_submode) }
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