2019-09-10-01 (#4291)

2019-09-10-01
This commit is contained in:
Pierre de La Morinerie 2019-09-10 15:21:09 +02:00 committed by GitHub
commit b6e5c0bde7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 213 additions and 810 deletions

View file

@ -48,19 +48,15 @@ class Admin::AttestationTemplatesController < AdminController
# In a case of a preview, when the user does not change its images,
# the images are not uploaded and thus should be retrieved from previous
# attestation_template
@logo = activated_attestation_params[:logo_active_storage] || @procedure.attestation_template&.proxy_logo
@signature = activated_attestation_params[:signature_active_storage] || @procedure.attestation_template&.proxy_signature
@logo = activated_attestation_params[:logo] || @procedure.attestation_template&.proxy_logo
@signature = activated_attestation_params[:signature] || @procedure.attestation_template&.proxy_signature
render 'admin/attestation_templates/show', formats: [:pdf]
end
def delete_logo
attestation_template = @procedure.attestation_template
if attestation_template.logo.present?
attestation_template.remove_logo!
attestation_template.save
end
attestation_template.logo.purge_later
attestation_template.logo_active_storage.purge_later
flash.notice = 'le logo a bien été supprimée'
@ -69,11 +65,7 @@ class Admin::AttestationTemplatesController < AdminController
def delete_signature
attestation_template = @procedure.attestation_template
if attestation_template.signature.present?
attestation_template.remove_signature!
attestation_template.save
end
attestation_template.signature.purge_later
attestation_template.signature_active_storage.purge_later
flash.notice = 'la signature a bien été supprimée'
@ -93,10 +85,10 @@ class Admin::AttestationTemplatesController < AdminController
signature_file = params['attestation_template'].delete('signature')
if logo_file.present?
@activated_attestation_params[:logo_active_storage] = uninterlaced_png(logo_file)
@activated_attestation_params[:logo] = uninterlaced_png(logo_file)
end
if signature_file.present?
@activated_attestation_params[:signature_active_storage] = uninterlaced_png(signature_file)
@activated_attestation_params[:signature] = uninterlaced_png(signature_file)
end
end

View file

@ -247,10 +247,7 @@ class Admin::ProceduresController < AdminController
end
def delete_logo
if @procedure.logo
@procedure.remove_logo!
@procedure.save
end
@procedure.logo.purge_later
@procedure.logo_active_storage.purge_later
flash.notice = 'le logo a bien été supprimé'
@ -284,9 +281,6 @@ class Admin::ProceduresController < AdminController
else
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :path)
end
if permited_params[:logo]
permited_params[:logo_active_storage] = permited_params.delete(:logo)
end
permited_params
end
end

View file

@ -14,10 +14,10 @@ module Instructeurs
after_action :mark_annotations_privees_as_read, only: [:annotations_privees, :update_annotations]
def attestation
if dossier.attestation.pdf_active_storage.attached?
if dossier.attestation.pdf.attached?
redirect_to url_for(dossier.attestation.pdf)
elsif dossier.attestation.pdf_active_storage.attached?
redirect_to url_for(dossier.attestation.pdf_active_storage)
else
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
end
end

View file

@ -48,10 +48,10 @@ module Users
end
def attestation
if dossier.attestation.pdf_active_storage.attached?
if dossier.attestation.pdf.attached?
redirect_to url_for(dossier.attestation.pdf)
elsif dossier.attestation.pdf_active_storage.attached?
redirect_to url_for(dossier.attestation.pdf_active_storage)
else
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
end
end

View file

@ -8,21 +8,19 @@ class ApplicationMailer < ActionMailer::Base
def attach_logo(procedure)
return nil if !procedure.logo?
begin
if procedure.logo_active_storage.attached?
logo_filename = procedure.logo_active_storage.filename.to_s
attachments.inline[logo_filename] = procedure.logo_active_storage.download
else
logo_filename = procedure.logo.filename
attachments.inline[logo_filename] = procedure.logo.read
end
attachments[logo_filename].url
rescue StandardError => e
# A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ?
Raven.extra_context(procedure_id: procedure.id)
Raven.capture_exception(e)
nil
if procedure.logo.attached?
logo_filename = procedure.logo.filename.to_s
attachments.inline[logo_filename] = procedure.logo.download
elsif procedure.logo_active_storage.attached?
logo_filename = procedure.logo_active_storage.filename.to_s
attachments.inline[logo_filename] = procedure.logo_active_storage.download
end
attachments[logo_filename].url
rescue StandardError => e
# A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ?
Raven.extra_context(procedure_id: procedure.id)
Raven.capture_exception(e)
nil
end
end

View file

@ -7,4 +7,9 @@ class DeviseUserMailer < Devise::Mailer
def template_paths
['devise_mailer']
end
def confirmation_instructions(record, token, opts = {})
opts[:from] = NO_REPLY_EMAIL
super
end
end

View file

@ -12,7 +12,7 @@ class DossierMailer < ApplicationMailer
subject = "Retrouvez votre brouillon pour la démarche « #{dossier.procedure.libelle} »"
mail(to: dossier.user.email, subject: subject) do |format|
mail(from: NO_REPLY_EMAIL, to: dossier.user.email, subject: subject) do |format|
format.html { render layout: 'mailers/notifications_layout' }
end
end
@ -24,7 +24,7 @@ class DossierMailer < ApplicationMailer
subject = "Nouveau message pour votre dossier nº #{dossier.id} (#{dossier.procedure.libelle})"
mail(to: dossier.user.email, subject: subject) do |format|
mail(from: NO_REPLY_EMAIL, to: dossier.user.email, subject: subject) do |format|
format.html { render layout: 'mailers/notifications_layout' }
end
end
@ -60,8 +60,13 @@ class DossierMailer < ApplicationMailer
def notify_revert_to_instruction(dossier)
@dossier = dossier
@subject = "Votre dossier nº #{@dossier.id} est en train d'être réexaminé"
@service = dossier.procedure.service
@logo_url = attach_logo(dossier.procedure)
mail(to: dossier.user.email, subject: @subject)
subject = "Votre dossier nº #{@dossier.id} est en train d'être réexaminé"
mail(from: NO_REPLY_EMAIL, to: dossier.user.email, subject: subject) do |format|
format.html { render layout: 'mailers/notifications_layout' }
end
end
end

