Merge branch 'develop' into staging

This commit is contained in:
Xavier J 2016-05-25 10:43:47 +02:00
commit ccd2754e58
104 changed files with 244165 additions and 265 deletions

2
.gitignore vendored
View file

@ -28,5 +28,7 @@ config/initializers/token.rb
doc/*.svg doc/*.svg
rubocop.html rubocop.html
config/france_connect.yml config/france_connect.yml
config/initializers/mailjet.rb
config/fog_credentials.yml
uploads/* uploads/*
coverage/**/* coverage/**/*

View file

@ -56,6 +56,8 @@ gem 'rest-client'
gem 'clamav-client', require: 'clamav/client' gem 'clamav-client', require: 'clamav/client'
gem 'carrierwave' gem 'carrierwave'
gem 'fog'
gem 'fog-openstack'
gem 'pg' gem 'pg'
@ -99,6 +101,7 @@ group :test do
gem 'guard' gem 'guard'
gem 'guard-rspec', require: false gem 'guard-rspec', require: false
gem 'guard-livereload', '~> 2.4', require: false gem 'guard-livereload', '~> 2.4', require: false
gem 'vcr'
end end
group :development, :test do group :development, :test do

View file

@ -9,6 +9,7 @@ GIT
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
CFPropertyList (2.3.2)
actionmailer (4.2.5.2) actionmailer (4.2.5.2)
actionpack (= 4.2.5.2) actionpack (= 4.2.5.2)
actionview (= 4.2.5.2) actionview (= 4.2.5.2)
@ -139,6 +140,7 @@ GEM
http_parser.rb (~> 0.6.0) http_parser.rb (~> 0.6.0)
erubis (2.7.0) erubis (2.7.0)
eventmachine (1.0.8) eventmachine (1.0.8)
excon (0.49.0)
execjs (2.5.2) execjs (2.5.2)
factory_girl (4.5.0) factory_girl (4.5.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
@ -146,6 +148,135 @@ GEM
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
fastercsv (1.5.5) fastercsv (1.5.5)
ffi (1.9.6) ffi (1.9.6)
fission (0.5.0)
CFPropertyList (~> 2.2)
fog (1.38.0)
fog-aliyun (>= 0.1.0)
fog-atmos
fog-aws (>= 0.6.0)
fog-brightbox (~> 0.4)
fog-cloudatcost (~> 0.1.0)
fog-core (~> 1.32)
fog-dynect (~> 0.0.2)
fog-ecloud (~> 0.1)
fog-google (<= 0.1.0)
fog-json
fog-local
fog-openstack
fog-powerdns (>= 0.1.1)
fog-profitbricks
fog-rackspace
fog-radosgw (>= 0.0.2)
fog-riakcs
fog-sakuracloud (>= 0.0.4)
fog-serverlove
fog-softlayer
fog-storm_on_demand
fog-terremark
fog-vmfusion
fog-voxel
fog-vsphere (>= 0.4.0)
fog-xenserver
fog-xml (~> 0.1.1)
ipaddress (~> 0.5)
fog-aliyun (0.1.0)
fog-core (~> 1.27)
fog-json (~> 1.0)
ipaddress (~> 0.8)
xml-simple (~> 1.1)
fog-atmos (0.1.0)
fog-core
fog-xml
fog-aws (0.9.2)
fog-core (~> 1.27)
fog-json (~> 1.0)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-brightbox (0.10.1)
fog-core (~> 1.22)
fog-json
inflecto (~> 0.0.2)
fog-cloudatcost (0.1.2)
fog-core (~> 1.36)
fog-json (~> 1.0)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-core (1.38.0)
builder
excon (~> 0.49)
formatador (~> 0.2)
fog-dynect (0.0.3)
fog-core
fog-json
fog-xml
fog-ecloud (0.3.0)
fog-core
fog-xml
fog-google (0.1.0)
fog-core
fog-json
fog-xml
fog-json (1.0.2)
fog-core (~> 1.0)
multi_json (~> 1.10)
fog-local (0.3.0)
fog-core (~> 1.27)
fog-openstack (0.1.5)
fog-core (>= 1.38)
fog-json (>= 1.0)
fog-xml (>= 0.1)
ipaddress (>= 0.8)
fog-powerdns (0.1.1)
fog-core (~> 1.27)
fog-json (~> 1.0)
fog-xml (~> 0.1)
fog-profitbricks (0.0.5)
fog-core
fog-xml
nokogiri
fog-rackspace (0.1.1)
fog-core (>= 1.35)
fog-json (>= 1.0)
fog-xml (>= 0.1)
ipaddress (>= 0.8)
fog-radosgw (0.0.5)
fog-core (>= 1.21.0)
fog-json
fog-xml (>= 0.0.1)
fog-riakcs (0.1.0)
fog-core
fog-json
fog-xml
fog-sakuracloud (1.7.5)
fog-core
fog-json
fog-serverlove (0.1.2)
fog-core
fog-json
fog-softlayer (1.1.1)
fog-core
fog-json
fog-storm_on_demand (0.1.1)
fog-core
fog-json
fog-terremark (0.1.0)
fog-core
fog-xml
fog-vmfusion (0.1.0)
fission
fog-core
fog-voxel (0.1.0)
fog-core
fog-xml
fog-vsphere (0.6.4)
fog-core
rbvmomi (~> 1.8)
fog-xenserver (0.2.3)
fog-core
fog-xml
fog-xml (0.1.2)
fog-core
nokogiri (~> 1.5, >= 1.5.11)
font-awesome-rails (4.4.0.0) font-awesome-rails (4.4.0.0)
railties (>= 3.2, < 5.0) railties (>= 3.2, < 5.0)
formatador (0.2.5) formatador (0.2.5)
@ -189,6 +320,8 @@ GEM
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
httpclient (2.6.0.1) httpclient (2.6.0.1)
i18n (0.7.0) i18n (0.7.0)
inflecto (0.0.2)
ipaddress (0.8.3)
jbuilder (2.3.1) jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5) activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2) multi_json (~> 1.2)
@ -316,6 +449,10 @@ GEM
rb-fsevent (0.9.6) rb-fsevent (0.9.6)
rb-inotify (0.9.5) rb-inotify (0.9.5)
ffi (>= 0.5.0) ffi (>= 0.5.0)
rbvmomi (1.8.2)
builder
nokogiri (>= 1.4.1)
trollop
rdoc (4.2.0) rdoc (4.2.0)
json (~> 1.4) json (~> 1.4)
ref (2.0.0) ref (2.0.0)
@ -430,6 +567,7 @@ GEM
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (1.4.1) tilt (1.4.1)
timecop (0.7.3) timecop (0.7.3)
trollop (2.1.2)
turbolinks (2.5.3) turbolinks (2.5.3)
coffee-rails coffee-rails
tzinfo (1.2.2) tzinfo (1.2.2)
@ -451,6 +589,7 @@ GEM
validate_url (1.0.2) validate_url (1.0.2)
activemodel (>= 3.0.0) activemodel (>= 3.0.0)
addressable addressable
vcr (3.0.1)
warden (1.2.3) warden (1.2.3)
rack (>= 1.0) rack (>= 1.0)
web-console (2.2.1) web-console (2.2.1)
@ -472,6 +611,7 @@ GEM
will_paginate (3.0.7) will_paginate (3.0.7)
will_paginate-bootstrap (1.0.1) will_paginate-bootstrap (1.0.1)
will_paginate (>= 3.0.3) will_paginate (>= 3.0.3)
xml-simple (1.1.5)
xpath (2.0.0) xpath (2.0.0)
nokogiri (~> 1.3) nokogiri (~> 1.3)
@ -497,6 +637,8 @@ DEPENDENCIES
devise devise
draper draper
factory_girl factory_girl
fog
fog-openstack
font-awesome-rails font-awesome-rails
guard guard
guard-livereload (~> 2.4) guard-livereload (~> 2.4)
@ -542,6 +684,7 @@ DEPENDENCIES
turbolinks turbolinks
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
unicorn unicorn
vcr
web-console (~> 2.0) web-console (~> 2.0)
webmock webmock
will_paginate-bootstrap will_paginate-bootstrap

View file

@ -31,6 +31,7 @@
//= require bootstrap-wysihtml5/locales/fr-FR //= require bootstrap-wysihtml5/locales/fr-FR
$(document).on('page:load', scroll_to); $(document).on('page:load', scroll_to);
$(document).ready(scroll_to); $(document).ready(scroll_to);

View file

@ -0,0 +1,30 @@
class Admin::AccompagnateursController < AdminController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
before_action :retrieve_procedure
def show
assign_scope = @procedure.gestionnaires
@accompagnateurs_assign = smart_listing_create :accompagnateurs_assign,
assign_scope,
partial: "admin/accompagnateurs/list_assign",
array: true
not_assign_scope = current_administrateur.gestionnaires.where.not(id: assign_scope.ids)
not_assign_scope = not_assign_scope.where("email LIKE '%#{params[:filter]}%'") if params[:filter]
@accompagnateurs_not_assign = smart_listing_create :accompagnateurs_not_assign,
not_assign_scope,
partial: "admin/accompagnateurs/list_not_assign",
array: true
end
def update
AccompagnateurService.change_assignement! Gestionnaire.find(params[:accompagnateur_id]), Procedure.find(params[:procedure_id]), params[:to]
flash.notice = "Assignement effectué"
redirect_to admin_procedure_accompagnateurs_path, procedure_id: params[:procedure_id]
end
end

View file

@ -4,37 +4,59 @@ class Admin::GestionnairesController < AdminController
def index def index
@gestionnaires = smart_listing_create :gestionnaires, @gestionnaires = smart_listing_create :gestionnaires,
current_administrateur.gestionnaires, current_administrateur.gestionnaires,
partial: "admin/gestionnaires/list", partial: "admin/gestionnaires/list",
array: true array: true
@gestionnaire ||= Gestionnaire.new @gestionnaire ||= Gestionnaire.new
end end
def create def create
@gestionnaire = Gestionnaire.create(create_gestionnaire_params) @gestionnaire = Gestionnaire.find_by_email(params[:gestionnaire][:email])
if @gestionnaire.errors.messages.empty? if @gestionnaire.nil?
flash.notice = 'Gestionnaire ajouté' new_gestionnaire!
GestionnaireMailer.new_gestionnaire(@gestionnaire.email, @gestionnaire.password).deliver_now!
else else
flash.alert = @gestionnaire.errors.full_messages.join('<br />').html_safe assign_gestionnaire!
end end
redirect_to admin_gestionnaires_path redirect_to admin_gestionnaires_path
end end
def destroy def destroy
Gestionnaire.find(params[:id]).destroy Gestionnaire.find(params[:id]).administrateurs.delete current_administrateur
redirect_to admin_gestionnaires_path redirect_to admin_gestionnaires_path
end end
def create_gestionnaire_params def create_gestionnaire_params
params.require(:gestionnaire).permit(:email) params.require(:gestionnaire).permit(:email)
.merge(administrateur_id: current_administrateur.id) .merge(password: SecureRandom.hex(5))
.merge(password: SecureRandom.hex(5)) .merge(administrateurs: [current_administrateur])
end end
private
def new_gestionnaire!
@gestionnaire = Gestionnaire.create(create_gestionnaire_params)
if @gestionnaire.errors.messages.empty?
flash.notice = 'Accompagnateur ajouté'
GestionnaireMailer.new_gestionnaire(@gestionnaire.email, @gestionnaire.password).deliver_now!
GestionnaireMailer.new_assignement(@gestionnaire.email, current_administrateur.email).deliver_now!
else
flash.alert = @gestionnaire.errors.full_messages.join('<br />').html_safe
end
end
def assign_gestionnaire!
if current_administrateur.gestionnaires.include? @gestionnaire
flash.alert = 'Accompagnateur déjà ajouté'
else
GestionnaireMailer.new_assignement(@gestionnaire.email, current_administrateur.email).deliver_now!
@gestionnaire.administrateurs.push current_administrateur
flash.notice = 'Accompagnateur ajouté'
#TODO Mailer no assign_to
end
end
end end

View file

@ -4,15 +4,19 @@ class GestionnaireMailer < ApplicationMailer
send_mail email, password, "Vous avez été nommé accompagnateur sur la plateforme TPS" send_mail email, password, "Vous avez été nommé accompagnateur sur la plateforme TPS"
end end
def new_assignement email, email_admin
send_mail email, email_admin, "Vous avez été assigné à un nouvel administrateur sur la plateforme TPS"
end
private private
def vars_mailer email, password def vars_mailer email, args
@password = password @args = args
@email = email @email = email
end end
def send_mail email, password, subject def send_mail email, args, subject
vars_mailer email, password vars_mailer email, args
mail(from: "tps@apientreprise.fr", to: email, mail(from: "tps@apientreprise.fr", to: email,
subject: subject) subject: subject)

View file

@ -1,10 +1,8 @@
class Administrateur < ActiveRecord::Base class Administrateur < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable :recoverable, :rememberable, :trackable, :validatable
has_many :gestionnaires has_and_belongs_to_many :gestionnaires
has_many :procedures has_many :procedures
before_save :ensure_api_token before_save :ensure_api_token

4
app/models/assign_to.rb Normal file
View file

@ -0,0 +1,4 @@
class AssignTo < ActiveRecord::Base
belongs_to :procedure
belongs_to :gestionnaire
end

View file

@ -11,7 +11,11 @@ class Cerfa < ActiveRecord::Base
def content_url def content_url
unless content.url.nil? unless content.url.nil?
(Downloader.new content, 'CERFA').url if Features.remote_storage
(RemoteDownloader.new content.filename).url
else
(LocalDownloader.new content.path, 'CERFA').url
end
end end
end end
end end

View file

@ -190,7 +190,7 @@ class Dossier < ActiveRecord::Base
def as_csv(options={}) def as_csv(options={})
dossier_attr = DossierSerializer.new(self).attributes dossier_attr = DossierSerializer.new(self).attributes
etablissement_attr = EtablissementSerializer.new(self.etablissement).attributes.map {|k, v| ["etablissement.#{k}", v] }.to_h etablissement_attr = EtablissementCsvSerializer.new(self.etablissement).attributes.map {|k, v| ["etablissement.#{k}", v] }.to_h
entreprise_attr = EntrepriseSerializer.new(self.entreprise).attributes.map {|k, v| ["entreprise.#{k}", v] }.to_h entreprise_attr = EntrepriseSerializer.new(self.entreprise).attributes.map {|k, v| ["entreprise.#{k}", v] }.to_h
dossier_attr.merge(etablissement_attr).merge(entreprise_attr) dossier_attr.merge(etablissement_attr).merge(entreprise_attr)
end end

View file

@ -1,12 +1,11 @@
class Gestionnaire < ActiveRecord::Base class Gestionnaire < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable :recoverable, :rememberable, :trackable, :validatable
belongs_to :administrateur has_and_belongs_to_many :administrateurs
has_many :procedures, through: :administrateur has_many :assign_to
has_many :procedures, through: :assign_to
has_many :dossiers, through: :procedures has_many :dossiers, through: :procedures
def dossiers_filter def dossiers_filter

View file

@ -19,8 +19,12 @@ class PieceJustificative < ActiveRecord::Base
def content_url def content_url
unless content.url.nil? unless content.url.nil?
(Downloader.new content, if Features.remote_storage
(type_de_piece_justificative.nil? ? content.file.original_filename : type_de_piece_justificative.libelle)).url (RemoteDownloader.new content.filename).url
else
(LocalDownloader.new content.path,
(type_de_piece_justificative.nil? ? content.original_filename : type_de_piece_justificative.libelle)).url
end
end end
end end

View file

@ -7,6 +7,9 @@ class Procedure < ActiveRecord::Base
belongs_to :administrateur belongs_to :administrateur
has_many :assign_to
has_many :gestionnaires, through: :assign_to
delegate :use_api_carto, to: :module_api_carto delegate :use_api_carto, to: :module_api_carto
accepts_nested_attributes_for :types_de_champ,:reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true accepts_nested_attributes_for :types_de_champ,:reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true

View file

@ -1,7 +1,15 @@
class Siret class Siret
include ActiveModel::Model include ActiveModel::Model
include ActiveModel::Validations::Callbacks
attr_accessor :siret attr_accessor :siret
validates_presence_of :siret validates_presence_of :siret
validates :siret, siret_format: true validates :siret, siret_format: true
before_validation :remove_whitespace
def remove_whitespace
siret.delete!(' ') unless siret.nil?
end
end end

View file

@ -0,0 +1,5 @@
class EtablissementCsvSerializer < EtablissementSerializer
def adresse
object.adresse.chomp.gsub("\r\n", ' ').gsub("\r", '')
end
end

View file

@ -11,4 +11,5 @@ class EtablissementSerializer < ActiveModel::Serializer
:code_postal, :code_postal,
:localite, :localite,
:code_insee_localite :code_insee_localite
end end

View file

@ -0,0 +1,12 @@
class AccompagnateurService
ASSIGN = 'assign'
NOT_ASSIGN = 'not_assign'
def self.change_assignement! accompagnateur, procedure, to
if to == ASSIGN
AssignTo.create(gestionnaire: accompagnateur, procedure: procedure)
elsif to == NOT_ASSIGN
AssignTo.delete_all(gestionnaire: accompagnateur, procedure: procedure)
end
end
end

View file

