Fix rubocop lint-level warnings

This commit is contained in:
Vasily Fedoseyev
2023-10-23 20:11:44 +03:00
parent 3e43e17790
commit 45bf0b208e
8 changed files with 21 additions and 20 deletions

View File

@@ -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"

View File

@@ -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

View File

@@ -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"]

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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