Add support for remote OVH cloud storage
This commit is contained in:
parent
b15c2bbb2b
commit
833d7790c2
53 changed files with 243518 additions and 126 deletions
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
|
||||
|
|
|
@ -10,8 +10,12 @@ class Cerfa < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def content_url
|
||||
unless content.url.nil?
|
||||
(Downloader.new content, 'CERFA').url
|
||||
if Features.remote_storage and !content.url.nil?
|
||||
(RemoteDownloader.new content.filename).url
|
||||
else
|
||||
unless content.url.nil?
|
||||
(LocalDownloader.new content, 'CERFA').url
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -18,9 +18,13 @@ class PieceJustificative < ActiveRecord::Base
|
|||
end
|
||||
|
||||
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 and !content.url.nil?
|
||||
(RemoteDownloader.new content.filename).url
|
||||
else
|
||||
unless content.url.nil?
|
||||
(LocalDownloader.new content,
|
||||
(type_de_piece_justificative.nil? ? content.original_filename : type_de_piece_justificative.libelle)).url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,40 +1,28 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class CerfaUploader < CarrierWave::Uploader::Base
|
||||
before :cache, :save_original_filename
|
||||
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
# include CarrierWave::MiniMagick
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
storage :file
|
||||
# storage :fog
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
if Features.remote_storage
|
||||
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
|
||||
"../uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
if Features.remote_storage
|
||||
nil
|
||||
else
|
||||
"../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 +30,30 @@ 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 || model.content_secure_token
|
||||
if Features.remote_storage
|
||||
@filename = "#{model.class.to_s.underscore}-#{secure_token}.pdf"
|
||||
else original_filename
|
||||
@filename = "#{model.class.to_s.underscore}.pdf"
|
||||
end
|
||||
else
|
||||
@filename = nil
|
||||
end
|
||||
@filename
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def secure_token
|
||||
model.content_secure_token ||= generate_secure_token
|
||||
end
|
||||
|
||||
def generate_secure_token
|
||||
SecureRandom.uuid
|
||||
end
|
||||
|
||||
def save_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,28 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class PieceJustificativeUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
# include CarrierWave::MiniMagick
|
||||
before :cache, :save_original_filename
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
storage :file
|
||||
# storage :fog
|
||||
if Features.remote_storage
|
||||
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
|
||||
"../uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
if Features.remote_storage
|
||||
nil
|
||||
else
|
||||
"../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 +30,34 @@ 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 || model.content_secure_token
|
||||
if Features.remote_storage
|
||||
@filename = "#{model.class.to_s.underscore}-#{secure_token}.pdf"
|
||||
else original_filename
|
||||
@filename = "#{model.class.to_s.underscore}.pdf"
|
||||
end
|
||||
else
|
||||
@filename = nil
|
||||
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 save_original_filename(file)
|
||||
model.original_filename ||= file.original_filename if file.respond_to?(:original_filename)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,39 +2,26 @@
|
|||
|
||||
class ProcedureLogoUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
# include CarrierWave::MiniMagick
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
storage :file
|
||||
# storage :fog
|
||||
if Features.remote_storage
|
||||
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
|
||||
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
if Features.remote_storage
|
||||
nil
|
||||
else
|
||||
"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 +29,27 @@ 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 || model.logo_secure_token
|
||||
if Features.remote_storage
|
||||
@filename = "#{model.class.to_s.underscore}-#{secure_token}.pdf"
|
||||
else original_filename
|
||||
@filename = "#{model.class.to_s.underscore}.pdf"
|
||||
end
|
||||
else
|
||||
@filename = nil
|
||||
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
|
|
@ -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
|
||||
|
|
28
config/initializers/carrierwave.rb
Normal file
28
config/initializers/carrierwave.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require_relative 'features'
|
||||
|
||||
Fog.credentials_path = Rails.root.join('config/fog_credentials.yml')
|
||||
|
||||
CarrierWave.configure do |config|
|
||||
# These permissions will make dir and files available only to the user running
|
||||
# the servers
|
||||
config.permissions = 0600
|
||||
config.directory_permissions = 0700
|
||||
|
||||
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
|
|
@ -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
|
|
@ -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: 20160513093425) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -72,6 +72,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
|
||||
|
@ -203,6 +205,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 +225,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_ovh_storage_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_ovh_storage_file do
|
||||
puts 'creating fog_credentials.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.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
|
||||
|
|
|
@ -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 }
|
||||
it { expect(subject[:url]).to match /^http:\/\/.*downloads.*_CERFA\.pdf$/ }
|
||||
if Features.remote_storage
|
||||
it { expect(subject[:url]).to match /^https:\/\/storage.apientreprise.fr\/tps_dev\/cerfa-.*\.pdf$/ }
|
||||
else
|
||||
it { expect(subject[:url]).to match /^http:\/\/.*downloads.*_CERFA\.pdf$/ }
|
||||
end
|
||||
|
||||
describe 'user' do
|
||||
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
|
||||
|
|
|
@ -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,11 @@ 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)
|
||||
expect(subject['content']).to eq('cerfa-3dbb3535-5388-4a37-bc2d-778327b9f999.pdf')
|
||||
end
|
||||
|
||||
it 'dossier_id' do
|
||||
|
@ -212,7 +212,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 +223,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 +250,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 +277,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 +285,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 +347,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
|
||||
|
|
|
@ -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
|
@ -11,7 +11,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 }
|
||||
|
|
|
@ -26,7 +26,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? }
|
||||
|
||||
|
|
|
@ -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,20 @@ 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!
|
||||
|
||||
VCR.use_cassette("ovh_storage_init") do
|
||||
CarrierWave.configure do |config|
|
||||
config.fog_credentials = { provider: 'OpenStack' }
|
||||
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
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/new.html.haml', type: :view do
|
||||
describe 'users/dossiers/new.html.haml', type: :view, vcr: { cassette_name: 'user_dossier_new_html' } do
|
||||
let(:user) { create(:user) }
|
||||
let(:euro_flag) { false }
|
||||
let(:cerfa_flag) { false }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view do
|
||||
describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view, vcr: { cassette_name: 'views_users_recapitulatif_commentaires_flux' } do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' }
|
||||
|
|
Loading…
Reference in a new issue