Merge branch 'dev'

This commit is contained in:
gregoirenovel 2018-10-30 17:58:54 +01:00
commit 513cfb4fd8
51 changed files with 206 additions and 347 deletions

View file

@ -64,10 +64,7 @@ function validatePath(path) {
} }
function path_type_init() { function path_type_init() {
$(PROCEDURE_PATH_SELECTOR).bind('autocomplete:select', function( $(PROCEDURE_PATH_SELECTOR).on('autocomplete:select', function(event) {
ev, togglePathMessage(true, event.detail['mine']);
suggestion
) {
togglePathMessage(true, suggestion['mine']);
}); });
} }

View file

@ -40,8 +40,7 @@ class Admin::ProceduresController < AdminController
def edit def edit
@path = @procedure.path || @procedure.default_path @path = @procedure.path || @procedure.default_path
@available = @procedure.path_available?(@path) @availability = @procedure.path_availability(@path)
@mine = @procedure.path_is_mine?(@path)
end end
def destroy def destroy
@ -60,8 +59,7 @@ class Admin::ProceduresController < AdminController
def new def new
@procedure ||= Procedure.new @procedure ||= Procedure.new
@procedure.module_api_carto ||= ModuleAPICarto.new @procedure.module_api_carto ||= ModuleAPICarto.new
@available = true @availability = Procedure::PATH_AVAILABLE
@mine = true
end end
def create def create
@ -71,59 +69,51 @@ class Admin::ProceduresController < AdminController
@procedure.module_api_carto = ModuleAPICarto.new(create_module_api_carto_params) @procedure.module_api_carto = ModuleAPICarto.new(create_module_api_carto_params)
end end
@path = params.require(:procedure).permit(:path)[:path] @path = @procedure.path
@available = !ProcedurePath.exists?(path: @path) @availability = Procedure.path_availability(current_administrateur, @procedure.path)
@mine = ProcedurePath.mine?(current_administrateur, @path)
if !@procedure.validate if !@procedure.save
flash.now.alert = @procedure.errors.full_messages flash.now.alert = @procedure.errors.full_messages
return render 'new' render 'new'
elsif Flipflop.publish_draft? && !ProcedurePath.valid?(Procedure.last, @path)
# FIXME: The code abow is a horrible hack that we need until we migrated path directly on procedure model
flash.now.alert = 'Lien de la démarche invalide.'
return render 'new'
else else
@procedure.save!
if Flipflop.publish_draft?
@procedure.publish_with_path!(@path)
end
flash.notice = 'Démarche enregistrée.' flash.notice = 'Démarche enregistrée.'
redirect_to admin_procedure_types_de_champ_path(procedure_id: @procedure.id)
end end
redirect_to admin_procedure_types_de_champ_path(procedure_id: @procedure.id)
end end
def update def update
@procedure = current_administrateur.procedures.find(params[:id]) @procedure = current_administrateur.procedures.find(params[:id])
path = params.require(:procedure).permit(:path)[:path]
if !@procedure.update(procedure_params) if !@procedure.update(procedure_params)
flash.alert = @procedure.errors.full_messages flash.now.alert = @procedure.errors.full_messages
elsif Flipflop.publish_draft? && @procedure.brouillon? @path = procedure_params[:path]
if ProcedurePath.valid?(@procedure, path) if @path.present?
@procedure.publish_with_path!(path) @availability = @procedure.path_availability(@path)
reset_procedure
flash.notice = 'Démarche modifiée. Tous les dossiers de cette démarche ont été supprimés.'
else
flash.alert = 'Lien de la démarche invalide.'
end end
else render 'edit'
elsif Flipflop.publish_draft? && @procedure.brouillon?
reset_procedure reset_procedure
flash.notice = 'Démarche modifiée. Tous les dossiers de cette démarche ont été supprimés.'
redirect_to edit_admin_procedure_path(id: @procedure.id)
else
flash.notice = 'Démarche modifiée.' flash.notice = 'Démarche modifiée.'
redirect_to edit_admin_procedure_path(id: @procedure.id)
end end
redirect_to edit_admin_procedure_path(id: @procedure.id)
end end
def publish def publish
path = params[:path]
procedure = current_administrateur.procedures.find(params[:procedure_id]) procedure = current_administrateur.procedures.find(params[:procedure_id])
if !ProcedurePath.valid?(procedure, params[:procedure_path]) procedure.path = path
if !procedure.validate
flash.alert = 'Lien de la démarche invalide' flash.alert = 'Lien de la démarche invalide'
return redirect_to admin_procedures_path return redirect_to admin_procedures_path
else
procedure.path = nil
end end
if procedure.publish_or_reopen!(params[:procedure_path]) if procedure.publish_or_reopen!(path)
flash.notice = "Démarche publiée" flash.notice = "Démarche publiée"
redirect_to admin_procedures_path redirect_to admin_procedures_path
else else
@ -216,9 +206,10 @@ class Admin::ProceduresController < AdminController
end end
def path_list def path_list
json_path_list = ProcedurePath json_path_list = Procedure
.find_with_path(params[:request]) .find_with_path(params[:request])
.pluck('procedure_paths.path', :administrateur_id) .order(:id)
.pluck(:path, :administrateur_id)
.map do |path, administrateur_id| .map do |path, administrateur_id|
{ {
label: path, label: path,
@ -235,11 +226,9 @@ class Admin::ProceduresController < AdminController
if procedure_id.present? if procedure_id.present?
procedure = current_administrateur.procedures.find(procedure_id) procedure = current_administrateur.procedures.find(procedure_id)
@available = procedure.path_available?(path) @availability = procedure.path_availability(path)
@mine = procedure.path_is_mine?(path)
else else
@available = !ProcedurePath.exists?(path: path) @availability = Procedure.path_availability(current_administrateur, path)
@mine = ProcedurePath.mine?(current_administrateur, path)
end end
end end
@ -276,6 +265,9 @@ class Admin::ProceduresController < AdminController
if @procedure&.locked? if @procedure&.locked?
params.require(:procedure).permit(*editable_params) params.require(:procedure).permit(*editable_params)
else else
if Flipflop.publish_draft?
editable_params << :path
end
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :individual_with_siret, :ask_birthday, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id) params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :individual_with_siret, :ask_birthday, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
end end
end end

View file

@ -6,12 +6,5 @@ module Manager
flash[:notice] = "L'email d'activation de votre compte a été renvoyé." flash[:notice] = "L'email d'activation de votre compte a été renvoyé."
redirect_to manager_user_path(user) redirect_to manager_user_path(user)
end end
def confirm
user = User.find(params[:id])
user.confirm
flash[:notice] = "Ladresse email de lutilisateur a été marquée comme activée."
redirect_to manager_user_path(user)
end
end end
end end

View file

@ -7,18 +7,19 @@ module NewAdministrateur
def new def new
@procedure = procedure @procedure = procedure
@service = Service.new
end end
def create def create
new_service = Service.new(service_params) @service = Service.new(service_params)
new_service.administrateur = current_administrateur @service.administrateur = current_administrateur
if new_service.save if @service.save
redirect_to services_path(procedure_id: params[:procedure_id]), redirect_to services_path(procedure_id: params[:procedure_id]),
notice: "#{new_service.nom} créé" notice: "#{@service.nom} créé"
else else
@procedure = procedure @procedure = procedure
flash[:alert] = new_service.errors.full_messages flash[:alert] = @service.errors.full_messages
render :new render :new
end end
end end

View file

@ -12,10 +12,9 @@ class Users::DossiersController < UsersController
end end
def commencer_test def commencer_test
procedure_path = ProcedurePath.find_by(path: params[:procedure_path]) procedure = Procedure.brouillons.find_by(path: params[:path])
procedure = procedure_path&.procedure
if procedure&.brouillon? && procedure&.path.present? if procedure.present?
redirect_to new_users_dossier_path(procedure_id: procedure.id, brouillon: true) redirect_to new_users_dossier_path(procedure_id: procedure.id, brouillon: true)
else else
flash.alert = "La démarche est inconnue." flash.alert = "La démarche est inconnue."
@ -24,17 +23,10 @@ class Users::DossiersController < UsersController
end end
def commencer def commencer
procedure_path = ProcedurePath.find_by(path: params[:procedure_path]) procedure = Procedure.publiees.find_by(path: params[:path])
procedure = procedure_path&.procedure
if procedure.present? if procedure.present?
if procedure.archivee? redirect_to new_users_dossier_path(procedure_id: procedure.id)
@dossier = Dossier.new(procedure: procedure)
render 'commencer/archived'
else
redirect_to new_users_dossier_path(procedure_id: procedure.id)
end
else else
flash.alert = "La démarche est inconnue, ou la création de nouveaux dossiers pour cette démarche est terminée." flash.alert = "La démarche est inconnue, ou la création de nouveaux dossiers pour cette démarche est terminée."
redirect_to root_path redirect_to root_path

View file

@ -2,9 +2,9 @@ module ProcedureHelper
def procedure_lien(procedure) def procedure_lien(procedure)
if procedure.path.present? if procedure.path.present?
if procedure.brouillon_avec_lien? if procedure.brouillon_avec_lien?
commencer_test_url(procedure_path: procedure.path) commencer_test_url(path: procedure.path)
else else
commencer_url(procedure_path: procedure.path) commencer_url(path: procedure.path)
end end
end end
end end

View file

@ -18,7 +18,10 @@ class ApiGeo::RPGAdapter
:code_culture, :code_culture,
:surface, :surface,
:bio :bio
).merge({ geometry: feature[:geometry] }) ).merge({
geometry: feature[:geometry],
geo_reference_id: feature[:properties][:id]
})
end end
end end
end end