@ -1,40 +1,26 @@
# encoding: utf-8 # encoding: utf-8
class CerfaUploader < CarrierWave::Uploader::Base class CerfaUploader < CarrierWave::Uploader::Base
before :cache, :set_original_filename
# Include RMagick or MiniMagick support: # Choose what kind of storage to use for this uploader:
# include CarrierWave::RMagick if Features.remote_storage
# include CarrierWave::MiniMagick storage :fog
else
# Choose what kind of storage to use for this uploader: storage :file
storage :file end
# storage :fog
# Override the directory where uploaded files will be stored. # Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted: # This is a sensible default for uploaders that are meant to be mounted:
def store_dir def store_dir
"../uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" unless Features.remote_storage
"./uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end end
# Provide a default URL as a default if there hasn't been a file uploaded: def cache_dir
# def default_url '/tmp/tps-cache'
# # For Rails 3.1+ asset pipeline compatibility: end
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process :resize_to_fit => [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded. # Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this: # For images you might use something like this:
@ -42,10 +28,28 @@ class CerfaUploader < CarrierWave::Uploader::Base
%w(pdf doc docx xls xlsx ppt pptx odt ods odp) %w(pdf doc docx xls xlsx ppt pptx odt ods odp)
end end
# Override the filename of the uploaded files: def filename
# Avoid using model.id or version_name here, see uploader/store.rb for details. if original_filename.present? || model.content_secure_token
# def filename if Features.remote_storage
# "something.jpg" if original_filename filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
# end else
filename = "#{model.class.to_s.underscore}.#{file.extension.downcase}"
end
end
filename
end
private
def secure_token
model.content_secure_token ||= generate_secure_token
end
def generate_secure_token
SecureRandom.uuid
end
def set_original_filename(file)
model.original_filename ||= file.original_filename if file.respond_to?(:original_filename)
end
end end

View file

@ -1,6 +1,6 @@
require 'securerandom' require 'securerandom'
class Downloader class LocalDownloader
BASE_PATH_DISK = File.join(Rails.root, "public/downloads/") BASE_PATH_DISK = File.join(Rails.root, "public/downloads/")
def initialize(filename, filename_suffix = '') def initialize(filename, filename_suffix = '')

View file

@ -1,40 +1,26 @@
# encoding: utf-8 # encoding: utf-8
class PieceJustificativeUploader < CarrierWave::Uploader::Base class PieceJustificativeUploader < CarrierWave::Uploader::Base
before :cache, :set_original_filename
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader: # Choose what kind of storage to use for this uploader:
storage :file if Features.remote_storage
# storage :fog storage :fog
else
storage :file
end
# Override the directory where uploaded files will be stored. # Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted: # This is a sensible default for uploaders that are meant to be mounted:
def store_dir def store_dir
"../uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" unless Features.remote_storage
"./uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end end
# Provide a default URL as a default if there hasn't been a file uploaded: def cache_dir
# def default_url '/tmp/tps-cache'
# # For Rails 3.1+ asset pipeline compatibility: end
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process :resize_to_fit => [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded. # Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this: # For images you might use something like this:
@ -42,10 +28,32 @@ class PieceJustificativeUploader < CarrierWave::Uploader::Base
%w(pdf doc docx xls xlsx ppt pptx odt ods odp) %w(pdf doc docx xls xlsx ppt pptx odt ods odp)
end end
# Override the filename of the uploaded files: def filename
# Avoid using model.id or version_name here, see uploader/store.rb for details. if original_filename.present? || model.content_secure_token
# def filename if Features.remote_storage
# "something.jpg" if original_filename filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
# end else original_filename
filename = "#{model.class.to_s.underscore}.#{file.extension.downcase}"
end
end
filename
end
def original_filename
model.original_filename
end
private
def secure_token
model.content_secure_token ||= generate_secure_token
end
def generate_secure_token
SecureRandom.uuid
end
def set_original_filename(file)
model.original_filename ||= file.original_filename if file.respond_to?(:original_filename)
end
end end

View file

@ -2,39 +2,28 @@
class ProcedureLogoUploader < CarrierWave::Uploader::Base class ProcedureLogoUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support: def root
# include CarrierWave::RMagick File.join(Rails.root, "public")
# include CarrierWave::MiniMagick end
# Choose what kind of storage to use for this uploader: # Choose what kind of storage to use for this uploader:
storage :file if Features.remote_storage
# storage :fog storage :fog
else
storage :file
end
# Override the directory where uploaded files will be stored. # Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted: # This is a sensible default for uploaders that are meant to be mounted:
def store_dir def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" unless Features.remote_storage
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end end
# Provide a default URL as a default if there hasn't been a file uploaded: def cache_dir
# def default_url '/tmp/tps-cache'
# # For Rails 3.1+ asset pipeline compatibility: end
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process :resize_to_fit => [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded. # Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this: # For images you might use something like this:
@ -42,10 +31,25 @@ class ProcedureLogoUploader < CarrierWave::Uploader::Base
%w(jpg jpeg png) %w(jpg jpeg png)
end end
# Override the filename of the uploaded files: def filename
# Avoid using model.id or version_name here, see uploader/store.rb for details. if original_filename.present? || model.logo_secure_token
# def filename if Features.remote_storage
# "something.jpg" if original_filename filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
# end else
filename = "logo.#{file.extension.downcase}"
end
end
filename
end
private
def secure_token
model.logo_secure_token ||= generate_secure_token
end
def generate_secure_token
SecureRandom.uuid
end
end end

View file

@ -0,0 +1,11 @@
class RemoteDownloader
DEST_URL = "https://storage.apientreprise.fr/" + CarrierWave::Uploader::Base.fog_directory + '/'
def initialize(filename)
@filename = filename
end
def url
@url ||= File.join(DEST_URL, @filename)
end
end

View file

@ -0,0 +1,20 @@
.row{style:'height: 34px'}
- unless smart_listing.empty?
%table.table#liste_gestionnaire
%thead
%th Enlever
%th#email{style:'text-align: right'} Email
- @accompagnateurs_assign.each do |accompagnateur|
%tr
%td.col-md-1.col-lg-1.center
%a.btn.btn-primary{href: "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: AccompagnateurService::NOT_ASSIGN)}", 'data-method' => 'put'}
.fa.fa-arrow-left
%td{style:'padding-top: 11px; font-size:15px; text-align:right'}= accompagnateur.email
= smart_listing.paginate
= smart_listing.pagination_per_page_links
- else
%h4.center
Aucun d'affecté

View file

@ -0,0 +1,27 @@
= smart_listing_controls_for(:accompagnateurs_not_assign, {class: "form-inline text-right"}) do
.form-group.filter.input-append
= text_field_tag :filter, '', class: "search form-control",
placeholder: "Recherche...", autocomplete: :off
%button.btn.btn-primary{type: :submit}
%span.glyphicon.glyphicon-search
- unless smart_listing.empty?
%table.table#liste_gestionnaire
%thead
%th#email Email
%th Ajouter
- @accompagnateurs_not_assign.each do |accompagnateur|
%tr
%td.col-md-11.col-lg-11{style:'padding-top: 11px; font-size:15px'}= accompagnateur.email
%td.center
%a.btn.btn-success{href: "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: AccompagnateurService::ASSIGN)}", 'data-method' => 'put'}
.fa.fa-arrow-right
= smart_listing.paginate
= smart_listing.pagination_per_page_links
- else
%h4.center
Aucun de disponible

View file

@ -0,0 +1,19 @@
%h2.text-info
=@procedure.libelle
%br
%ul.nav.nav-tabs
= render partial: 'admin/procedures/navbar', locals: {active: 'Accompagnateurs'}
#accompagnateur_form
.row
.col-md-6.col-lg-6
%h3.text-info Disponibles
= smart_listing_render :accompagnateurs_not_assign
.col-md-6.col-lg-6
%h3.text-success Affectés
= smart_listing_render :accompagnateurs_assign

View file

@ -0,0 +1,3 @@
<%= smart_listing_update :accompagnateurs_not_assign %>
<%= smart_listing_update :accompagnateurs_assign %>

View file

@ -3,14 +3,7 @@
%br %br
%ul.nav.nav-tabs %ul.nav.nav-tabs
%li = render partial: 'admin/procedures/navbar', locals: {active: 'Pieces'}
= link_to('Informations', admin_procedure_path(@procedure))
%li
= link_to('Description', edit_admin_procedure_path(@procedure))
%li
= link_to('Champs', admin_procedure_types_de_champ_path(@procedure))
%li.active
= link_to('Pièces justificatives', admin_procedure_pieces_justificatives_path(@procedure))
#piece_justificative_form #piece_justificative_form
= render 'form' = render 'form'

View file

@ -0,0 +1,17 @@
%li{ class: ('active' if active == 'Informations') }
= link_to('Informations', admin_procedure_path(@procedure))
%li{ class: ('active' if active == 'Accompagnateurs') }
= link_to('Accompagnateurs', admin_procedure_accompagnateurs_path(@procedure))
%li{ class: ('disabled' if @procedure.locked?) || ('active' if active == 'Description') }
= link_to_unless(@procedure.locked?, 'Description', edit_admin_procedure_path(@procedure)) do
= link_to('Description', '#')
%li{ class: ('disabled' if @procedure.locked?) || ('active' if active == 'Champs') }
= link_to_unless(@procedure.locked?, 'Champs', admin_procedure_types_de_champ_path(@procedure)) do
= link_to('Champs', '#')
%li{ class: ('disabled' if @procedure.locked?) || ('active' if active == 'Pieces') }
= link_to_unless(@procedure.locked?, 'Pièces justificatives', admin_procedure_pieces_justificatives_path(@procedure)) do
= link_to('Pièces justificatives', '#')

View file

@ -3,14 +3,7 @@
%br %br
%ul.nav.nav-tabs %ul.nav.nav-tabs
%li = render partial: 'navbar', locals: {active: 'Description'}
= link_to('Informations', admin_procedure_path(@procedure))
%li.active
= link_to('Description', edit_admin_procedure_path(@procedure))
%li
= link_to('Champs', admin_procedure_types_de_champ_path(@procedure))
%li
= link_to('Pièces justificatives', admin_procedure_pieces_justificatives_path(@procedure))
#procedure_new.section.section-label #procedure_new.section.section-label
= 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|

View file

@ -4,21 +4,7 @@
%br %br
%ul.nav.nav-tabs %ul.nav.nav-tabs
%li.active = render partial: 'navbar', locals: {active: 'Informations'}
= link_to('Informations', admin_procedure_path(@facade.procedure))
%li{ class: ('disabled' if @facade.procedure.locked?) }
= link_to_unless(@facade.procedure.locked?, 'Description', edit_admin_procedure_path(@facade.procedure)) do
= link_to('Description', '#')
%li{ class: ('disabled' if @facade.procedure.locked?) }
= link_to_unless(@facade.procedure.locked?, 'Champs', admin_procedure_types_de_champ_path(@facade.procedure)) do
= link_to('Champs', '#')
%li{ class: ('disabled' if @facade.procedure.locked?) }
= link_to_unless(@facade.procedure.locked?, 'Pièces justificatives', admin_procedure_pieces_justificatives_path(@facade.procedure)) do
= link_to('Pièces justificatives', '#')
%li{style:'float:right'} %li{style:'float:right'}
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put do = form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put do

View file

@ -3,14 +3,7 @@
%br %br
%ul.nav.nav-tabs %ul.nav.nav-tabs
%li = render partial: 'admin/procedures/navbar', locals: {active: 'Champs'}
= link_to('Informations', admin_procedure_path(@procedure))
%li
= link_to('Description', edit_admin_procedure_path(@procedure))
%li.active
= link_to('Champs', admin_procedure_types_de_champ_path(@procedure))
%li
= link_to('Pièces justificatives', admin_procedure_pieces_justificatives_path(@procedure))
#liste_champ #liste_champ
= render partial: 'form' = render partial: 'form'

View file

@ -13,7 +13,7 @@
%li %li
= link_to(admin_gestionnaires_path) do = link_to(admin_gestionnaires_path) do
%i.fa.fa-user %i.fa.fa-user
&nbsp;Gestionnaires &nbsp;Accompagnateur
%li.divider{ role: :separator} %li.divider{ role: :separator}
%li %li
= link_to(admin_profile_path, id: :profile) do = link_to(admin_profile_path, id: :profile) do

View file

@ -0,0 +1,11 @@
Bienvenue sur la plateforme TPS
Vous venez d'être assigné à un administrateur sur la plateforme TPS. Voici quelques informations utiles :
URL : https://tps.apientreprise.fr/gestionnaires/sign_in
Email administrateur : <%= @args %>
Bonne journée,
---
L'équipe TPS - tps@apientreprise.fr

View file

@ -2,9 +2,9 @@ Bienvenue sur la plateforme TPS
Vous venez d'être nommé accompagnateur sur la plateforme TPS. Pour mémoire, voici quelques informations utiles : Vous venez d'être nommé accompagnateur sur la plateforme TPS. Pour mémoire, voici quelques informations utiles :
URL : https://tps.apientreprise.fr/gestionnaires/sign_in URL : <%= new_gestionnaire_session_url %>
Login : <%= @email %> Login : <%= @email %>
Mot de passe : <%= @password %> Mot de passe : <%= @args %>
Bonne journée, Bonne journée,

View file

@ -16,7 +16,7 @@
\- \-
%span#piece_justificative %span#piece_justificative
%b %b
= link_to com.piece_justificative.content.file.original_filename, com.piece_justificative.content_url, style:'color: green', target: '_blank' = link_to com.piece_justificative.original_filename, com.piece_justificative.content_url, style:'color: green', target: '_blank'
%br %br
.description#body .description#body

View file

@ -0,0 +1,32 @@
require_relative 'features'
if Rails.env.test?
Fog.credentials_path = Rails.root.join('config/fog_credentials.test.yml')
else
Fog.credentials_path = Rails.root.join('config/fog_credentials.yml')
end
CarrierWave.configure do |config|
# These permissions will make dir and files available only to the user running
# the servers
config.permissions = 0664
config.directory_permissions = 0775
if Features.remote_storage and not Rails.env.test?
config.fog_credentials = { provider: 'OpenStack' }
end
# This avoids uploaded files from saving to public/ and so
# they will not be available for public (non-authenticated) downloading
config.root = Rails.root
config.cache_dir = "#{Rails.root}/uploads"
config.fog_public = true
if Rails.env.production?
config.fog_directory = "tps"
else
config.fog_directory = "tps_dev"
end
end

View file

@ -0,0 +1,26 @@
require 'yaml'
# this class manage features
# Features must be added in file config/initializers/features.yml :
# feature_name: true
# other_feature: false
#
# this file is templated by ansible for staging and production so don't forget to add your features in
# ansible config
class Features
class << self
if File.exist?(File.dirname(__FILE__) + '/features.yml')
features_map = YAML.load_file(File.dirname(__FILE__) + '/features.yml')
if features_map
features_map.each do |feature, is_active|
define_method("#{feature}") do
is_active
end
end
end
def method_missing(method, *args)
false
end
end
end
end

View file

@ -0,0 +1 @@
remote_storage: false

View file

@ -13,6 +13,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.irregular 'piece_justificative', 'pieces_justificatives' inflect.irregular 'piece_justificative', 'pieces_justificatives'
inflect.irregular 'type_de_piece_justificative', 'types_de_piece_justificative' inflect.irregular 'type_de_piece_justificative', 'types_de_piece_justificative'
inflect.irregular 'type_de_champ', 'types_de_champ' inflect.irregular 'type_de_champ', 'types_de_champ'
inflect.irregular 'assign_to', 'assign_tos'
end end
# These inflection rules are supported but not enabled by default: # These inflection rules are supported but not enabled by default:

View file

@ -80,6 +80,7 @@ Rails.application.routes.draw do
get 'sign_in' => '/administrateurs/sessions#new' get 'sign_in' => '/administrateurs/sessions#new'
get 'procedures/archived' => 'procedures#archived' get 'procedures/archived' => 'procedures#archived'
get 'profile' => 'profile#show', as: :profile get 'profile' => 'profile#show', as: :profile
resources :procedures do resources :procedures do
resource :types_de_champ, only: [:show, :update] do resource :types_de_champ, only: [:show, :update] do
post '/:index/move_up' => 'types_de_champ#move_up', as: :move_up post '/:index/move_up' => 'types_de_champ#move_up', as: :move_up
@ -88,10 +89,18 @@ Rails.application.routes.draw do
put 'archive' => 'procedures#archive', as: :archive put 'archive' => 'procedures#archive', as: :archive
resource :accompagnateurs, only: [:show, :update]
resources :types_de_champ, only: [:destroy] resources :types_de_champ, only: [:destroy]
resource :pieces_justificatives, only: [:show, :update] resource :pieces_justificatives, only: [:show, :update]
resources :pieces_justificatives, only: :destroy resources :pieces_justificatives, only: :destroy
end end
namespace :accompagnateurs do
get 'show' #delete after fixed tests admin/accompagnateurs/show_spec without this line
end
resources :gestionnaires, only: [:index, :create, :destroy] resources :gestionnaires, only: [:index, :create, :destroy]
end end

View file

@ -0,0 +1,5 @@
class AddOriginalFilenameToPiecesJustificatives < ActiveRecord::Migration
def change
add_column :pieces_justificatives, :original_filename, :string
end
end

View file

@ -0,0 +1,5 @@
class AddOriginalFilenameToCerfas < ActiveRecord::Migration
def change
add_column :cerfas, :original_filename, :string
end
end

View file

@ -0,0 +1,5 @@
class AddContentSecureTokenToCerfas < ActiveRecord::Migration
def change
add_column :cerfas, :content_secure_token, :string
end
end

View file

@ -0,0 +1,5 @@
class AddContentSecureTokenToPiecesJustificatives < ActiveRecord::Migration
def change
add_column :pieces_justificatives, :content_secure_token, :string
end
end

View file

@ -0,0 +1,5 @@
class AddLogoSecureTokenToProcedures < ActiveRecord::Migration
def change
add_column :procedures, :logo_secure_token, :string
end
end

View file

@ -0,0 +1,32 @@
class AdminHasAndBelongGestionnaire < ActiveRecord::Migration
class Gestionnaire < ActiveRecord::Base
end
class AdministrateursGestionnaire < ActiveRecord::Base
end
def up
create_table :administrateurs_gestionnaires, id: false do |t|
t.belongs_to :administrateur, index: true
t.belongs_to :gestionnaire, index: true
end
Gestionnaire.all.each do |gestionnaire|
execute "insert into administrateurs_gestionnaires (gestionnaire_id, administrateur_id) values (#{gestionnaire.id}, #{gestionnaire.administrateur_id}) "
end
remove_column :gestionnaires, :administrateur_id
end
def down
add_column :gestionnaires, :administrateur_id, :integer
AdministrateursGestionnaire.all.each do |ag|
gestionnaire = Gestionnaire.find(ag.gestionnaire_id)
gestionnaire.administrateur_id = ag.administrateur_id
gestionnaire.save
end
drop_table :administrateurs_gestionnaires
end
end

View file

@ -0,0 +1,36 @@
class GestionnaireIsAssignToProcedure < ActiveRecord::Migration
class AssignTo < ActiveRecord::Base
belongs_to :gestionnaire
belongs_to :procedure
end
class Gestionnaire < ActiveRecord::Base
has_and_belongs_to_many :administrateurs
has_many :procedures, through: :assign_to
end
class Administrateur < ActiveRecord::Base
has_and_belongs_to_many :gestionnaires
has_many :procedures
end
class Procedure < ActiveRecord::Base
belongs_to :administrateur
has_many :gestionnaires, through: :assign_to
end
def change
create_table :assign_tos, id: false do |t|
t.belongs_to :gestionnaire, index: true
t.belongs_to :procedure, index: true
end
Administrateur.all.each do |administrateur|
administrateur.gestionnaires.each do |gestionnaire|
administrateur.procedures.each do |procedure|
AssignTo.create gestionnaire: gestionnaire, procedure: procedure
end
end
end
end
end

View file

@ -0,0 +1,5 @@
class AddForeignKeyAdmnistrateurGestionnaire < ActiveRecord::Migration
def change
add_index :administrateurs_gestionnaires, [:gestionnaire_id, :administrateur_id], unique: true, name: 'unique_couple_administrateur_gestionnaire'
end
end

View file

@ -0,0 +1,25 @@
class SetOriginalFilenameForUploaders < ActiveRecord::Migration
class PieceJustificative < ActiveRecord::Base
end
class Cerfa < ActiveRecord::Base
end
def change
PieceJustificative.all.each do |pj|
if pj.original_filename.nil?
pj.original_filename = pj.content
pj.save!
end
end
Cerfa.all.each do |cerfa|
if cerfa.original_filename.nil?
cerfa.original_filename = cerfa.content
cerfa.save!
end
end
end
end

View file

@ -11,7 +11,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: 20160419142017) do ActiveRecord::Schema.define(version: 20160524093540) 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"
@ -35,6 +35,15 @@ ActiveRecord::Schema.define(version: 20160419142017) do
add_index "administrateurs", ["email"], name: "index_administrateurs_on_email", unique: true, using: :btree add_index "administrateurs", ["email"], name: "index_administrateurs_on_email", unique: true, using: :btree
add_index "administrateurs", ["reset_password_token"], name: "index_administrateurs_on_reset_password_token", unique: true, using: :btree add_index "administrateurs", ["reset_password_token"], name: "index_administrateurs_on_reset_password_token", unique: true, using: :btree
create_table "administrateurs_gestionnaires", id: false, force: :cascade do |t|
t.integer "administrateur_id"
t.integer "gestionnaire_id"
end
add_index "administrateurs_gestionnaires", ["administrateur_id"], name: "index_administrateurs_gestionnaires_on_administrateur_id", using: :btree
add_index "administrateurs_gestionnaires", ["gestionnaire_id", "administrateur_id"], name: "unique_couple_administrateur_gestionnaire", unique: true, using: :btree
add_index "administrateurs_gestionnaires", ["gestionnaire_id"], name: "index_administrateurs_gestionnaires_on_gestionnaire_id", using: :btree
create_table "administrations", force: :cascade do |t| create_table "administrations", force: :cascade do |t|
t.string "email", default: "", null: false t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false t.string "encrypted_password", default: "", null: false
@ -53,6 +62,14 @@ ActiveRecord::Schema.define(version: 20160419142017) do
add_index "administrations", ["email"], name: "index_administrations_on_email", unique: true, using: :btree add_index "administrations", ["email"], name: "index_administrations_on_email", unique: true, using: :btree
add_index "administrations", ["reset_password_token"], name: "index_administrations_on_reset_password_token", unique: true, using: :btree add_index "administrations", ["reset_password_token"], name: "index_administrations_on_reset_password_token", unique: true, using: :btree
create_table "assign_tos", id: false, force: :cascade do |t|
t.integer "gestionnaire_id"
t.integer "procedure_id"
end
add_index "assign_tos", ["gestionnaire_id"], name: "index_assign_tos_on_gestionnaire_id", using: :btree
add_index "assign_tos", ["procedure_id"], name: "index_assign_tos_on_procedure_id", using: :btree
create_table "cadastres", force: :cascade do |t| create_table "cadastres", force: :cascade do |t|
t.string "surface_intersection" t.string "surface_intersection"
t.float "surface_parcelle" t.float "surface_parcelle"
@ -72,6 +89,8 @@ ActiveRecord::Schema.define(version: 20160419142017) do
t.integer "dossier_id" t.integer "dossier_id"
t.datetime "created_at" t.datetime "created_at"
t.integer "user_id" t.integer "user_id"
t.string "original_filename"
t.string "content_secure_token"
end end
add_index "cerfas", ["dossier_id"], name: "index_cerfas_on_dossier_id", using: :btree add_index "cerfas", ["dossier_id"], name: "index_cerfas_on_dossier_id", using: :btree
@ -174,7 +193,6 @@ ActiveRecord::Schema.define(version: 20160419142017) do
t.inet "last_sign_in_ip" t.inet "last_sign_in_ip"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "administrateur_id"
t.integer "procedure_filter", default: [], array: true t.integer "procedure_filter", default: [], array: true
end end
@ -203,6 +221,8 @@ ActiveRecord::Schema.define(version: 20160419142017) do
t.integer "type_de_piece_justificative_id" t.integer "type_de_piece_justificative_id"
t.datetime "created_at" t.datetime "created_at"
t.integer "user_id" t.integer "user_id"
t.string "original_filename"
t.string "content_secure_token"
end end
add_index "pieces_justificatives", ["type_de_piece_justificative_id"], name: "index_pieces_justificatives_on_type_de_piece_justificative_id", using: :btree add_index "pieces_justificatives", ["type_de_piece_justificative_id"], name: "index_pieces_justificatives_on_type_de_piece_justificative_id", using: :btree
@ -221,6 +241,7 @@ ActiveRecord::Schema.define(version: 20160419142017) do
t.boolean "euro_flag", default: false t.boolean "euro_flag", default: false
t.string "logo" t.string "logo"
t.boolean "cerfa_flag", default: false t.boolean "cerfa_flag", default: false
t.string "logo_secure_token"
end end
create_table "quartier_prioritaires", force: :cascade do |t| create_table "quartier_prioritaires", force: :cascade do |t|

View file

@ -4,6 +4,8 @@ namespace :dev do
puts 'start initialisation' puts 'start initialisation'
Rake::Task['dev:generate_token_file'].invoke Rake::Task['dev:generate_token_file'].invoke
Rake::Task['dev:generate_franceconnect_file'].invoke Rake::Task['dev:generate_franceconnect_file'].invoke
Rake::Task['dev:generate_fog_credentials_file'].invoke
Rake::Task['dev:generate_features_file'].invoke
puts 'end initialisation' puts 'end initialisation'
end end
@ -35,4 +37,29 @@ EOF
file.write(comment) file.write(comment)
file.close file.close
end end
task :generate_fog_credentials_file do
puts 'creating fog_credentials.test.yml file'
content = <<EOF
default:
openstack_tenant: "ovh_fake_tenant_name"
openstack_api_key: "ovh_fake_password"
openstack_username: "ovh_fake_username"
openstack_auth_url: "https://auth.cloud.ovh.net/v2.0/tokens"
openstack_region: "SBG1"
EOF
file = File.new("config/fog_credentials.test.yml", "w+")
file.write(content)
file.close
end
task :generate_features_file do
puts 'creating features.yml file'
content = <<EOF
remote_storage: true
EOF
file = File.new("config/initializers/features.yml", "w+")
file.write(content)
file.close
end
end end

View file

@ -0,0 +1,30 @@
require 'spec_helper'
describe Admin::AccompagnateursController, type: :controller do
let(:admin) { create(:administrateur) }
let(:procedure) { create :procedure, administrateur: admin }
let(:gestionnaire) { create :gestionnaire, administrateurs: [admin] }
before do
sign_in admin
end
describe 'GET #show' do
subject { get :show, procedure_id: procedure.id }
it { expect(subject.status).to eq(200) }
end
describe 'PUT #update' do
subject { put :update, accompagnateur_id: gestionnaire.id ,procedure_id: procedure.id }
it { expect(subject).to redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure.id) }
context 'when assignement is valid' do
before do
subject
end
it { expect(flash[:notice]).to be_present }
end
end
end

View file

@ -1,31 +1,40 @@
require 'spec_helper' require 'spec_helper'
describe Admin::GestionnairesController, type: :controller do describe Admin::GestionnairesController, type: :controller do
let(:admin) { create(:administrateur) } let(:admin) { create(:administrateur) }
let(:email_2) { 'plip@octo.com' }
let(:admin_2) { create :administrateur, email: email_2 }
before do before do
sign_in admin sign_in admin
end end
describe 'GET #index' do describe 'GET #index' do
subject { get :index } subject { get :index }
it { expect(subject.status).to eq(200) } it { expect(subject.status).to eq(200) }
end end
describe 'POST #create' do describe 'POST #create' do
let(:email) { 'test@plop.com' } let(:email) { 'test@plop.com' }
subject { post :create, gestionnaire: { email: email } } subject { post :create, gestionnaire: {email: email} }
context 'When email is valid' do context 'When email is valid' do
before do before do
subject subject
end end
let(:gestionnaire) { Gestionnaire.last }
it { expect(response.status).to eq(302) } it { expect(response.status).to eq(302) }
it { expect(response).to redirect_to admin_gestionnaires_path } it { expect(response).to redirect_to admin_gestionnaires_path }
describe 'Gestionnaire attributs in database' do describe 'Gestionnaire attributs in database' do
let(:gestionnaire) { Gestionnaire.last }
it { expect(gestionnaire.email).to eq(email) } it { expect(gestionnaire.email).to eq(email) }
it { expect(gestionnaire.administrateur_id).to eq(admin.id) } end
describe 'New gestionnaire is assign to the admin' do
it { expect(gestionnaire.administrateurs).to include admin }
it { expect(admin.gestionnaires).to include gestionnaire }
end end
end end
@ -33,77 +42,124 @@ describe Admin::GestionnairesController, type: :controller do
before do before do
subject subject
end end
let(:email) { 'piou' } let(:email) { 'piou' }
it { expect(response.status).to eq(302) }
it { expect{ response }.not_to change(Gestionnaire, :count) }
end
context 'when email is empty' do
before do
subject
end
let(:email) { '' }
it { expect(response.status).to eq(302) }
it { expect{ response }.not_to change(Gestionnaire, :count) }
it 'Notification email is not send' do
expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
expect(GestionnaireMailer).not_to receive(:deliver_now!)
end
end
context ' when email already exists' do
let(:email) { 'test@plop.com' }
before do
subject
post :create, gestionnaire: { email: email }
end
it { expect(response.status).to eq(302) } it { expect(response.status).to eq(302) }
it { expect{ response }.not_to change(Gestionnaire, :count) } it { expect { response }.not_to change(Gestionnaire, :count) }
end it { expect(flash[:alert]).to be_present }
context 'Email notification' do describe 'Email Notification' do
it 'Notification email is sent when email is valid' do
expect(GestionnaireMailer).to receive(:new_gestionnaire).and_return(GestionnaireMailer)
expect(GestionnaireMailer).to receive(:deliver_now!)
subject
end
context 'is not sent when email is not valid' do
let(:email) { 'testplop.com' }
it { it {
expect(GestionnaireMailer).not_to receive(:new_gestionnaire) expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
expect(GestionnaireMailer).not_to receive(:deliver_now!) expect(GestionnaireMailer).not_to receive(:deliver_now!)
subject subject
} }
end end
end
it 'is not sent when email already exists' do context 'when email is empty' do
before do
subject subject
end
let(:email) { '' }
it { expect(response.status).to eq(302) }
it { expect { response }.not_to change(Gestionnaire, :count) }
it 'Notification email is not send' do
expect(GestionnaireMailer).not_to receive(:new_gestionnaire) expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
expect(GestionnaireMailer).not_to receive(:deliver_now!) expect(GestionnaireMailer).not_to receive(:deliver_now!)
end
end
context 'when email is already assign at the admin' do
before do
create :gestionnaire, email: email, administrateurs: [admin]
subject subject
end end
it { expect(response.status).to eq(302) }
it { expect { response }.not_to change(Gestionnaire, :count) }
it { expect(flash[:alert]).to be_present }
describe 'Email notification' do
it 'is not sent when email already exists' do
expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
expect(GestionnaireMailer).not_to receive(:deliver_now!)
subject
end
end
end
context 'when an other admin will add the same email' do
let(:gestionnaire) { Gestionnaire.find_by_email(email) }
before do
create :gestionnaire, email: email, administrateurs: [admin]
sign_out admin
sign_in admin_2
subject
end
it { expect(response.status).to eq(302) }
it { expect { response }.not_to change(Gestionnaire, :count) }
it { expect(flash[:notice]).to be_present }
it { expect(admin_2.gestionnaires).to include gestionnaire }
it { expect(gestionnaire.administrateurs.size).to eq 2 }
end
context 'Email notification' do
it 'Notification email is sent when accompagnateur is create' do
expect(GestionnaireMailer).to receive(:new_gestionnaire).and_return(GestionnaireMailer)
expect(GestionnaireMailer).to receive(:deliver_now!)
subject
end
it 'Notification email is sent when accompagnateur is assign' do
expect(GestionnaireMailer).to receive(:new_assignement).and_return(GestionnaireMailer)
expect(GestionnaireMailer).to receive(:deliver_now!)
subject
end
context 'when accompagnateur is assign at a new admin' do
before do
create :gestionnaire, email: email, administrateurs: [admin]
sign_out admin
sign_in admin_2
end
it {
expect(GestionnaireMailer).to receive(:new_assignement).and_return(GestionnaireMailer)
expect(GestionnaireMailer).to receive(:deliver_now!)
subject
}
end
end end
end end
describe 'DELETE #destroy' do describe 'DELETE #destroy' do
let(:email) { 'test@plop.com' } let(:email) { 'test@plop.com' }
let!(:gestionnaire) { create :gestionnaire, email: email } let!(:admin) { create :administrateur }
let!(:gestionnaire) { create :gestionnaire, email: email, administrateurs: [admin] }
subject { delete :destroy, id: gestionnaire.id } subject { delete :destroy, id: gestionnaire.id }
context "when gestionaire_id is valid" do context "when gestionaire_id is valid" do
before do before do
subject subject
admin.reload
gestionnaire.reload
end end
it { expect(response.status).to eq(302) } it { expect(response.status).to eq(302) }
it { expect(response).to redirect_to admin_gestionnaires_path } it { expect(response).to redirect_to admin_gestionnaires_path }
it { expect{Gestionnaire.find(gestionnaire.id)}.to raise_error ActiveRecord::RecordNotFound} it { expect(admin.gestionnaires).not_to include gestionnaire }
it { expect(gestionnaire.administrateurs).not_to include admin }
end end
it { expect{subject}.to change(Gestionnaire, :count).by(-1) } it { expect { subject }.not_to change(Gestionnaire, :count) }
end end
end end

View file

@ -179,7 +179,7 @@ describe API::V1::DossiersController do
end end
end end
describe 'piece justificative' do describe 'piece justificative', vcr: { cassette_name: 'controllers_api_v1_dossiers_controller_piece_justificative' } do
before do before do
create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative: dossier.procedure.types_de_piece_justificative.first, user: dossier.user create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative: dossier.procedure.types_de_piece_justificative.first, user: dossier.user
end end
@ -249,7 +249,7 @@ describe API::V1::DossiersController do
it { expect(subject.first[:email]).to eq 'plop@plip.com' } it { expect(subject.first[:email]).to eq 'plop@plip.com' }
end end
describe 'cerfa' do describe 'cerfa', vcr: { cassette_name: 'controllers_api_v1_dossiers_controller_cerfa' } do
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :with_cerfa_upload, procedure: procedure) } } let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :with_cerfa_upload, procedure: procedure) } }
let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') } let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
@ -263,7 +263,11 @@ describe API::V1::DossiersController do
subject { super()[:cerfa].first } subject { super()[:cerfa].first }
it { expect(subject[:created_at]).not_to be_nil } it { expect(subject[:created_at]).not_to be_nil }
it { expect(subject[:url]).to match /^http:\/\/.*downloads.*_CERFA\.pdf$/ } if Features.remote_storage
it { expect(subject[:url]).to match /^https:\/\/storage.apientreprise.fr\/tps_dev\/cerfa-.*\.pdf$/ }
else
it { expect(subject[:url]).to match /^http:\/\/.*downloads.*_CERFA\.pdf$/ }
end
describe 'user' do describe 'user' do
let(:field_list) { [ let(:field_list) { [

View file

@ -21,7 +21,7 @@ describe Backoffice::CommentairesController, type: :controller do
end end
end end
context 'when document is upload whith a commentaire' do context 'when document is upload whith a commentaire', vcr: { cassette_name: 'controllers_backoffice_commentaires_controller_doc_upload_with_comment' } do
let(:document_upload) { Rack::Test::UploadedFile.new("./spec/support/files/piece_justificative_0.pdf", 'application/pdf') } let(:document_upload) { Rack::Test::UploadedFile.new("./spec/support/files/piece_justificative_0.pdf", 'application/pdf') }
subject do subject do

View file

@ -6,7 +6,7 @@ describe Backoffice::DossiersController, type: :controller do
let(:dossier_id) { dossier.id } let(:dossier_id) { dossier.id }
let(:bad_dossier_id) { Dossier.count + 10 } let(:bad_dossier_id) { Dossier.count + 10 }
let(:gestionnaire) { create(:gestionnaire, administrateur: create(:administrateur)) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [create(:administrateur)]) }
describe 'GET #show' do describe 'GET #show' do
context 'gestionnaire is connected' do context 'gestionnaire is connected' do

View file

@ -30,7 +30,7 @@ describe Users::CommentairesController, type: :controller do
end end
end end
context 'when document is upload whith a commentaire' do context 'when document is upload whith a commentaire', vcr: { cassette_name: 'controllers_sers_commentaires_controller_upload_doc' } do
let(:document_upload) { Rack::Test::UploadedFile.new("./spec/support/files/piece_justificative_0.pdf", 'application/pdf') } let(:document_upload) { Rack::Test::UploadedFile.new("./spec/support/files/piece_justificative_0.pdf", 'application/pdf') }
subject do subject do

View file

@ -1,6 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe Users::DescriptionController, type: :controller do describe Users::DescriptionController, type: :controller, vcr: { cassette_name: 'controllers_users_description_controller' } do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: true) } let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: true) }
@ -125,7 +125,7 @@ describe Users::DescriptionController, type: :controller do
end end
context 'Quand la procédure accepte les CERFA' do context 'Quand la procédure accepte les CERFA' do
context 'Sauvegarde du CERFA PDF' do context 'Sauvegarde du CERFA PDF', vcr: { cassette_name: 'controllers_users_description_controller_save_cerfa' } do
before do before do
post :create, dossier_id: dossier_id, post :create, dossier_id: dossier_id,
nom_projet: nom_projet, nom_projet: nom_projet,
@ -134,11 +134,15 @@ describe Users::DescriptionController, type: :controller do
dossier.reload dossier.reload
end end
context 'when a CERFA PDF is send' do context 'when a CERFA PDF is sent', vcr: { cassette_name: 'controllers_users_description_controller_cerfa_is_sent' } do
subject { dossier.cerfa.first } subject { dossier.cerfa.first }
it 'content' do it 'content' do
expect(subject['content']).to eq(name_piece_justificative) if Features.remote_storage
expect(subject['content']).to eq('cerfa-3dbb3535-5388-4a37-bc2d-778327b9f999.pdf')
else
expect(subject['content']).to eq('cerfa.pdf')
end
end end
it 'dossier_id' do it 'dossier_id' do
@ -212,7 +216,7 @@ describe Users::DescriptionController, type: :controller do
end end
end end
context 'Sauvegarde des pièces justificatives' do context 'Sauvegarde des pièces justificatives', vcr: { cassette_name: 'controllers_users_description_controller_sauvegarde_pj' } do
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids } let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
before do before do
post :create, {dossier_id: dossier_id, post :create, {dossier_id: dossier_id,
@ -223,7 +227,7 @@ describe Users::DescriptionController, type: :controller do
dossier.reload dossier.reload
end end
describe 'clamav anti-virus presence' do describe 'clamav anti-virus presence', vcr: { cassette_name: 'controllers_users_description_controller_clamav_presence' } do
it 'ClamavService safe_file? is call' do it 'ClamavService safe_file? is call' do
expect(ClamavService).to receive(:safe_file?).twice expect(ClamavService).to receive(:safe_file?).twice
@ -250,7 +254,7 @@ describe Users::DescriptionController, type: :controller do
end end
end end
describe 'POST #pieces_justificatives' do describe 'POST #pieces_justificatives', vcr: { cassette_name: 'controllers_users_description_controller_pieces_justificatives' } do
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids } let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
subject { patch :pieces_justificatives, {dossier_id: dossier.id, subject { patch :pieces_justificatives, {dossier_id: dossier.id,
@ -277,7 +281,7 @@ describe Users::DescriptionController, type: :controller do
end end
end end
context 'when PJ have already a document' do context 'when PJ have already a document', vcr: { cassette_name: 'controllers_users_description_controller_pj_already_exist' } do
before do before do
create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative_id: all_pj_type[0] create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative_id: all_pj_type[0]
create :piece_justificative, :contrat, dossier: dossier, type_de_piece_justificative_id: all_pj_type[1] create :piece_justificative, :contrat, dossier: dossier, type_de_piece_justificative_id: all_pj_type[1]
@ -285,7 +289,7 @@ describe Users::DescriptionController, type: :controller do
it { expect(dossier.pieces_justificatives.size).to eq 2 } it { expect(dossier.pieces_justificatives.size).to eq 2 }
context 'when upload two PJ' do context 'when upload two PJ', vcr: { cassette_name: 'controllers_users_description_controller_pj_already_exist_upload_2pj' } do
before do before do
subject subject
dossier.reload dossier.reload
@ -347,7 +351,7 @@ describe Users::DescriptionController, type: :controller do
it { expect(dossier.pieces_justificatives.size).to eq 2 } it { expect(dossier.pieces_justificatives.size).to eq 2 }
context 'when upload two PJ' do context 'when upload two PJ', vcr: { cassette_name: 'controllers_users_description_controller_upload_2pj' } do
before do before do
subject subject
dossier.reload dossier.reload

View file

@ -17,6 +17,7 @@ describe Users::DossiersController, type: :controller do
let(:siren) { dossier.siren } let(:siren) { dossier.siren }
let(:siret) { dossier.siret } let(:siret) { dossier.siret }
let(:siret_with_whitespaces) { '440 1176 2001 530' }
let(:bad_siret) { 1 } let(:bad_siret) { 1 }
describe 'GET #show' do describe 'GET #show' do
@ -103,12 +104,12 @@ describe Users::DossiersController, type: :controller do
describe 'dossier attributs' do describe 'dossier attributs' do
let(:user) { create(:user) } let(:user) { create(:user) }
context 'with valid siret ' do shared_examples 'with valid siret' do
before do before do
sign_in user sign_in user
end end
subject { post :create, dossier: {siret: siret, procedure_id: Procedure.last} } subject { post :create, dossier: {siret: example_siret, procedure_id: Procedure.last} }
it 'create a dossier' do it 'create a dossier' do
expect { subject }.to change { Dossier.count }.by(1) expect { subject }.to change { Dossier.count }.by(1)
@ -215,6 +216,16 @@ describe Users::DossiersController, type: :controller do
end end
end end
describe "with siret without whitespaces" do
let(:example_siret) { siret }
it_should_behave_like "with valid siret"
end
describe "with siret with whitespaces" do
let(:example_siret) { siret_with_whitespaces }
it_should_behave_like "with valid siret"
end
context 'with non existant siret' do context 'with non existant siret' do
before do before do
sign_in create(:user) sign_in create(:user)

View file

@ -0,0 +1,4 @@
FactoryGirl.define do
factory :assign_to do
end
end

View file

@ -21,7 +21,7 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do
end end
context 'when user enter good credentials' do context 'when user enter good credentials' do
let(:administrateur) { create(:administrateur) } let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
before do before do
page.find_by_id(:gestionnaire_email).set gestionnaire.email page.find_by_id(:gestionnaire_email).set gestionnaire.email

View file

@ -2,13 +2,16 @@ require 'spec_helper'
feature 'on backoffice page' do feature 'on backoffice page' do
let(:administrateur) { create(:administrateur) } let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
let(:procedure) { create(:procedure, administrateur: administrateur) } let(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
before do before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
visit backoffice_path visit backoffice_path
end end
context 'when gestionnaire is logged in' do context 'when gestionnaire is logged in' do
before do before do
page.find_by_id(:gestionnaire_email).set gestionnaire.email page.find_by_id(:gestionnaire_email).set gestionnaire.email

View file

@ -2,7 +2,7 @@ require 'spec_helper'
feature 'on click on tabs button' do feature 'on click on tabs button' do
let(:administrateur) { create(:administrateur) } let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
before do before do
login_as gestionnaire, scope: :gestionnaire login_as gestionnaire, scope: :gestionnaire

View file

@ -2,7 +2,7 @@ require 'spec_helper'
feature 'search file on gestionnaire backoffice' do feature 'search file on gestionnaire backoffice' do
let(:administrateur) { create(:administrateur) } let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
before do before do
login_as gestionnaire, scope: :gestionnaire login_as gestionnaire, scope: :gestionnaire
@ -11,8 +11,11 @@ feature 'search file on gestionnaire backoffice' do
context 'when gestionnaire is logged in' do context 'when gestionnaire is logged in' do
context 'when he click on search button' do context 'when he click on search button' do
let(:terms) { '' } let(:terms) { '' }
let!(:procedure) { create(:procedure, administrateur: administrateur) }
before do before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
visit backoffice_dossiers_url visit backoffice_dossiers_url
page.find_by_id(:q).set terms page.find_by_id(:q).set terms
page.find_by_id(:search_button).click page.find_by_id(:search_button).click
@ -36,7 +39,6 @@ feature 'search file on gestionnaire backoffice' do
end end
context 'when terms input does return result' do context 'when terms input does return result' do
let!(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated', nom_projet: 'Projet de test') } let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated', nom_projet: 'Projet de test') }

View file

@ -34,7 +34,7 @@ feature 'user is on description page' do
end end
end end
end end
context 'he adds cerfa' do context 'he adds cerfa', vcr: { cassette_name: 'description_page_upload_piece_justificative_adds_cerfa' } do
before do before do
attach_file('cerfa_pdf', File.path('spec/support/files/dossierPDF.pdf')) attach_file('cerfa_pdf', File.path('spec/support/files/dossierPDF.pdf'))
click_on("Soumettre mon dossier") click_on("Soumettre mon dossier")
@ -44,7 +44,7 @@ feature 'user is on description page' do
expect(dossier.cerfa).not_to be_empty expect(dossier.cerfa).not_to be_empty
end end
end end
context 'when he adds a piece_justificative and submit form' do context 'when he adds a piece_justificative and submit form', vcr: { cassette_name: 'description_page_upload_piece_justificative_adds_cerfa_and_submit' } do
before do before do
file_input_id = 'piece_justificative_' + dossier.types_de_piece_justificative.first.id.to_s file_input_id = 'piece_justificative_' + dossier.types_de_piece_justificative.first.id.to_s
attach_file(file_input_id, File.path('spec/support/files/dossierPDF.pdf')) attach_file(file_input_id, File.path('spec/support/files/dossierPDF.pdf'))

View file

@ -25,7 +25,7 @@ feature 'drawing a zone with freedraw' do
end end
context 'when procedure have api carto activated' do context 'when procedure have api carto activated' do
scenario 'he is redirected to carte page' do scenario 'he is redirected to carte page', vcr: { cassette_name: 'drawing_a_zone_with_freedraw_redirected_to_carte_page' } do
expect(page).to have_css('.content #map') expect(page).to have_css('.content #map')
end end
end end
@ -42,7 +42,7 @@ feature 'drawing a zone with freedraw' do
end end
end end
context 'when draw a zone on #map', js: true do context 'when draw a zone on #map', js: true, vcr: { cassette_name: 'drawing_a_zone_with_freedraw_when_draw_a_zone_on_map' } do
context 'when module quartiers prioritaires is activated' do context 'when module quartiers prioritaires is activated' do
let(:module_api_carto) { create(:module_api_carto, :with_quartiers_prioritaires) } let(:module_api_carto) { create(:module_api_carto, :with_quartiers_prioritaires) }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,143 @@
---
http_interactions:
- request:
method: post
uri: https://auth.cloud.ovh.net/v2.0/tokens
body:
encoding: UTF-8
string: '{"auth":{"passwordCredentials":{"username":"ovh_fake_username","password":"ovh_fake_password"},"tenantName":"ovh_fake_tenant_name"}}'
headers:
User-Agent:
- fog/1.38.0 fog-core/1.38.0
Content-Type:
- application/json
response:
status:
code: 200
message: ''
headers:
Vary:
- X-Auth-Token
Content-Type:
- application/json
Content-Length:
- '7079'
Date:
- Thu, 12 May 2016 14:05:17 GMT
Connection:
- close
body:
encoding: UTF-8
string: '{"access": {"token": {"issued_at": "2016-05-12T14:05:17.214079", "expires":
"2016-05-13T14:05:17Z", "id": "ff665d4700654b6d9c94964dfc1a262f", "tenant":
{"id": "a24c37ed11a84896914514384898c34b", "enabled": true, "name": "2627898119540674",
"description": "apientreprise"}, "audit_ids": ["Y2ixVCRJQe-D6IN-cPQQsw"]},
"serviceCatalog": [{"endpoints": [{"adminURL": "https://compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "GRA1", "internalURL": "https://compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "17f6ef1cc63e492ab8d3f2bda8428cb0", "publicURL": "https://compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "BHS1", "internalURL": "https://compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "21fdd202afd04470bbaf84f9396d0dcc", "publicURL": "https://compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "SBG1", "internalURL": "https://compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "a707bffedf1c4b80a124c585c67c1639", "publicURL": "https://compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"}],
"endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL":
"https://network.compute.gra1.cloud.ovh.net/", "region": "GRA1", "internalURL":
"https://network.compute.gra1.cloud.ovh.net/", "id": "26a339a8c7d5463f89ca937068ebbcd4",
"publicURL": "https://network.compute.gra1.cloud.ovh.net/"}, {"adminURL":
"https://network.compute.bhs1.cloud.ovh.net/", "region": "BHS1", "internalURL":
"https://network.compute.bhs1.cloud.ovh.net/", "id": "3fe2326789ec4e37af2e6b2c80a90876",
"publicURL": "https://network.compute.bhs1.cloud.ovh.net/"}, {"adminURL":
"https://network.compute.sbg1.cloud.ovh.net/", "region": "SBG1", "internalURL":
"https://network.compute.sbg1.cloud.ovh.net/", "id": "075839111e7a41f1bb458926e5f04cec",
"publicURL": "https://network.compute.sbg1.cloud.ovh.net/"}], "endpoints_links":
[], "type": "network", "name": "neutron"}, {"endpoints": [{"adminURL": "https://volume.compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "GRA1", "internalURL": "https://volume.compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "7231957fdf0346e5adebe860ac5e5e57", "publicURL": "https://volume.compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://volume.compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "BHS1", "internalURL": "https://volume.compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "2f5b68f95d7b4b1fad1a683dac8e8ca3", "publicURL": "https://volume.compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://volume.compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "SBG1", "internalURL": "https://volume.compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "021b61bd7313479e8f8d77d21c7b434a", "publicURL": "https://volume.compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"}],
"endpoints_links": [], "type": "volumev2", "name": "cinderv2"}, {"endpoints":
[{"adminURL": "https://image.compute.gra1.cloud.ovh.net/", "region": "GRA1",
"internalURL": "https://image.compute.gra1.cloud.ovh.net/", "id": "56795c82f1744e47b7782f1fc2407212",
"publicURL": "https://image.compute.gra1.cloud.ovh.net/"}, {"adminURL": "https://image.compute.bhs1.cloud.ovh.net/",
"region": "BHS1", "internalURL": "https://image.compute.bhs1.cloud.ovh.net/",
"id": "5eaa4cbe80354ea482f2b0477c9c16f0", "publicURL": "https://image.compute.bhs1.cloud.ovh.net/"},
{"adminURL": "https://image.compute.sbg1.cloud.ovh.net/", "region": "SBG1",
"internalURL": "https://image.compute.sbg1.cloud.ovh.net/", "id": "15758b246d1340e887a2170bd3399071",
"publicURL": "https://image.compute.sbg1.cloud.ovh.net/"}], "endpoints_links":
[], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "https://volume.compute.gra1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"region": "GRA1", "internalURL": "https://volume.compute.gra1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"id": "a6936c8876c1490cbf91d0707e78d350", "publicURL": "https://volume.compute.gra1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://volume.compute.bhs1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"region": "BHS1", "internalURL": "https://volume.compute.bhs1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"id": "43bc107cf78448faa9e5a6b3a5ca48dd", "publicURL": "https://volume.compute.bhs1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://volume.compute.sbg1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"region": "SBG1", "internalURL": "https://volume.compute.sbg1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"id": "2be04ee1ddb148c19e91d3da5934fa55", "publicURL": "https://volume.compute.sbg1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b"}],
"endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints":
[{"adminURL": "https://storage.gra1.cloud.ovh.net", "region": "GRA1", "internalURL":
"http://127.0.0.1:8888/v1/AUTH_a24c37ed11a84896914514384898c34b", "id": "c96f61d071a74e36bd3c07e53d241ce3",
"publicURL": "https://storage.gra1.cloud.ovh.net/v1/AUTH_a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://storage.bhs1.cloud.ovh.net:8888/", "region": "BHS1",
"internalURL": "http://127.0.0.1:8888/v1/AUTH_a24c37ed11a84896914514384898c34b",
"id": "3327534a1a824389aae5d663b9821d67", "publicURL": "https://storage.bhs1.cloud.ovh.net/v1/AUTH_a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://storage.sbg1.cloud.ovh.net", "region": "SBG1", "internalURL":
"http://127.0.0.1:8888/v1/AUTH_a24c37ed11a84896914514384898c34b", "id": "2af96b87ad484cb7879a9ea554d5418c",
"publicURL": "https://storage.sbg1.cloud.ovh.net/v1/AUTH_a24c37ed11a84896914514384898c34b"}],
"endpoints_links": [], "type": "object-store", "name": "swift"}, {"endpoints":
[{"adminURL": "https://auth.cloud.ovh.net:35357/v2.0", "region": "GRA1", "internalURL":
"http://127.0.0.1:5000/v2.0", "id": "62101e498fc3404dbc18ec80888992cb", "publicURL":
"https://auth.cloud.ovh.net/v2.0"}, {"adminURL": "https://auth.cloud.ovh.net:35357/v2.0",
"region": "BHS1", "internalURL": "http://127.0.0.1:5000/v2.0", "id": "00e403276b3246c4a5c54dc7133f9f0a",
"publicURL": "https://auth.cloud.ovh.net/v2.0"}, {"adminURL": "https://auth.cloud.ovh.net:35357/v2.0",
"region": "SBG1", "internalURL": "http://127.0.0.1:5000/v2.0", "id": "6094ef2ed9f240ed9b648dfcc0d9f923",
"publicURL": "https://auth.cloud.ovh.net/v2.0"}], "endpoints_links": [], "type":
"identity", "name": "keystone"}], "user": {"username": "MhsuDbK4DsPr", "roles_links":
[], "id": "43914cf4645747ba90d075c62ebb5018", "roles": [{"name": "_member_"}],
"name": "MhsuDbK4DsPr"}, "metadata": {"is_admin": 0, "roles": ["9fe2ff9ee4384b1894a90878d3e92bab"]}}}'
http_version:
recorded_at: Thu, 12 May 2016 14:05:17 GMT
- request:
method: get
uri: http://api-adresse.data.gouv.fr/search?limit=1&q=6%20RUE%20RAOUL%20NORDLING%20IMMEUBLE%20BORA%2092270%20BOIS%20COLOMBES
body:
encoding: US-ASCII
string: ''
headers:
Accept:
- "*/*; q=0.5, application/xml"
Accept-Encoding:
- gzip, deflate
User-Agent:
- Ruby
response:
status:
code: 200
message: OK
headers:
Server:
- nginx/1.6.2
Date:
- Thu, 12 May 2016 14:13:15 GMT
Content-Type:
- application/json; charset=utf-8
Content-Length:
- '189'
Connection:
- keep-alive
Access-Control-Allow-Origin:
- "*"
Access-Control-Allow-Headers:
- X-Requested-With
body:
encoding: UTF-8
string: '{"limit": 1, "attribution": "BAN", "version": "draft", "licence": "ODbL
1.0", "query": "6 RUE RAOUL NORDLING IMMEUBLE BORA 92270 BOIS COLOMBES", "type":
"FeatureCollection", "features": []}'
http_version:
recorded_at: Thu, 12 May 2016 14:13:16 GMT
recorded_with: VCR 3.0.1

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,104 @@
---
http_interactions:
- request:
method: post
uri: https://auth.cloud.ovh.net/v2.0/tokens
body:
encoding: UTF-8
string: '{"auth":{"passwordCredentials":{"username":"ovh_fake_username","password":"ovh_fake_password"},"tenantName":"ovh_fake_tenant_name"}}'
headers:
User-Agent:
- fog/1.38.0 fog-core/1.38.0
Content-Type:
- application/json
response:
status:
code: 200
message: ''
headers:
Vary:
- X-Auth-Token
Content-Type:
- application/json
Content-Length:
- '7079'
Date:
- Thu, 12 May 2016 13:58:56 GMT
Connection:
- close
body:
encoding: UTF-8
string: '{"access": {"token": {"issued_at": "2016-05-12T13:58:56.448274", "expires":
"2016-05-13T13:58:56Z", "id": "b80279bbdb5040b0901870d040c56dda", "tenant":
{"id": "a24c37ed11a84896914514384898c34b", "enabled": true, "name": "2627898119540674",
"description": "apientreprise"}, "audit_ids": ["b2vx3mXxTBOpADiqbwFo3Q"]},
"serviceCatalog": [{"endpoints": [{"adminURL": "https://compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "GRA1", "internalURL": "https://compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "17f6ef1cc63e492ab8d3f2bda8428cb0", "publicURL": "https://compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "BHS1", "internalURL": "https://compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "21fdd202afd04470bbaf84f9396d0dcc", "publicURL": "https://compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "SBG1", "internalURL": "https://compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "a707bffedf1c4b80a124c585c67c1639", "publicURL": "https://compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"}],
"endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL":
"https://network.compute.gra1.cloud.ovh.net/", "region": "GRA1", "internalURL":
"https://network.compute.gra1.cloud.ovh.net/", "id": "26a339a8c7d5463f89ca937068ebbcd4",
"publicURL": "https://network.compute.gra1.cloud.ovh.net/"}, {"adminURL":
"https://network.compute.bhs1.cloud.ovh.net/", "region": "BHS1", "internalURL":
"https://network.compute.bhs1.cloud.ovh.net/", "id": "3fe2326789ec4e37af2e6b2c80a90876",
"publicURL": "https://network.compute.bhs1.cloud.ovh.net/"}, {"adminURL":
"https://network.compute.sbg1.cloud.ovh.net/", "region": "SBG1", "internalURL":
"https://network.compute.sbg1.cloud.ovh.net/", "id": "075839111e7a41f1bb458926e5f04cec",
"publicURL": "https://network.compute.sbg1.cloud.ovh.net/"}], "endpoints_links":
[], "type": "network", "name": "neutron"}, {"endpoints": [{"adminURL": "https://volume.compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "GRA1", "internalURL": "https://volume.compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "7231957fdf0346e5adebe860ac5e5e57", "publicURL": "https://volume.compute.gra1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://volume.compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "BHS1", "internalURL": "https://volume.compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "2f5b68f95d7b4b1fad1a683dac8e8ca3", "publicURL": "https://volume.compute.bhs1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://volume.compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"region": "SBG1", "internalURL": "https://volume.compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b",
"id": "021b61bd7313479e8f8d77d21c7b434a", "publicURL": "https://volume.compute.sbg1.cloud.ovh.net/v2/a24c37ed11a84896914514384898c34b"}],
"endpoints_links": [], "type": "volumev2", "name": "cinderv2"}, {"endpoints":
[{"adminURL": "https://image.compute.gra1.cloud.ovh.net/", "region": "GRA1",
"internalURL": "https://image.compute.gra1.cloud.ovh.net/", "id": "56795c82f1744e47b7782f1fc2407212",
"publicURL": "https://image.compute.gra1.cloud.ovh.net/"}, {"adminURL": "https://image.compute.bhs1.cloud.ovh.net/",
"region": "BHS1", "internalURL": "https://image.compute.bhs1.cloud.ovh.net/",
"id": "5eaa4cbe80354ea482f2b0477c9c16f0", "publicURL": "https://image.compute.bhs1.cloud.ovh.net/"},
{"adminURL": "https://image.compute.sbg1.cloud.ovh.net/", "region": "SBG1",
"internalURL": "https://image.compute.sbg1.cloud.ovh.net/", "id": "15758b246d1340e887a2170bd3399071",
"publicURL": "https://image.compute.sbg1.cloud.ovh.net/"}], "endpoints_links":
[], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "https://volume.compute.gra1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"region": "GRA1", "internalURL": "https://volume.compute.gra1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"id": "a6936c8876c1490cbf91d0707e78d350", "publicURL": "https://volume.compute.gra1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://volume.compute.bhs1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"region": "BHS1", "internalURL": "https://volume.compute.bhs1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"id": "43bc107cf78448faa9e5a6b3a5ca48dd", "publicURL": "https://volume.compute.bhs1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://volume.compute.sbg1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"region": "SBG1", "internalURL": "https://volume.compute.sbg1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b",
"id": "2be04ee1ddb148c19e91d3da5934fa55", "publicURL": "https://volume.compute.sbg1.cloud.ovh.net/v1/a24c37ed11a84896914514384898c34b"}],
"endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints":
[{"adminURL": "https://storage.gra1.cloud.ovh.net", "region": "GRA1", "internalURL":
"http://127.0.0.1:8888/v1/AUTH_a24c37ed11a84896914514384898c34b", "id": "c96f61d071a74e36bd3c07e53d241ce3",
"publicURL": "https://storage.gra1.cloud.ovh.net/v1/AUTH_a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://storage.bhs1.cloud.ovh.net:8888/", "region": "BHS1",
"internalURL": "http://127.0.0.1:8888/v1/AUTH_a24c37ed11a84896914514384898c34b",
"id": "3327534a1a824389aae5d663b9821d67", "publicURL": "https://storage.bhs1.cloud.ovh.net/v1/AUTH_a24c37ed11a84896914514384898c34b"},
{"adminURL": "https://storage.sbg1.cloud.ovh.net", "region": "SBG1", "internalURL":
"http://127.0.0.1:8888/v1/AUTH_a24c37ed11a84896914514384898c34b", "id": "2af96b87ad484cb7879a9ea554d5418c",
"publicURL": "https://storage.sbg1.cloud.ovh.net/v1/AUTH_a24c37ed11a84896914514384898c34b"}],
"endpoints_links": [], "type": "object-store", "name": "swift"}, {"endpoints":
[{"adminURL": "https://auth.cloud.ovh.net:35357/v2.0", "region": "GRA1", "internalURL":
"http://127.0.0.1:5000/v2.0", "id": "62101e498fc3404dbc18ec80888992cb", "publicURL":
"https://auth.cloud.ovh.net/v2.0"}, {"adminURL": "https://auth.cloud.ovh.net:35357/v2.0",
"region": "BHS1", "internalURL": "http://127.0.0.1:5000/v2.0", "id": "00e403276b3246c4a5c54dc7133f9f0a",
"publicURL": "https://auth.cloud.ovh.net/v2.0"}, {"adminURL": "https://auth.cloud.ovh.net:35357/v2.0",
"region": "SBG1", "internalURL": "http://127.0.0.1:5000/v2.0", "id": "6094ef2ed9f240ed9b648dfcc0d9f923",
"publicURL": "https://auth.cloud.ovh.net/v2.0"}], "endpoints_links": [], "type":
"identity", "name": "keystone"}], "user": {"username": "MhsuDbK4DsPr", "roles_links":
[], "id": "43914cf4645747ba90d075c62ebb5018", "roles": [{"name": "_member_"}],
"name": "MhsuDbK4DsPr"}, "metadata": {"is_admin": 0, "roles": ["9fe2ff9ee4384b1894a90878d3e92bab"]}}}'
http_version:
recorded_at: Thu, 12 May 2016 13:58:56 GMT
recorded_with: VCR 3.0.1

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -18,7 +18,7 @@ describe Administrateur, type: :model do
end end
describe 'assocations' do describe 'assocations' do
it { is_expected.to have_many(:gestionnaires) } it { is_expected.to have_and_belong_to_many(:gestionnaires) }
it { is_expected.to have_many(:procedures) } it { is_expected.to have_many(:procedures) }
end end

