Skip to content
This repository was archived by the owner on Jul 13, 2023. It is now read-only.

Commit d97a6c6

Browse files
committed
Merge pull request #1976 from thoughtbot/add-rails-master-appraisals
Add Rails master appraisals in preparation for Rails 5
2 parents 65ef0d3 + 799845e commit d97a6c6

15 files changed

+155
-25
lines changed

.travis.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
rvm:
22
- 2.1
3-
- 2.2
3+
- 2.2.2
44

55
script: "bundle exec rake clean spec cucumber"
66

77
gemfile:
8-
- gemfiles/4.2.awsv2.1.gemfile
98
- gemfiles/4.2.awsv2.0.gemfile
9+
- gemfiles/4.2.awsv2.1.gemfile
10+
- gemfiles/5.0.awsv2.0.gemfile
11+
- gemfiles/5.0.awsv2.1.gemfile
12+
13+
matrix:
14+
fast_finish: true
15+
exclude:
16+
- gemfile: gemfiles/5.0.awsv2.0.gemfile
17+
rvm: 2.0
18+
- gemfile: gemfiles/5.0.awsv2.1.gemfile
19+
rvm: 2.0
20+
- gemfile: gemfiles/5.0.awsv2.0.gemfile
21+
rvm: 2.1
22+
- gemfile: gemfiles/5.0.awsv2.1.gemfile
23+
rvm: 2.1
1024

1125
sudo: false
1226
cache: bundler

Appraisals

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
appraise "4.2.awsv2.0" do
2+
gem "rails", "~> 4.2.0"
3+
gem "aws-sdk", "~> 2.0.0"
4+
end
5+
16
appraise "4.2.awsv2.1" do
27
gem "rails", "~> 4.2.0"
38
gem "aws-sdk", "~> 2.1.0"
@@ -7,11 +12,16 @@ appraise "4.2.awsv2.1" do
712
end
813
end
914

10-
appraise "4.2.awsv2.0" do
11-
gem "rails", "~> 4.2.0"
15+
appraise "5.0.awsv2.0" do
16+
gem "rails", "5.0.0.beta3"
1217
gem "aws-sdk", "~> 2.0.0"
1318

1419
group :development, :test do
1520
gem 'mime-types', '>= 1.16', '< 4'
1621
end
1722
end
23+
24+
appraise "5.0.awsv2.1" do
25+
gem "rails", "5.0.0.beta3"
26+
gem "aws-sdk", "~> 2.1.0"
27+
end

README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Paperclip
22
=========
33