View file

@ -9,7 +9,6 @@ class Procedure < ApplicationRecord
has_one :module_api_carto, dependent: :destroy has_one :module_api_carto, dependent: :destroy
has_one :attestation_template, dependent: :destroy has_one :attestation_template, dependent: :destroy
has_one :procedure_path, dependent: :destroy
belongs_to :administrateur belongs_to :administrateur
belongs_to :parent_procedure, class_name: 'Procedure' belongs_to :parent_procedure, class_name: 'Procedure'
@ -46,12 +45,12 @@ class Procedure < ApplicationRecord
scope :by_libelle, -> { order(libelle: :asc) } scope :by_libelle, -> { order(libelle: :asc) }
scope :created_during, -> (range) { where(created_at: range) } scope :created_during, -> (range) { where(created_at: range) }
scope :cloned_from_library, -> { where(cloned_from_library: true) } scope :cloned_from_library, -> { where(cloned_from_library: true) }
scope :avec_lien, -> { joins(:procedure_path) } scope :avec_lien, -> { where.not(path: nil) }
validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :description, presence: true, allow_blank: false, allow_nil: false validates :description, presence: true, allow_blank: false, allow_nil: false
validate :check_juridique validate :check_juridique
validates :path, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, uniqueness: true, presence: true, allow_blank: false, allow_nil: true validates :path, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, uniqueness: { scope: :aasm_state, case_sensitive: false }, presence: true, allow_blank: false, allow_nil: true
# FIXME: remove duree_conservation_required flag once all procedures are converted to the new style # FIXME: remove duree_conservation_required flag once all procedures are converted to the new style
validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }, if: :durees_conservation_required validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }, if: :durees_conservation_required
validates :duree_conservation_dossiers_hors_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :durees_conservation_required validates :duree_conservation_dossiers_hors_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :durees_conservation_required
@ -101,19 +100,6 @@ class Procedure < ApplicationRecord
end end
end end
def publish_with_path!(path)
procedure_path = ProcedurePath
.where(administrateur: administrateur)
.find_by(path: path)
if procedure_path.present?
procedure_path.publish!(self)
else
create_procedure_path!(administrateur: administrateur, path: path)
end
update!(path: path)
end
def reset! def reset!
if locked? if locked?
raise "Can not reset a locked procedure." raise "Can not reset a locked procedure."
@ -126,14 +112,6 @@ class Procedure < ApplicationRecord
publiee_ou_archivee? publiee_ou_archivee?
end end
def path_available?(path)
!ProcedurePath.where.not(procedure: self).exists?(path: path)
end
def path_is_mine?(path)
ProcedurePath.where.not(procedure: self).mine?(administrateur, path)
end
# This method is needed for transition. Eventually this will be the same as brouillon?. # This method is needed for transition. Eventually this will be the same as brouillon?.
def brouillon_avec_lien? def brouillon_avec_lien?
Flipflop.publish_draft? && brouillon? && path.present? Flipflop.publish_draft? && brouillon? && path.present?
@ -157,10 +135,6 @@ class Procedure < ApplicationRecord
Dossier.new(procedure: self, champs: champs, champs_private: champs_private) Dossier.new(procedure: self, champs: champs, champs_private: champs_private)
end end
def path
read_attribute(:path) || procedure_path&.path
end
def default_path def default_path
libelle&.parameterize&.first(50) libelle&.parameterize&.first(50)
end end
@ -332,21 +306,66 @@ class Procedure < ApplicationRecord
mean_time(:en_instruction_at, :processed_at) mean_time(:en_instruction_at, :processed_at)
end end
PATH_AVAILABLE = :available
PATH_AVAILABLE_PUBLIEE = :available_publiee
PATH_NOT_AVAILABLE = :not_available
PATH_NOT_AVAILABLE_BROUILLON = :not_available_brouillon
PATH_CAN_PUBLISH = [PATH_AVAILABLE, PATH_AVAILABLE_PUBLIEE]
def path_availability(path)
Procedure.path_availability(administrateur, path, id)
end
def self.path_availability(administrateur, path, exclude_id = nil)
if exclude_id.present?
procedure = where.not(id: exclude_id).find_by(path: path)
else
procedure = find_by(path: path)
end
if procedure.blank?
PATH_AVAILABLE
elsif administrateur.owns?(procedure)
if procedure.brouillon?
PATH_NOT_AVAILABLE_BROUILLON
else
PATH_AVAILABLE_PUBLIEE
end
else
PATH_NOT_AVAILABLE
end
end
def self.find_with_path(path)
where.not(aasm_state: :archivee).where("path LIKE ?", "%#{path}%")
end
private private
def can_publish?(path) def claim_path_ownership!(path)
procedure_path = ProcedurePath.find_by(path: path) procedure = Procedure.where(administrateur: administrateur).find_by(path: path)
if procedure_path.present?
administrateur.owns?(procedure_path) if procedure&.publiee? && procedure != self
else procedure.archive!
true
end end
update!(path: path)
end
def can_publish?(path)
path_availability(path).in?(PATH_CAN_PUBLISH)
end end
def after_publish(path) def after_publish(path)
update!(published_at: Time.zone.now) update!(published_at: Time.zone.now)
publish_with_path!(path) claim_path_ownership!(path)
end
def after_reopen(path)
update!(published_at: Time.zone.now, archived_at: nil)
claim_path_ownership!(path)
end end
def after_archive def after_archive
@ -356,16 +375,9 @@ class Procedure < ApplicationRecord
def after_hide def after_hide
now = Time.zone.now now = Time.zone.now
update!(hidden_at: now, path: nil) update!(hidden_at: now, path: nil)
procedure_path&.hide!
dossiers.update_all(hidden_at: now) dossiers.update_all(hidden_at: now)
end end
def after_reopen(path)
update!(published_at: Time.zone.now, archived_at: nil)
publish_with_path!(path)
end
def after_draft def after_draft
update!(published_at: nil) update!(published_at: nil)
end end