View file

@ -3,6 +3,8 @@ require 'spec_helper'
describe Cerfa do describe Cerfa do
describe 'database columns' do describe 'database columns' do
it { is_expected.to have_db_column(:content) } it { is_expected.to have_db_column(:content) }
it { is_expected.to have_db_column(:original_filename) }
it { is_expected.to have_db_column(:content_secure_token) }
it { is_expected.to have_db_column(:created_at) } it { is_expected.to have_db_column(:created_at) }
end end
@ -11,7 +13,7 @@ describe Cerfa do
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
end end
describe 'empty?' do describe 'empty?', vcr: { cassette_name: 'models_cerfa_empty' } do
subject { create(:cerfa, content: content) } subject { create(:cerfa, content: content) }
context 'when content exist' do context 'when content exist' do
let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') } let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }

View file

@ -88,7 +88,7 @@ describe Dossier do
end end
end end
describe '#retrieve_last_piece_justificative_by_type' do describe '#retrieve_last_piece_justificative_by_type', vcr: { cassette_name: 'models_dossier_retrieve_last_piece_justificative_by_type' } do
let(:types_de_pj_dossier) { dossier.procedure.types_de_piece_justificative } let(:types_de_pj_dossier) { dossier.procedure.types_de_piece_justificative }
subject { dossier.retrieve_last_piece_justificative_by_type types_de_pj_dossier.first } subject { dossier.retrieve_last_piece_justificative_by_type types_de_pj_dossier.first }
@ -387,10 +387,14 @@ describe Dossier do
let(:admin) { create(:administrateur) } let(:admin) { create(:administrateur) }
let(:admin_2) { create(:administrateur) } let(:admin_2) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateur: admin) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [admin]) }
let(:procedure_admin) { create(:procedure, administrateur: admin) } let(:procedure_admin) { create(:procedure, administrateur: admin) }
let(:procedure_admin_2) { create(:procedure, administrateur: admin_2) } let(:procedure_admin_2) { create(:procedure, administrateur: admin_2) }
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_admin
end
let!(:dossier1) { create(:dossier, procedure: procedure_admin, state: 'draft') } let!(:dossier1) { create(:dossier, procedure: procedure_admin, state: 'draft') }
let!(:dossier2) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter let!(:dossier2) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
let!(:dossier3) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter let!(:dossier3) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
@ -432,8 +436,13 @@ describe Dossier do
let(:administrateur_1) { create(:administrateur) } let(:administrateur_1) { create(:administrateur) }
let(:administrateur_2) { create(:administrateur) } let(:administrateur_2) { create(:administrateur) }
let(:gestionnaire_1) { create(:gestionnaire, administrateur: administrateur_1) } let(:gestionnaire_1) { create(:gestionnaire, administrateurs: [administrateur_1]) }
let(:gestionnaire_2) { create(:gestionnaire, administrateur: administrateur_2) } let(:gestionnaire_2) { create(:gestionnaire, administrateurs: [administrateur_2]) }
before do
create :assign_to, gestionnaire: gestionnaire_1, procedure: procedure_1
create :assign_to, gestionnaire: gestionnaire_2, procedure: procedure_2
end
let(:procedure_1) { create(:procedure, administrateur: administrateur_1) } let(:procedure_1) { create(:procedure, administrateur: administrateur_1) }
let(:procedure_2) { create(:procedure, administrateur: administrateur_2) } let(:procedure_2) { create(:procedure, administrateur: administrateur_2) }
@ -538,7 +547,7 @@ describe Dossier do
it { expect(subject['etablissement.siege_social']).to be_truthy } it { expect(subject['etablissement.siege_social']).to be_truthy }
it { expect(subject['etablissement.naf']).to eq('4950Z') } it { expect(subject['etablissement.naf']).to eq('4950Z') }
it { expect(subject['etablissement.libelle_naf']).to eq('Transports par conduites') } it { expect(subject['etablissement.libelle_naf']).to eq('Transports par conduites') }
it { expect(subject['etablissement.adresse']).to eq("GRTGAZ\r IMMEUBLE BORA\r 6 RUE RAOUL NORDLING\r 92270 BOIS COLOMBES\r") } it { expect(subject['etablissement.adresse']).to eq("GRTGAZ IMMEUBLE BORA 6 RUE RAOUL NORDLING 92270 BOIS COLOMBES") }
it { expect(subject['etablissement.numero_voie']).to eq('6') } it { expect(subject['etablissement.numero_voie']).to eq('6') }
it { expect(subject['etablissement.type_voie']).to eq('RUE') } it { expect(subject['etablissement.type_voie']).to eq('RUE') }
it { expect(subject['etablissement.nom_voie']).to eq('RAOUL NORDLING') } it { expect(subject['etablissement.nom_voie']).to eq('RAOUL NORDLING') }

