mirror of
https://github.com/kemko/paperclip.git
synced 2026-01-01 16:05:40 +03:00
Make test run, use appraisal, cleanup
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
Gemfile.lock
|
|
||||||
.ruby-version
|
.ruby-version
|
||||||
|
Gemfile.lock
|
||||||
|
gemfiles/*.lock
|
||||||
|
tmp/
|
||||||
|
|||||||
15
Appraisals
Normal file
15
Appraisals
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
appraise 'rails_40' do
|
||||||
|
gem 'rails', '~> 4.0.0'
|
||||||
|
end
|
||||||
|
|
||||||
|
appraise 'rails_41' do
|
||||||
|
gem 'rails', '~> 4.1.0'
|
||||||
|
end
|
||||||
|
|
||||||
|
appraise 'rails_42' do
|
||||||
|
gem 'rails', '~> 4.2.0'
|
||||||
|
end
|
||||||
|
|
||||||
|
appraise 'rails_5' do
|
||||||
|
gem 'rails', '~> 5.2.0'
|
||||||
|
end
|
||||||
11
Gemfile
11
Gemfile
@@ -1,6 +1,15 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
source 'http://rubygems.org'
|
source 'http://rubygems.org'
|
||||||
|
gemspec
|
||||||
|
|
||||||
|
gem 'appraisal'
|
||||||
|
|
||||||
gem 'fastimage'
|
gem 'fastimage'
|
||||||
|
gem 'sqlite3'
|
||||||
|
|
||||||
gemspec
|
gem 'test-unit'
|
||||||
|
gem 'thoughtbot-shoulda', '>= 2.9.0'
|
||||||
|
gem 'mocha'
|
||||||
|
|
||||||
|
gem 'pry'
|
||||||
|
gem 'pry-byebug'
|
||||||
|
|||||||
2
Rakefile
2
Rakefile
@@ -12,7 +12,7 @@ task :default => [:clean, :test]
|
|||||||
|
|
||||||
desc 'Test the paperclip plugin.'
|
desc 'Test the paperclip plugin.'
|
||||||
Rake::TestTask.new(:test) do |t|
|
Rake::TestTask.new(:test) do |t|
|
||||||
t.libs << 'lib' << 'profile'
|
t.libs << 'lib' << 'test'
|
||||||
t.pattern = 'test/**/*_test.rb'
|
t.pattern = 'test/**/*_test.rb'
|
||||||
t.verbose = true
|
t.verbose = true
|
||||||
end
|
end
|
||||||
|
|||||||
15
gemfiles/rails_40.gemfile
Normal file
15
gemfiles/rails_40.gemfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# This file was generated by Appraisal
|
||||||
|
|
||||||
|
source "http://rubygems.org"
|
||||||
|
|
||||||
|
gem "appraisal"
|
||||||
|
gem "fastimage"
|
||||||
|
gem "sqlite3"
|
||||||
|
gem "test-unit"
|
||||||
|
gem "thoughtbot-shoulda", ">= 2.9.0"
|
||||||
|
gem "mocha"
|
||||||
|
gem "pry"
|
||||||
|
gem "pry-byebug"
|
||||||
|
gem "rails", "~> 4.0.0"
|
||||||
|
|
||||||
|
gemspec path: "../"
|
||||||
15
gemfiles/rails_41.gemfile
Normal file
15
gemfiles/rails_41.gemfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# This file was generated by Appraisal
|
||||||
|
|
||||||
|
source "http://rubygems.org"
|
||||||
|
|
||||||
|
gem "appraisal"
|
||||||
|
gem "fastimage"
|
||||||
|
gem "sqlite3"
|
||||||
|
gem "test-unit"
|
||||||
|
gem "thoughtbot-shoulda", ">= 2.9.0"
|
||||||
|
gem "mocha"
|
||||||
|
gem "pry"
|
||||||
|
gem "pry-byebug"
|
||||||
|
gem "rails", "~> 4.1.0"
|
||||||
|
|
||||||
|
gemspec path: "../"
|
||||||
15
gemfiles/rails_42.gemfile
Normal file
15
gemfiles/rails_42.gemfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# This file was generated by Appraisal
|
||||||
|
|
||||||
|
source "http://rubygems.org"
|
||||||
|
|
||||||
|
gem "appraisal"
|
||||||
|
gem "fastimage"
|
||||||
|
gem "sqlite3"
|
||||||
|
gem "test-unit"
|
||||||
|
gem "thoughtbot-shoulda", ">= 2.9.0"
|
||||||
|
gem "mocha"
|
||||||
|
gem "pry"
|
||||||
|
gem "pry-byebug"
|
||||||
|
gem "rails", "~> 4.2.0"
|
||||||
|
|
||||||
|
gemspec path: "../"
|
||||||
15
gemfiles/rails_5.gemfile
Normal file
15
gemfiles/rails_5.gemfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# This file was generated by Appraisal
|
||||||
|
|
||||||
|
source "http://rubygems.org"
|
||||||
|
|
||||||
|
gem "appraisal"
|
||||||
|
gem "fastimage"
|
||||||
|
gem "sqlite3"
|
||||||
|
gem "test-unit"
|
||||||
|
gem "thoughtbot-shoulda", ">= 2.9.0"
|
||||||
|
gem "mocha"
|
||||||
|
gem "pry"
|
||||||
|
gem "pry-byebug"
|
||||||
|
gem "rails", "~> 5.2.0"
|
||||||
|
|
||||||
|
gemspec path: "../"
|
||||||
@@ -8,7 +8,7 @@ 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 = ["README.rdoc", "LICENSE", "Rakefile", "init.rb", "generators/paperclip", "generators/paperclip/paperclip_generator.rb", "generators/paperclip/templates", "generators/paperclip/templates/paperclip_migration.rb.erb", "generators/paperclip/USAGE", "lib/paperclip", "lib/paperclip/attachment.rb", "lib/paperclip/callback_compatability.rb", "lib/paperclip/geometry.rb", "lib/paperclip/interpolations.rb", "lib/paperclip/iostream.rb", "lib/paperclip/matchers", "lib/paperclip/matchers/have_attached_file_matcher.rb", "lib/paperclip/matchers/validate_attachment_content_type_matcher.rb", "lib/paperclip/matchers/validate_attachment_presence_matcher.rb", "lib/paperclip/matchers/validate_attachment_size_matcher.rb", "lib/paperclip/matchers.rb", "lib/paperclip/processor.rb", "lib/paperclip/storage.rb", "lib/paperclip/thumbnail.rb", "lib/paperclip/upfile.rb", "lib/paperclip.rb", "tasks/paperclip_tasks.rake", "test/attachment_test.rb", "test/database.yml", "test/fixtures", "test/fixtures/12k.png", "test/fixtures/50x50.png", "test/fixtures/5k.png", "test/fixtures/bad.png", "test/fixtures/s3.yml", "test/fixtures/text.txt", "test/fixtures/twopage.pdf", "test/geometry_test.rb", "test/helper.rb", "test/integration_test.rb", "test/interpolations_test.rb", "test/iostream_test.rb", "test/matchers", "test/matchers/have_attached_file_matcher_test.rb", "test/matchers/validate_attachment_content_type_matcher_test.rb", "test/matchers/validate_attachment_presence_matcher_test.rb", "test/matchers/validate_attachment_size_matcher_test.rb", "test/paperclip_test.rb", "test/processor_test.rb", "test/storage_test.rb", "test/thumbnail_test.rb", "shoulda_macros/paperclip.rb"]
|
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|gemfiles)/}) }
|
||||||
s.has_rdoc = true
|
s.has_rdoc = true
|
||||||
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"]
|
||||||
@@ -19,20 +19,4 @@ Gem::Specification.new do |s|
|
|||||||
s.summary = %q{File attachments as attributes for ActiveRecord}
|
s.summary = %q{File attachments as attributes for ActiveRecord}
|
||||||
|
|
||||||
s.add_dependency('sidekiq', ["~> 2.0"])
|
s.add_dependency('sidekiq', ["~> 2.0"])
|
||||||
|
|
||||||
if s.respond_to? :specification_version then
|
|
||||||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
||||||
s.specification_version = 2
|
|
||||||
|
|
||||||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
||||||
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
|
||||||
s.add_development_dependency(%q<mocha>, [">= 0"])
|
|
||||||
else
|
|
||||||
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
|
||||||
s.add_dependency(%q<mocha>, [">= 0"])
|
|
||||||
end
|
|
||||||
else
|
|
||||||
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
|
||||||
s.add_dependency(%q<mocha>, [">= 0"])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class Dummy
|
class Dummy
|
||||||
# This is a dummy class
|
# This is a dummy class
|
||||||
@@ -105,12 +105,11 @@ class AttachmentTest < Test::Unit::TestCase
|
|||||||
@dummy.stubs(:id).returns(@id)
|
@dummy.stubs(:id).returns(@id)
|
||||||
@file = StringIO.new(".")
|
@file = StringIO.new(".")
|
||||||
@dummy.avatar = @file
|
@dummy.avatar = @file
|
||||||
|
Rails.stub(:env) { @rails_env }
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return the proper path" do
|
should "return the proper path" do
|
||||||
temporary_rails_env(@rails_env) {
|
assert_equal "#{@rails_env}/#{@id}.png", @dummy.avatar.path
|
||||||
assert_equal "#{@rails_env}/#{@id}.png", @dummy.avatar.path
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class GeometryTest < Test::Unit::TestCase
|
class GeometryTest < Test::Unit::TestCase
|
||||||
context "Paperclip::Geometry" do
|
context "Paperclip::Geometry" do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class IntegrationTest < Test::Unit::TestCase
|
class IntegrationTest < Test::Unit::TestCase
|
||||||
context "Many models at once" do
|
context "Many models at once" do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class InterpolationsTest < Test::Unit::TestCase
|
class InterpolationsTest < Test::Unit::TestCase
|
||||||
should "return all methods but the infrastructure when sent #all" do
|
should "return all methods but the infrastructure when sent #all" do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class IOStreamTest < Test::Unit::TestCase
|
class IOStreamTest < Test::Unit::TestCase
|
||||||
context "IOStream" do
|
context "IOStream" do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class HaveAttachedFileMatcherTest < Test::Unit::TestCase
|
class HaveAttachedFileMatcherTest < Test::Unit::TestCase
|
||||||
context "have_attached_file" do
|
context "have_attached_file" do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class ValidateAttachmentContentTypeMatcherTest < Test::Unit::TestCase
|
class ValidateAttachmentContentTypeMatcherTest < Test::Unit::TestCase
|
||||||
context "validate_attachment_content_type" do
|
context "validate_attachment_content_type" do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class ValidateAttachmentPresenceMatcherTest < Test::Unit::TestCase
|
class ValidateAttachmentPresenceMatcherTest < Test::Unit::TestCase
|
||||||
context "validate_attachment_presence" do
|
context "validate_attachment_presence" do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase
|
class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase
|
||||||
context "validate_attachment_size" do
|
context "validate_attachment_size" do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class PaperclipTest < Test::Unit::TestCase
|
class PaperclipTest < Test::Unit::TestCase
|
||||||
[:image_magick_path, :convert_path].each do |path|
|
[:image_magick_path, :convert_path].each do |path|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class ProcessorTest < Test::Unit::TestCase
|
class ProcessorTest < Test::Unit::TestCase
|
||||||
should "instantiate and call #make when sent #make to the class" do
|
should "instantiate and call #make when sent #make to the class" do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class StorageTest < Test::Unit::TestCase
|
class StorageTest < Test::Unit::TestCase
|
||||||
context "Parsing S3 credentials" do
|
context "Parsing S3 credentials" do
|
||||||
|
|||||||
@@ -1,23 +1,20 @@
|
|||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
gem 'thoughtbot-shoulda', ">= 2.9.0"
|
|
||||||
require 'shoulda'
|
require 'shoulda'
|
||||||
require 'mocha'
|
require 'mocha/test_unit'
|
||||||
|
require 'pry'
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
|
require 'sqlite3'
|
||||||
gem 'sqlite3-ruby'
|
|
||||||
|
|
||||||
require 'active_record'
|
require 'active_record'
|
||||||
require 'active_support'
|
require 'active_support'
|
||||||
begin
|
require 'rails'
|
||||||
require 'ruby-debug'
|
|
||||||
rescue LoadError
|
|
||||||
puts "ruby-debug not loaded"
|
|
||||||
end
|
|
||||||
|
|
||||||
ROOT = File.join(File.dirname(__FILE__), '..')
|
ROOT = File.expand_path('../', __dir__)
|
||||||
Rails.root = ROOT
|
|
||||||
Rails.env = "test"
|
ENV['RAILS_ENV'] = 'test'
|
||||||
|
class TestRailsApp < Rails::Application; end
|
||||||
|
Rails.application.config.root = "#{ROOT}/tmp/rails"
|
||||||
|
|
||||||
$LOAD_PATH << File.join(ROOT, 'lib')
|
$LOAD_PATH << File.join(ROOT, 'lib')
|
||||||
$LOAD_PATH << File.join(ROOT, 'lib', 'paperclip')
|
$LOAD_PATH << File.join(ROOT, 'lib', 'paperclip')
|
||||||
@@ -69,17 +66,6 @@ def rebuild_class options = {}
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def temporary_rails_env(new_env)
|
|
||||||
old_env = Object.const_defined?("Rails.env") ? Rails.env : nil
|
|
||||||
silence_warnings do
|
|
||||||
Object.const_set("Rails.env", new_env)
|
|
||||||
end
|
|
||||||
yield
|
|
||||||
silence_warnings do
|
|
||||||
Object.const_set("Rails.env", old_env)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class FakeModel
|
class FakeModel
|
||||||
attr_accessor :avatar_file_name,
|
attr_accessor :avatar_file_name,
|
||||||
:avatar_file_size,
|
:avatar_file_size,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'test/helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class ThumbnailTest < Test::Unit::TestCase
|
class ThumbnailTest < Test::Unit::TestCase
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user