View file

@ -1,36 +0,0 @@
class ProcedurePath < ApplicationRecord
validates :path, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, uniqueness: true, presence: true, allow_blank: false, allow_nil: false
validates :administrateur_id, presence: true, allow_blank: false, allow_nil: false
validates :procedure_id, presence: true, allow_blank: false, allow_nil: false
belongs_to :procedure
belongs_to :administrateur
def self.valid?(procedure, path)
create_with(procedure: procedure, administrateur: procedure.administrateur)
.find_or_initialize_by(path: path).validate
end
def self.mine?(administrateur, path)
procedure_path = find_by(path: path)
procedure_path && administrateur.owns?(procedure_path)
end
def self.find_with_path(path)
joins(:procedure)
.where.not(procedures: { aasm_state: :archivee })
.where("procedure_paths.path LIKE ?", "%#{path}%")
.order(:id)
end
def hide!
destroy!
end
def publish!(new_procedure)
if procedure&.publiee? && procedure != new_procedure
procedure.archive!
end
update!(procedure: new_procedure)
end
end

View file

@ -111,7 +111,7 @@ class ProcedurePresentation < ApplicationRecord
column = sanitized_column(filter) column = sanitized_column(filter)
case table case table
when 'self' when 'self'
date = Time.zone.parse(filter['value']) rescue nil date = Time.zone.parse(filter['value']).beginning_of_day rescue nil
if date.present? if date.present?
dossiers.where("#{column} BETWEEN ? AND ?", date, date + 1.day) dossiers.where("#{column} BETWEEN ? AND ?", date, date + 1.day)
else else

View file

@ -1,5 +1,10 @@
class CommentaireSerializer < ActiveModel::Serializer class CommentaireSerializer < ActiveModel::Serializer
attributes :email, attributes :email,
:body, :body,
:created_at :created_at,
:attachment
def attachment
object.file_url
end
end end

View file

@ -1,5 +1,5 @@
class GeoAreaSerializer < ActiveModel::Serializer class GeoAreaSerializer < ActiveModel::Serializer
attributes :geometry, :source attributes :geometry, :source, :geo_reference_id
attribute :surface_intersection, if: :include_cadastre? attribute :surface_intersection, if: :include_cadastre?
attribute :surface_parcelle, if: :include_cadastre? attribute :surface_parcelle, if: :include_cadastre?

View file

@ -21,9 +21,9 @@ class ProcedureSerializer < ActiveModel::Serializer
def link def link
if object.path.present? if object.path.present?
if object.brouillon_avec_lien? if object.brouillon_avec_lien?
commencer_test_url(procedure_path: object.path) commencer_test_url(path: object.path)
else else
commencer_url(procedure_path: object.path) commencer_url(path: object.path)
end end
end end
end end

View file

@ -1,15 +0,0 @@
class ProcedurePathFormatValidator < ActiveModel::Validator
def path_regex
/^[a-z0-9_]{3,30}$/
end
def validate(record)
if record.path.blank?
return false
end
if !path_regex.match(record.path)
record.errors[:path] << "Path invalide"
end
end
end

View file

