Merge branch 'develop' into staging
This commit is contained in:
commit
ccd2754e58
104 changed files with 244165 additions and 265 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -28,5 +28,7 @@ config/initializers/token.rb
|
|||
doc/*.svg
|
||||
rubocop.html
|
||||
config/france_connect.yml
|
||||
config/initializers/mailjet.rb
|
||||
config/fog_credentials.yml
|
||||
uploads/*
|
||||
coverage/**/*
|
||||
|
|
3
Gemfile
3
Gemfile
|
@ -56,6 +56,8 @@ gem 'rest-client'
|
|||
gem 'clamav-client', require: 'clamav/client'
|
||||
|
||||
gem 'carrierwave'
|
||||
gem 'fog'
|
||||
gem 'fog-openstack'
|
||||
|
||||
gem 'pg'
|
||||
|
||||
|
@ -99,6 +101,7 @@ group :test do
|
|||
gem 'guard'
|
||||
gem 'guard-rspec', require: false
|
||||
gem 'guard-livereload', '~> 2.4', require: false
|
||||
gem 'vcr'
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
|
|
143
Gemfile.lock
143
Gemfile.lock
|
@ -9,6 +9,7 @@ GIT
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (2.3.2)
|
||||
actionmailer (4.2.5.2)
|
||||
actionpack (= 4.2.5.2)
|
||||
actionview (= 4.2.5.2)
|
||||
|
@ -139,6 +140,7 @@ GEM
|
|||
http_parser.rb (~> 0.6.0)
|
||||
erubis (2.7.0)
|
||||
eventmachine (1.0.8)
|
||||
excon (0.49.0)
|
||||
execjs (2.5.2)
|
||||
factory_girl (4.5.0)
|
||||
activesupport (>= 3.0.0)
|
||||
|
@ -146,6 +148,135 @@ GEM
|
|||
multipart-post (>= 1.2, < 3)
|
||||
fastercsv (1.5.5)
|
||||
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)
|
||||
railties (>= 3.2, < 5.0)
|
||||
formatador (0.2.5)
|
||||
|
@ -189,6 +320,8 @@ GEM
|
|||
http_parser.rb (0.6.0)
|
||||
httpclient (2.6.0.1)
|
||||
i18n (0.7.0)
|
||||
inflecto (0.0.2)
|
||||
ipaddress (0.8.3)
|
||||
jbuilder (2.3.1)
|
||||
activesupport (>= 3.0.0, < 5)
|
||||
multi_json (~> 1.2)
|
||||
|
@ -316,6 +449,10 @@ GEM
|
|||
rb-fsevent (0.9.6)
|
||||
rb-inotify (0.9.5)
|
||||
ffi (>= 0.5.0)
|
||||
rbvmomi (1.8.2)
|
||||
builder
|
||||
nokogiri (>= 1.4.1)
|
||||
trollop
|
||||
rdoc (4.2.0)
|
||||
json (~> 1.4)
|
||||
ref (2.0.0)
|
||||
|
@ -430,6 +567,7 @@ GEM
|
|||
thread_safe (0.3.5)
|
||||
tilt (1.4.1)
|
||||
timecop (0.7.3)
|
||||
trollop (2.1.2)
|
||||
turbolinks (2.5.3)
|
||||
coffee-rails
|
||||
tzinfo (1.2.2)
|
||||
|
@ -451,6 +589,7 @@ GEM
|
|||
validate_url (1.0.2)
|
||||
activemodel (>= 3.0.0)
|
||||
addressable
|
||||
vcr (3.0.1)
|
||||
warden (1.2.3)
|
||||
rack (>= 1.0)
|
||||
web-console (2.2.1)
|
||||
|
@ -472,6 +611,7 @@ GEM
|
|||
will_paginate (3.0.7)
|
||||
will_paginate-bootstrap (1.0.1)
|
||||
will_paginate (>= 3.0.3)
|
||||
xml-simple (1.1.5)
|
||||
xpath (2.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
|
||||
|
@ -497,6 +637,8 @@ DEPENDENCIES
|
|||
devise
|
||||
draper
|
||||
factory_girl
|
||||
fog
|
||||
fog-openstack
|
||||
font-awesome-rails
|
||||
guard
|
||||
guard-livereload (~> 2.4)
|
||||
|
@ -542,6 +684,7 @@ DEPENDENCIES
|
|||
turbolinks
|
||||
uglifier (>= 1.3.0)
|
||||
unicorn
|
||||
vcr
|
||||
web-console (~> 2.0)
|
||||
webmock
|
||||
will_paginate-bootstrap
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
//= require bootstrap-wysihtml5/locales/fr-FR
|
||||
|
||||
|
||||
|
||||
$(document).on('page:load', scroll_to);
|
||||
$(document).ready(scroll_to);
|
||||
|
||||
|
|
30
app/controllers/admin/accompagnateurs_controller.rb
Normal file
30
app/controllers/admin/accompagnateurs_controller.rb
Normal 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
|
|
@ -12,29 +12,51 @@ class Admin::GestionnairesController < AdminController
|
|||
|
||||
|
||||
def create
|
||||
@gestionnaire = Gestionnaire.create(create_gestionnaire_params)
|
||||
@gestionnaire = Gestionnaire.find_by_email(params[:gestionnaire][:email])
|
||||
|
||||
if @gestionnaire.errors.messages.empty?
|
||||
flash.notice = 'Gestionnaire ajouté'
|
||||
GestionnaireMailer.new_gestionnaire(@gestionnaire.email, @gestionnaire.password).deliver_now!
|
||||
if @gestionnaire.nil?
|
||||
new_gestionnaire!
|
||||
else
|
||||
flash.alert = @gestionnaire.errors.full_messages.join('<br />').html_safe
|
||||
assign_gestionnaire!
|
||||
end
|
||||
|
||||
redirect_to admin_gestionnaires_path
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
Gestionnaire.find(params[:id]).destroy
|
||||
Gestionnaire.find(params[:id]).administrateurs.delete current_administrateur
|
||||
redirect_to admin_gestionnaires_path
|
||||
end
|
||||
|
||||
|
||||
def create_gestionnaire_params
|
||||
params.require(:gestionnaire).permit(:email)
|
||||
.merge(administrateur_id: current_administrateur.id)
|
||||
.merge(password: SecureRandom.hex(5))
|
||||
.merge(administrateurs: [current_administrateur])
|
||||
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
|
|
@ -4,15 +4,19 @@ class GestionnaireMailer < ApplicationMailer
|
|||
send_mail email, password, "Vous avez été nommé accompagnateur sur la plateforme TPS"
|
||||
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
|
||||
|
||||
def vars_mailer email, password
|
||||
@password = password
|
||||
def vars_mailer email, args
|
||||
@args = args
|
||||
@email = email
|
||||
end
|
||||
|
||||
def send_mail email, password, subject
|
||||
vars_mailer email, password
|
||||
def send_mail email, args, subject
|
||||
vars_mailer email, args
|
||||
|
||||
mail(from: "tps@apientreprise.fr", to: email,
|
||||
subject: subject)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
class Administrateur < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
has_many :gestionnaires
|
||||
has_and_belongs_to_many :gestionnaires
|
||||
has_many :procedures
|
||||
|
||||
before_save :ensure_api_token
|
||||
|
|
4
app/models/assign_to.rb
Normal file
4
app/models/assign_to.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class AssignTo < ActiveRecord::Base
|
||||
belongs_to :procedure
|
||||
belongs_to :gestionnaire
|
||||
end
|
|
@ -11,7 +11,11 @@ class Cerfa < ActiveRecord::Base
|
|||
|
||||
def content_url
|
||||
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
|
|
@ -190,7 +190,7 @@ class Dossier < ActiveRecord::Base
|
|||
|
||||
def as_csv(options={})
|
||||
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
|
||||
dossier_attr.merge(etablissement_attr).merge(entreprise_attr)
|
||||
end
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
class Gestionnaire < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
: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
|
||||
|
||||
def dossiers_filter
|
||||
|
|
|
@ -19,8 +19,12 @@ class PieceJustificative < ActiveRecord::Base
|
|||
|
||||
def content_url
|
||||
unless content.url.nil?
|
||||
(Downloader.new content,
|
||||
(type_de_piece_justificative.nil? ? content.file.original_filename : type_de_piece_justificative.libelle)).url
|
||||
if Features.remote_storage
|
||||
(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
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ class Procedure < ActiveRecord::Base
|
|||
|
||||
belongs_to :administrateur
|
||||
|
||||
has_many :assign_to
|
||||
has_many :gestionnaires, through: :assign_to
|
||||
|
||||
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
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
class Siret
|
||||
include ActiveModel::Model
|
||||
include ActiveModel::Validations::Callbacks
|
||||
|
||||
attr_accessor :siret
|
||||
|
||||
validates_presence_of :siret
|
||||
validates :siret, siret_format: true
|
||||
|
||||
before_validation :remove_whitespace
|
||||
|
||||
def remove_whitespace
|
||||
siret.delete!(' ') unless siret.nil?
|
||||
end
|
||||
end
|
||||
|
|
5
app/serializers/etablissement_csv_serializer.rb
Normal file
5
app/serializers/etablissement_csv_serializer.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class EtablissementCsvSerializer < EtablissementSerializer
|
||||
def adresse
|
||||
object.adresse.chomp.gsub("\r\n", ' ').gsub("\r", '')
|
||||
end
|
||||
end
|
|
@ -11,4 +11,5 @@ class EtablissementSerializer < ActiveModel::Serializer
|
|||
:code_postal,
|
||||
:localite,
|
||||
:code_insee_localite
|
||||
|
||||
end
|
12
app/services/accompagnateur_service.rb
Normal file
12
app/services/accompagnateur_service.rb
Normal 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
|
|
@ -1,40 +1,26 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class CerfaUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
# include CarrierWave::MiniMagick
|
||||
before :cache, :set_original_filename
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
if Features.remote_storage
|
||||
storage :fog
|
||||
else
|
||||
storage :file
|
||||
# storage :fog
|
||||
end
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
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
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
# def default_url
|
||||
# # For Rails 3.1+ asset pipeline compatibility:
|
||||
# # 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
|
||||
def cache_dir
|
||||
'/tmp/tps-cache'
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# 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)
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def filename
|
||||
if original_filename.present? || model.content_secure_token
|
||||
if Features.remote_storage
|
||||
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
|
||||
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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'securerandom'
|
||||
|
||||
class Downloader
|
||||
class LocalDownloader
|
||||
BASE_PATH_DISK = File.join(Rails.root, "public/downloads/")
|
||||
|
||||
def initialize(filename, filename_suffix = '')
|
|
@ -1,40 +1,26 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class PieceJustificativeUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
# include CarrierWave::MiniMagick
|
||||
before :cache, :set_original_filename
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
if Features.remote_storage
|
||||
storage :fog
|
||||
else
|
||||
storage :file
|
||||
# storage :fog
|
||||
end
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
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
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
# def default_url
|
||||
# # For Rails 3.1+ asset pipeline compatibility:
|
||||
# # 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
|
||||
def cache_dir
|
||||
'/tmp/tps-cache'
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# 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)
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
def filename
|
||||
if original_filename.present? || model.content_secure_token
|
||||
if Features.remote_storage
|
||||
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
|
||||
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
|
||||
|
|
|
@ -2,39 +2,28 @@
|
|||
|
||||
class ProcedureLogoUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
# include CarrierWave::MiniMagick
|
||||
def root
|
||||
File.join(Rails.root, "public")
|
||||
end
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
if Features.remote_storage
|
||||
storage :fog
|
||||
else
|
||||
storage :file
|
||||
# storage :fog
|
||||
end
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
unless Features.remote_storage
|
||||
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
# def default_url
|
||||
# # For Rails 3.1+ asset pipeline compatibility:
|
||||
# # 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
|
||||
def cache_dir
|
||||
'/tmp/tps-cache'
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
|
@ -42,10 +31,25 @@ class ProcedureLogoUploader < CarrierWave::Uploader::Base
|
|||
%w(jpg jpeg png)
|
||||
end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
def filename
|
||||
if original_filename.present? || model.logo_secure_token
|
||||
if Features.remote_storage
|
||||
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
|
||||
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
|
||||
|
|
11
app/uploaders/remote_downloader.rb
Normal file
11
app/uploaders/remote_downloader.rb
Normal 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
|
20
app/views/admin/accompagnateurs/_list_assign.html.haml
Normal file
20
app/views/admin/accompagnateurs/_list_assign.html.haml
Normal 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é
|
27
app/views/admin/accompagnateurs/_list_not_assign.html.haml
Normal file
27
app/views/admin/accompagnateurs/_list_not_assign.html.haml
Normal 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
|
19
app/views/admin/accompagnateurs/show.html.haml
Normal file
19
app/views/admin/accompagnateurs/show.html.haml
Normal 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
|
||||
|
||||
|
3
app/views/admin/accompagnateurs/show.js.erb
Normal file
3
app/views/admin/accompagnateurs/show.js.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
<%= smart_listing_update :accompagnateurs_not_assign %>
|
||||
|
||||
<%= smart_listing_update :accompagnateurs_assign %>
|
|
@ -3,14 +3,7 @@
|
|||
%br
|
||||
|
||||
%ul.nav.nav-tabs
|
||||
%li
|
||||
= 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))
|
||||
= render partial: 'admin/procedures/navbar', locals: {active: 'Pieces'}
|
||||
|
||||
#piece_justificative_form
|
||||
= render 'form'
|
17
app/views/admin/procedures/_navbar.html.haml
Normal file
17
app/views/admin/procedures/_navbar.html.haml
Normal 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', '#')
|
|
@ -3,14 +3,7 @@
|
|||
%br
|
||||
|
||||
%ul.nav.nav-tabs
|
||||
%li
|
||||
= 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))
|
||||
= render partial: 'navbar', locals: {active: 'Description'}
|
||||
|
||||
#procedure_new.section.section-label
|
||||
= form_for @procedure, url: url_for({controller: 'admin/procedures', action: :update, id: @procedure.id}), multipart: true do |f|
|
||||
|
|
|
@ -4,21 +4,7 @@
|
|||
%br
|
||||
|
||||
%ul.nav.nav-tabs
|
||||
%li.active
|
||||
= 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', '#')
|
||||
|
||||
= render partial: 'navbar', locals: {active: 'Informations'}
|
||||
|
||||
%li{style:'float:right'}
|
||||
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put do
|
||||
|
|
|
@ -3,14 +3,7 @@
|
|||
%br
|
||||
|
||||
%ul.nav.nav-tabs
|
||||
%li
|
||||
= 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))
|
||||
= render partial: 'admin/procedures/navbar', locals: {active: 'Champs'}
|
||||
|
||||
#liste_champ
|
||||
= render partial: 'form'
|
|
@ -13,7 +13,7 @@
|
|||
%li
|
||||
= link_to(admin_gestionnaires_path) do
|
||||
%i.fa.fa-user
|
||||
Gestionnaires
|
||||
Accompagnateur
|
||||
%li.divider{ role: :separator}
|
||||
%li
|
||||
= link_to(admin_profile_path, id: :profile) do
|
||||
|
|
11
app/views/gestionnaire_mailer/new_assignement.text.erb
Normal file
11
app/views/gestionnaire_mailer/new_assignement.text.erb
Normal 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
|
|
@ -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 :
|
||||
|
||||
URL : https://tps.apientreprise.fr/gestionnaires/sign_in
|
||||
URL : <%= new_gestionnaire_session_url %>
|
||||
Login : <%= @email %>
|
||||
Mot de passe : <%= @password %>
|
||||
Mot de passe : <%= @args %>
|
||||
|
||||
Bonne journée,
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
\-
|
||||
%span#piece_justificative
|
||||
%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
|
||||
.description#body
|
||||
|
|
32
config/initializers/carrierwave.rb
Normal file
32
config/initializers/carrierwave.rb
Normal 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
|
26
config/initializers/features.rb
Normal file
26
config/initializers/features.rb
Normal 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
|
1
config/initializers/features.yml
Normal file
1
config/initializers/features.yml
Normal file
|
@ -0,0 +1 @@
|
|||
remote_storage: false
|
|
@ -13,6 +13,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
|
|||
inflect.irregular 'piece_justificative', 'pieces_justificatives'
|
||||
inflect.irregular 'type_de_piece_justificative', 'types_de_piece_justificative'
|
||||
inflect.irregular 'type_de_champ', 'types_de_champ'
|
||||
inflect.irregular 'assign_to', 'assign_tos'
|
||||
end
|
||||
|
||||
# These inflection rules are supported but not enabled by default:
|
||||
|
|
|
@ -80,6 +80,7 @@ Rails.application.routes.draw do
|
|||
get 'sign_in' => '/administrateurs/sessions#new'
|
||||
get 'procedures/archived' => 'procedures#archived'
|
||||
get 'profile' => 'profile#show', as: :profile
|
||||
|
||||
resources :procedures do
|
||||
resource :types_de_champ, only: [:show, :update] do
|
||||
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
|
||||
|
||||
resource :accompagnateurs, only: [:show, :update]
|
||||
|
||||
|
||||
resources :types_de_champ, only: [:destroy]
|
||||
resource :pieces_justificatives, only: [:show, :update]
|
||||
resources :pieces_justificatives, only: :destroy
|
||||
end
|
||||
|
||||
namespace :accompagnateurs do
|
||||
get 'show' #delete after fixed tests admin/accompagnateurs/show_spec without this line
|
||||
end
|
||||
|
||||
resources :gestionnaires, only: [:index, :create, :destroy]
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddOriginalFilenameToPiecesJustificatives < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :pieces_justificatives, :original_filename, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddOriginalFilenameToCerfas < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :cerfas, :original_filename, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddContentSecureTokenToCerfas < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :cerfas, :content_secure_token, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddContentSecureTokenToPiecesJustificatives < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :pieces_justificatives, :content_secure_token, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddLogoSecureTokenToProcedures < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :procedures, :logo_secure_token, :string
|
||||
end
|
||||
end
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
25
db/schema.rb
25
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# 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
|
||||
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", ["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|
|
||||
t.string "email", 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", ["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|
|
||||
t.string "surface_intersection"
|
||||
t.float "surface_parcelle"
|
||||
|
@ -72,6 +89,8 @@ ActiveRecord::Schema.define(version: 20160419142017) do
|
|||
t.integer "dossier_id"
|
||||
t.datetime "created_at"
|
||||
t.integer "user_id"
|
||||
t.string "original_filename"
|
||||
t.string "content_secure_token"
|
||||
end
|
||||
|
||||
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.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "administrateur_id"
|
||||
t.integer "procedure_filter", default: [], array: true
|
||||
end
|
||||
|
||||
|
@ -203,6 +221,8 @@ ActiveRecord::Schema.define(version: 20160419142017) do
|
|||
t.integer "type_de_piece_justificative_id"
|
||||
t.datetime "created_at"
|
||||
t.integer "user_id"
|
||||
t.string "original_filename"
|
||||
t.string "content_secure_token"
|
||||
end
|
||||
|
||||
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.string "logo"
|
||||
t.boolean "cerfa_flag", default: false
|
||||
t.string "logo_secure_token"
|
||||
end
|
||||
|
||||
create_table "quartier_prioritaires", force: :cascade do |t|
|
||||
|
|
|
@ -4,6 +4,8 @@ namespace :dev do
|
|||
puts 'start initialisation'
|
||||
Rake::Task['dev:generate_token_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'
|
||||
end
|
||||
|
@ -35,4 +37,29 @@ EOF
|
|||
file.write(comment)
|
||||
file.close
|
||||
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
|
||||
|
|
30
spec/controllers/admin/accompagnateurs_controller_spec.rb
Normal file
30
spec/controllers/admin/accompagnateurs_controller_spec.rb
Normal 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
|
|
@ -2,6 +2,9 @@ require 'spec_helper'
|
|||
|
||||
describe Admin::GestionnairesController, type: :controller do
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:email_2) { 'plip@octo.com' }
|
||||
let(:admin_2) { create :administrateur, email: email_2 }
|
||||
|
||||
before do
|
||||
sign_in admin
|
||||
end
|
||||
|
@ -19,13 +22,19 @@ describe Admin::GestionnairesController, type: :controller do
|
|||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
let(:gestionnaire) { Gestionnaire.last }
|
||||
|
||||
it { expect(response.status).to eq(302) }
|
||||
it { expect(response).to redirect_to admin_gestionnaires_path }
|
||||
|
||||
describe 'Gestionnaire attributs in database' do
|
||||
let(:gestionnaire) { Gestionnaire.last }
|
||||
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
|
||||
|
||||
|
@ -36,6 +45,15 @@ describe Admin::GestionnairesController, type: :controller do
|
|||
let(:email) { 'piou' }
|
||||
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 {
|
||||
expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
|
||||
expect(GestionnaireMailer).not_to receive(:deliver_now!)
|
||||
subject
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context 'when email is empty' do
|
||||
|
@ -45,65 +63,103 @@ describe Admin::GestionnairesController, type: :controller do
|
|||
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' }
|
||||
context 'when email is already assign at the admin' do
|
||||
before do
|
||||
create :gestionnaire, email: email, administrateurs: [admin]
|
||||
subject
|
||||
post :create, gestionnaire: { email: email }
|
||||
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 email is valid' 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
|
||||
|
||||
context 'is not sent when email is not valid' do
|
||||
let(:email) { 'testplop.com' }
|
||||
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).not_to receive(:new_gestionnaire)
|
||||
expect(GestionnaireMailer).not_to receive(:deliver_now!)
|
||||
expect(GestionnaireMailer).to receive(:new_assignement).and_return(GestionnaireMailer)
|
||||
expect(GestionnaireMailer).to receive(:deliver_now!)
|
||||
subject
|
||||
}
|
||||
end
|
||||
|
||||
it 'is not sent when email already exists' do
|
||||
subject
|
||||
expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
|
||||
expect(GestionnaireMailer).not_to receive(:deliver_now!)
|
||||
subject
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
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 }
|
||||
|
||||
context "when gestionaire_id is valid" do
|
||||
before do
|
||||
subject
|
||||
admin.reload
|
||||
gestionnaire.reload
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq(302) }
|
||||
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
|
||||
|
||||
it { expect{subject}.to change(Gestionnaire, :count).by(-1) }
|
||||
it { expect { subject }.not_to change(Gestionnaire, :count) }
|
||||
end
|
||||
|
||||
end
|
|
@ -179,7 +179,7 @@ describe API::V1::DossiersController do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'piece justificative' do
|
||||
describe 'piece justificative', vcr: { cassette_name: 'controllers_api_v1_dossiers_controller_piece_justificative' } do
|
||||
before do
|
||||
create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative: dossier.procedure.types_de_piece_justificative.first, user: dossier.user
|
||||
end
|
||||
|
@ -249,7 +249,7 @@ describe API::V1::DossiersController do
|
|||
it { expect(subject.first[:email]).to eq 'plop@plip.com' }
|
||||
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(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
|
||||
|
||||
|
@ -263,7 +263,11 @@ describe API::V1::DossiersController do
|
|||
subject { super()[:cerfa].first }
|
||||
|
||||
it { expect(subject[:created_at]).not_to be_nil }
|
||||
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
|
||||
let(:field_list) { [
|
||||
|
|
|
@ -21,7 +21,7 @@ describe Backoffice::CommentairesController, type: :controller do
|
|||
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') }
|
||||
|
||||
subject do
|
||||
|
|
|
@ -6,7 +6,7 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
|
||||
let(:dossier_id) { dossier.id }
|
||||
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
|
||||
context 'gestionnaire is connected' do
|
||||
|
|
|
@ -30,7 +30,7 @@ describe Users::CommentairesController, type: :controller do
|
|||
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') }
|
||||
|
||||
subject do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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(: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
|
||||
|
||||
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
|
||||
post :create, dossier_id: dossier_id,
|
||||
nom_projet: nom_projet,
|
||||
|
@ -134,11 +134,15 @@ describe Users::DescriptionController, type: :controller do
|
|||
dossier.reload
|
||||
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 }
|
||||
|
||||
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
|
||||
|
||||
it 'dossier_id' do
|
||||
|
@ -212,7 +216,7 @@ describe Users::DescriptionController, type: :controller do
|
|||
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 }
|
||||
before do
|
||||
post :create, {dossier_id: dossier_id,
|
||||
|
@ -223,7 +227,7 @@ describe Users::DescriptionController, type: :controller do
|
|||
dossier.reload
|
||||
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
|
||||
expect(ClamavService).to receive(:safe_file?).twice
|
||||
|
||||
|
@ -250,7 +254,7 @@ describe Users::DescriptionController, type: :controller do
|
|||
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 }
|
||||
|
||||
subject { patch :pieces_justificatives, {dossier_id: dossier.id,
|
||||
|
@ -277,7 +281,7 @@ describe Users::DescriptionController, type: :controller do
|
|||
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
|
||||
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]
|
||||
|
@ -285,7 +289,7 @@ describe Users::DescriptionController, type: :controller do
|
|||
|
||||
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
|
||||
subject
|
||||
dossier.reload
|
||||
|
@ -347,7 +351,7 @@ describe Users::DescriptionController, type: :controller do
|
|||
|
||||
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
|
||||
subject
|
||||
dossier.reload
|
||||
|
|
|
@ -17,6 +17,7 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
let(:siren) { dossier.siren }
|
||||
let(:siret) { dossier.siret }
|
||||
let(:siret_with_whitespaces) { '440 1176 2001 530' }
|
||||
let(:bad_siret) { 1 }
|
||||
|
||||
describe 'GET #show' do
|
||||
|
@ -103,12 +104,12 @@ describe Users::DossiersController, type: :controller do
|
|||
describe 'dossier attributs' do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
context 'with valid siret ' do
|
||||
shared_examples 'with valid siret' do
|
||||
before do
|
||||
sign_in user
|
||||
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
|
||||
expect { subject }.to change { Dossier.count }.by(1)
|
||||
|
@ -215,6 +216,16 @@ describe Users::DossiersController, type: :controller do
|
|||
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
|
||||
before do
|
||||
sign_in create(:user)
|
||||
|
|
4
spec/factories/assign_to.rb
Normal file
4
spec/factories/assign_to.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
FactoryGirl.define do
|
||||
factory :assign_to do
|
||||
end
|
||||
end
|
|
@ -21,7 +21,7 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do
|
|||
end
|
||||
context 'when user enter good credentials' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
|
||||
before do
|
||||
page.find_by_id(:gestionnaire_email).set gestionnaire.email
|
||||
|
|
|
@ -2,13 +2,16 @@ require 'spec_helper'
|
|||
|
||||
feature 'on backoffice page' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
let(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
visit backoffice_path
|
||||
end
|
||||
|
||||
context 'when gestionnaire is logged in' do
|
||||
before do
|
||||
page.find_by_id(:gestionnaire_email).set gestionnaire.email
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
feature 'on click on tabs button' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
|
||||
before do
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
feature 'search file on gestionnaire backoffice' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
|
||||
before do
|
||||
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 he click on search button' do
|
||||
let(:terms) { '' }
|
||||
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
|
||||
visit backoffice_dossiers_url
|
||||
page.find_by_id(:q).set terms
|
||||
page.find_by_id(:search_button).click
|
||||
|
@ -36,7 +39,6 @@ feature 'search file on gestionnaire backoffice' do
|
|||
end
|
||||
|
||||
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_2) { create(:dossier, procedure: procedure, state: 'initiated', nom_projet: 'Projet de test') }
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ feature 'user is on description page' do
|
|||
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
|
||||
attach_file('cerfa_pdf', File.path('spec/support/files/dossierPDF.pdf'))
|
||||
click_on("Soumettre mon dossier")
|
||||
|
@ -44,7 +44,7 @@ feature 'user is on description page' do
|
|||
expect(dossier.cerfa).not_to be_empty
|
||||
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
|
||||
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'))
|
||||
|
|
|
@ -25,7 +25,7 @@ feature 'drawing a zone with freedraw' do
|
|||
end
|
||||
|
||||
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')
|
||||
end
|
||||
end
|
||||
|
@ -42,7 +42,7 @@ feature 'drawing a zone with freedraw' do
|
|||
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
|
||||
let(:module_api_carto) { create(:module_api_carto, :with_quartiers_prioritaires) }
|
||||
|
||||
|
|
7833
spec/fixtures/cassettes/controllers_api_v1_dossiers_controller_cerfa.yml
vendored
Normal file
7833
spec/fixtures/cassettes/controllers_api_v1_dossiers_controller_cerfa.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
7833
spec/fixtures/cassettes/controllers_api_v1_dossiers_controller_piece_justificative.yml
vendored
Normal file
7833
spec/fixtures/cassettes/controllers_api_v1_dossiers_controller_piece_justificative.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
7833
spec/fixtures/cassettes/controllers_backoffice_commentaires_controller_doc_upload_with_comment.yml
vendored
Normal file
7833
spec/fixtures/cassettes/controllers_backoffice_commentaires_controller_doc_upload_with_comment.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
7833
spec/fixtures/cassettes/controllers_sers_commentaires_controller_upload_doc.yml
vendored
Normal file
7833
spec/fixtures/cassettes/controllers_sers_commentaires_controller_upload_doc.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
7833
spec/fixtures/cassettes/controllers_users_description_controller_cerfa_is_sent.yml
vendored
Normal file
7833
spec/fixtures/cassettes/controllers_users_description_controller_cerfa_is_sent.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
31020
spec/fixtures/cassettes/controllers_users_description_controller_clamav_presence.yml
vendored
Normal file
31020
spec/fixtures/cassettes/controllers_users_description_controller_clamav_presence.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
15562
spec/fixtures/cassettes/controllers_users_description_controller_pieces_justificatives.yml
vendored
Normal file
15562
spec/fixtures/cassettes/controllers_users_description_controller_pieces_justificatives.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
15562
spec/fixtures/cassettes/controllers_users_description_controller_pj_already_exist.yml
vendored
Normal file
15562
spec/fixtures/cassettes/controllers_users_description_controller_pj_already_exist.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
31020
spec/fixtures/cassettes/controllers_users_description_controller_pj_already_exist_upload_2pj.yml
vendored
Normal file
31020
spec/fixtures/cassettes/controllers_users_description_controller_pj_already_exist_upload_2pj.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
15562
spec/fixtures/cassettes/controllers_users_description_controller_sauvegarde_pj.yml
vendored
Normal file
15562
spec/fixtures/cassettes/controllers_users_description_controller_sauvegarde_pj.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
15562
spec/fixtures/cassettes/controllers_users_description_controller_save_cerfa.yml
vendored
Normal file
15562
spec/fixtures/cassettes/controllers_users_description_controller_save_cerfa.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
31020
spec/fixtures/cassettes/controllers_users_description_controller_upload_2pj.yml
vendored
Normal file
31020
spec/fixtures/cassettes/controllers_users_description_controller_upload_2pj.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
7833
spec/fixtures/cassettes/description_page_upload_piece_justificative_adds_cerfa.yml
vendored
Normal file
7833
spec/fixtures/cassettes/description_page_upload_piece_justificative_adds_cerfa.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
7833
spec/fixtures/cassettes/description_page_upload_piece_justificative_adds_cerfa_and_submit.yml
vendored
Normal file
7833
spec/fixtures/cassettes/description_page_upload_piece_justificative_adds_cerfa_and_submit.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
143
spec/fixtures/cassettes/drawing_a_zone_with_freedraw_when_draw_a_zone_on_map.yml
vendored
Normal file
143
spec/fixtures/cassettes/drawing_a_zone_with_freedraw_when_draw_a_zone_on_map.yml
vendored
Normal 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
|
7833
spec/fixtures/cassettes/model_piece_justificative.yml
vendored
Normal file
7833
spec/fixtures/cassettes/model_piece_justificative.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
7833
spec/fixtures/cassettes/models_cerfa_empty.yml
vendored
Normal file
7833
spec/fixtures/cassettes/models_cerfa_empty.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
7833
spec/fixtures/cassettes/models_dossier_retrieve_last_piece_justificative_by_type.yml
vendored
Normal file
7833
spec/fixtures/cassettes/models_dossier_retrieve_last_piece_justificative_by_type.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
104
spec/fixtures/cassettes/ovh_storage_init.yml
vendored
Normal file
104
spec/fixtures/cassettes/ovh_storage_init.yml
vendored
Normal 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
|
1344
spec/fixtures/cassettes/user_dossier_new_html.yml
vendored
Normal file
1344
spec/fixtures/cassettes/user_dossier_new_html.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
7833
spec/fixtures/cassettes/views_users_recapitulatif_commentaires_flux.yml
vendored
Normal file
7833
spec/fixtures/cassettes/views_users_recapitulatif_commentaires_flux.yml
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -18,7 +18,7 @@ describe Administrateur, type: :model do
|
|||
end
|
||||
|
||||
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) }
|
||||
end
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ require 'spec_helper'
|
|||
describe Cerfa do
|
||||
describe 'database columns' do
|
||||
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) }
|
||||
end
|
||||
|
||||
|
@ -11,7 +13,7 @@ describe Cerfa do
|
|||
it { is_expected.to belong_to(:user) }
|
||||
end
|
||||
|
||||
describe 'empty?' do
|
||||
describe 'empty?', vcr: { cassette_name: 'models_cerfa_empty' } do
|
||||
subject { create(:cerfa, content: content) }
|
||||
context 'when content exist' do
|
||||
let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
|
||||
|
|
|
@ -88,7 +88,7 @@ describe Dossier do
|
|||
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 }
|
||||
|
||||
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_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_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!(:dossier2) { 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_2) { create(:administrateur) }
|
||||
|
||||
let(:gestionnaire_1) { create(:gestionnaire, administrateur: administrateur_1) }
|
||||
let(:gestionnaire_2) { create(:gestionnaire, administrateur: administrateur_2) }
|
||||
let(:gestionnaire_1) { create(:gestionnaire, administrateurs: [administrateur_1]) }
|
||||
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_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.naf']).to eq('4950Z') }
|
||||
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.type_voie']).to eq('RUE') }
|
||||
it { expect(subject['etablissement.nom_voie']).to eq('RAOUL NORDLING') }
|
||||
|
|
|
@ -17,7 +17,7 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
|
||||
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(:dossiers) }
|
||||
end
|
||||
|
@ -26,10 +26,15 @@ describe Gestionnaire, type: :model do
|
|||
let(:admin) { create :administrateur }
|
||||
let(:procedure) { 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(:procedure_filter) { [] }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
|
||||
end
|
||||
|
||||
subject { gestionnaire.dossiers_filter }
|
||||
|
||||
context 'before filter' do
|
||||
|
@ -47,7 +52,12 @@ describe Gestionnaire, type: :model do
|
|||
let(:admin) { create :administrateur }
|
||||
let!(:procedure) { 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) { [] }
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ require 'spec_helper'
|
|||
describe PieceJustificative do
|
||||
describe 'database columns' do
|
||||
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) }
|
||||
end
|
||||
|
||||
|
@ -26,7 +28,7 @@ describe PieceJustificative do
|
|||
it { is_expected.to delegate_method(:api_entreprise).to(:type_de_piece_justificative) }
|
||||
end
|
||||
|
||||
describe '#empty?' do
|
||||
describe '#empty?', vcr: { cassette_name: 'model_piece_justificative' } do
|
||||
let(:piece_justificative) { create(:piece_justificative, content: content) }
|
||||
subject { piece_justificative.empty? }
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ describe Procedure do
|
|||
it { is_expected.to have_db_column(:test) }
|
||||
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_secure_token) }
|
||||
it { is_expected.to have_db_column(:cerfa_flag) }
|
||||
end
|
||||
|
||||
|
|
32
spec/services/accompagnateur_service_spec.rb
Normal file
32
spec/services/accompagnateur_service_spec.rb
Normal 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
|
|
@ -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.
|
||||
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
|
||||
|
||||
SIADETOKEN = :valid_token unless defined? SIADETOKEN
|
||||
|
@ -88,4 +95,22 @@ RSpec.configure do |config|
|
|||
config.include Devise::TestHelpers, type: :controller
|
||||
|
||||
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
|
||||
|
|
3
spec/support/factory_girl.rb
Normal file
3
spec/support/factory_girl.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
RSpec.configure do |config|
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
end
|
60
spec/views/admin/accompagnateurs/show.html.haml_spec.rb
Normal file
60
spec/views/admin/accompagnateurs/show.html.haml_spec.rb
Normal 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
|
|
@ -21,7 +21,7 @@ describe 'admin/gestionnaires/index.html.haml', type: :view do
|
|||
|
||||
context 'Ajout d\'un accompagnateur' do
|
||||
before do
|
||||
create(:gestionnaire, administrateur: admin)
|
||||
create(:gestionnaire, administrateurs: [admin])
|
||||
admin.reload
|
||||
assign(:gestionnaires, (smart_listing_create :gestionnaires,
|
||||
admin.gestionnaires,
|
||||
|
|
|
@ -5,7 +5,7 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
|||
|
||||
before do
|
||||
assign(:facade, AdminProceduresShowFacades.new(procedure.decorate))
|
||||
|
||||
assign(:procedure, procedure)
|
||||
render
|
||||
end
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue