From 2eae20a0c94c7fd6c5eede93588d4f788a5de421 Mon Sep 17 00:00:00 2001 From: Vasily Fedoseyev Date: Mon, 23 Oct 2023 19:44:59 +0300 Subject: [PATCH 1/3] Allow rails 7.1 --- .github/workflows/test.yaml | 3 ++- Appraisals | 6 +++++- gemfiles/rails_70.gemfile | 2 +- gemfiles/rails_71.gemfile | 19 +++++++++++++++++++ paperclip.gemspec | 2 +- 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 gemfiles/rails_71.gemfile diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 74138e2..53fa22b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,9 +13,10 @@ jobs: rails-version: 60 - ruby-version: 2.7.8 rails-version: 61 - # EDGE - ruby-version: 3.2.2 rails-version: 70 + - ruby-version: 3.2.2 + rails-version: 71 env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails-version }}.gemfile diff --git a/Appraisals b/Appraisals index c0b3d04..40bc0c0 100644 --- a/Appraisals +++ b/Appraisals @@ -9,5 +9,9 @@ appraise 'rails_61' do end appraise 'rails_70' do - gem 'rails', '~>7.0.0' + gem 'rails', '~>7.0.8' +end + +appraise 'rails_71' do + gem 'rails', '~>7.1.1' end diff --git a/gemfiles/rails_70.gemfile b/gemfiles/rails_70.gemfile index 43d836e..c1b94b7 100644 --- a/gemfiles/rails_70.gemfile +++ b/gemfiles/rails_70.gemfile @@ -7,7 +7,7 @@ gem "pg" gem "aws-sdk-s3" gem "fog-local" gem "delayed_paperclip", git: "https://github.com/insales/delayed_paperclip.git" -gem "rails", "~>7.0.0" +gem "rails", "~>7.0.8" gem "sidekiq" gem "test-unit" gem "mocha" diff --git a/gemfiles/rails_71.gemfile b/gemfiles/rails_71.gemfile new file mode 100644 index 0000000..e5e35d6 --- /dev/null +++ b/gemfiles/rails_71.gemfile @@ -0,0 +1,19 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "fastimage" +gem "pg" +gem "aws-sdk-s3" +gem "fog-local" +gem "delayed_paperclip", git: "https://github.com/insales/delayed_paperclip.git" +gem "rails", "~>7.1.1" +gem "sidekiq" +gem "test-unit" +gem "mocha" +gem "thoughtbot-shoulda", ">= 2.9.0" +gem "pry" +gem "pry-byebug" +gem "addressable" + +gemspec path: "../" diff --git a/paperclip.gemspec b/paperclip.gemspec index 834461d..21cfcdb 100644 --- a/paperclip.gemspec +++ b/paperclip.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.rubyforge_project = %q{paperclip} s.summary = %q{File attachments as attributes for ActiveRecord} - s.add_dependency 'activesupport', '< 7.1' + s.add_dependency 'activesupport', '< 7.2' s.add_dependency 'addressable' s.add_dependency 'fastimage' end From 3e43e17790f074dda85f56cadac76ab687ea4bf2 Mon Sep 17 00:00:00 2001 From: Vasily Fedoseyev Date: Mon, 23 Oct 2023 19:57:09 +0300 Subject: [PATCH 2/3] Remove unneeded files from gem --- Gemfile | 3 --- docker-compose.yml | 12 ++++++++++++ gemfiles/rails_60.gemfile | 2 -- gemfiles/rails_61.gemfile | 2 -- gemfiles/rails_70.gemfile | 2 -- gemfiles/rails_71.gemfile | 2 -- paperclip.gemspec | 5 ++++- 7 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 docker-compose.yml diff --git a/Gemfile b/Gemfile index b09e37d..7700f4f 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,6 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" } gemspec -gem 'fastimage' gem 'pg' gem 'aws-sdk-s3' @@ -22,8 +21,6 @@ gem 'thoughtbot-shoulda', '>= 2.9.0' gem 'pry' gem 'pry-byebug' -gem 'addressable' - unless defined?(Appraisal) gem 'appraisal' diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..aae4a88 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.6' + +services: + postgres: + image: postgres:12-alpine + environment: + POSTGRES_DB: paperclip_test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: "" + POSTGRES_HOST_AUTH_METHOD: trust + ports: + - 5432:5432 diff --git a/gemfiles/rails_60.gemfile b/gemfiles/rails_60.gemfile index 7483901..fa45414 100644 --- a/gemfiles/rails_60.gemfile +++ b/gemfiles/rails_60.gemfile @@ -2,7 +2,6 @@ source "https://rubygems.org" -gem "fastimage" gem "pg" gem "aws-sdk-s3" gem "fog-local" @@ -14,6 +13,5 @@ gem "mocha" gem "thoughtbot-shoulda", ">= 2.9.0" gem "pry" gem "pry-byebug" -gem "addressable" gemspec path: "../" diff --git a/gemfiles/rails_61.gemfile b/gemfiles/rails_61.gemfile index 0c0d359..32f9ec2 100644 --- a/gemfiles/rails_61.gemfile +++ b/gemfiles/rails_61.gemfile @@ -2,7 +2,6 @@ source "https://rubygems.org" -gem "fastimage" gem "pg" gem "aws-sdk-s3" gem "fog-local" @@ -14,6 +13,5 @@ gem "mocha" gem "thoughtbot-shoulda", ">= 2.9.0" gem "pry" gem "pry-byebug" -gem "addressable" gemspec path: "../" diff --git a/gemfiles/rails_70.gemfile b/gemfiles/rails_70.gemfile index c1b94b7..7a1b3de 100644 --- a/gemfiles/rails_70.gemfile +++ b/gemfiles/rails_70.gemfile @@ -2,7 +2,6 @@ source "https://rubygems.org" -gem "fastimage" gem "pg" gem "aws-sdk-s3" gem "fog-local" @@ -14,6 +13,5 @@ gem "mocha" gem "thoughtbot-shoulda", ">= 2.9.0" gem "pry" gem "pry-byebug" -gem "addressable" gemspec path: "../" diff --git a/gemfiles/rails_71.gemfile b/gemfiles/rails_71.gemfile index e5e35d6..cf2e45a 100644 --- a/gemfiles/rails_71.gemfile +++ b/gemfiles/rails_71.gemfile @@ -2,7 +2,6 @@ source "https://rubygems.org" -gem "fastimage" gem "pg" gem "aws-sdk-s3" gem "fog-local" @@ -14,6 +13,5 @@ gem "mocha" gem "thoughtbot-shoulda", ">= 2.9.0" gem "pry" gem "pry-byebug" -gem "addressable" gemspec path: "../" diff --git a/paperclip.gemspec b/paperclip.gemspec index 21cfcdb..56ab4ac 100644 --- a/paperclip.gemspec +++ b/paperclip.gemspec @@ -8,7 +8,10 @@ Gem::Specification.new do |s| s.date = %q{2009-06-18} s.email = %q{jyurek@thoughtbot.com} s.extra_rdoc_files = ["README.rdoc"] - s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|gemfiles)/}) } + s.files = `git ls-files -z`.split("\x0").reject do |f| + f.start_with?('.') || f.match?(%r{^(test|gemfiles)/}) || + f.match?(%r{docker-compose.yml|Appraisals|Gemfile|Rakefile}) + end s.homepage = %q{http://www.thoughtbot.com/projects/paperclip} s.rdoc_options = ["--line-numbers", "--inline-source"] s.require_paths = ["lib"] From 45bf0b208ef60f041e52574d3afa94a64a8cce7c Mon Sep 17 00:00:00 2001 From: Vasily Fedoseyev Date: Mon, 23 Oct 2023 20:11:44 +0300 Subject: [PATCH 3/3] Fix rubocop lint-level warnings --- Rakefile | 4 ++-- lib/paperclip/storage/no_cache_s3.rb | 2 +- paperclip.gemspec | 6 +++--- test/attachment_test.rb | 5 +++-- test/integration_test.rb | 8 ++++---- test/plural_cache_test.rb | 4 ++-- test/test_helper.rb | 8 ++++---- test/thumbnail_test.rb | 4 ++-- 8 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Rakefile b/Rakefile index 4b9260b..3582859 100644 --- a/Rakefile +++ b/Rakefile @@ -19,7 +19,7 @@ Rake::TestTask.new(:test) do |t| end desc 'Start an IRB session with all necessary files required.' -task :shell do |t| +task :shell do chdir File.dirname(__FILE__) exec 'irb -I lib/ -I lib/paperclip -r rubygems -r active_record -r tempfile -r init' end @@ -39,7 +39,7 @@ task :sync_docs => 'rdoc' do end desc 'Clean up files.' -task :clean do |t| +task :clean do FileUtils.rm_rf "doc" FileUtils.rm_rf "tmp" FileUtils.rm_rf "pkg" diff --git a/lib/paperclip/storage/no_cache_s3.rb b/lib/paperclip/storage/no_cache_s3.rb index e8d8653..d92444e 100644 --- a/lib/paperclip/storage/no_cache_s3.rb +++ b/lib/paperclip/storage/no_cache_s3.rb @@ -142,7 +142,7 @@ module Paperclip (self.class.store_ids - [self.class.main_store_id]).each { |store_id| enqueue_sync_job(store_id) } end # HACK: Iostream пишет в tempfile, и он нигде не закрывается. Будем закрывать хотя бы тут - if queued_for_write[:original]&.is_a?(Tempfile) + if queued_for_write[:original].is_a?(Tempfile) queued_for_write[:original].close queued_for_write[:original].unlink end diff --git a/paperclip.gemspec b/paperclip.gemspec index 56ab4ac..6d03eb2 100644 --- a/paperclip.gemspec +++ b/paperclip.gemspec @@ -8,9 +8,9 @@ Gem::Specification.new do |s| s.date = %q{2009-06-18} s.email = %q{jyurek@thoughtbot.com} s.extra_rdoc_files = ["README.rdoc"] - s.files = `git ls-files -z`.split("\x0").reject do |f| - f.start_with?('.') || f.match?(%r{^(test|gemfiles)/}) || - f.match?(%r{docker-compose.yml|Appraisals|Gemfile|Rakefile}) + s.files = `git ls-files -z`.split("\x0").reject do |file| + file.start_with?('.') || file.match?(%r{^(test|gemfiles)/}) || + file.match?(/docker-compose.yml|Appraisals|Gemfile|Rakefile/) end s.homepage = %q{http://www.thoughtbot.com/projects/paperclip} s.rdoc_options = ["--line-numbers", "--inline-source"] diff --git a/test/attachment_test.rb b/test/attachment_test.rb index 6f2efb1..b602b70 100644 --- a/test/attachment_test.rb +++ b/test/attachment_test.rb @@ -153,9 +153,10 @@ class AttachmentTest < Test::Unit::TestCase end end + class Paperclip::Test < Paperclip::Processor; end + context "An attachment with multiple processors" do setup do - class Paperclip::Test < Paperclip::Processor; end @style_params = { :once => {:one => 1, :two => 2} } rebuild_model :processors => [:thumbnail, :test], :styles => @style_params @dummy = Dummy.new @@ -345,7 +346,7 @@ class AttachmentTest < Test::Unit::TestCase [:small, 32, 32, "JPEG"]].each do |style| cmd = %Q[identify -format "%w %h %b %m" "#{@attachment.path(style.first)}"] out = `#{cmd}` - width, height, size, format = out.split(" ") + width, height, _size, format = out.split(" ") assert_equal style[1].to_s, width.to_s assert_equal style[2].to_s, height.to_s assert_equal style[3].to_s, format.to_s diff --git a/test/integration_test.rb b/test/integration_test.rb index 25f83cc..16ae117 100644 --- a/test/integration_test.rb +++ b/test/integration_test.rb @@ -6,9 +6,9 @@ class IntegrationTest < Test::Unit::TestCase context "Many models at once" do setup do rebuild_model - @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') - 300.times do |i| - Dummy.create! :avatar => @file + @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') + 300.times do + Dummy.create! avatar: @file end end @@ -33,7 +33,7 @@ class IntegrationTest < Test::Unit::TestCase teardown { @file.close } should "create its thumbnails properly" do - assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:thumb)}"` + assert_match(/\b50x50\b/, `identify "#{@dummy.avatar.path(:thumb)}"`) end end diff --git a/test/plural_cache_test.rb b/test/plural_cache_test.rb index 0e9a1d0..6b67b48 100644 --- a/test/plural_cache_test.rb +++ b/test/plural_cache_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class PluralCacheTest < Test::Unit::TestCase + class BigBox; end + should 'cache pluralizations' do cache = Paperclip::Interpolations::PluralCache.new symbol = :box @@ -11,7 +13,6 @@ class PluralCacheTest < Test::Unit::TestCase end should 'cache pluralizations and underscores' do - class BigBox ; end cache = Paperclip::Interpolations::PluralCache.new klass = BigBox @@ -26,7 +27,6 @@ class PluralCacheTest < Test::Unit::TestCase end should 'pluralize and underscore words' do - class BigBox ; end cache = Paperclip::Interpolations::PluralCache.new klass = BigBox assert_equal 'plural_cache_test/big_boxes', cache.underscore_and_pluralize_class(klass) diff --git a/test/test_helper.rb b/test/test_helper.rb index 984f4fa..3e4684e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -34,19 +34,19 @@ ActiveRecord::Base.try(:raise_in_transactional_callbacks=, true) ActiveRecord::Base.establish_connection(config['test']) def reset_class class_name - ActiveRecord::Base.send(:include, Paperclip) + ActiveRecord::Base.include Paperclip Object.send(:remove_const, class_name) rescue nil klass = Object.const_set(class_name, Class.new(ActiveRecord::Base)) klass.class_eval{ include Paperclip } klass end -def reset_table table_name, &block +def reset_table(_table_name, &block) block ||= ->(_) { true } ActiveRecord::Base.connection.create_table :dummies, force: true, &block end -def modify_table table_name, &block +def modify_table(_table_name, &block) ActiveRecord::Base.connection.change_table :dummies, &block end @@ -62,7 +62,7 @@ def rebuild_model options = {} end def rebuild_class(options = {}) - ActiveRecord::Base.send(:include, Paperclip) + ActiveRecord::Base.include Paperclip begin Object.send(:remove_const, "Dummy") rescue StandardError diff --git a/test/thumbnail_test.rb b/test/thumbnail_test.rb index 0eb5faf..2feb7a3 100644 --- a/test/thumbnail_test.rb +++ b/test/thumbnail_test.rb @@ -73,7 +73,7 @@ class ThumbnailTest < Test::Unit::TestCase should "create the thumbnail when sent #make" do dst = @thumb.make - assert_match /100x50/, `identify "#{dst.path}"` + assert_match(/100x50/, `identify "#{dst.path}"`) end end @@ -98,7 +98,7 @@ class ThumbnailTest < Test::Unit::TestCase should "create the thumbnail when sent #make" do dst = @thumb.make - assert_match /100x50/, `identify "#{dst.path}"` + assert_match(/100x50/, `identify "#{dst.path}"`) end context "redefined to have bad convert_options setting" do