@ -16,11 +16,11 @@
%h4 Lien public* %h4 Lien public*
.procedure-lien .procedure-lien
%span.prefix %span.prefix
= commencer_test_url(procedure_path: '') = commencer_test_url(path: '')
= f.text_field :path, value: @path, class: 'form-control', data: { remote: true, debounce: true, url: admin_procedures_available_path, params: { id: @procedure.id }.to_query(:procedure) } = f.text_field :path, value: @path, class: 'form-control', data: { remote: true, debounce: true, url: admin_procedures_available_path, params: { id: @procedure.id }.to_query(:procedure) }
%p.unavailable-path-message.text-warning %p.unavailable-path-message.text-warning
- if !@available - if @availability != Procedure::PATH_AVAILABLE
= render partial: 'unavailable', locals: { mine: @mine } = render partial: 'unavailable', locals: { availability: @availability }
%p.help-block %p.help-block
%i.fa.fa-info-circle %i.fa.fa-info-circle
Afin de faciliter laccès à la démarche, vous êtes invité à personnaliser ladresse d'accès public. C'est ce lien qu'il va falloir communiquer aux usagers souhaitant faire la démarche. Afin de faciliter laccès à la démarche, vous êtes invité à personnaliser ladresse d'accès public. C'est ce lien qu'il va falloir communiquer aux usagers souhaitant faire la démarche.

View file