4+
## Documentation valid for `master` branch
5+
6+
Please check the documentation for the paperclip version you are using:
7+
https://github.com/thoughtbot/paperclip/releases
8+
9+
---
10+
411
[![Build Status](https://secure.travis-ci.org/thoughtbot/paperclip.svg?branch=master)](http://travis-ci.org/thoughtbot/paperclip)
512
[![Dependency Status](https://gemnasium.com/thoughtbot/paperclip.svg?travis)](https://gemnasium.com/thoughtbot/paperclip)
613
[![Code Climate](https://codeclimate.com/github/thoughtbot/paperclip.svg)](https://codeclimate.com/github/thoughtbot/paperclip)
@@ -71,9 +78,8 @@ Requirements
7178

7279
### Ruby and Rails
7380

74-
Paperclip now requires Ruby version **>= 2.0.0** and Rails version **3.2, >= 4.1** (Only if you're going to use Paperclip with Ruby on Rails.)
75-
76-
If you're still on Ruby 1.8.7 or Ruby on Rails 2.3.x, you can still use Paperclip 2.7.x with your project. Also, everything in this README might not apply to your version of Paperclip, and you should read [the README for version 2.7](http://www.rubydoc.info/gems/paperclip/2.7.0) instead.
81+
Paperclip now requires Ruby version **>= 2.1** and Rails version **>= 4.2**
82+
(only if you're going to use Paperclip with Ruby on Rails.)
7783

7884
### Image Processor
7985

@@ -100,7 +106,7 @@ to install GhostScript. On Mac OS X, you can also install that using Homebrew:
100106

101107
brew install gs
102108

103-
If you're on Ubuntu (or any Debian base Linux distribution), you'll want to run
109+
If you are on Ubuntu (or any Debian base Linux distribution), you'll want to run
104110
the following with apt-get:
105111

106112
sudo apt-get install imagemagick -y
@@ -153,7 +159,7 @@ Paperclip is distributed as a gem, which is how it should be used in your app.
153159
Include the gem in your Gemfile:
154160

155161
```ruby
156-
gem "paperclip", "~> 4.3"
162+
gem "paperclip", "~> 5.0"
157163
```
158164

159165
Or, if you want to get the latest, you can get master from the main paperclip repository:

gemfiles/4.2.awsv2.0.gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
source "https://rubygems.org"
44

5-
gem "sqlite3", "~> 1.3.8", platforms: :ruby
5+
gem "sqlite3", "~> 1.3.8", :platforms => :ruby
66
gem "pry"
77
gem "rails", "~> 4.2.0"
88
gem "aws-sdk", "~> 2.0.0"
99

1010
group :development, :test do
1111
gem "activerecord-import"
12-
gem "mime-types", ">= 1.16", "< 4"
12+
gem "mime-types"
1313
gem "builder"
1414
gem "rubocop", :require => false
1515
end
1616

17-
gemspec path: "../"
17+
gemspec :path => "../"

gemfiles/4.2.awsv2.1.gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "sqlite3", "~> 1.3.8", platforms: :ruby
5+
gem "sqlite3", "~> 1.3.8", :platforms => :ruby
66
gem "pry"
77
gem "rails", "~> 4.2.0"
88
gem "aws-sdk", "~> 2.1.0"
@@ -14,4 +14,4 @@ group :development, :test do
1414
gem "rubocop", :require => false
1515
end
1616

17-
gemspec path: "../"
17+
gemspec :path => "../"

gemfiles/4.2.awsv2.gemfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "sqlite3", "~> 1.3.8", :platforms => :ruby
6+
gem "jruby-openssl", :platforms => :jruby
7+
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
8+
gem "rubysl", :platforms => :rbx
9+
gem "racc", :platforms => :rbx
10+
gem "pry"
11+
gem "rails", "~> 4.2.0"
12+
gem "aws-sdk", "~> 2.0"
13+
14+
group :development, :test do
15+
gem "mime-types", "~> 1.16"
16+
gem "builder"
17+
gem "rubocop", :require => false
18+
end
19+
20+
gemspec :path => "../"

gemfiles/5.0.awsv2.0.gemfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "sqlite3", "~> 1.3.8", :platforms => :ruby
6+
gem "pry"
7+
gem "rails", "5.0.0.beta3"
8+
gem "aws-sdk", "~> 2.0.0"
9+
10+
group :development, :test do
11+
gem "activerecord-import"
12+
gem "mime-types", ">= 1.16", "< 4"
13+
gem "builder"
14+
gem "rubocop", :require => false
15+
end
16+
17+
gemspec :path => "../"

gemfiles/5.0.awsv2.1.gemfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "sqlite3", "~> 1.3.8", :platforms => :ruby
6+
gem "pry"
7+
gem "rails", "5.0.0.beta3"
8+
gem "aws-sdk", "~> 2.1.0"
9+
10+
group :development, :test do
11+
gem "activerecord-import"
12+
gem "mime-types"
13+
gem "builder"
14+
gem "rubocop", :require => false
15+
end
16+
17+
gemspec :path => "../"

gemfiles/5.0.awsv2.gemfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "sqlite3", "~> 1.3.8", :platforms => :ruby
6+
gem "jruby-openssl", :platforms => :jruby
7+
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
8+
gem "rubysl", :platforms => :rbx
9+
gem "racc", :platforms => :rbx
10+
gem "pry"
11+
gem "rails", :github => "rails/rails"
12+
gem "sprockets-rails", :github => "rails/sprockets-rails"
13+
gem "sprockets", :github => "rails/sprockets"
14+
gem "sass-rails", :github => "rails/sass-rails"
15+
gem "arel", :github => "rails/arel"
16+
gem "rack", :github => "rack/rack"
17+
gem "aws-sdk", "~> 2.0"
18+
19+
group :development, :test do
20+
gem "mime-types", "~> 1.16"
21+
gem "builder"
22+
gem "rubocop", :require => false
23+
end
24+
25+
gemspec :path => "../"

lib/paperclip/attachment.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def post_process(*style_args) #:nodoc:
501501

502502
instance.run_paperclip_callbacks(:post_process) do
503503
instance.run_paperclip_callbacks(:"#{name}_post_process") do
504-
unless @options[:check_validity_before_processing] && instance.errors.any?
504+
if !@options[:check_validity_before_processing] || !instance.errors.any?
505505
post_process_styles(*style_args)
506506
end
507507
end

lib/paperclip/callbacks.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def self.included(base)
77

88
module Defining
99
def define_paperclip_callbacks(*callbacks)
10-
define_callbacks(*[callbacks, {:terminator => callback_terminator}].flatten)
10+
define_callbacks(*[callbacks, { terminator: hasta_la_vista_baby }].flatten)
1111
callbacks.each do |callback|
1212
eval <<-end_callbacks
1313
def before_#{callback}(*args, &blk)
@@ -22,11 +22,13 @@ def after_#{callback}(*args, &blk)
2222

2323
private
2424

25-
def callback_terminator
26-
if ::ActiveSupport::VERSION::STRING >= '4.1'
27-
lambda { |target, result| result == false }
28-
else
29-
'result == false'
25+
def hasta_la_vista_baby
26+
lambda do |_, result|
27+
if result.respond_to?(:call)
28+
result.call == false
29+
else
30+
result == false
31+
end
3032
end
3133
end
3234
end

spec/paperclip/validators_spec.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,11 @@
6464
assert_raises(RuntimeError){ dummy.valid? }
6565
end
6666

67-
it 'allows you to attach a file that does not violates these validations' do
67+
it 'allows you to attach a file that does not violate these validations' do
6868
dummy = Dummy.new(avatar: File.new(fixture_file('rotated.jpg')))
69-
expect(dummy.errors.keys).to match_array []
69+
expect(dummy.errors.full_messages).to be_empty
7070
assert dummy.valid?
7171
end
72-
7372
end
7473

7574
context "using the helper with a conditional" do

spec/spec_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
config.include Assertions
3737
config.include ModelReconstruction
3838
config.include TestData
39+
config.include Reporting
3940
config.extend VersionHelper
4041
config.mock_framework = :mocha
4142
config.before(:all) do

spec/support/model_reconstruction.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ def reset_class class_name
1010

1111
klass.reset_column_information
1212
klass.connection_pool.clear_table_cache!(klass.table_name) if klass.connection_pool.respond_to?(:clear_table_cache!)
13-
klass.connection.schema_cache.clear_table_cache!(klass.table_name) if klass.connection.respond_to?(:schema_cache)
13+
14+
if klass.connection.respond_to?(:schema_cache)
15+
if ActiveRecord::VERSION::STRING >= "5.0"
16+
klass.connection.schema_cache.clear_data_source_cache!(klass.table_name)
17+
else
18+
klass.connection.schema_cache.clear_table_cache!(klass.table_name)
19+
end
20+
end
21+
1422
klass
1523
end
1624

spec/support/reporting.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module Reporting
2+
def silence_stream(stream)
3+
old_stream = stream.dup
4+
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
5+
stream.sync = true
6+
yield
7+
ensure
8+
stream.reopen(old_stream)
9+
old_stream.close
10+
end
11+
end

0 commit comments

Comments
 (0)