View file

@ -12,6 +12,7 @@ class NotificationMailer < ApplicationMailer
helper MailerHelper
layout 'mailers/notifications_layout'
default from: NO_REPLY_EMAIL
def send_dossier_received(dossier)
send_notification(dossier, dossier.procedure.received_mail_template)

View file

@ -1,18 +1,16 @@
class Attestation < ApplicationRecord
self.ignored_columns = ['pdf']
belongs_to :dossier
mount_uploader :pdf, AttestationUploader
has_one_attached :pdf
has_one_attached :pdf_active_storage
def pdf_url
if pdf_active_storage.attached?
if pdf.attached?
Rails.application.routes.url_helpers.url_for(pdf)
elsif pdf_active_storage.attached?
Rails.application.routes.url_helpers.url_for(pdf_active_storage)
elsif Rails.application.secrets.fog[:enabled]
RemoteDownloader.new(pdf.path).url
elsif pdf&.url
# FIXME: this is horrible but used only in dev and will be removed after migration
File.join(LOCAL_DOWNLOAD_URL, pdf.url)
end
end
end

View file

@ -1,13 +1,14 @@
class AttestationTemplate < ApplicationRecord
self.ignored_columns = ['logo', 'signature']
include ActionView::Helpers::NumberHelper
include TagsSubstitutionConcern
belongs_to :procedure
mount_uploader :logo, AttestationTemplateLogoUploader
mount_uploader :signature, AttestationTemplateSignatureUploader
has_one_attached :logo
has_one_attached :logo_active_storage
has_one_attached :signature
has_one_attached :signature_active_storage
validates :footer, length: { maximum: 190 }
@ -16,7 +17,7 @@ class AttestationTemplate < ApplicationRecord
def attestation_for(dossier)
attestation = Attestation.new(title: replace_tags(title, dossier))
attestation.pdf_active_storage.attach(
attestation.pdf.attach(
io: build_pdf(dossier),
filename: "attestation-dossier-#{dossier.id}.pdf",
content_type: 'application/pdf',
@ -45,80 +46,82 @@ class AttestationTemplate < ApplicationRecord
def dup
attestation_template = AttestationTemplate.new(title: title, body: body, footer: footer, activated: activated)
if logo_active_storage.attached?
attestation_template.logo_active_storage.attach(
if logo.attached?
attestation_template.logo.attach(
io: StringIO.new(logo.download),
filename: logo.filename.to_s,
content_type: logo.content_type,
# we don't want to run virus scanner on duplicated file
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
)
elsif logo_active_storage.attached?
attestation_template.logo.attach(
io: StringIO.new(logo_active_storage.download),
filename: logo_active_storage.filename,
filename: logo_active_storage.filename.to_s,
content_type: logo_active_storage.content_type,
# we don't want to run virus scanner on duplicated file
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
)
elsif logo.present?
CopyCarrierwaveFile::CopyFileService.new(self, attestation_template, :logo).set_file
end
if signature_active_storage.attached?
attestation_template.signature_active_storage.attach(
if signature.attached?
attestation_template.signature.attach(
io: StringIO.new(signature.download),
filename: signature.filename.to_s,
content_type: signature.content_type,
# we don't want to run virus scanner on duplicated file
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
)
elsif signature_active_storage.attached?
attestation_template.signature.attach(
io: StringIO.new(signature_active_storage.download),
filename: signature_active_storage.filename,
filename: signature_active_storage.filename.to_s,
content_type: signature_active_storage.content_type,
# we don't want to run virus scanner on duplicated file
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
)
elsif signature.present?
CopyCarrierwaveFile::CopyFileService.new(self, attestation_template, :signature).set_file
end
attestation_template
end
def logo?
logo_active_storage.attached? || logo.present?
logo.attached? || logo_active_storage.attached?
end
def signature?
signature_active_storage.attached? || signature.present?
signature.attached? || signature_active_storage.attached?
end
def logo_url
if logo_active_storage.attached?
if logo.attached?
Rails.application.routes.url_helpers.url_for(logo)
elsif logo_active_storage.attached?
Rails.application.routes.url_helpers.url_for(logo_active_storage)
elsif logo.present?
if Rails.application.secrets.fog[:enabled]
RemoteDownloader.new(logo.path).url
elsif logo&.url
# FIXME: this is horrible but used only in dev and will be removed after migration
File.join(LOCAL_DOWNLOAD_URL, logo.url)
end
end
end
def signature_url
if signature_active_storage.attached?
if signature.attached?
Rails.application.routes.url_helpers.url_for(signature)
elsif signature_active_storage.attached?
Rails.application.routes.url_helpers.url_for(signature_active_storage)
elsif signature.present?
if Rails.application.secrets.fog[:enabled]
RemoteDownloader.new(signature.path).url
elsif signature&.url
# FIXME: this is horrible but used only in dev and will be removed after migration
File.join(LOCAL_DOWNLOAD_URL, signature.url)
end
end
end
def proxy_logo
if logo_active_storage.attached?
logo_active_storage
else
if logo.attached?
logo
elsif logo_active_storage.attached?
logo_active_storage
end
end
def proxy_signature
if signature_active_storage.attached?
signature_active_storage
else
if signature.attached?
signature
elsif signature_active_storage.attached?
signature_active_storage
end
end

View file

@ -1,4 +1,6 @@
class Commentaire < ApplicationRecord
self.ignored_columns = ['file']
belongs_to :dossier, inverse_of: :commentaires, touch: true
belongs_to :user

View file

@ -454,7 +454,7 @@ class Dossier < ApplicationRecord
['Archivé', :archived],
['État du dossier', I18n.t(state, scope: [:activerecord, :attributes, :dossier, :state])],
['Dernière mise à jour le', :updated_at],
['Passé en construction le', :en_construction_at],
['Déposé le', :en_construction_at],
['Passé en instruction le', :en_instruction_at],
['Traité le', :processed_at],
['Motivation de la décision', :motivation],

View file

@ -2,6 +2,6 @@ class GroupeInstructeur < ApplicationRecord
DEFAULT_LABEL = 'défaut'
belongs_to :procedure
has_many :assign_tos
has_many :instructeurs, through: :assign_tos
has_many :instructeurs, through: :assign_tos, dependent: :destroy
has_many :dossiers
end

View file

@ -1,6 +1,8 @@
require Rails.root.join('lib', 'percentile')
class Procedure < ApplicationRecord
self.ignored_columns = ['logo']
MAX_DUREE_CONSERVATION = 36
has_many :types_de_champ, -> { root.public_only.ordered }, inverse_of: :procedure, dependent: :destroy
@ -25,6 +27,7 @@ class Procedure < ApplicationRecord
has_one :refused_mail, class_name: "Mails::RefusedMail", dependent: :destroy
has_one :without_continuation_mail, class_name: "Mails::WithoutContinuationMail", dependent: :destroy
has_one_attached :logo
has_one_attached :logo_active_storage
has_one_attached :notice
has_one_attached :deliberation
@ -32,8 +35,6 @@ class Procedure < ApplicationRecord
accepts_nested_attributes_for :types_de_champ, reject_if: proc { |attributes| attributes['libelle'].blank? }, allow_destroy: true
accepts_nested_attributes_for :types_de_champ_private, reject_if: proc { |attributes| attributes['libelle'].blank? }, allow_destroy: true
mount_uploader :logo, ProcedureLogoUploader
default_scope { where(hidden_at: nil) }
scope :brouillons, -> { where(aasm_state: :brouillon) }
scope :publiees, -> { where(aasm_state: :publiee) }
@ -221,10 +222,6 @@ class Procedure < ApplicationRecord
procedure.test_started_at = nil
procedure.archived_at = nil
procedure.published_at = nil
procedure.logo_secure_token = nil
if logo.present?
procedure.remote_logo_url = self.logo_url
end
procedure.lien_notice = nil
if is_different_admin || from_library
@ -264,6 +261,7 @@ class Procedure < ApplicationRecord
if original.is_a?(TypeDeChamp)
clone_attachment(:piece_justificative_template, original, kopy)
elsif original.is_a?(Procedure)
clone_attachment(:logo, original, kopy)
clone_attachment(:logo_active_storage, original, kopy)
clone_attachment(:notice, original, kopy)
clone_attachment(:deliberation, original, kopy)
@ -466,21 +464,16 @@ class Procedure < ApplicationRecord
end
def logo?
logo.present? || logo_active_storage.attached?
logo.attached? || logo_active_storage.attached?
end
def logo_url
if !logo?
ActionController::Base.helpers.image_url("marianne.svg")
if logo.attached?
Rails.application.routes.url_helpers.url_for(logo)
elsif logo_active_storage.attached?
Rails.application.routes.url_helpers.url_for(logo_active_storage)
else
if Rails.application.secrets.fog[:enabled]
RemoteDownloader.new(logo.filename).url
else
# FIXME: this is horrible but used only in dev and will be removed after migration
File.join(LOCAL_DOWNLOAD_URL, logo.url)
end
ActionController::Base.helpers.image_url("marianne.svg")
end
end

View file

@ -17,6 +17,7 @@ class ProcedureSerializer < ActiveModel::Serializer
has_many :types_de_champ, serializer: TypeDeChampSerializer
has_many :types_de_champ_private, serializer: TypeDeChampSerializer
has_many :types_de_piece_justificative
belongs_to :service, serializer: ServiceSerializer
def archived_at
object.archived_at&.in_time_zone('UTC')

View file

@ -0,0 +1,9 @@
class ServiceSerializer < ActiveModel::Serializer
attributes :id, :email
attribute :nom, key: :name
attribute :type_organisme, key: :type_organization
attribute :organisme, key: :organization
attribute :telephone, key: :phone
attribute :horaires, key: :schedule
attribute :adresse, key: :address
end

View file

@ -1,38 +0,0 @@
class AttestationTemplateLogoUploader < BaseUploader
def root
Rails.root.join("public")
end
# Choose what kind of storage to use for this uploader:
if Rails.application.secrets.fog[:enabled]
storage :fog
else
storage :file
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
if !Rails.application.secrets.fog[:enabled]
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
['jpg', 'jpeg', 'png']
end
def filename
if file.present?
"attestation-template-logo-#{secure_token}.#{file.extension.downcase}"
end
end
private
def secure_token
model.logo_secure_token ||= SecureRandom.uuid
end
end

View file

@ -1,38 +0,0 @@
class AttestationTemplateSignatureUploader < BaseUploader
def root
Rails.root.join("public")
end
# Choose what kind of storage to use for this uploader:
if Rails.application.secrets.fog[:enabled]
storage :fog
else
storage :file
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
if !Rails.application.secrets.fog[:enabled]
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
['jpg', 'jpeg', 'png']
end
def filename
if file.present?
"attestation-template-signature-#{secure_token}.#{file.extension.downcase}"
end
end
private
def secure_token
model.signature_secure_token ||= SecureRandom.uuid
end
end

View file

@ -1,32 +0,0 @@
class AttestationUploader < BaseUploader
def root
Rails.root.join("public")
end
# Choose what kind of storage to use for this uploader:
if Rails.application.secrets.fog[:enabled]
storage :fog
else
storage :file
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
if !Rails.application.secrets.fog[:enabled]
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
def filename
if file.present?
"attestation-#{secure_token}.pdf"
end
end
private
def secure_token
model.content_secure_token ||= SecureRandom.uuid
end
end

View file

@ -1,13 +0,0 @@
class BaseUploader < CarrierWave::Uploader::Base
def cache_dir
Rails.application.secrets.carrierwave[:cache_dir]
end
# https://github.com/carrierwaveuploader/carrierwave/wiki/how-to:-silently-ignore-missing-files-on-destroy-or-overwrite
def remove!
begin
super
rescue Fog::OpenStack::Storage::NotFound
end
end
end

View file

@ -1,41 +0,0 @@
require 'securerandom'
class LocalDownloader
BASE_PATH_DISK = Rails.root.join("public", "downloads")
def initialize(filename, filename_suffix = '')
@filename = filename.to_s
@filename_suffix = filename_suffix.empty? ? '' : "_#{filename_suffix}"
@extension = @filename.split(/[.]/).last
generate_random_base_path!
FileUtils.ln_s @filename, "#{@base_path}/#{@filename_suffix}.#{@extension}"
end
def url
@url ||= File.join(LOCAL_DOWNLOAD_URL, 'downloads', random_folder_name, "#{@filename_suffix}.#{@extension}")
end
protected
attr_accessor :random_folder_name
def generate_random_base_path!
@base_path ||= begin
loop do
self.random_folder_name = SecureRandom.hex
base_path = File.join(BASE_PATH_DISK, self.random_folder_name)
if !File.directory?(BASE_PATH_DISK)
Dir.mkdir(BASE_PATH_DISK)
end
if !File.directory?(base_path)
Dir.mkdir(base_path)
break base_path
end
end
end
end
end

View file

@ -1,49 +0,0 @@
class ProcedureLogoUploader < BaseUploader
def root
Rails.root.join("public")
end
# Choose what kind of storage to use for this uploader:
if Rails.application.secrets.fog[:enabled]
storage :fog
else
storage :file
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
if !Rails.application.secrets.fog[:enabled]
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
['jpg', 'jpeg', 'png']
end
def filename
if file.present?
if original_filename.present? || model.logo_secure_token
if Rails.application.secrets.fog[:enabled]
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension&.downcase}"
else
filename = "logo-#{secure_token}.#{file.extension&.downcase}"
end
end
filename
end
end
private
def secure_token
model.logo_secure_token ||= generate_secure_token
end
def generate_secure_token
SecureRandom.uuid
end
end

View file

@ -1,17 +0,0 @@
class RemoteDownloader
def initialize(filename)
@filename = filename
end
def url
if @filename.present?
@url ||= File.join(base_url, CarrierWave::Uploader::Base.fog_directory, @filename)
end
end
protected
def base_url
FOG_BASE_URL
end
end

View file

@ -1,3 +1,6 @@
- content_for :procedure_logo do
= render 'layouts/mailers/logo', url: @logo_url
%p
Bonjour,
@ -13,4 +16,7 @@
email:
= mail_to @dossier.procedure.service.email, @dossier.procedure.service.email
= render partial: "layouts/mailers/signature"
= render 'layouts/mailers/signature'
- content_for :footer do
= render 'layouts/mailers/service_footer', service: @service, dossier: @dossier

View file

@ -5,8 +5,8 @@
%strong Logo
%p
- if field.data.logo.present?
= image_tag field.data.logo.url
- if field.data.logo?
= image_tag field.data.logo_url
- else
Aucun
@ -20,8 +20,8 @@
%strong Signature
%p
- if field.data.signature.present?
= image_tag field.data.signature.url
- if field.data.signature?
= image_tag field.data.signature_url
- else
Aucun

View file

@ -9,7 +9,7 @@
= link_to(instructeur_procedure_path(p)) do
.flex
.procedure-logo{ style: p.logo.present? ? "background-image: url(#{p.logo.url})" : nil }
.procedure-logo{ style: "background-image: url(#{p.logo_url})" }
.procedure-details
%p.procedure-title

View file

@ -4,7 +4,7 @@
.sub-header
.container.flex
.procedure-logo{ style: @procedure.logo? ? "background-image: url(#{@procedure.logo_url})" : nil,
.procedure-logo{ style: "background-image: url(#{@procedure.logo_url})",
role: 'img', 'aria-label': "logo de la démarche #{@procedure.libelle}" }
.procedure-header

View file

@ -1,7 +1,6 @@
#first-block
.en-cours
- if @procedure.logo?
= image_tag @procedure.logo_url, style: 'width: 30px;'
= image_tag @procedure.logo_url, style: 'width: 30px;'
%b
= @procedure.libelle

View file

@ -1,5 +1,8 @@
= form_for(commentaire, url: form_url, html: { class: 'form' }) do |f|
= f.text_area :body, rows: 5, placeholder: 'Écrivez votre message à ladministration ici', required: true, class: 'message-textarea'
- placeholder = 'Écrivez votre message à ladministration ici'
- if instructeur_signed_in? || administrateur_signed_in?
- placeholder = 'Écrivez votre message ici'
= f.text_area :body, rows: 5, placeholder: placeholder, required: true, class: 'message-textarea'
.flex.justify-between.wrap
%div
= f.file_field :piece_jointe, id: 'piece_jointe', direct_upload: true

View file

@ -14,11 +14,6 @@
- if commentaire.piece_jointe.attached?
.attachment-link
= render partial: "shared/attachment/show", locals: { attachment: commentaire.piece_jointe.attachment }
- elsif commentaire.file.present?
.attachment-link
= link_to commentaire.file_url, class: "button", target: "_blank", rel: "noopener", title: "Télécharger" do
%span.icon.attachment
= commentaire.file_identifier
- if show_reply_button
= button_tag type: 'button', class: 'button small message-answer-button', onclick: 'document.querySelector("#commentaire_body").focus()' do

View file

@ -1,47 +0,0 @@
module Fog
module ServicesMixin
private
def require_service_provider_library(service, provider)
# Monkey patch to fix https://github.com/fog/fog/issues/4014
# This method exists in fog to load legacy providers that have not yet been extracted to
# their own gem.
# fog-openstack has been extracted to its own gem and does not need this method.
# Furthermore, fog-openstack has recently been refactored in a way that breaks this method.
#
# Therefore, until either fog or fog-openstack fixes the problem, we have to neuter the method.
end
end
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
config.fog_provider = 'fog/openstack'
if ENV['FOG_ENABLED'] == 'enabled'
config.fog_credentials = {
provider: 'OpenStack',
openstack_tenant: Rails.application.secrets.fog[:openstack_tenant],
openstack_api_key: Rails.application.secrets.fog[:openstack_api_key],
openstack_username: Rails.application.secrets.fog[:openstack_username],
openstack_auth_url: Rails.application.secrets.fog[:openstack_auth_url],
openstack_region: Rails.application.secrets.fog[:openstack_region],
openstack_identity_api_version: Rails.application.secrets.fog[:openstack_identity_api_version]
}
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.join("uploads")
config.fog_public = true
config.fog_directory = Rails.application.secrets.fog[:directory]
end

View file

@ -2,7 +2,7 @@ if !defined?(CONTACT_EMAIL)
CONTACT_EMAIL = "contact@demarches-simplifiees.fr"
EQUIPE_EMAIL = "equipe@demarches-simplifiees.fr"
TECH_EMAIL = "tech@demarches-simplifiees.fr"
NO_REPLY_EMAIL = "Ne pas répondre <ne-pas-repondre@demarches-simplifiees.fr>"
CONTACT_PHONE = "01 76 42 02 87"
OLD_CONTACT_EMAIL = "contact@tps.apientreprise.fr"

View file

@ -28,6 +28,3 @@ FAQ_ADMIN_URL = "https://faq.demarches-simplifiees.fr/collection/1-administrateu
COMMENT_TROUVER_MA_DEMARCHE_URL = [FAQ_URL, "article", "59-comment-trouver-ma-demarche"].join("/")
STATUS_PAGE_URL = "https://status.demarches-simplifiees.fr"
MATOMO_IFRAME_URL = "https://stats.data.gouv.fr/index.php?module=CoreAdminHome&action=optOut&language=fr&&fontColor=333333&fontSize=16px&fontFamily=Muli"
# FIXME: This is only used in dev in couple of places and should be removed after PJ migration
LOCAL_DOWNLOAD_URL = "http://#{ENV.fetch('APP_HOST', 'localhost:3000')}"

View file

@ -1,33 +0,0 @@
namespace :'2019_08_20_migrate_procedure_logo' do
task run: :environment do
procedures = Procedure.unscope(where: :hidden_at)
.where.not(logo: nil)
.left_joins(:logo_active_storage_attachment)
.where('active_storage_attachments.id IS NULL')
.order(:created_at)
limit = ENV['LIMIT']
if limit
procedures.limit!(limit.to_i)
end
progress = ProgressReport.new(procedures.count)
procedures.find_each do |procedure|
if procedure.logo.present?
uri = URI.parse(URI.escape(procedure.logo_url))
response = Typhoeus.get(uri)
if response.success?
filename = procedure.logo.filename || procedure.logo_identifier
procedure.logo_active_storage.attach(
io: StringIO.new(response.body),
filename: filename,
content_type: procedure.logo.content_type,
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
)
end
end
progress.inc
end
progress.finish
end
end

View file

@ -1,97 +0,0 @@
namespace :'2019_08_22_migrate_attestation_files' do
task migrate_attestation_pdf: :environment do
attestations = Attestation.where
.not(pdf: nil)
.left_joins(:pdf_active_storage_attachment)
.where('active_storage_attachments.id IS NULL')
.order(:created_at)
limit = ENV['LIMIT']
if limit
attestations.limit!(limit.to_i)
end
progress = ProgressReport.new(attestations.count)
attestations.find_each do |attestation|
if attestation.pdf.present?
uri = URI.parse(URI.escape(attestation.pdf_url))
response = Typhoeus.get(uri)
if response.success?
filename = attestation.pdf.filename || attestation.pdf_identifier
attestation.pdf_active_storage.attach(
io: StringIO.new(response.body),
filename: filename,
content_type: attestation.pdf.content_type,
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
)
end
end
progress.inc
end
progress.finish
end
task migrate_attestation_template_logo: :environment do
attestation_templates = AttestationTemplate.where
.not(logo: nil)
.left_joins(:logo_active_storage_attachment)
.where('active_storage_attachments.id IS NULL')
.order(:created_at)
limit = ENV['LIMIT']
if limit
attestation_templates.limit!(limit.to_i)
end
progress = ProgressReport.new(attestation_templates.count)
attestation_templates.find_each do |attestation_template|
if attestation_template.logo.present?
uri = URI.parse(URI.escape(attestation_template.logo_url))
response = Typhoeus.get(uri)
if response.success?
filename = attestation_template.logo.filename || attestation_template.logo_identifier
attestation_template.logo_active_storage.attach(
io: StringIO.new(response.body),
filename: filename,
content_type: attestation_template.logo.content_type,
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
)
end
end
progress.inc
end
progress.finish
end
task migrate_attestation_template_signature: :environment do
attestation_templates = AttestationTemplate.where
.not(signature: nil)
.left_joins(:signature_active_storage_attachment)
.where('active_storage_attachments.id IS NULL')
.order(:created_at)
limit = ENV['LIMIT']
if limit
attestation_templates.limit!(limit.to_i)
end
progress = ProgressReport.new(attestation_templates.count)
attestation_templates.find_each do |attestation_template|
if attestation_template.signature.present?
uri = URI.parse(URI.escape(attestation_template.signature_url))
response = Typhoeus.get(uri)
if response.success?
filename = attestation_template.signature.filename || attestation_template.signature_identifier
attestation_template.signature_active_storage.attach(
io: StringIO.new(response.body),
filename: filename,
content_type: attestation_template.signature.content_type,
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE }
)
end
end
progress.inc
end
progress.finish
end
end

View file

@ -0,0 +1,14 @@
namespace :after_party do
desc 'Deployment task: rename_active_storage_attachments'
task rename_active_storage_attachments: :environment do
puts "Running deploy task 'rename_active_storage_attachments'"
ActiveStorage::Attachment.where(name: 'logo_active_storage').update_all(name: 'logo')
ActiveStorage::Attachment.where(name: 'signature_active_storage').update_all(name: 'signature')
ActiveStorage::Attachment.where(name: 'pdf_active_storage').update_all(name: 'pdf')
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord.create version: '20190828130014'
end
end

View file

@ -40,6 +40,8 @@ describe Admin::AttestationTemplatesController, type: :controller do
end
context 'if an attestation template exists on the procedure' do
after { procedure.attestation_template.destroy }
context 'with logos' do
let!(:attestation_template) do
create(:attestation_template, logo: logo, signature: signature)
@ -48,9 +50,16 @@ describe Admin::AttestationTemplatesController, type: :controller do
it { expect(subject.status).to eq(200) }
it { expect(assigns).to include(upload_params.stringify_keys) }
it { expect(assigns[:created_at]).to eq(Time.zone.now) }
it { expect(assigns(:logo).read).to eq(logo.read) }
it { expect(assigns(:signature).read).to eq(signature.read) }
after { procedure.attestation_template.destroy }
it { expect(assigns(:logo).download).to eq(logo2.read) }
it { expect(assigns(:signature).download).to eq(signature2.read) }
end
context 'with empty logo' do
it { expect(subject.status).to eq(200) }
it { expect(assigns).to include(upload_params.stringify_keys) }
it { expect(assigns[:created_at]).to eq(Time.zone.now) }
it { expect(assigns(:logo)).to eq(nil) }
it { expect(assigns(:signature)).to eq(nil) }
end
end
end
@ -87,8 +96,8 @@ describe Admin::AttestationTemplatesController, type: :controller do
it { expect(procedure.attestation_template).to have_attributes(attestation_params) }
it { expect(procedure.attestation_template.activated).to be true }
it { expect(procedure.attestation_template.logo_active_storage.download).to eq(logo2.read) }
it { expect(procedure.attestation_template.signature_active_storage.download).to eq(signature2.read) }
it { expect(procedure.attestation_template.logo.download).to eq(logo2.read) }
it { expect(procedure.attestation_template.signature.download).to eq(signature2.read) }
it { expect(response).to redirect_to edit_admin_procedure_attestation_template_path(procedure) }
it { expect(flash.notice).to eq("L'attestation a bien été sauvegardée") }
@ -130,8 +139,8 @@ describe Admin::AttestationTemplatesController, type: :controller do
end
it { expect(procedure.attestation_template).to have_attributes(attestation_params) }
it { expect(procedure.attestation_template.logo_active_storage.download).to eq(logo2.read) }
it { expect(procedure.attestation_template.signature_active_storage.download).to eq(signature2.read) }
it { expect(procedure.attestation_template.logo.download).to eq(logo2.read) }
it { expect(procedure.attestation_template.signature.download).to eq(signature2.read) }
it { expect(response).to redirect_to edit_admin_procedure_attestation_template_path(procedure) }
it { expect(flash.notice).to eq("L'attestation a bien été modifiée") }

View file

@ -96,9 +96,9 @@ describe Admin::ProceduresController, type: :controller do
end
describe 'DELETE #destroy' do
let(:procedure_draft) { create :procedure_with_dossiers, administrateur: admin, published_at: nil, archived_at: nil }
let(:procedure_published) { create :procedure_with_dossiers, administrateur: admin, aasm_state: :publiee, published_at: Time.zone.now, archived_at: nil }
let(:procedure_archived) { create :procedure_with_dossiers, administrateur: admin, aasm_state: :archivee, published_at: nil, archived_at: Time.zone.now }
let(:procedure_draft) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], published_at: nil, archived_at: nil }
let(:procedure_published) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], aasm_state: :publiee, published_at: Time.zone.now, archived_at: nil }
let(:procedure_archived) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], aasm_state: :archivee, published_at: nil, archived_at: Time.zone.now }
subject { delete :destroy, params: { id: procedure.id } }