@ -20,8 +20,8 @@
%br %br
%h4 Lien de la démarche %h4 Lien de la démarche
%p.center %p.center
= commencer_url(procedure_path: '') = commencer_url(path: '')
= text_field_tag('procedure_path', @procedure.path || @procedure.default_path, = text_field_tag(:path, @procedure.path || @procedure.default_path,
id: 'procedure_path', id: 'procedure_path',
placeholder: 'Chemin vers la démarche', placeholder: 'Chemin vers la démarche',
data: { autocomplete: 'path' }, data: { autocomplete: 'path' },
@ -41,7 +41,8 @@
%br %br
Vous ne pouvez pas lutiliser car il appartient à un autre administrateur. Vous ne pouvez pas lutiliser car il appartient à un autre administrateur.
#path_is_invalid.text-danger.center.message #path_is_invalid.text-danger.center.message
= t('activerecord.errors.models.procedure_path.attributes.path.format') Ce lien
= t('activerecord.errors.models.procedure.attributes.path.invalid')
.modal-footer .modal-footer
= submit_tag procedure_modal_text(@procedure, :submit), class: %w(btn btn btn-success), disabled: :disabled, id: 'publish' = submit_tag procedure_modal_text(@procedure, :submit), class: %w(btn btn btn-success), disabled: :disabled, id: 'publish'
= button_tag "Annuler", class: %w(btn btn btn-default), data: { dismiss: :modal }, id: 'cancel' = button_tag "Annuler", class: %w(btn btn btn-default), data: { dismiss: :modal }, id: 'cancel'

View file

@ -1,8 +1,11 @@
- if mine - case availability
- when Procedure::PATH_AVAILABLE_PUBLIEE
Ce lien est déjà utilisé par une de vos démarche. Ce lien est déjà utilisé par une de vos démarche.
%br %br
Si vous voulez lutiliser, lancienne démarche sera archivée (plus accessible du public). Si vous voulez lutiliser, lancienne démarche sera archivée lors de la publication de la démarche (plus accessible du public).
- else - when Procedure::PATH_NOT_AVAILABLE_BROUILLON
Un brouillon de démarche existe déjà avec ce lien.
- when Procedure::PATH_NOT_AVAILABLE
Ce lien est déjà utilisé par une démarche. Ce lien est déjà utilisé par une démarche.
%br %br
Vous ne pouvez pas lutiliser car il appartient à un autre administrateur. Vous ne pouvez pas lutiliser car il appartient à un autre administrateur.

View file

@ -1,11 +1,11 @@
<% if @available %> <% if @availability == Procedure::PATH_AVAILABLE %>
<%= remove_element('.unavailable-path-message', inner: true) %> <%= remove_element('.unavailable-path-message', inner: true) %>
<% else %>
<%= render_to_element('.unavailable-path-message', partial: 'unavailable', locals: { availability: @availability }) %>
<% end %>
<% if @availability.in?(Procedure::PATH_CAN_PUBLISH) %>
<%= enable_element('button[type=submit]') %> <%= enable_element('button[type=submit]') %>
<% else %> <% else %>
<%= render_to_element('.unavailable-path-message', partial: 'unavailable', locals: { mine: @mine }) %> <%= disable_element('button[type=submit]') %>
<% if @mine %>
<%= enable_element('button[type=submit]') %>
<% else %>
<%= disable_element('button[type=submit]') %>
<% end %>
<% end %> <% end %>

View file

@ -3,7 +3,7 @@
= form_for @procedure, url: url_for({ controller: 'admin/procedures', action: :update, id: @procedure.id }), multipart: true do |f| = form_for @procedure, url: url_for({ controller: 'admin/procedures', action: :update, id: @procedure.id }), multipart: true do |f|
= render partial: 'informations', locals: { f: f } = render partial: 'informations', locals: { f: f }
.text-right .text-right
- if !Flipflop.publish_draft? || (@available || @mine) - if !Flipflop.publish_draft? || @availability.in?(Procedure::PATH_CAN_PUBLISH)
= f.button 'Enregistrer', class: 'btn btn-success' = f.button 'Enregistrer', class: 'btn btn-success'
- else - else
= f.button 'Enregistrer', class: 'btn btn-success', disabled: true = f.button 'Enregistrer', class: 'btn btn-success', disabled: true

View file

@ -6,7 +6,7 @@
= form_for @procedure, url: { controller: 'admin/procedures', action: :create }, multipart: true do |f| = form_for @procedure, url: { controller: 'admin/procedures', action: :create }, multipart: true do |f|
= render partial: 'informations', locals: { f: f } = render partial: 'informations', locals: { f: f }
.text-right .text-right
- if !Flipflop.publish_draft? || (@available || @mine) - if !Flipflop.publish_draft? || @availability.in?(Procedure::PATH_CAN_PUBLISH)
= f.button 'Valider', class: 'btn btn-info', id: 'save-procedure' = f.button 'Valider', class: 'btn btn-info', id: 'save-procedure'
- else - else
= f.button 'Valider', class: 'btn btn-info', id: 'save-procedure', disabled: true = f.button 'Valider', class: 'btn btn-info', id: 'save-procedure', disabled: true

View file

@ -1,15 +0,0 @@
%br
%div{ style: 'text-align: center; max-width: 500px; margin-left: auto; margin-right: auto; padding: 20px;' }
= render partial: 'users/sessions/resume_procedure'
.center{ style: 'margin-top: -20px;' }
%h3
La campagne de création de nouveau dossier
%br
pour cette démarche en ligne est maintenant terminée.
%br
%p
Si vous avez déjà déposé un ou plusieurs dossiers :
%a.btn.btn-lg.btn-info{ href: new_user_session_path }
Accéder à mon espace en ligne.

View file

@ -1,4 +1,4 @@
- if field.data.present? - if field.data.present?
= link_to "/commencer/#{field.data}", commencer_url(procedure_path: field.data), target: '_blank' = link_to "/commencer/#{field.data}", commencer_url(path: field.data), target: '_blank'
- else - else
Plus en ligne Plus en ligne

View file

@ -0,0 +1 @@
= render partial: 'layouts/left_panels/left_panel_admin_procedurescontroller_navbar', locals: { active: 'Description' }

View file

@ -35,7 +35,6 @@ as well as a link to its edit page.
<div> <div>
<% if !user.confirmed? %> <% if !user.confirmed? %>
<%= link_to('Renvoyer lemail de confirmation', [:resend_confirmation_instructions, namespace, page.resource], method: :post, class: 'button') %> <%= link_to('Renvoyer lemail de confirmation', [:resend_confirmation_instructions, namespace, page.resource], method: :post, class: 'button') %>
<%= link_to('Confirmer lemail', confirm_manager_user_path(user), method: :post, class: 'button') %>
<% end %> <% end %>
<div> <div>
</header> </header>

View file

@ -8,4 +8,4 @@
%h1 Nouveau Service %h1 Nouveau Service
= render partial: 'form', = render partial: 'form',
locals: { service: Service.new, procedure_id: @procedure.id } locals: { service: @service, procedure_id: @procedure.id }

View file

@ -12,7 +12,7 @@
%ul.demarche-links %ul.demarche-links
- @previous_demarches_still_active.each do |demarche| - @previous_demarches_still_active.each do |demarche|
%li %li
= link_to(commencer_url(procedure_path: demarche.path), class: "demarche-link") do = link_to(commencer_url(path: demarche.path), class: "demarche-link") do
= demarche.libelle = demarche.libelle
%br %br
.service-name .service-name
@ -23,7 +23,7 @@
%ul.demarche-links %ul.demarche-links
- @popular_demarches.each do |demarche| - @popular_demarches.each do |demarche|
%li %li
= link_to(commencer_url(procedure_path: demarche.path), class: "demarche-link") do = link_to(commencer_url(path: demarche.path), class: "demarche-link") do
= demarche.libelle = demarche.libelle
%br %br
.service-name .service-name

View file

@ -35,9 +35,12 @@
Pièces jointes Pièces jointes
.warning .warning
Pour éviter toute erreur, nous vous conseillons de limiter la taille de chaque pièce jointe à 20 Mo, et de les ajouter une par une, en enregistrant votre - if tpjs.many?
= dossier.brouillon? ? "brouillon" : "dossier" Pour éviter toute erreur, nous vous conseillons de limiter la taille de chaque pièce jointe à 20 Mo, et de les ajouter une par une, en enregistrant votre
après chaque ajout. = dossier.brouillon? ? "brouillon" : "dossier"
après chaque ajout.
- else
Pour éviter toute erreur, nous vous conseillons de limiter la taille de votre pièce jointe à 20 Mo.
- tpjs.each do |tpj| - tpjs.each do |tpj|
.pj-input .pj-input

View file

@ -156,6 +156,10 @@ fr:
taken: déjà utilisé taken: déjà utilisé
password: password:
too_short: 'est trop court' too_short: 'est trop court'
procedure:
attributes:
path:
invalid: n'est pas valide. Il doit comporter au moins 3 caractères, au plus 50 caractères et seuls les caractères a-z, 0-9, '_' et '-' sont autorisés.
errors: errors:
messages: messages:

View file

@ -2,6 +2,7 @@ fr:
activerecord: activerecord:
attributes: attributes:
procedure: procedure:
path: Lien public
organisation: Organisme organisation: Organisme
duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers sur demarches-simplifiees.fr duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers sur demarches-simplifiees.fr
duree_conservation_dossiers_hors_ds: Durée de conservation des dossiers hors demarches-simplifiees.fr duree_conservation_dossiers_hors_ds: Durée de conservation des dossiers hors demarches-simplifiees.fr

View file

@ -1,12 +0,0 @@
fr:
activerecord:
attributes:
procedure_path:
path: Lien
errors:
models:
procedure_path:
attributes:
path:
format: Ce lien n'est pas valide. Il doit comporter au moins 3 caractères, au plus 50 caractères et seuls les caractères a-z, 0-9, '_' et '-' sont autorisés.
taken: est déjà utilisé par une procédure.

View file

@ -22,7 +22,6 @@ Rails.application.routes.draw do
resources :users, only: [:index, :show] do resources :users, only: [:index, :show] do
post 'resend_confirmation_instructions', on: :member post 'resend_confirmation_instructions', on: :member
post 'confirm', on: :member
end end
resources :gestionnaires, only: [:index, :show] do resources :gestionnaires, only: [:index, :show] do
@ -129,8 +128,8 @@ Rails.application.routes.draw do
end end
namespace :commencer do namespace :commencer do
get '/test/:procedure_path' => '/users/dossiers#commencer_test', as: :test get '/test/:path' => '/users/dossiers#commencer_test', as: :test
get '/:procedure_path' => '/users/dossiers#commencer' get '/:path' => '/users/dossiers#commencer'
end end
get "patron" => "root#patron" get "patron" => "root#patron"

View file

@ -0,0 +1,5 @@
class AddGeoIdToGeoAreas < ActiveRecord::Migration[5.2]
def change
add_column :geo_areas, :geo_reference_id, :string
end
end

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2018_10_10_183331) do ActiveRecord::Schema.define(version: 2018_10_30_103913) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -347,6 +347,7 @@ ActiveRecord::Schema.define(version: 2018_10_10_183331) do
t.jsonb "geometry" t.jsonb "geometry"
t.jsonb "properties" t.jsonb "properties"
t.bigint "champ_id" t.bigint "champ_id"
t.string "geo_reference_id"
t.index ["champ_id"], name: "index_geo_areas_on_champ_id" t.index ["champ_id"], name: "index_geo_areas_on_champ_id"
t.index ["source"], name: "index_geo_areas_on_source" t.index ["source"], name: "index_geo_areas_on_source"
end end

View file

@ -27,11 +27,6 @@ namespace :support do
rake_puts("Changing owner of procedure ##{procedure_id} from ##{procedure.administrateur_id} to ##{new_owner.id}") rake_puts("Changing owner of procedure ##{procedure_id} from ##{procedure.administrateur_id} to ##{new_owner.id}")
procedure.update(administrateur: new_owner) procedure.update(administrateur: new_owner)
ProcedurePath.where(procedure_id: procedure_id).each do |pp|
rake_puts("Changing owner of procedure_path #{pp.path} from ##{pp.administrateur_id} to ##{new_owner.id}")
pp.update(administrateur: new_owner)
end
end end
desc <<~EOD desc <<~EOD
@ -74,13 +69,6 @@ namespace :support do
end end
procedures.update_all(administrateur_id: new_owner.id) procedures.update_all(administrateur_id: new_owner.id)
procedures.pluck(:id).each do |procedure_id|
ProcedurePath.where(procedure_id: procedure_id).each do |pp|
rake_puts("Changing owner of procedure_path #{pp.path} from ##{pp.administrateur_id} to ##{new_owner.id}")
pp.update(administrateur: new_owner)
end
end
end end
desc <<~EOD desc <<~EOD

View file

@ -359,28 +359,28 @@ describe Admin::ProceduresController, type: :controller do
context 'when admin is the owner of the procedure' do context 'when admin is the owner of the procedure' do
before do before do
put :publish, params: { procedure_id: procedure.id, procedure_path: procedure_path } put :publish, params: { procedure_id: procedure.id, path: path }
procedure.reload procedure.reload
procedure2.reload procedure2.reload
end end
context 'procedure path does not exist' do context 'procedure path does not exist' do
let(:procedure_path) { 'new_path' } let(:path) { 'new_path' }
it 'publish the given procedure' do it 'publish the given procedure' do
expect(procedure.publiee?).to be_truthy expect(procedure.publiee?).to be_truthy
expect(procedure.path).to eq(procedure_path) expect(procedure.path).to eq(path)
expect(response.status).to eq 302 expect(response.status).to eq 302
expect(flash[:notice]).to have_content 'Démarche publiée' expect(flash[:notice]).to have_content 'Démarche publiée'
end end
end end
context 'procedure path exists and is owned by current administrator' do context 'procedure path exists and is owned by current administrator' do
let(:procedure_path) { procedure2.path } let(:path) { procedure2.path }
it 'publish the given procedure' do it 'publish the given procedure' do
expect(procedure.publiee?).to be_truthy expect(procedure.publiee?).to be_truthy
expect(procedure.path).to eq(procedure_path) expect(procedure.path).to eq(path)
expect(response.status).to eq 302 expect(response.status).to eq 302
expect(flash[:notice]).to have_content 'Démarche publiée' expect(flash[:notice]).to have_content 'Démarche publiée'
end end
@ -391,24 +391,8 @@ describe Admin::ProceduresController, type: :controller do
end end
end end
context 'procedure path exists and has archived procedure' do
let(:procedure_path) { procedure2.path }
let(:procedure2) { create(:procedure, :archived, administrateur: admin) }
it 'publish the given procedure' do
expect(procedure.publiee?).to be_truthy
expect(procedure.path).to eq(procedure_path)
expect(response.status).to eq 302
expect(flash[:notice]).to have_content 'Démarche publiée'
end
it 'archive previous procedure' do
expect(procedure2.archivee?).to be_truthy
end
end
context 'procedure path exists and is not owned by current administrator' do context 'procedure path exists and is not owned by current administrator' do
let(:procedure_path) { procedure3.path } let(:path) { procedure3.path }
it 'does not publish the given procedure' do it 'does not publish the given procedure' do
expect(procedure.publiee?).to be_falsey expect(procedure.publiee?).to be_falsey
@ -424,7 +408,7 @@ describe Admin::ProceduresController, type: :controller do
end end
context 'procedure path is invalid' do context 'procedure path is invalid' do
let(:procedure_path) { 'Invalid Procedure Path' } let(:path) { 'Invalid Procedure Path' }
it 'does not publish the given procedure' do it 'does not publish the given procedure' do
expect(procedure.publiee?).to be_falsey expect(procedure.publiee?).to be_falsey
@ -442,7 +426,7 @@ describe Admin::ProceduresController, type: :controller do
sign_out admin sign_out admin
sign_in admin_2 sign_in admin_2
put :publish, params: { procedure_id: procedure.id, procedure_path: 'fake_path' } put :publish, params: { procedure_id: procedure.id, path: 'fake_path' }
procedure.reload procedure.reload
end end
@ -470,7 +454,7 @@ describe Admin::ProceduresController, type: :controller do
context 'when owner want to re-enable procedure' do context 'when owner want to re-enable procedure' do
before do before do
put :publish, params: { procedure_id: procedure.id, procedure_path: 'fake_path' } put :publish, params: { procedure_id: procedure.id, path: 'fake_path' }
procedure.reload procedure.reload
end end
@ -751,10 +735,19 @@ describe Admin::ProceduresController, type: :controller do
it { expect(response.body).to include("innerHTML = ''") } it { expect(response.body).to include("innerHTML = ''") }
end end
context 'my path' do context 'my path (brouillon)' do
let(:procedure_owned) { create(:procedure, :with_path, administrateur: admin) } let(:procedure_owned) { create(:procedure, :with_path, administrateur: admin) }
let(:path) { procedure_owned.path } let(:path) { procedure_owned.path }
it {
expect(response.body).to include('Un brouillon de démarche existe déjà avec ce lien.')
}
end
context 'my path' do
let(:procedure_owned) { create(:procedure, :published, administrateur: admin) }
let(:path) { procedure_owned.path }
it { it {
expect(response.body).to include('Ce lien est déjà utilisé par une de vos démarche.') expect(response.body).to include('Ce lien est déjà utilisé par une de vos démarche.')
expect(response.body).to include('Si vous voulez lutiliser, lancienne démarche sera archivée') expect(response.body).to include('Si vous voulez lutiliser, lancienne démarche sera archivée')

View file

@ -43,6 +43,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
it { expect(flash.alert).not_to be_nil } it { expect(flash.alert).not_to be_nil }
it { expect(response).to render_template(:new) } it { expect(response).to render_template(:new) }
it { expect(assigns(:service).nom).to eq('super service') }
end end
end end

View file

@ -244,7 +244,7 @@ describe StatsController, type: :controller do
describe "#avis_average_answer_time" do describe "#avis_average_answer_time" do
before do before do
Timecop.freeze(Time.zone.now) Timecop.freeze(Time.zone.local(2016, 10, 2))
# 1 week ago # 1 week ago
create(:avis, answer: "voila ma réponse", created_at: 1.week.ago + 1.day, updated_at: 1.week.ago + 2.days) # 1 day create(:avis, answer: "voila ma réponse", created_at: 1.week.ago + 1.day, updated_at: 1.week.ago + 2.days) # 1 day

View file

@ -65,7 +65,7 @@ describe Users::DossiersController, type: :controller do
end end
describe 'GET #commencer' do describe 'GET #commencer' do
subject { get :commencer, params: { procedure_path: path } } subject { get :commencer, params: { path: path } }
let(:path) { procedure.path } let(:path) { procedure.path }
it { expect(subject.status).to eq 302 } it { expect(subject.status).to eq 302 }
@ -83,7 +83,7 @@ describe Users::DossiersController, type: :controller do
Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true) Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true)
end end
subject { get :commencer_test, params: { procedure_path: path } } subject { get :commencer_test, params: { path: path } }
let(:procedure) { create(:procedure, :with_path) } let(:procedure) { create(:procedure, :with_path) }
let(:path) { procedure.path } let(:path) { procedure.path }

View file

@ -3,7 +3,6 @@ require 'spec_helper'
describe ProcedureDecorator do describe ProcedureDecorator do
let(:published_at) { Time.zone.local(2017, 12, 24, 14, 12) } let(:published_at) { Time.zone.local(2017, 12, 24, 14, 12) }
let(:procedure) { create(:procedure, published_at: published_at, created_at: Time.zone.local(2015, 12, 24, 14, 10)) } let(:procedure) { create(:procedure, published_at: published_at, created_at: Time.zone.local(2015, 12, 24, 14, 10)) }
let!(:procedure_path) { create(:procedure_path, administrateur: create(:administrateur), procedure: procedure) }
subject { procedure.decorate } subject { procedure.decorate }

View file

@ -37,12 +37,7 @@ FactoryBot.define do
end end
trait :with_path do trait :with_path do
after(:create) do |procedure| path { generate(:published_path) }
create(:procedure_path,
procedure: procedure,
administrateur: procedure.administrateur,
path: generate(:published_path))
end
end end
trait :with_service do trait :with_service do

View file

@ -1,5 +0,0 @@
FactoryBot.define do
factory :procedure_path do
path { 'fake_path' }
end
end

View file

@ -7,8 +7,6 @@ feature 'As an administrateur I wanna clone a procedure', js: true do
let(:administrateur) { create(:administrateur) } let(:administrateur) { create(:administrateur) }
before do before do
# FIXME: needed to make procedure_path validation work
create(:procedure)
Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true) Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true)
login_as administrateur, scope: :administrateur login_as administrateur, scope: :administrateur
visit root_path visit root_path