View file

@ -17,7 +17,7 @@ describe Gestionnaire, type: :model do
end end
describe 'association' do describe 'association' do
it { is_expected.to belong_to(:administrateur) } it { is_expected.to have_and_belong_to_many(:administrateurs) }
it { is_expected.to have_many(:procedures) } it { is_expected.to have_many(:procedures) }
it { is_expected.to have_many(:dossiers) } it { is_expected.to have_many(:dossiers) }
end end
@ -26,10 +26,15 @@ describe Gestionnaire, type: :model do
let(:admin) { create :administrateur } let(:admin) { create :administrateur }
let(:procedure) { create :procedure, administrateur: admin } let(:procedure) { create :procedure, administrateur: admin }
let(:procedure_2) { create :procedure, administrateur: admin } let(:procedure_2) { create :procedure, administrateur: admin }
let(:gestionnaire) { create :gestionnaire, procedure_filter: procedure_filter, administrateur: admin } let(:gestionnaire) { create :gestionnaire, procedure_filter: procedure_filter, administrateurs: [admin] }
let!(:dossier) { create :dossier, procedure: procedure } let!(:dossier) { create :dossier, procedure: procedure }
let(:procedure_filter) { [] } let(:procedure_filter) { [] }
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
end
subject { gestionnaire.dossiers_filter } subject { gestionnaire.dossiers_filter }
context 'before filter' do context 'before filter' do
@ -47,7 +52,12 @@ describe Gestionnaire, type: :model do
let(:admin) { create :administrateur } let(:admin) { create :administrateur }
let!(:procedure) { create :procedure, administrateur: admin } let!(:procedure) { create :procedure, administrateur: admin }
let!(:procedure_2) { create :procedure, administrateur: admin } let!(:procedure_2) { create :procedure, administrateur: admin }
let(:gestionnaire) { create :gestionnaire, procedure_filter: procedure_filter, administrateur: admin } let(:gestionnaire) { create :gestionnaire, procedure_filter: procedure_filter, administrateurs: [admin] }
before do
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
end
let(:procedure_filter) { [] } let(:procedure_filter) { [] }

