Merge pull request #1856 from betagouv/bump-rails

Bump rails
This commit is contained in:
gregoirenovel 2018-04-24 16:12:08 +02:00 committed by GitHub
commit 4aec1d7bfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 137 additions and 111 deletions

View file

@ -1,6 +1,6 @@
source 'https://rubygems.org'
gem 'rails', '~> 5.2.0.rc1'
gem 'rails', '~> 5.2.0'
# Use SCSS for stylesheets
gem 'sass-rails'

View file

@ -29,25 +29,25 @@ GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.6)
actioncable (5.2.0.rc1)
actionpack (= 5.2.0.rc1)
actioncable (5.2.0)
actionpack (= 5.2.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.0.rc1)
actionpack (= 5.2.0.rc1)
actionview (= 5.2.0.rc1)
activejob (= 5.2.0.rc1)
actionmailer (5.2.0)
actionpack (= 5.2.0)
actionview (= 5.2.0)
activejob (= 5.2.0)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.0.rc1)
actionview (= 5.2.0.rc1)
activesupport (= 5.2.0.rc1)
actionpack (5.2.0)
actionview (= 5.2.0)
activesupport (= 5.2.0)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.0.rc1)
activesupport (= 5.2.0.rc1)
actionview (5.2.0)
activesupport (= 5.2.0)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
@ -57,34 +57,34 @@ GEM
activemodel (>= 4.1, < 6)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (5.2.0.rc1)
activesupport (= 5.2.0.rc1)
activejob (5.2.0)
activesupport (= 5.2.0)
globalid (>= 0.3.6)
activemodel (5.2.0.rc1)
activesupport (= 5.2.0.rc1)
activemodel (5.2.0)
activesupport (= 5.2.0)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (5.2.0.rc1)
activemodel (= 5.2.0.rc1)
activesupport (= 5.2.0.rc1)
activerecord (5.2.0)
activemodel (= 5.2.0)
activesupport (= 5.2.0)
arel (>= 9.0)
activestorage (5.2.0.rc1)
actionpack (= 5.2.0.rc1)
activerecord (= 5.2.0.rc1)
activestorage (5.2.0)
actionpack (= 5.2.0)
activerecord (= 5.2.0)
marcel (~> 0.3.1)
activesupport (5.2.0.rc1)
activesupport (5.2.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
administrate (0.9.0)
actionpack (>= 4.2, < 5.2)
actionview (>= 4.2, < 5.2)
activerecord (>= 4.2, < 5.2)
administrate (0.10.0)
actionpack (>= 4.2, < 6.0)
actionview (>= 4.2, < 6.0)
activerecord (>= 4.2, < 6.0)
autoprefixer-rails (>= 6.0)
datetime_picker_rails (~> 0.0.7)
jquery-rails (>= 4.0)
@ -98,7 +98,7 @@ GEM
arel (9.0.0)
ast (2.4.0)
attr_required (1.0.1)
autoprefixer-rails (8.0.0)
autoprefixer-rails (8.3.0)
execjs
axlsx (2.0.1)
htmlentities (~> 4.3.1)
@ -155,7 +155,7 @@ GEM
safe_yaml (~> 1.0.0)
crass (1.0.4)
daemons (1.2.6)
database_cleaner (1.6.2)
database_cleaner (1.7.0)
datetime_picker_rails (0.0.7)
momentjs-rails (>= 2.8.1)
deep_cloneable (2.3.2)
@ -176,9 +176,9 @@ GEM
diff-lcs (1.3)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.2.2)
dotenv-rails (2.2.2)
dotenv (= 2.2.2)
dotenv (2.3.0)
dotenv-rails (2.3.0)
dotenv (= 2.3.0)
railties (>= 3.2, < 6.0)
draper (3.0.1)
actionpack (~> 5.0)
@ -189,7 +189,7 @@ GEM
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
erubi (1.7.0)
erubi (1.7.1)
erubis (2.7.0)
ethon (0.11.0)
ffi (>= 1.3.0)
@ -409,11 +409,11 @@ GEM
domain_name (~> 0.5)
http_parser.rb (0.6.0)
httpclient (2.8.3)
i18n (0.9.5)
i18n (1.0.1)
concurrent-ruby (~> 1.0)
inflecto (0.0.2)
ipaddress (0.8.3)
jquery-rails (4.3.1)
jquery-rails (4.3.3)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
@ -465,7 +465,7 @@ GEM
activesupport (>= 3.1.0)
rack (>= 1.4.0)
rest-client
marcel (0.3.1)
marcel (0.3.2)
mimemagic (~> 0.3.2)
maruku (0.7.3)
method_source (0.9.0)
@ -476,7 +476,7 @@ GEM
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
momentjs-rails (2.17.1)
momentjs-rails (2.20.1)
railties (>= 3.1)
multi_json (1.13.1)
multi_xml (0.6.0)
@ -484,7 +484,7 @@ GEM
mustermann (1.0.2)
nenv (0.3.0)
netrc (0.11.0)
nio4r (2.2.0)
nio4r (2.3.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
notiffany (0.1.1)
@ -551,20 +551,20 @@ GEM
rack
rack-protection (2.0.1)
rack
rack-test (0.8.2)
rack-test (1.0.0)
rack (>= 1.0, < 3)
rails (5.2.0.rc1)
actioncable (= 5.2.0.rc1)
actionmailer (= 5.2.0.rc1)
actionpack (= 5.2.0.rc1)
actionview (= 5.2.0.rc1)
activejob (= 5.2.0.rc1)
activemodel (= 5.2.0.rc1)
activerecord (= 5.2.0.rc1)
activestorage (= 5.2.0.rc1)
activesupport (= 5.2.0.rc1)
rails (5.2.0)
actioncable (= 5.2.0)
actionmailer (= 5.2.0)
actionpack (= 5.2.0)
actionview (= 5.2.0)
activejob (= 5.2.0)
activemodel (= 5.2.0)
activerecord (= 5.2.0)
activestorage (= 5.2.0)
activesupport (= 5.2.0)
bundler (>= 1.3.0)
railties (= 5.2.0.rc1)
railties (= 5.2.0)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
@ -575,16 +575,16 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.0.rc1)
actionpack (= 5.2.0.rc1)
activesupport (= 5.2.0.rc1)
railties (5.2.0)
actionpack (= 5.2.0)
activesupport (= 5.2.0)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
raindrops (0.19.0)
rake (12.3.0)
rb-fsevent (0.10.2)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rbnacl (5.0.0)
@ -600,7 +600,7 @@ GEM
nokogiri (~> 1.5)
trollop (~> 2.1)
ref (2.0.0)
request_store (1.4.0)
request_store (1.4.1)
rack (>= 1.4)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
@ -650,12 +650,12 @@ GEM
rubocop (>= 0.51)
ruby-progressbar (1.9.0)
ruby_dep (1.5.0)
ruby_parser (3.10.1)
ruby_parser (3.11.0)
sexp_processor (~> 4.9)
rubyzip (1.0.0)
safe_yaml (1.0.4)
sanitize-url (0.1.4)
sass (3.5.5)
sass (3.5.6)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
@ -681,13 +681,13 @@ GEM
rubyzip (~> 1.0)
sentry-raven (2.7.2)
faraday (>= 0.7.6, < 1.0)
sexp_processor (4.10.1)
sexp_processor (4.11.0)
shellany (0.0.1)
shoulda-matchers (3.1.2)
activesupport (>= 4.0.0)
simple_form (3.5.1)
actionpack (> 4, < 5.2)
activemodel (> 4, < 5.2)
simple_form (4.0.0)
actionpack (> 4)
activemodel (> 4)
sinatra (2.0.1)
mustermann (~> 1.0)
rack (~> 2.0)
@ -736,7 +736,7 @@ GEM
ethon (>= 0.9.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (4.1.9)
uglifier (4.1.10)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
@ -754,7 +754,7 @@ GEM
activemodel (>= 3.0.0)
addressable
vcr (4.0.0)
web-console (3.6.0)
web-console (3.6.1)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
@ -834,7 +834,7 @@ DEPENDENCIES
pry-byebug
rack-handlers
rack-mini-profiler
rails (~> 5.2.0.rc1)
rails (~> 5.2.0)
rails-controller-testing
rbnacl-libsodium
rest-client

View file

@ -1,12 +0,0 @@
# Monkey patch ActiveStorage to make Range query compatible with CleverCloud Cellar
#
# FIXME : remove when better fix is available
ActiveStorage::Identification.class_eval do
private
def identifiable_chunk
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |client|
client.get(uri, "Range" => "bytes=0-4096").body
end
end
end

View file

@ -22,6 +22,12 @@ module ActiveStorage
end
end
def download_chunk(key, range)
instrument :download_chunk, key: key, range: range do
@adapter.session { |s| s.download(key, range: range) }
end
end
def delete(key)
instrument :delete, key: key do
@adapter.session { |s| s.delete(key) }

View file

@ -47,8 +47,11 @@ module Cellar
end
end
def download(key)
def download(key, range: nil)
request = Net::HTTP::Get.new("/#{key}")
if range.present?
add_range_header(request, range)
end
@signer.sign(request, key)
if block_given?
@http.request(request) do |response|
@ -106,6 +109,12 @@ module Cellar
private
def add_range_header(request, range)
bytes_end = range.exclude_end? ? range.end - 1 : range.end
request['range'] = "bytes=#{range.begin}-#{bytes_end}"
end
def parse_bucket_listing(bucket_listing_xml)
doc = Nokogiri::XML(bucket_listing_xml)
doc

View file

@ -4,30 +4,52 @@ describe 'CellarAdapter' do
before { Timecop.freeze(Time.gm(2016, 10, 2)) }
after { Timecop.return }
describe 'add_range_header' do
let(:request) { Net::HTTP::Get.new('/whatever') }
before { session.send(:add_range_header, request, range) }
subject { request['range'] }
context 'with end included' do
let(:range) { 100..500 }
it { is_expected.to eq('bytes=100-500') }
end
context 'with end excluded' do
let(:range) { 10...50 }
it { is_expected.to eq('bytes=10-49') }
end
end
describe 'parse_bucket_listing' do
let(:response) do
'<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>example-bucket</Name>
<Prefix></Prefix>
<KeyCount>2</KeyCount>
<MaxKeys>1000</MaxKeys>
<Delimiter>/</Delimiter>
<IsTruncated>false</IsTruncated>
<Contents>
<Key>sample1.jpg</Key>
<LastModified>2011-02-26T01:56:20.000Z</LastModified>
<ETag>&quot;bf1d737a4d46a19f3bced6905cc8b902&quot;</ETag>
<Size>142863</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>sample2.jpg</Key>
<LastModified>2011-02-26T01:56:20.000Z</LastModified>
<ETag>&quot;bf1d737a4d46a19f3bced6905cc8b902&quot;</ETag>
<Size>142863</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
</ListBucketResult>'
<<~EOS
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>example-bucket</Name>
<Prefix></Prefix>
<KeyCount>2</KeyCount>
<MaxKeys>1000</MaxKeys>
<Delimiter>/</Delimiter>
<IsTruncated>false</IsTruncated>
<Contents>
<Key>sample1.jpg</Key>
<LastModified>2011-02-26T01:56:20.000Z</LastModified>
<ETag>&quot;bf1d737a4d46a19f3bced6905cc8b902&quot;</ETag>
<Size>142863</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>sample2.jpg</Key>
<LastModified>2011-02-26T01:56:20.000Z</LastModified>
<ETag>&quot;bf1d737a4d46a19f3bced6905cc8b902&quot;</ETag>
<Size>142863</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
</ListBucketResult>'
EOS
end
subject { session.send(:parse_bucket_listing, response) }
@ -37,16 +59,17 @@ describe 'CellarAdapter' do
describe 'bulk_deletion_request_body' do
let(:expected_response) do
'<?xml version="1.0" encoding="UTF-8"?>
<Delete>
<Object>
<Key>chapi</Key>
</Object>
<Object>
<Key>chapo</Key>
</Object>
</Delete>
'
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<Delete>
<Object>
<Key>chapi</Key>
</Object>
<Object>
<Key>chapo</Key>
</Object>
</Delete>
EOS
end
subject { session.send(:bulk_deletion_request_body, ['chapi', 'chapo']) }