View file

@ -7,8 +7,6 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
let(:administrateur) { create(:administrateur) } let(:administrateur) { create(:administrateur) }
before do before do
# FIXME: needed to make procedure_path validation work
create(:procedure)
Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true) Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true)
login_as administrateur, scope: :administrateur login_as administrateur, scope: :administrateur
visit root_path visit root_path

View file

@ -129,7 +129,7 @@ feature 'The user' do
private private
def log_in(email, password, procedure) def log_in(email, password, procedure)
visit "/commencer/#{procedure.procedure_path.path}" visit "/commencer/#{procedure.path}"
expect(page).to have_current_path(new_user_session_path) expect(page).to have_current_path(new_user_session_path)
fill_in 'user_email', with: email fill_in 'user_email', with: email

View file

@ -16,7 +16,7 @@ feature 'Creating a new dossier:' do
let(:expected_birthday) { nil } let(:expected_birthday) { nil }
before do before do
visit commencer_path(procedure_path: procedure.path) visit commencer_path(path: procedure.path)
fill_in 'individual_nom', with: 'Nom' fill_in 'individual_nom', with: 'Nom'
fill_in 'individual_prenom', with: 'Prenom' fill_in 'individual_prenom', with: 'Prenom'
end end
@ -76,7 +76,7 @@ feature 'Creating a new dossier:' do
end end
scenario 'the user can enter the SIRET of its etablissement and create a new draft', vcr: { cassette_name: 'api_adresse_search_paris_3' }, js: true do scenario 'the user can enter the SIRET of its etablissement and create a new draft', vcr: { cassette_name: 'api_adresse_search_paris_3' }, js: true do
visit commencer_path(procedure_path: procedure.path) visit commencer_path(path: procedure.path)
expect(page).to have_current_path(siret_dossier_path(dossier)) expect(page).to have_current_path(siret_dossier_path(dossier))
fill_in 'Numéro SIRET', with: siret fill_in 'Numéro SIRET', with: siret
@ -93,7 +93,7 @@ feature 'Creating a new dossier:' do
end end
scenario 'the user is notified when its SIRET is invalid' do scenario 'the user is notified when its SIRET is invalid' do
visit commencer_path(procedure_path: procedure.path) visit commencer_path(path: procedure.path)
expect(page).to have_current_path(siret_dossier_path(dossier)) expect(page).to have_current_path(siret_dossier_path(dossier))
fill_in 'Numéro SIRET', with: '0000' fill_in 'Numéro SIRET', with: '0000'

