aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraf832017-07-04 17:42:10 +0200
committeraf832017-07-04 17:42:10 +0200
commitebd292c7a6abaab5aeb90b37e34e21253184979f (patch)
tree64d4a24ace793a6f9c4a0760c9cb478ff25be111
parent3b03d3a554731b3afb71ae18ee8a8d03a0ff7a77 (diff)
parenta4b4c84ea5a1ed8ec7b77c1aebd2ff8252897f63 (diff)
downloadchouette-core-ebd292c7a6abaab5aeb90b37e34e21253184979f.tar.bz2
Change typo to RCZ translation
-rw-r--r--app/controllers/autocomplete_calendars_controller.rb3
-rw-r--r--app/controllers/workbenches_controller.rb24
-rw-r--r--app/helpers/newapplication_helper.rb2
-rw-r--r--app/views/lines/index.html.slim2
-rw-r--r--app/views/referential_companies/index.html.slim4
-rw-r--r--app/views/referential_companies/show.html.slim2
-rw-r--r--app/views/referential_lines/_filters.html.slim2
-rw-r--r--app/views/referential_lines/show.html.slim4
-rw-r--r--app/views/referential_networks/index.html.slim4
-rw-r--r--app/views/referential_networks/show.html.slim2
-rw-r--r--app/views/referentials/show.html.slim2
-rw-r--r--app/views/routes/show.html.slim4
-rw-r--r--app/views/routing_constraint_zones/_filters.html.slim2
-rw-r--r--app/views/routing_constraint_zones/index.html.slim2
-rw-r--r--app/views/stop_areas/index.html.slim3
-rw-r--r--app/views/stop_areas/show.html.slim2
-rw-r--r--app/views/time_tables/index.html.slim2
-rw-r--r--app/views/workbenches/show.html.slim3
-rw-r--r--config/locales/actions.en.yml1
-rw-r--r--config/locales/actions.fr.yml5
-rw-r--r--config/locales/companies.en.yml2
-rw-r--r--config/locales/companies.fr.yml2
-rw-r--r--config/locales/en.yml4
-rw-r--r--config/locales/fr.yml3
-rw-r--r--config/locales/networks.en.yml2
-rw-r--r--config/locales/networks.fr.yml2
-rw-r--r--config/locales/stop_areas.fr.yml2
-rw-r--r--spec/features/workbenches_permissions_spec.rb8
-rw-r--r--spec/features/workbenches_spec.rb53
29 files changed, 112 insertions, 41 deletions
diff --git a/app/controllers/autocomplete_calendars_controller.rb b/app/controllers/autocomplete_calendars_controller.rb
index 2b85fcff3..533b5503a 100644
--- a/app/controllers/autocomplete_calendars_controller.rb
+++ b/app/controllers/autocomplete_calendars_controller.rb
@@ -2,6 +2,7 @@ class AutocompleteCalendarsController < ApplicationController
respond_to :json, :only => [:autocomplete]
def autocomplete
- @calendars = current_organisation.calendars.search(params[:q]).result.paginate(page: params[:page])
+ scope = Calendar.where('organisation_id = ? OR shared = true', current_organisation.id)
+ @calendars = scope.search(params[:q]).result.paginate(page: params[:page])
end
end
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb
index 30b98eec0..22a71863a 100644
--- a/app/controllers/workbenches_controller.rb
+++ b/app/controllers/workbenches_controller.rb
@@ -7,7 +7,7 @@ class WorkbenchesController < BreadcrumbController
def show
scope = resource.all_referentials
scope = ransack_associated_lines(scope)
- scope = ransack_periode(scope)
+ scope = ransack_period(scope)
scope = ransack_status(scope)
@q_for_form = scope.ransack(params[:q])
@@ -60,13 +60,21 @@ class WorkbenchesController < BreadcrumbController
end
# Fake ransack filter
- def ransack_periode scope
- return scope unless params[:q] && params[:q]['validity_period']
- periode = params[:q]['validity_period']
- return scope if periode['end_lteq(1i)'].blank? || periode['begin_gteq(1i)'].blank?
-
- begin_range = Date.civil(periode["begin_gteq(1i)"].to_i, periode["begin_gteq(2i)"].to_i, periode["begin_gteq(3i)"].to_i)
- end_range = Date.civil(periode["end_lteq(1i)"].to_i, periode["end_lteq(2i)"].to_i, periode["end_lteq(3i)"].to_i)
+ def ransack_period scope
+ period = params[:q]['validity_period']
+ return scope unless period
+
+ begin
+ if period['begin_gteq'].kind_of?(Array)
+ begin_range = Date.new(*period['begin_gteq'].map(&:to_i))
+ end_range = Date.new(*period['end_lteq'].map(&:to_i))
+ else
+ begin_range = Date.new(period["begin_gteq(1i)"].to_i, period["begin_gteq(2i)"].to_i, period["begin_gteq(3i)"].to_i)
+ end_range = Date.new(period["end_lteq(1i)"].to_i, period["end_lteq(2i)"].to_i, period["end_lteq(3i)"].to_i)
+ end
+ rescue Exception => e
+ return scope
+ end
if begin_range > end_range
flash.now[:error] = t('referentials.errors.validity_period')
diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb
index 3d43e9fc7..edcad76c3 100644
--- a/app/helpers/newapplication_helper.rb
+++ b/app/helpers/newapplication_helper.rb
@@ -16,7 +16,7 @@ module NewapplicationHelper
end
columns.map do |k, v|
- if ["ID Codif", "Oid", "OiD", "ID Reflex", "Arrêt de départ", "Arrêt d'arrivée", "Période de validité englobante", "Période englobante", "Nombre de courses associées", "Journées d'application", "Arrêts de l'itinéraire", "Arrêts inclus dans l'ITL"].include? k
+ if ["ID Codifligne", "Oid", "OiD", "ID", "ID Reflex", "Arrêt de départ", "Arrêt d'arrivée", "Période de validité englobante", "Période englobante", "Nombre de courses associées", "Journées d'application", "Arrêts de l'itinéraire", "Arrêts inclus dans l'ITL"].include? k
hcont << content_tag(:th, k)
else
hcont << content_tag(:th, sortable_columns(collection, k))
diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim
index d7b6be5c8..d3ee46b8a 100644
--- a/app/views/lines/index.html.slim
+++ b/app/views/lines/index.html.slim
@@ -17,7 +17,7 @@
.row
.col-lg-12
= table_builder @lines,
- { 'Oid' => Proc.new { |n| n.objectid.local_id },
+ { 'ID Codifligne' => Proc.new { |n| n.objectid.local_id },
:number => 'number',
:name => 'name',
:deactivated => Proc.new{|n| n.deactivated? ? t('false') : t('true')},
diff --git a/app/views/referential_companies/index.html.slim b/app/views/referential_companies/index.html.slim
index 7a033fb5f..85d1d416d 100644
--- a/app/views/referential_companies/index.html.slim
+++ b/app/views/referential_companies/index.html.slim
@@ -1,7 +1,7 @@
/ PageHeader
= pageheader 'map-marker',
t('companies.index.title'),
- 'Lorem ipsum dolor sit amet',
+ '',
'',
(policy(Chouette::Company).create? ? link_to(t('companies.actions.new'), new_referential_company_path(@referential), class: 'btn btn-default') : '')
@@ -23,7 +23,7 @@
.row
.col-lg-12
= table_builder @companies,
- { 'ID Codif' => Proc.new { |n| n.try(:objectid).try(:local_id) },
+ { 'ID Codifligne' => Proc.new { |n| n.try(:objectid).try(:local_id) },
:name => 'name', :phone => 'phone', :email => 'email', :url => 'url' },
[:show, :edit, :delete],
[],
diff --git a/app/views/referential_companies/show.html.slim b/app/views/referential_companies/show.html.slim
index ae89c1444..177ce2d69 100644
--- a/app/views/referential_companies/show.html.slim
+++ b/app/views/referential_companies/show.html.slim
@@ -22,7 +22,7 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- { 'ID Codif' => @company.try(:objectid).try(:local_id),
+ { t('id_codif') => @company.try(:objectid).try(:local_id),
Chouette::Company.human_attribute_name(:phone) => @company.phone,
Chouette::Company.human_attribute_name(:email) => @company.email,
Chouette::Company.human_attribute_name(:url) => @company.url }
diff --git a/app/views/referential_lines/_filters.html.slim b/app/views/referential_lines/_filters.html.slim
index 93d449507..379d6234f 100644
--- a/app/views/referential_lines/_filters.html.slim
+++ b/app/views/referential_lines/_filters.html.slim
@@ -1,7 +1,7 @@
= search_form_for @q, url: referential_line_path(@referential, @line), class: 'form form-filter' do |f|
.ffg-row
.input-group.search_bar
- = f.search_field :name_or_objectid_cont, class: 'form-control', placeholder: "Indiquez un nom d'itinéraire ou un OiD..."
+ = f.search_field :name_or_objectid_cont, class: 'form-control', placeholder: "Indiquez un nom d'itinéraire ou un ID..."
span.input-group-btn
button.btn.btn-default#search-btn type='submit'
span.fa.fa-search
diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim
index db99381d3..0bb6d9032 100644
--- a/app/views/referential_lines/show.html.slim
+++ b/app/views/referential_lines/show.html.slim
@@ -29,7 +29,7 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- { 'ID Codif' => @line.objectid.local_id,
+ { t('id_codif') => @line.objectid.local_id,
'Activé' => (@line.deactivated? ? t('false') : t('true')),
@line.human_attribute_name(:network) => (@line.network.nil? ? t('lines.index.unset') : link_to(@line.network.name, [@referential, @line.network]) ),
@line.human_attribute_name(:company) => (@line.company.nil? ? t('lines.index.unset') : link_to(@line.company.name, [@referential, @line.company]) ),
@@ -52,7 +52,7 @@
.row
.col-lg-12
= table_builder @routes,
- { 'OiD' => Proc.new { |n| n.objectid.local_id },
+ { 'ID' => Proc.new { |n| n.objectid.local_id },
:name => 'name',
:published_name => 'published_name',
:wayback => 'wayback_text',
diff --git a/app/views/referential_networks/index.html.slim b/app/views/referential_networks/index.html.slim
index 38ffb836a..d6c52d352 100644
--- a/app/views/referential_networks/index.html.slim
+++ b/app/views/referential_networks/index.html.slim
@@ -23,11 +23,11 @@
.row
.col-lg-12
= table_builder @networks,
- { 'ID Codif' => Proc.new { |n| n.try(:objectid).try(:local_id) }, :name => 'name' },
+ { 'ID Codifligne' => Proc.new { |n| n.try(:objectid).try(:local_id) }, :name => 'name' },
[:show, :edit, :delete],
[],
'table has-search'
-
+
= new_pagination @networks, 'pull-right'
- unless @networks.any?
diff --git a/app/views/referential_networks/show.html.slim b/app/views/referential_networks/show.html.slim
index 3a195b342..59bdd0dee 100644
--- a/app/views/referential_networks/show.html.slim
+++ b/app/views/referential_networks/show.html.slim
@@ -22,4 +22,4 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- { 'ID Codif' => @network.try(:objectid).try(:local_id) }
+ { t('id_codif') => @network.try(:objectid).try(:local_id) }
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index 8308cf770..81cd0ebfd 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -39,7 +39,7 @@
.col-lg-12
/ ID Codif, nom court, nom de la ligne, réseau, mode, transporteur principal, actions = [show, edit_notes]
= table_builder @reflines,
- { 'ID Codif' => Proc.new { |n| n.objectid.local_id },
+ { 'ID Codifligne' => Proc.new { |n| n.objectid.local_id },
:number => 'number',
:name => 'name',
:deactivated => Proc.new{ |n| n.deactivated? ? t('false') : t('true') },
diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim
index 92a5080ae..eee19d85a 100644
--- a/app/views/routes/show.html.slim
+++ b/app/views/routes/show.html.slim
@@ -1,7 +1,7 @@
/ PageHeader
= pageheader 'map-marker',
@route.name,
- 'Lorem ipsum dolor sit amet',
+ '',
t('last_update', time: l(@route.updated_at, format: :short)),
(policy(@route).edit? ? link_to(t('actions.edit'), edit_referential_line_route_path(@referential, @line, @route), class: 'btn btn-default') : '') do
@@ -21,7 +21,7 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- { 'OiD' => @route.try(:objectid).try(:local_id),
+ { t('id_codif') => @route.try(:objectid).try(:local_id),
t('activerecord.attributes.route.published_name') => (@route.published_name ? @route.published_name : '-'),
@route.human_attribute_name(:wayback) => (@route.wayback ? @route.wayback_text : '-' ),
@route.human_attribute_name(:opposite_route) => (@route.opposite_route ? @route.opposite_route.name : '-') }
diff --git a/app/views/routing_constraint_zones/_filters.html.slim b/app/views/routing_constraint_zones/_filters.html.slim
index 07d351b1f..433dde4ab 100644
--- a/app/views/routing_constraint_zones/_filters.html.slim
+++ b/app/views/routing_constraint_zones/_filters.html.slim
@@ -1,7 +1,7 @@
= search_form_for @q, url: referential_line_routing_constraint_zones_path(@referential, @line), class: 'form form-filter' do |f|
.ffg-row
.input-group.search_bar
- = f.search_field :name_or_objectid_cont, class: 'form-control', placeholder: "Indiquez un nom d'ITL ou un OiD..."
+ = f.search_field :name_or_objectid_cont, class: 'form-control', placeholder: "Indiquez un nom d'ITL ou un ID..."
span.input-group-btn
button.btn.btn-default#search-btn type='submit'
span.fa.fa-search
diff --git a/app/views/routing_constraint_zones/index.html.slim b/app/views/routing_constraint_zones/index.html.slim
index 248efedb4..596ea9e91 100644
--- a/app/views/routing_constraint_zones/index.html.slim
+++ b/app/views/routing_constraint_zones/index.html.slim
@@ -17,7 +17,7 @@
.row
.col-lg-12
= table_builder @routing_constraint_zones,
- { 'Oid' => Proc.new { |n| n.try(:objectid).try(:local_id) },
+ { 'ID' => Proc.new { |n| n.try(:objectid).try(:local_id) },
:name => 'name', :stop_points_count => 'stop_points_count',
:route => 'route_name' },
[:show, :edit, :delete],
diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim
index 27c9372ac..338e7e878 100644
--- a/app/views/stop_areas/index.html.slim
+++ b/app/views/stop_areas/index.html.slim
@@ -1,7 +1,7 @@
/ PageHeader
= pageheader 'map-marker',
t('stop_areas.index.title'),
- 'Lorem ipsum dolor sit amet',
+ '',
'',
(policy(Chouette::StopArea).create? ? link_to(t('stop_areas.actions.new'), new_stop_area_referential_stop_area_path(@stop_area_referential), class: 'btn btn-primary') : '')
@@ -16,7 +16,6 @@
- if @stop_areas.any?
.row
.col-lg-12
- p = t('activerecord.attributes.stop_point.deleted_at')
= table_builder @stop_areas,
{ 'ID Reflex' => Proc.new { |n| n.try(:user_objectid) }, :name => 'name', :registration_number => 'registration_number', :deleted_at => Proc.new{|s| s.deleted_at ? t('false') : t('true')},
:zip_code => 'zip_code', :city_name => 'city_name', :area_type => Proc.new{|s| (s.area_type.nil? ? '-' : t("enumerize.stop_area.area_type.#{s.try(:area_type)}"))} },
diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim
index bdf7b61a5..0427554ef 100644
--- a/app/views/stop_areas/show.html.slim
+++ b/app/views/stop_areas/show.html.slim
@@ -22,7 +22,7 @@
= definition_list t('metadatas'),
{ @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"),
@stop_area.human_attribute_name(:registration_number) => @stop_area.registration_number,
- 'Code Reflex' => @stop_area.user_objectid,
+ t('id_reflex') => @stop_area.user_objectid,
'Coordonnées' => geo_data(@stop_area, @stop_area_referential),
@stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code,
@stop_area.human_attribute_name(:city_name) => @stop_area.city_name,
diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim
index 402b09b98..a0b9e4380 100644
--- a/app/views/time_tables/index.html.slim
+++ b/app/views/time_tables/index.html.slim
@@ -15,7 +15,7 @@
.row
.col-lg-12
= table_builder @time_tables,
- { 'OiD' => Proc.new { |n| n.objectid.local_id }, :color => Proc.new{|tt| tt.color ? content_tag(:span, '', class: 'fa fa-circle', style: "color:#{tt.color}") : '-' }, :comment => 'comment',
+ { 'ID' => Proc.new { |n| n.objectid.local_id }, :color => Proc.new{|tt| tt.color ? content_tag(:span, '', class: 'fa fa-circle', style: "color:#{tt.color}") : '-' }, :comment => 'comment',
"Période englobante" => Proc.new{ |tt| tt.bounding_dates.empty? ? '-' : t('bounding_dates', debut: l(tt.bounding_dates.min), end: l(tt.bounding_dates.max)) },
"Nombre de courses associées" => Proc.new{ |tt| tt.vehicle_journeys.count },
"Journées d'application" => Proc.new{ |tt| (%w(monday tuesday wednesday thursday friday saturday sunday).collect{|d| tt.send(d) ? t("calendars.days.#{d}") : '' }).reject{|a| a.empty?}.join(', ').html_safe },
diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim
index 37c396b46..bb8b71ab2 100644
--- a/app/views/workbenches/show.html.slim
+++ b/app/views/workbenches/show.html.slim
@@ -7,7 +7,7 @@
/ Below is secundary actions & optional contents (filters, ...)
.row.mb-sm
.col-lg-12.text-right
- = link_to Import.model_name.human.pluralize.capitalize, workbench_imports_path(@workbench), class: 'btn btn-primary'
+ = link_to t('actions.import'), workbench_imports_path(@workbench), class: 'btn btn-primary'
- if policy(Referential).create?
= link_to t('actions.add'), new_referential_path(workbench_id: @workbench), class: 'btn btn-primary'
@@ -43,6 +43,7 @@
), \
TableBuilderHelper::Column.new( \
key: :lines, \
+ name: 'Nb lignes', \
attribute: Proc.new {|w| w.lines.count} \
), \
TableBuilderHelper::Column.new( \
diff --git a/config/locales/actions.en.yml b/config/locales/actions.en.yml
index fe4d3d4e5..cffd04fcf 100644
--- a/config/locales/actions.en.yml
+++ b/config/locales/actions.en.yml
@@ -15,6 +15,7 @@ en:
sync: 'Synchronize'
combine: 'Combine'
actualize: 'Actualize'
+ import: 'Import'
or: "or"
cancel: "Cancel"
search_hint: "Type in a search term"
diff --git a/config/locales/actions.fr.yml b/config/locales/actions.fr.yml
index ae0537ebb..86e72088a 100644
--- a/config/locales/actions.fr.yml
+++ b/config/locales/actions.fr.yml
@@ -5,8 +5,8 @@ fr:
delete: 'Supprimer'
search: "Chercher"
submit: "Valider"
- add: 'Ajouter'
- new: 'Ajouter'
+ add: 'Créer'
+ new: 'Créer'
show: 'Consulter'
archive: 'Conserver'
unarchive: 'Déconserver'
@@ -16,6 +16,7 @@ fr:
sync: 'Synchroniser'
combine: 'Combiner'
actualize: 'Actualiser'
+ import: 'Importer'
or: "ou"
cancel: "Annuler"
search_hint: "Entrez un texte à rechercher"
diff --git a/config/locales/companies.en.yml b/config/locales/companies.en.yml
index ac11a896a..301f4d68d 100644
--- a/config/locales/companies.en.yml
+++ b/config/locales/companies.en.yml
@@ -15,7 +15,7 @@ en:
index:
title: "Companies"
name: "Search by name..."
- name_or_objectid: "Search by name or by objectid..."
+ name_or_objectid: "Search by name or by Codifligne ID..."
advanced_search: "Advanced search"
activerecord:
models:
diff --git a/config/locales/companies.fr.yml b/config/locales/companies.fr.yml
index e582736c9..58fcc2ed7 100644
--- a/config/locales/companies.fr.yml
+++ b/config/locales/companies.fr.yml
@@ -15,7 +15,7 @@ fr:
index:
title: "Transporteurs"
name: "Recherche par nom..."
- name_or_objectid: "Recherche par nom ou objectid..."
+ name_or_objectid: "Recherche par nom ou ID Codifligne..."
advanced_search: "Recherche avancée"
activerecord:
models:
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3f6a68f8d..0a6002175 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -20,3 +20,7 @@ en:
validity_range: '%{debut} > %{end}'
bounding_dates: '%{debut} > %{end}'
metadatas: 'Informations'
+
+ id_codif: 'Codifligne ID'
+ id_reflex: 'Reflex ID'
+ objectid: 'ID'
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 49d1c5bb7..782844ba4 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -20,3 +20,6 @@ fr:
validity_range: '%{debut} > %{end}'
bounding_dates: '%{debut} > %{end}'
metadatas: 'Informations'
+
+ id_codif: 'ID Codifligne'
+ id_reflex: 'ID Reflex'
diff --git a/config/locales/networks.en.yml b/config/locales/networks.en.yml
index a5962e2a6..86be535e4 100644
--- a/config/locales/networks.en.yml
+++ b/config/locales/networks.en.yml
@@ -15,7 +15,7 @@ en:
index:
title: "Networks"
name: "Search by name..."
- name_or_objectid: "Search by name or by objectid..."
+ name_or_objectid: "Search by name or by Codifligne ID..."
advanced_search: "Advanced search"
activerecord:
models:
diff --git a/config/locales/networks.fr.yml b/config/locales/networks.fr.yml
index 99fd2ac95..30d061968 100644
--- a/config/locales/networks.fr.yml
+++ b/config/locales/networks.fr.yml
@@ -15,7 +15,7 @@ fr:
index:
title: "Réseaux"
name: "Recherche par nom..."
- name_or_objectid: "Recherche par nom ou objectid..."
+ name_or_objectid: "Recherche par nom ou ID Codifligne..."
advanced_search: "Recherche avancée"
activerecord:
models:
diff --git a/config/locales/stop_areas.fr.yml b/config/locales/stop_areas.fr.yml
index 60ab3fa3d..3e49cdf7c 100644
--- a/config/locales/stop_areas.fr.yml
+++ b/config/locales/stop_areas.fr.yml
@@ -90,7 +90,7 @@ fr:
published_name: "Nom public"
deleted: "Supprimé"
deleted_at: "Activé"
- comment: "Description"
+ comment: "Commentaire"
stop_area_type: "Type d'arrêt"
area_type: "Type d'arrêt"
nearest_topic_name: "Point d'intérêt le plus proche"
diff --git a/spec/features/workbenches_permissions_spec.rb b/spec/features/workbenches_permissions_spec.rb
index 962ffdedc..d58293538 100644
--- a/spec/features/workbenches_permissions_spec.rb
+++ b/spec/features/workbenches_permissions_spec.rb
@@ -18,20 +18,20 @@ describe 'Workbenches', type: :feature do
context 'on show view' do
let( :path ){ workbench_path(workbench) }
- context 'if present → ' do
+ context 'if present → ' do
let( :permission ){ true }
it 'shows the corresponding button' do
expected_href = new_referential_path(workbench_id: workbench)
- expect( page ).to have_link('Ajouter', href: expected_href)
+ expect( page ).to have_link('Créer', href: expected_href)
end
end
- context 'if absent → ' do
+ context 'if absent → ' do
let( :permission ){ false }
it 'does not show the corresponding button' do
- expect( page ).not_to have_link('Ajouter')
+ expect( page ).not_to have_link('Créer')
end
end
# let!(:ready_referential) { create :referential, workbench: workbench, metadatas: referential_metadatas, ready: true, organisation: @user.organisation }
diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches_spec.rb
index 2f453389d..9a40a8376 100644
--- a/spec/features/workbenches_spec.rb
+++ b/spec/features/workbenches_spec.rb
@@ -103,6 +103,59 @@ describe 'Workbenches', type: :feature do
expect(find("#q_archived_at_null")).to be_checked
end
end
+
+ context 'filter by validity period' do
+ def fill_validity_field date, field
+ select date.year, :from => "q[validity_period][#{field}(1i)]"
+ select I18n.t("date.month_names")[date.month], :from => "q[validity_period][#{field}(2i)]"
+ select date.day, :from => "q[validity_period][#{field}(3i)]"
+ end
+
+ it 'should show results for referential in range' do
+ dates = referential.validity_period.to_a
+ fill_validity_field dates[0], 'begin_gteq'
+ fill_validity_field dates[1], 'end_lteq'
+ click_button 'Filtrer'
+
+ expect(page).to have_content(referential.name)
+ expect(page).to_not have_content(other_referential.name)
+ end
+
+ it 'should keep filtering on sort' do
+ dates = referential.validity_period.to_a
+ fill_validity_field dates[0], 'begin_gteq'
+ fill_validity_field dates[1], 'end_lteq'
+ click_button 'Filtrer'
+
+ find('a[href*="&sort=validity_period"]').click
+
+ expect(page).to have_content(referential.name)
+ expect(page).to_not have_content(other_referential.name)
+ end
+
+ it 'should not show results for out off range' do
+ fill_validity_field(Date.today - 2.year, 'begin_gteq')
+ fill_validity_field(Date.today - 1.year, 'end_lteq')
+ click_button 'Filtrer'
+
+ expect(page).to_not have_content(referential.name)
+ expect(page).to_not have_content(other_referential.name)
+ end
+
+ it 'should keep value on submit' do
+ dates = referential.validity_period.to_a
+ ['begin_gteq', 'end_lteq'].each_with_index do |field, index|
+ fill_validity_field dates[index], field
+ end
+ click_button 'Filtrer'
+
+ ['begin_gteq', 'end_lteq'].each_with_index do |field, index|
+ expect(find("#q_validity_period_#{field}_3i").value).to eq dates[index].day.to_s
+ expect(find("#q_validity_period_#{field}_2i").value).to eq dates[index].month.to_s
+ expect(find("#q_validity_period_#{field}_1i").value).to eq dates[index].year.to_s
+ end
+ end
+ end
end
context 'permissions' do