From 9a37fc9e7ce2937c66d5419ce1943ed114385beb Mon Sep 17 00:00:00 2001 From: "M.Shibuya" Date: Fri, 27 Dec 2019 12:58:41 +0900 Subject: [PATCH] Test against Ruby 2.7 --- .travis.yml | 13 +++++++------ lib/carrierwave/downloader/base.rb | 2 +- lib/carrierwave/mounter.rb | 2 +- lib/carrierwave/sanitized_file.rb | 2 +- spec/downloader/base_spec.rb | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index a1280f0f7..cb0879176 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,9 @@ language: ruby cache: bundler rvm: - - 2.5.5 - - 2.6.2 + - 2.5.7 + - 2.6.5 + - 2.7.0 - jruby-9.2.8.0 gemfile: @@ -27,13 +28,13 @@ matrix: gemfile: gemfiles/rails-5-2.gemfile - rvm: 2.3.8 gemfile: gemfiles/rails-5-2.gemfile - - rvm: 2.4.5 + - rvm: 2.4.9 gemfile: gemfiles/rails-5-2.gemfile - - rvm: 2.5.5 + - rvm: 2.5.7 gemfile: gemfiles/rails-5-0.gemfile - - rvm: 2.5.5 + - rvm: 2.5.7 gemfile: gemfiles/rails-5-1.gemfile - - rvm: 2.6.2 + - rvm: 2.7.0 gemfile: gemfiles/rails-master.gemfile - rvm: ruby-head gemfile: gemfiles/rails-6-0.gemfile diff --git a/lib/carrierwave/downloader/base.rb b/lib/carrierwave/downloader/base.rb index acb75cdda..ad77e921f 100644 --- a/lib/carrierwave/downloader/base.rb +++ b/lib/carrierwave/downloader/base.rb @@ -40,7 +40,7 @@ def download(url, remote_headers = {}) def process_uri(uri) uri_parts = uri.split('?') encoded_uri = Addressable::URI.parse(uri_parts.shift).normalize.to_s - encoded_uri << '?' << URI.encode(uri_parts.join('?')) if uri_parts.any? + encoded_uri << '?' << Addressable::URI.encode(uri_parts.join('?')).gsub('%5B', '[').gsub('%5D', ']') if uri_parts.any? URI.parse(encoded_uri) rescue URI::InvalidURIError, Addressable::URI::InvalidURIError raise CarrierWave::DownloadError, "couldn't parse URL: #{uri}" diff --git a/lib/carrierwave/mounter.rb b/lib/carrierwave/mounter.rb index cf2655893..71cfcc6f2 100644 --- a/lib/carrierwave/mounter.rb +++ b/lib/carrierwave/mounter.rb @@ -114,7 +114,7 @@ def blank? end def remove? - remove.present? && remove !~ /\A0|false$\z/ + remove.present? && (remove == true || remove !~ /\A0|false$\z/) end def remove! diff --git a/lib/carrierwave/sanitized_file.rb b/lib/carrierwave/sanitized_file.rb index 1e0464211..fd5d3a378 100644 --- a/lib/carrierwave/sanitized_file.rb +++ b/lib/carrierwave/sanitized_file.rb @@ -305,7 +305,7 @@ def file=(file) def mkdir!(path, directory_permissions) options = {} options[:mode] = directory_permissions if directory_permissions - FileUtils.mkdir_p(File.dirname(path), options) unless File.exist?(File.dirname(path)) + FileUtils.mkdir_p(File.dirname(path), **options) unless File.exist?(File.dirname(path)) end def chmod!(path, permissions) diff --git a/spec/downloader/base_spec.rb b/spec/downloader/base_spec.rb index 1e205c77e..4fb649bb3 100644 --- a/spec/downloader/base_spec.rb +++ b/spec/downloader/base_spec.rb @@ -5,7 +5,7 @@ let(:uploader) { uploader_class.new } let(:file) { File.read(file_path("test.jpg")) } let(:filename) { "test.jpg" } - let(:uri) { URI.encode("http://www.example.com/#{filename}") } + let(:uri) { "http://www.example.com/#{CGI.escape(filename)}" } subject { CarrierWave::Downloader::Base.new(uploader) } @@ -27,7 +27,7 @@ end context "with a URL with internationalized domain name" do - let(:uri) { URI.encode("http://ドメイン名例.jp/#{filename}") } + let(:uri) { "http://ドメイン名例.jp/#{CGI.escape(filename)}" } before do stub_request(:get, 'http://xn--eckwd4c7cu47r2wf.jp/test.jpg').to_return(body: file) end