View file

@ -25,7 +25,7 @@ describe API::V1::ProceduresController, type: :controller do
it { is_expected.to have_http_status(200) }
describe 'body' do
let(:procedure) { create(:procedure, :with_type_de_champ, administrateur: admin) }
let(:procedure) { create(:procedure, :with_type_de_champ, :with_service, administrateur: admin) }
let(:response) { get :show, params: { id: procedure.id, token: token } }
subject { JSON.parse(response.body, symbolize_names: true)[:procedure] }
@ -51,6 +51,21 @@ describe API::V1::ProceduresController, type: :controller do
it { expect(subject[:order_place]).to eq(champ.order_place) }
it { expect(subject[:description]).to eq(champ.description) }
end
describe 'service' do
subject { super()[:service] }
let(:service) { procedure.service }
it { expect(subject[:id]).to eq(service.id) }
it { expect(subject[:email]).to eq(service.email) }
it { expect(subject[:name]).to eq(service.nom) }
it { expect(subject[:type_organization]).to eq(service.type_organisme) }
it { expect(subject[:organization]).to eq(service.organisme) }
it { expect(subject[:phone]).to eq(service.telephone) }
it { expect(subject[:schedule]).to eq(service.horaires) }
it { expect(subject[:address]).to eq(service.adresse) }
end
end
end
end

