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