View file

@ -3,6 +3,8 @@ require 'spec_helper'
describe PieceJustificative do describe PieceJustificative do
describe 'database columns' do describe 'database columns' do
it { is_expected.to have_db_column(:content) } it { is_expected.to have_db_column(:content) }
it { is_expected.to have_db_column(:original_filename) }
it { is_expected.to have_db_column(:content_secure_token) }
it { is_expected.to have_db_column(:created_at) } it { is_expected.to have_db_column(:created_at) }
end end
@ -26,7 +28,7 @@ describe PieceJustificative do
it { is_expected.to delegate_method(:api_entreprise).to(:type_de_piece_justificative) } it { is_expected.to delegate_method(:api_entreprise).to(:type_de_piece_justificative) }
end end
describe '#empty?' do describe '#empty?', vcr: { cassette_name: 'model_piece_justificative' } do
let(:piece_justificative) { create(:piece_justificative, content: content) } let(:piece_justificative) { create(:piece_justificative, content: content) }
subject { piece_justificative.empty? } subject { piece_justificative.empty? }

View file

@ -17,6 +17,7 @@ describe Procedure do
it { is_expected.to have_db_column(:test) } it { is_expected.to have_db_column(:test) }
it { is_expected.to have_db_column(:euro_flag) } it { is_expected.to have_db_column(:euro_flag) }
it { is_expected.to have_db_column(:logo) } it { is_expected.to have_db_column(:logo) }
it { is_expected.to have_db_column(:logo_secure_token) }
it { is_expected.to have_db_column(:cerfa_flag) } it { is_expected.to have_db_column(:cerfa_flag) }
end end

