mirror of
https://github.com/kemko/paperclip.git
synced 2026-01-01 16:05:40 +03:00
3
.github/workflows/test.yaml
vendored
3
.github/workflows/test.yaml
vendored
@@ -13,9 +13,10 @@ jobs:
|
|||||||
rails-version: 60
|
rails-version: 60
|
||||||
- ruby-version: 2.7.8
|
- ruby-version: 2.7.8
|
||||||
rails-version: 61
|
rails-version: 61
|
||||||
# EDGE
|
|
||||||
- ruby-version: 3.2.2
|
- ruby-version: 3.2.2
|
||||||
rails-version: 70
|
rails-version: 70
|
||||||
|
- ruby-version: 3.2.2
|
||||||
|
rails-version: 71
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails-version }}.gemfile
|
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails-version }}.gemfile
|
||||||
|
|||||||
@@ -9,5 +9,9 @@ appraise 'rails_61' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
appraise 'rails_70' do
|
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
|
end
|
||||||
|
|||||||
3
Gemfile
3
Gemfile
@@ -5,7 +5,6 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
|
|||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
gem 'fastimage'
|
|
||||||
gem 'pg'
|
gem 'pg'
|
||||||
|
|
||||||
gem 'aws-sdk-s3'
|
gem 'aws-sdk-s3'
|
||||||
@@ -22,8 +21,6 @@ gem 'thoughtbot-shoulda', '>= 2.9.0'
|
|||||||
gem 'pry'
|
gem 'pry'
|
||||||
gem 'pry-byebug'
|
gem 'pry-byebug'
|
||||||
|
|
||||||
gem 'addressable'
|
|
||||||
|
|
||||||
unless defined?(Appraisal)
|
unless defined?(Appraisal)
|
||||||
gem 'appraisal'
|
gem 'appraisal'
|
||||||
|
|
||||||
|
|||||||
4
Rakefile
4
Rakefile
@@ -19,7 +19,7 @@ Rake::TestTask.new(:test) do |t|
|
|||||||
end
|
end
|
||||||
|
|
||||||
desc 'Start an IRB session with all necessary files required.'
|
desc 'Start an IRB session with all necessary files required.'
|
||||||
task :shell do |t|
|
task :shell do
|
||||||
chdir File.dirname(__FILE__)
|
chdir File.dirname(__FILE__)
|
||||||
exec 'irb -I lib/ -I lib/paperclip -r rubygems -r active_record -r tempfile -r init'
|
exec 'irb -I lib/ -I lib/paperclip -r rubygems -r active_record -r tempfile -r init'
|
||||||
end
|
end
|
||||||
@@ -39,7 +39,7 @@ task :sync_docs => 'rdoc' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
desc 'Clean up files.'
|
desc 'Clean up files.'
|
||||||
task :clean do |t|
|
task :clean do
|
||||||
FileUtils.rm_rf "doc"
|
FileUtils.rm_rf "doc"
|
||||||
FileUtils.rm_rf "tmp"
|
FileUtils.rm_rf "tmp"
|
||||||
FileUtils.rm_rf "pkg"
|
FileUtils.rm_rf "pkg"
|
||||||
|
|||||||
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@@ -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
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem "fastimage"
|
|
||||||
gem "pg"
|
gem "pg"
|
||||||
gem "aws-sdk-s3"
|
gem "aws-sdk-s3"
|
||||||
gem "fog-local"
|
gem "fog-local"
|
||||||
@@ -14,6 +13,5 @@ gem "mocha"
|
|||||||
gem "thoughtbot-shoulda", ">= 2.9.0"
|
gem "thoughtbot-shoulda", ">= 2.9.0"
|
||||||
gem "pry"
|
gem "pry"
|
||||||
gem "pry-byebug"
|
gem "pry-byebug"
|
||||||
gem "addressable"
|
|
||||||
|
|
||||||
gemspec path: "../"
|
gemspec path: "../"
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem "fastimage"
|
|
||||||
gem "pg"
|
gem "pg"
|
||||||
gem "aws-sdk-s3"
|
gem "aws-sdk-s3"
|
||||||
gem "fog-local"
|
gem "fog-local"
|
||||||
@@ -14,6 +13,5 @@ gem "mocha"
|
|||||||
gem "thoughtbot-shoulda", ">= 2.9.0"
|
gem "thoughtbot-shoulda", ">= 2.9.0"
|
||||||
gem "pry"
|
gem "pry"
|
||||||
gem "pry-byebug"
|
gem "pry-byebug"
|
||||||
gem "addressable"
|
|
||||||
|
|
||||||
gemspec path: "../"
|
gemspec path: "../"
|
||||||
|
|||||||
@@ -2,18 +2,16 @@
|
|||||||
|
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem "fastimage"
|
|
||||||
gem "pg"
|
gem "pg"
|
||||||
gem "aws-sdk-s3"
|
gem "aws-sdk-s3"
|
||||||
gem "fog-local"
|
gem "fog-local"
|
||||||
gem "delayed_paperclip", git: "https://github.com/insales/delayed_paperclip.git"
|
gem "delayed_paperclip", git: "https://github.com/insales/delayed_paperclip.git"
|
||||||
gem "rails", "~>7.0.0"
|
gem "rails", "~>7.0.8"
|
||||||
gem "sidekiq"
|
gem "sidekiq"
|
||||||
gem "test-unit"
|
gem "test-unit"
|
||||||
gem "mocha"
|
gem "mocha"
|
||||||
gem "thoughtbot-shoulda", ">= 2.9.0"
|
gem "thoughtbot-shoulda", ">= 2.9.0"
|
||||||
gem "pry"
|
gem "pry"
|
||||||
gem "pry-byebug"
|
gem "pry-byebug"
|
||||||
gem "addressable"
|
|
||||||
|
|
||||||
gemspec path: "../"
|
gemspec path: "../"
|
||||||
|
|||||||
17
gemfiles/rails_71.gemfile
Normal file
17
gemfiles/rails_71.gemfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# This file was generated by Appraisal
|
||||||
|
|
||||||
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
gemspec path: "../"
|
||||||
@@ -142,7 +142,7 @@ module Paperclip
|
|||||||
(self.class.store_ids - [self.class.main_store_id]).each { |store_id| enqueue_sync_job(store_id) }
|
(self.class.store_ids - [self.class.main_store_id]).each { |store_id| enqueue_sync_job(store_id) }
|
||||||
end
|
end
|
||||||
# HACK: Iostream пишет в tempfile, и он нигде не закрывается. Будем закрывать хотя бы тут
|
# 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].close
|
||||||
queued_for_write[:original].unlink
|
queued_for_write[:original].unlink
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ Gem::Specification.new do |s|
|
|||||||
s.date = %q{2009-06-18}
|
s.date = %q{2009-06-18}
|
||||||
s.email = %q{jyurek@thoughtbot.com}
|
s.email = %q{jyurek@thoughtbot.com}
|
||||||
s.extra_rdoc_files = ["README.rdoc"]
|
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 |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.homepage = %q{http://www.thoughtbot.com/projects/paperclip}
|
||||||
s.rdoc_options = ["--line-numbers", "--inline-source"]
|
s.rdoc_options = ["--line-numbers", "--inline-source"]
|
||||||
s.require_paths = ["lib"]
|
s.require_paths = ["lib"]
|
||||||
@@ -16,7 +19,7 @@ Gem::Specification.new do |s|
|
|||||||
s.rubyforge_project = %q{paperclip}
|
s.rubyforge_project = %q{paperclip}
|
||||||
s.summary = %q{File attachments as attributes for ActiveRecord}
|
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 'addressable'
|
||||||
s.add_dependency 'fastimage'
|
s.add_dependency 'fastimage'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -153,9 +153,10 @@ class AttachmentTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Paperclip::Test < Paperclip::Processor; end
|
||||||
|
|
||||||
context "An attachment with multiple processors" do
|
context "An attachment with multiple processors" do
|
||||||
setup do
|
setup do
|
||||||
class Paperclip::Test < Paperclip::Processor; end
|
|
||||||
@style_params = { :once => {:one => 1, :two => 2} }
|
@style_params = { :once => {:one => 1, :two => 2} }
|
||||||
rebuild_model :processors => [:thumbnail, :test], :styles => @style_params
|
rebuild_model :processors => [:thumbnail, :test], :styles => @style_params
|
||||||
@dummy = Dummy.new
|
@dummy = Dummy.new
|
||||||
@@ -345,7 +346,7 @@ class AttachmentTest < Test::Unit::TestCase
|
|||||||
[:small, 32, 32, "JPEG"]].each do |style|
|
[:small, 32, 32, "JPEG"]].each do |style|
|
||||||
cmd = %Q[identify -format "%w %h %b %m" "#{@attachment.path(style.first)}"]
|
cmd = %Q[identify -format "%w %h %b %m" "#{@attachment.path(style.first)}"]
|
||||||
out = `#{cmd}`
|
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[1].to_s, width.to_s
|
||||||
assert_equal style[2].to_s, height.to_s
|
assert_equal style[2].to_s, height.to_s
|
||||||
assert_equal style[3].to_s, format.to_s
|
assert_equal style[3].to_s, format.to_s
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ class IntegrationTest < Test::Unit::TestCase
|
|||||||
context "Many models at once" do
|
context "Many models at once" do
|
||||||
setup do
|
setup do
|
||||||
rebuild_model
|
rebuild_model
|
||||||
@file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb')
|
@file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb')
|
||||||
300.times do |i|
|
300.times do
|
||||||
Dummy.create! :avatar => @file
|
Dummy.create! avatar: @file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ class IntegrationTest < Test::Unit::TestCase
|
|||||||
teardown { @file.close }
|
teardown { @file.close }
|
||||||
|
|
||||||
should "create its thumbnails properly" do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class PluralCacheTest < Test::Unit::TestCase
|
class PluralCacheTest < Test::Unit::TestCase
|
||||||
|
class BigBox; end
|
||||||
|
|
||||||
should 'cache pluralizations' do
|
should 'cache pluralizations' do
|
||||||
cache = Paperclip::Interpolations::PluralCache.new
|
cache = Paperclip::Interpolations::PluralCache.new
|
||||||
symbol = :box
|
symbol = :box
|
||||||
@@ -11,7 +13,6 @@ class PluralCacheTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should 'cache pluralizations and underscores' do
|
should 'cache pluralizations and underscores' do
|
||||||
class BigBox ; end
|
|
||||||
cache = Paperclip::Interpolations::PluralCache.new
|
cache = Paperclip::Interpolations::PluralCache.new
|
||||||
klass = BigBox
|
klass = BigBox
|
||||||
|
|
||||||
@@ -26,7 +27,6 @@ class PluralCacheTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should 'pluralize and underscore words' do
|
should 'pluralize and underscore words' do
|
||||||
class BigBox ; end
|
|
||||||
cache = Paperclip::Interpolations::PluralCache.new
|
cache = Paperclip::Interpolations::PluralCache.new
|
||||||
klass = BigBox
|
klass = BigBox
|
||||||
assert_equal 'plural_cache_test/big_boxes', cache.underscore_and_pluralize_class(klass)
|
assert_equal 'plural_cache_test/big_boxes', cache.underscore_and_pluralize_class(klass)
|
||||||
|
|||||||
@@ -34,19 +34,19 @@ ActiveRecord::Base.try(:raise_in_transactional_callbacks=, true)
|
|||||||
ActiveRecord::Base.establish_connection(config['test'])
|
ActiveRecord::Base.establish_connection(config['test'])
|
||||||
|
|
||||||
def reset_class class_name
|
def reset_class class_name
|
||||||
ActiveRecord::Base.send(:include, Paperclip)
|
ActiveRecord::Base.include Paperclip
|
||||||
Object.send(:remove_const, class_name) rescue nil
|
Object.send(:remove_const, class_name) rescue nil
|
||||||
klass = Object.const_set(class_name, Class.new(ActiveRecord::Base))
|
klass = Object.const_set(class_name, Class.new(ActiveRecord::Base))
|
||||||
klass.class_eval{ include Paperclip }
|
klass.class_eval{ include Paperclip }
|
||||||
klass
|
klass
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_table table_name, &block
|
def reset_table(_table_name, &block)
|
||||||
block ||= ->(_) { true }
|
block ||= ->(_) { true }
|
||||||
ActiveRecord::Base.connection.create_table :dummies, force: true, &block
|
ActiveRecord::Base.connection.create_table :dummies, force: true, &block
|
||||||
end
|
end
|
||||||
|
|
||||||
def modify_table table_name, &block
|
def modify_table(_table_name, &block)
|
||||||
ActiveRecord::Base.connection.change_table :dummies, &block
|
ActiveRecord::Base.connection.change_table :dummies, &block
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ def rebuild_model options = {}
|
|||||||
end
|
end
|
||||||
|
|
||||||
def rebuild_class(options = {})
|
def rebuild_class(options = {})
|
||||||
ActiveRecord::Base.send(:include, Paperclip)
|
ActiveRecord::Base.include Paperclip
|
||||||
begin
|
begin
|
||||||
Object.send(:remove_const, "Dummy")
|
Object.send(:remove_const, "Dummy")
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class ThumbnailTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
should "create the thumbnail when sent #make" do
|
should "create the thumbnail when sent #make" do
|
||||||
dst = @thumb.make
|
dst = @thumb.make
|
||||||
assert_match /100x50/, `identify "#{dst.path}"`
|
assert_match(/100x50/, `identify "#{dst.path}"`)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class ThumbnailTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
should "create the thumbnail when sent #make" do
|
should "create the thumbnail when sent #make" do
|
||||||
dst = @thumb.make
|
dst = @thumb.make
|
||||||
assert_match /100x50/, `identify "#{dst.path}"`
|
assert_match(/100x50/, `identify "#{dst.path}"`)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "redefined to have bad convert_options setting" do
|
context "redefined to have bad convert_options setting" do
|
||||||
|
|||||||
Reference in New Issue
Block a user