View file

@ -47,7 +47,7 @@ feature 'linked dropdown lists' do
private private
def log_in(email, password, procedure) def log_in(email, password, procedure)
visit "/commencer/#{procedure.procedure_path.path}" visit "/commencer/#{procedure.path}"
expect(page).to have_current_path(new_user_session_path) expect(page).to have_current_path(new_user_session_path)
fill_in 'user_email', with: email fill_in 'user_email', with: email

View file

@ -53,7 +53,8 @@ describe ApiGeo::RPGAdapter do
:code_culture, :code_culture,
:surface, :surface,
:bio, :bio,
:geometry :geometry,
:geo_reference_id
]) ])
end end
end end

View file

@ -1,49 +0,0 @@
require 'spec_helper'
describe ProcedurePath do
describe 'assocations' do
it { is_expected.to belong_to(:administrateur) }
it { is_expected.to belong_to(:procedure) }
end
describe 'attributes' do
it { is_expected.to have_db_column(:path) }
end
describe 'validation' do
describe 'path' do
let(:admin) { create(:administrateur) }
let(:procedure) { create(:procedure) }
let(:procedure_path) { create(:procedure_path, administrateur: admin, procedure: procedure, path: path) }
context 'when path is nil' do
let(:path) { nil }
it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid }
end
context 'when path is empty' do
let(:path) { '' }
it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid }
end
context 'when path contains spaces' do
let(:path) { 'Demande de subvention' }
it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid }
end
context 'when path contains alphanumerics and underscores' do
let(:path) { 'ma_super_procedure_1' }
it { expect{ procedure_path }.not_to raise_error }
end
context 'when path contains dashes' do
let(:path) { 'ma-super-procedure' }
it { expect{ procedure_path }.not_to raise_error }
end
context 'when path is too long' do
let(:path) { 'ma-super-procedure-12345678901234567890123456789012345678901234567890' }
it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid }
end
context 'when path is too short' do
let(:path) { 'pr' }
it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid }
end
end
end
end