View file

@ -0,0 +1,32 @@
require 'spec_helper'
describe AccompagnateurService do
describe '#change_assignement!' do
let(:procedure) { create :procedure }
let(:accompagnateur) { create :gestionnaire }
subject { AccompagnateurService.change_assignement! accompagnateur, procedure, to }
context 'when accompagnateur is not assign at the procedure' do
let(:to) { AccompagnateurService::ASSIGN }
before do
subject
end
it { expect(accompagnateur.procedures).to include procedure }
end
context 'when accompagnateur is assign at the procedure' do
let(:to) { AccompagnateurService::NOT_ASSIGN }
before do
create :assign_to, gestionnaire: accompagnateur, procedure: procedure
subject
end
it { expect(accompagnateur.procedures).not_to include procedure }
end
end
end

View file

@ -50,6 +50,13 @@ Dir[Rails.root.join('spec/factories/**/*.rb')].each { |f| require f }
# If you are not using ActiveRecord, you can remove this line. # If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
VCR.configure do |c|
c.ignore_localhost = true
c.hook_into :webmock
c.cassette_library_dir = 'spec/fixtures/cassettes'
c.configure_rspec_metadata!
end
DatabaseCleaner.strategy = :truncation DatabaseCleaner.strategy = :truncation
SIADETOKEN = :valid_token unless defined? SIADETOKEN SIADETOKEN = :valid_token unless defined? SIADETOKEN
@ -88,4 +95,22 @@ RSpec.configure do |config|
config.include Devise::TestHelpers, type: :controller config.include Devise::TestHelpers, type: :controller
config.include FactoryGirl::Syntax::Methods config.include FactoryGirl::Syntax::Methods
config.before(:each) do
allow_any_instance_of(PieceJustificativeUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f997")
allow_any_instance_of(ProcedureLogoUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f998")
allow_any_instance_of(CerfaUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f999")
end
config.before(:all) {
Warden.test_mode!
if Features.remote_storage
VCR.use_cassette("ovh_storage_init") do
CarrierWave.configure do |config|
config.fog_credentials = { provider: 'OpenStack' }
end
end
end
}
end end

View file

@ -0,0 +1,3 @@
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end

View file

@ -0,0 +1,60 @@
require 'spec_helper'
describe 'admin/accompagnateurs/show.html.haml', type: :view do
let(:admin) { create(:administrateur) }
let(:procedure) { create :procedure, administrateur: admin }
let(:assign_gestionnaires) { procedure.gestionnaires }
let(:not_assign_gestionnaires) { admin.gestionnaires.where.not(id: assign_gestionnaires.ids) }
before do
assign(:procedure, procedure)
assign(:accompagnateurs_assign, (smart_listing_create :accompagnateurs_assign,
assign_gestionnaires,
partial: "admin/accompagnateurs/list_assign",
array: true))
assign(:accompagnateurs_not_assign, (smart_listing_create :accompagnateurs_not_assign,
not_assign_gestionnaires,
partial: "admin/accompagnateurs/list_not_assign",
array: true))
end
context 'when admin have none accompagnateur ' do
before do
render
end
it { expect(rendered).to have_content('Aucun de disponible') }
context 'when administrateur have none accompagnateur assign' do
it { expect(rendered).to have_content('Aucun d\'affecté') }
end
end
context 'when administrateur have two accompagnateur' do
let!(:accompagnateur_1) { create :gestionnaire, email: 'plop@plop.com', administrateurs: [admin] }
let!(:accompagnateur_2) { create :gestionnaire, email: 'plip@plop.com', administrateurs: [admin] }
before do
not_assign_gestionnaires.reload
assign_gestionnaires.reload
assign(:accompagnateurs_assign, (smart_listing_create :accompagnateurs_assign,
assign_gestionnaires,
partial: "admin/accompagnateurs/list_assign",
array: true))
assign(:accompagnateurs_not_assign, (smart_listing_create :accompagnateurs_not_assign,
not_assign_gestionnaires,
partial: "admin/accompagnateurs/list_not_assign",
array: true))
render
end
it { expect(rendered).to have_content(accompagnateur_1.email) }
it { expect(rendered).to have_content(accompagnateur_2.email) }
end
end

View file

@ -6,9 +6,9 @@ describe 'admin/gestionnaires/index.html.haml', type: :view do
before do before do
assign(:gestionnaires, (smart_listing_create :gestionnaires, assign(:gestionnaires, (smart_listing_create :gestionnaires,
admin.gestionnaires, admin.gestionnaires,
partial: "admin/gestionnaires/list", partial: "admin/gestionnaires/list",
array: true)) array: true))
assign(:gestionnaire, Gestionnaire.new()) assign(:gestionnaire, Gestionnaire.new())
end end
@ -21,12 +21,12 @@ describe 'admin/gestionnaires/index.html.haml', type: :view do
context 'Ajout d\'un accompagnateur' do context 'Ajout d\'un accompagnateur' do
before do before do
create(:gestionnaire, administrateur: admin) create(:gestionnaire, administrateurs: [admin])
admin.reload admin.reload
assign(:gestionnaires, (smart_listing_create :gestionnaires, assign(:gestionnaires, (smart_listing_create :gestionnaires,
admin.gestionnaires, admin.gestionnaires,
partial: "admin/gestionnaires/list", partial: "admin/gestionnaires/list",
array: true)) array: true))
render render
end end
it { expect(rendered).to match(/plop\d+@plop.com/) } it { expect(rendered).to match(/plop\d+@plop.com/) }

View file

@ -5,7 +5,7 @@ describe 'admin/procedures/show.html.haml', type: :view do
before do before do
assign(:facade, AdminProceduresShowFacades.new(procedure.decorate)) assign(:facade, AdminProceduresShowFacades.new(procedure.decorate))
assign(:procedure, procedure)
render render
end end

Some files were not shown because too many files have changed in this diff Show more