Merge pull request #3438 from betagouv/dev

2019-02-14-02
This commit is contained in:
Pierre de La Morinerie 2019-02-14 16:34:02 +01:00 committed by GitHub
commit 06e0bfea34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 9 deletions

1
.gitignore vendored
View file

@ -25,3 +25,4 @@ storage/
/node_modules /node_modules
yarn-debug.log* yarn-debug.log*
.yarn-integrity .yarn-integrity
/.vscode

View file

@ -99,6 +99,7 @@ group :development, :test do
gem 'pry-byebug' gem 'pry-byebug'
gem 'rspec-rails' gem 'rspec-rails'
gem 'rspec_junit_formatter' gem 'rspec_junit_formatter'
gem 'ruby-debug-ide', require: false
gem 'spring' # Spring speeds up development by keeping your application running in the background gem 'spring' # Spring speeds up development by keeping your application running in the background
gem 'spring-commands-rspec' gem 'spring-commands-rspec'
end end

View file

@ -510,6 +510,8 @@ GEM
unicode-display_width (~> 1.4.0) unicode-display_width (~> 1.4.0)
rubocop-rspec-focused (1.0.0) rubocop-rspec-focused (1.0.0)
rubocop (>= 0.51) rubocop (>= 0.51)
ruby-debug-ide (0.6.1)
rake (>= 0.8.1)
ruby-progressbar (1.10.0) ruby-progressbar (1.10.0)
ruby_dep (1.5.0) ruby_dep (1.5.0)
ruby_parser (3.12.0) ruby_parser (3.12.0)
@ -713,6 +715,7 @@ DEPENDENCIES
rspec_junit_formatter rspec_junit_formatter
rubocop rubocop
rubocop-rspec-focused rubocop-rspec-focused
ruby-debug-ide
sanitize-url sanitize-url
sassc-rails sassc-rails
scenic scenic

View file

@ -27,7 +27,7 @@ module ActiveStorage
def publicize(url) def publicize(url)
search = %r{^https://[^/]+/v1/AUTH_[a-f0-9]{32}} search = %r{^https://[^/]+/v1/AUTH_[a-f0-9]{32}}
replace = "https://#{ENV['APP_HOST']}/direct-upload" replace = 'https://static.demarches-simplifiees.fr'
url.gsub(search, replace) url.gsub(search, replace)
end end
end end

View file

@ -1,20 +1,17 @@
describe ActiveStorage::Service::DsProxyService do describe ActiveStorage::Service::DsProxyService do
let(:private_host) { 'storage.sbg1.cloud.ovh.net:443' } let(:private_host) { 'storage.sbg1.cloud.ovh.net:443' }
let(:public_host) { 'www.demarches-simplifiees.fr' } let(:public_host) { 'static.demarches-simplifiees.fr' }
let(:auth) { 'AUTH_a24c37ed11a84896914514384898c34b' } let(:auth) { 'AUTH_a24c37ed11a84896914514384898c34b' }
let(:bucket) { 'test_local' } let(:bucket) { 'test_local' }
let(:key) { '2R6rr89nFeSRkSgXHd3smvEf' } let(:key) { '2R6rr89nFeSRkSgXHd3smvEf' }
let(:temp_url_params) { 'temp_url_sig=5ab8cfc3ba5da2598a6c88cc6b1b461fe4e115bc&temp_url_expires=1547598179' } let(:temp_url_params) { 'temp_url_sig=5ab8cfc3ba5da2598a6c88cc6b1b461fe4e115bc&temp_url_expires=1547598179' }
let(:storage_service) { storage_service = double(ActiveStorage::Service) }
subject do let(:storage_service) { storage_service = double(ActiveStorage::Service) }
allow(ENV).to receive(:[]).with('APP_HOST').and_return(public_host) subject { ActiveStorage::Service::DsProxyService.new(wrapped: storage_service) }
ActiveStorage::Service::DsProxyService.new(wrapped: storage_service)
end
describe '#url' do describe '#url' do
let(:private_url) { "https://#{private_host}/v1/#{auth}/#{bucket}/#{key}?#{temp_url_params}" } let(:private_url) { "https://#{private_host}/v1/#{auth}/#{bucket}/#{key}?#{temp_url_params}" }
let(:public_url) { "https://#{public_host}/direct-upload/#{bucket}/#{key}?#{temp_url_params}" } let(:public_url) { "https://#{public_host}/#{bucket}/#{key}?#{temp_url_params}" }
before do before do
expect(storage_service).to receive(:url).and_return(private_url) expect(storage_service).to receive(:url).and_return(private_url)
@ -28,7 +25,7 @@ describe ActiveStorage::Service::DsProxyService do
describe '#url_for_direct_upload' do describe '#url_for_direct_upload' do
let(:download_params) { 'inline&filename=documents_top_confidentiels.bmp' } let(:download_params) { 'inline&filename=documents_top_confidentiels.bmp' }
let(:private_url) { "https://#{private_host}/v1/#{auth}/#{bucket}/#{key}?#{temp_url_params}&#{download_params}" } let(:private_url) { "https://#{private_host}/v1/#{auth}/#{bucket}/#{key}?#{temp_url_params}&#{download_params}" }
let(:public_url) { "https://#{public_host}/direct-upload/#{bucket}/#{key}?#{temp_url_params}&#{download_params}" } let(:public_url) { "https://#{public_host}/#{bucket}/#{key}?#{temp_url_params}&#{download_params}" }
before do before do
expect(storage_service).to receive(:url_for_direct_upload).and_return(private_url) expect(storage_service).to receive(:url_for_direct_upload).and_return(private_url)