View file

@ -135,14 +135,14 @@ describe ProcedurePresentation do
let(:column) { 'created_at' } let(:column) { 'created_at' }
let(:dossier) { Timecop.freeze(Time.zone.local(1992, 3, 22)) { create(:dossier, procedure: procedure) } } let(:dossier) { Timecop.freeze(Time.zone.local(1992, 3, 22)) { create(:dossier, procedure: procedure) } }
it { is_expected.to eq(Time.zone.local(1992, 3, 22).strftime('%d/%m/%Y')) } it { is_expected.to eq('22/03/1992') }
end end
context 'for en_construction_at column' do context 'for en_construction_at column' do
let(:column) { 'en_construction_at' } let(:column) { 'en_construction_at' }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: Time.zone.local(2018, 10, 17)) } let(:dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: Time.zone.local(2018, 10, 17)) }
it { is_expected.to eq(Time.zone.local(2018, 10, 17).strftime('%d/%m/%Y')) } it { is_expected.to eq('17/10/2018') }
end end
context 'for updated_at column' do context 'for updated_at column' do
@ -151,7 +151,7 @@ describe ProcedurePresentation do
before { dossier.touch(time: Time.zone.local(2018, 9, 25)) } before { dossier.touch(time: Time.zone.local(2018, 9, 25)) }
it { is_expected.to eq(Time.zone.local(2018, 9, 25).strftime('%d/%m/%Y')) } it { is_expected.to eq('25/09/2018') }
end end
end end
@ -405,6 +405,14 @@ describe ProcedurePresentation do
it { is_expected.to contain_exactly(kept_dossier.id) } it { is_expected.to contain_exactly(kept_dossier.id) }
end end
context 'ignore time of day' do
let!(:kept_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: Time.zone.local(2018, 10, 17, 15, 56)) }
let!(:discarded_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: Time.zone.local(2018, 10, 18, 5, 42)) }
let(:filter) { [{ 'table' => 'self', 'column' => 'en_construction_at', 'value' => '17/10/2018 19:30' }] }
it { is_expected.to contain_exactly(kept_dossier.id) }
end
context 'for a malformed date' do context 'for a malformed date' do
context 'when its a string' do context 'when its a string' do
let(:filter) { [{ 'table' => 'self', 'column' => 'updated_at', 'value' => 'malformed date' }] } let(:filter) { [{ 'table' => 'self', 'column' => 'updated_at', 'value' => 'malformed date' }] }

View file

@ -439,9 +439,8 @@ describe Procedure do
it { expect(procedure.archived_at).to eq(nil) } it { expect(procedure.archived_at).to eq(nil) }
it { expect(procedure.published_at).to eq(now) } it { expect(procedure.published_at).to eq(now) }
it { expect(ProcedurePath.find_by(path: "example-path")).to be } it { expect(Procedure.find_by(path: "example-path")).to eq(procedure) }
it { expect(ProcedurePath.find_by(path: "example-path").procedure).to eq(procedure) } it { expect(Procedure.find_by(path: "example-path").administrateur).to eq(procedure.administrateur) }
it { expect(ProcedurePath.find_by(path: "example-path").administrateur).to eq(procedure.administrateur) }
end end
describe "#brouillon?" do describe "#brouillon?" do
@ -486,7 +485,6 @@ describe Procedure do
describe 'archive' do describe 'archive' do
let(:procedure) { create(:procedure, :published) } let(:procedure) { create(:procedure, :published) }
let(:procedure_path) { ProcedurePath.find(procedure.procedure_path.id) }
let(:now) { Time.zone.now.beginning_of_minute } let(:now) { Time.zone.now.beginning_of_minute }
before do before do
Timecop.freeze(now) Timecop.freeze(now)
@ -634,7 +632,7 @@ describe Procedure do
context "with a path" do context "with a path" do
let(:procedure) { create(:procedure, :published) } let(:procedure) { create(:procedure, :published) }
it { is_expected.to eq("dossiers_#{procedure.procedure_path.path}_2018-01-02_23-11") } it { is_expected.to eq("dossiers_#{procedure.path}_2018-01-02_23-11") }
end end
context "without a path" do context "without a path" do

View file

@ -53,7 +53,7 @@ describe 'admin/procedures/show.html.haml', type: :view do
end end
describe 'procedure link is present' do describe 'procedure link is present' do
it { expect(rendered).to have_content(commencer_url(procedure_path: procedure.path)) } it { expect(rendered).to have_content(commencer_url(path: procedure.path)) }
end end
end end