View file

@ -15,21 +15,11 @@ describe Instructeurs::DossiersController, type: :controller do
describe '#attestation' do
context 'when a dossier has an attestation' do
let(:fake_pdf) { double(read: 'pdf content') }
let!(:dossier) { create(:dossier, :en_construction, attestation: Attestation.new, procedure: procedure) }
let!(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
let!(:dossier) { create(:dossier, :en_construction, attestation: Attestation.new, procedure: procedure) }
it 'returns the attestation pdf' do
allow_any_instance_of(Attestation).to receive(:pdf).and_return(fake_pdf)
expect(controller).to receive(:send_data)
.with('pdf content', filename: 'attestation.pdf', type: 'application/pdf') do
controller.head :ok
end
let(:dossier) { create(:dossier, :accepte, attestation: create(:attestation, :with_pdf), procedure: procedure) }
it 'redirects to attestation pdf' do
get :attestation, params: { procedure_id: procedure.id, dossier_id: dossier.id }
expect(response).to have_http_status(:success)
expect(response).to redirect_to(dossier.attestation.pdf_url.gsub('http://localhost:3000', ''))
end
end
end

View file

@ -141,19 +141,11 @@ describe Users::DossiersController, type: :controller do
before { sign_in(user) }
context 'when a dossier has an attestation' do
let(:fake_pdf) { double(read: 'pdf content') }
let!(:dossier) { create(:dossier, attestation: Attestation.new, user: user) }
it 'returns the attestation pdf' do
allow_any_instance_of(Attestation).to receive(:pdf).and_return(fake_pdf)
expect(controller).to receive(:send_data)
.with('pdf content', filename: 'attestation.pdf', type: 'application/pdf') do
controller.head :ok
end
let(:dossier) { create(:dossier, :accepte, attestation: create(:attestation, :with_pdf), user: user) }
it 'redirects to attestation pdf' do
get :attestation, params: { id: dossier.id }
expect(response).to have_http_status(:success)
expect(response).to redirect_to(dossier.attestation.pdf_url.gsub('http://localhost:3000', ''))
end
end
end

View file

@ -4,7 +4,7 @@ FactoryBot.define do
dossier { create(:dossier) }
end
trait :with_legacy_pdf do
trait :with_pdf do
pdf { Rack::Test::UploadedFile.new("./spec/fixtures/files/dossierPDF.pdf", 'application/pdf') }
end
end

View file

@ -7,11 +7,6 @@ FactoryBot.define do
end
trait :with_files do
logo_active_storage { Rack::Test::UploadedFile.new("./spec/fixtures/files/logo_test_procedure.png", 'image/png') }
signature_active_storage { Rack::Test::UploadedFile.new("./spec/fixtures/files/logo_test_procedure.png", 'image/png') }
end
trait :with_legacy_files do
logo { Rack::Test::UploadedFile.new("./spec/fixtures/files/logo_test_procedure.png", 'image/png') }
signature { Rack::Test::UploadedFile.new("./spec/fixtures/files/logo_test_procedure.png", 'image/png') }
end

View file

@ -53,10 +53,6 @@ FactoryBot.define do
end
trait :with_logo do
logo_active_storage { Rack::Test::UploadedFile.new("./spec/fixtures/files/logo_test_procedure.png", 'image/png') }
end
trait :with_legacy_logo do
logo { Rack::Test::UploadedFile.new("./spec/fixtures/files/logo_test_procedure.png", 'image/png') }
end

View file

@ -1,60 +0,0 @@
describe '2019_08_20_migrate_procedure_logo.rake' do
let(:rake_task) { Rake::Task['2019_08_20_migrate_procedure_logo:run'] }
let(:procedures) do
[
create(:procedure),
create(:procedure, :with_legacy_logo),
create(:procedure, :with_legacy_logo)
]
end
let(:run_task) do
rake_task.invoke
procedures.each(&:reload)
end
before do
procedures.each do |procedure|
if procedure.logo.present?
stub_request(:get, procedure.logo_url)
.to_return(status: 200, body: File.read(procedure.logo.path))
end
end
end
after do
ENV['LIMIT'] = nil
rake_task.reenable
end
it 'should migrate logo' do
expect(procedures.map(&:logo_active_storage).map(&:attached?)).to eq([false, false, false])
run_task
expect(Procedure.where(logo: nil).count).to eq(1)
expect(procedures.map(&:logo_active_storage).map(&:attached?)).to eq([false, true, true])
end
it 'should migrate logo within limit' do
expect(procedures.map(&:logo_active_storage).map(&:attached?)).to eq([false, false, false])
ENV['LIMIT'] = '1'
run_task
expect(Procedure.where(logo: nil).count).to eq(1)
expect(procedures.map(&:logo_active_storage).map(&:attached?)).to eq([false, true, false])
end
context 'when a procedure is hidden' do
let(:hidden_procedure) { create(:procedure, :hidden, :with_legacy_logo) }
let(:procedures) { [hidden_procedure] }
it 'should migrate logo' do
run_task
expect(hidden_procedure.logo_active_storage.attached?).to be true
end
end
end

View file

@ -1,128 +0,0 @@
describe '2019_08_22_migrate_attestation_files.rake' do
let(:rake_task) { Rake::Task["2019_08_22_migrate_attestation_files:#{sub_task}"] }
let(:run_task) do
rake_task.invoke
models.each(&:reload)
end
after do
ENV['LIMIT'] = nil
rake_task.reenable
end
context 'attestation' do
let(:models) do
[
create(:attestation, created_at: 3.days.ago),
create(:attestation, :with_legacy_pdf, created_at: 2.days.ago),
create(:attestation, :with_legacy_pdf, created_at: 1.day.ago)
]
end
before do
first_attestation = models[0]
expect(first_attestation.pdf.present?).to be_falsey
expect(first_attestation.read_attribute(:pdf)).to be_nil
models.each do |attestation|
if attestation.pdf.present?
stub_request(:get, attestation.pdf_url)
.to_return(status: 200, body: File.read(attestation.pdf.path))
end
end
end
context 'pdf' do
let(:sub_task) { 'migrate_attestation_pdf' }
it 'should migrate pdf' do
expect(models.map(&:pdf_active_storage).map(&:attached?)).to eq([false, false, false])
run_task
expect(Attestation.where(pdf: nil).count).to eq(1)
expect(models.map(&:pdf_active_storage).map(&:attached?)).to eq([false, true, true])
end
it 'should migrate pdf within limit' do
expect(models.map(&:pdf_active_storage).map(&:attached?)).to eq([false, false, false])
ENV['LIMIT'] = '1'
run_task
expect(Attestation.where(pdf: nil).count).to eq(1)
expect(models.map(&:pdf_active_storage).map(&:attached?)).to eq([false, true, false])
end
end
end
context 'attestation_templates' do
let(:models) do
[
create(:attestation_template),
create(:attestation_template, :with_legacy_files),
create(:attestation_template, :with_legacy_files)
]
end
before do
models.each do |attestation_template|
if attestation_template.logo.present?
stub_request(:get, attestation_template.logo_url)
.to_return(status: 200, body: File.read(attestation_template.logo.path))
end
if attestation_template.signature.present?
stub_request(:get, attestation_template.signature_url)
.to_return(status: 200, body: File.read(attestation_template.signature.path))
end
end
end
context 'logo' do
let(:sub_task) { 'migrate_attestation_template_logo' }
it 'should migrate logo' do
expect(models.map(&:logo_active_storage).map(&:attached?)).to eq([false, false, false])
run_task
expect(AttestationTemplate.where(logo: nil).count).to eq(1)
expect(models.map(&:logo_active_storage).map(&:attached?)).to eq([false, true, true])
end
it 'should migrate logo within limit' do
expect(models.map(&:logo_active_storage).map(&:attached?)).to eq([false, false, false])
ENV['LIMIT'] = '1'
run_task
expect(AttestationTemplate.where(logo: nil).count).to eq(1)
expect(models.map(&:logo_active_storage).map(&:attached?)).to eq([false, true, false])
end
end
context 'signature' do
let(:sub_task) { 'migrate_attestation_template_signature' }
it 'should migrate signature' do
expect(models.map(&:signature_active_storage).map(&:attached?)).to eq([false, false, false])
run_task
expect(AttestationTemplate.where(signature: nil).count).to eq(1)
expect(models.map(&:signature_active_storage).map(&:attached?)).to eq([false, true, true])
end
it 'should migrate signature within limit' do
expect(models.map(&:signature_active_storage).map(&:attached?)).to eq([false, false, false])
ENV['LIMIT'] = '1'
run_task
expect(AttestationTemplate.where(signature: nil).count).to eq(1)
expect(models.map(&:signature_active_storage).map(&:attached?)).to eq([false, true, false])
end
end
end
end

View file

@ -4,6 +4,10 @@ RSpec.describe DossierMailer, type: :mailer do
let(:to_email) { 'instructeur@exemple.gouv.fr' }
shared_examples 'a dossier notification' do
it 'is sent from a no-reply address' do
expect(subject.from.first).to eq(Mail::Address.new(NO_REPLY_EMAIL).address)
end
it 'includes the contact informations in the footer' do
expect(subject.body).to include('ne pas répondre')
end
@ -67,4 +71,16 @@ RSpec.describe DossierMailer, type: :mailer do
it { expect(subject.body).to include("n'a pas pu être supprimé") }
it { expect(subject.body).to include(dossier.procedure.libelle) }
end
describe '.notify_revert_to_instruction' do
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
subject { described_class.notify_revert_to_instruction(dossier) }
it { expect(subject.subject).to include('réexaminé') }
it { expect(subject.body).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include(dossier_url(dossier)) }
it_behaves_like 'a dossier notification'
end
end

View file

@ -56,5 +56,9 @@ RSpec.describe NotificationMailer, type: :mailer do
expect(mail.body).not_to include('iframe')
end
end
it 'sends the mail from a no-reply address' do
expect(subject.from.first).to eq(Mail::Address.new(NO_REPLY_EMAIL).address)
end
end
end

View file

@ -57,13 +57,11 @@ describe AttestationTemplate, type: :model do
describe 'dup' do
before do
@logo = File.open('spec/fixtures/files/white.png')
@signature = File.open('spec/fixtures/files/black.png')
@logo = Rack::Test::UploadedFile.new('spec/fixtures/files/white.png', 'image/png')
@signature = Rack::Test::UploadedFile.new('spec/fixtures/files/black.png', 'image/png')
end
after do
@logo.close
@signature.close
subject.destroy
end
@ -75,17 +73,17 @@ describe AttestationTemplate, type: :model do
it { is_expected.to have_attributes(attributes) }
it { is_expected.to have_attributes(id: nil) }
it { expect(subject.logo.file).to be_nil }
it { expect(subject.logo.attached?).to be_falsey }
end
context 'with an attestation with images' do
let(:attributes) { { logo: @logo, signature: @signature } }
it { expect(subject.logo.file.file).not_to eq(attestation_template.logo.file.file) }
it { expect(subject.logo.file.read).to eq(attestation_template.logo.file.read) }
it { expect(subject.logo.blob).not_to eq(attestation_template.logo.blob) }
it { expect(subject.logo.download).to eq(attestation_template.logo.download) }
it { expect(subject.signature.file.file).not_to eq(attestation_template.signature.file.file) }
it { expect(subject.signature.file.read).to eq(attestation_template.signature.file.read) }
it { expect(subject.signature.blob).not_to eq(attestation_template.signature.blob) }
it { expect(subject.signature.download).to eq(attestation_template.signature.download) }
end
end
@ -113,14 +111,10 @@ describe AttestationTemplate, type: :model do
end
before do
@logo = File.open('spec/fixtures/files/white.png')
@signature = File.open('spec/fixtures/files/black.png')
Timecop.freeze(Time.zone.now)
end
after do
@logo.close
@signature.close
Timecop.return
end

View file

@ -45,7 +45,7 @@ describe ProcedureExportV2Service do
"Archivé",
"État du dossier",
"Dernière mise à jour le",
"Passé en construction le",
"Déposé le",
"Passé en instruction le",
"Traité le",
"Motivation de la décision",

View file

@ -139,8 +139,6 @@ RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
config.before(:each) do
allow_any_instance_of(ProcedureLogoUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f998")
Flipflop::FeatureSet.current.test!.reset!
end

View file

@ -1,11 +0,0 @@
require 'spec_helper'
describe BaseUploader do
let(:uploader) { described_class.new }
describe '#cache_dir' do
subject { uploader.cache_dir }
it { is_expected.to eq '/tmp/tps-test-cache' }
end
end

View file

@ -1,17 +0,0 @@
require 'spec_helper'
describe RemoteDownloader do
let(:filename) { 'file_name.pdf' }
subject { described_class.new filename }
describe '#url' do
it { expect(subject.url).to eq 'https://static.demarches-simplifiees.fr/tps_dev/file_name.pdf' }
context 'no filename' do
let(:filename) { nil }
it { expect(subject.url).to be_nil }
end
end
end