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

Commit 1dd84aa

Browse files
authored
Merge pull request #2161 from thoughtbot/tc-release
Release version 4.3.7
2 parents 98e0c34 + 4744973 commit 1dd84aa

File tree

7 files changed

+128
-2
lines changed

7 files changed

+128
-2
lines changed

NEWS

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
* Improvement: the `URI adapter` now uses the content-disposition header to name the downloaded file.
1+
4.3.7 (6/1/2016):
2+
3+
* Add deprecation warnings
24
* Improvement: Add `fog_options` configuration to send options to fog when storing files.
5+
* Improvement: the `URI adapter` now uses the content-disposition header to name the downloaded file.
36

47
4.3.6 (3/13/2016):
58

lib/paperclip.rb

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
require 'paperclip/attachment_registry'
5757
require 'paperclip/filename_cleaner'
5858
require 'paperclip/rails_environment'
59+
require "paperclip/deprecations"
5960

6061
begin
6162
# Use mime/types/columnar if available, for reduced memory usage
@@ -191,6 +192,7 @@ module ClassMethods
191192
# end
192193
# end
193194
def has_attached_file(name, options = {})
195+
Paperclip::Deprecations.check
194196
HasAttachedFile.define_on(self, name, options)
195197
end
196198
end

lib/paperclip/deprecations.rb

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require "active_support/deprecation"
2+
3+
module Paperclip
4+
class Deprecations
5+
class << self
6+
def check
7+
warn_aws_sdk_v1 if aws_sdk_v1?
8+
warn_outdated_rails if active_model_version < "4.2"
9+
end
10+
11+
private
12+
13+
def active_model_version
14+
::ActiveModel::VERSION::STRING
15+
end
16+
17+
def aws_sdk_v1?
18+
defined?(::AWS) && aws_sdk_version < "2"
19+
end
20+
21+
def warn_aws_sdk_v1
22+
warn "[paperclip] [deprecation] AWS SDK v1 has been deprecated in " \
23+
"paperclip 5. Please consider upgrading to AWS 2 before " \
24+
"upgrading paperclip."
25+
end
26+
27+
def warn_outdated_rails
28+
warn "[paperclip] [deprecation] Rails 3.2 and 4.1 are unsupported as " \
29+
"of Rails 5 release. Please upgrade to Rails 4.2 before " \
30+
"upgrading paperclip."
31+
end
32+
33+
def aws_sdk_version
34+
::AWS::VERSION
35+
end
36+
37+
def warn(message)
38+
ActiveSupport::Deprecation.warn(message)
39+
end
40+
end
41+
end
42+
end

lib/paperclip/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Paperclip
2-
VERSION = "4.3.6" unless defined? Paperclip::VERSION
2+
VERSION = "4.3.7".freeze unless defined? Paperclip::VERSION
33
end

spec/paperclip/deprecations_spec.rb

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
require "spec_helper"
2+
require "aws-sdk"
3+
require "active_support/testing/deprecation"
4+
5+
describe Paperclip::Deprecations do
6+
include ActiveSupport::Testing::Deprecation
7+
8+
describe ".check" do
9+
before do
10+
ActiveSupport::Deprecation.silenced = false
11+
end
12+
13+
after do
14+
ActiveSupport::Deprecation.silenced = true
15+
end
16+
17+
context "when active model version is < 4.2" do
18+
it "displays deprecation warning" do
19+
Paperclip::Deprecations.stubs(:active_model_version).returns("4.1")
20+
21+
assert_deprecated("Rails 3.2 and 4.1 are unsupported") do
22+
Paperclip::Deprecations.check
23+
end
24+
end
25+
end
26+
27+
context "when active model version is 4.2" do
28+
it "do not display deprecation warning" do
29+
Paperclip::Deprecations.stubs(:active_model_version).returns("4.2")
30+
31+
assert_not_deprecated do
32+
Paperclip::Deprecations.check
33+
end
34+
end
35+
end
36+
37+
context "when aws sdk version is < 2" do
38+
before do
39+
::AWS.stub! if !defined?(::AWS)
40+
end
41+
42+
it "displays deprecation warning" do
43+
Paperclip::Deprecations.stubs(:aws_sdk_version).returns("1.68.0")
44+
45+
assert_deprecated("AWS SDK v1 has been deprecated") do
46+
Paperclip::Deprecations.check
47+
end
48+
end
49+
end
50+
51+
context "when aws sdk version is 2" do
52+
before do
53+
::AWS.stub! if !defined?(::AWS)
54+
end
55+
56+
it "do not display deprecation warning" do
57+
Paperclip::Deprecations.stubs(:aws_sdk_version).returns("2.0.0")
58+
59+
assert_not_deprecated do
60+
Paperclip::Deprecations.check
61+
end
62+
end
63+
end
64+
end
65+
end

spec/paperclip/paperclip_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class ::Four; end
109109

110110
context "An ActiveRecord model with an 'avatar' attachment" do
111111
before do
112+
Paperclip::Deprecations.stubs(:check)
112113
rebuild_model path: "tmp/:class/omg/:style.:extension"
113114
@file = File.new(fixture_file("5k.png"), 'rb')
114115
end
@@ -150,6 +151,10 @@ class ::Four; end
150151
end
151152
end
152153

154+
it "calls Paperclip::Deprecations.check" do
155+
expect(Paperclip::Deprecations).to have_received(:check)
156+
end
157+
153158
context "with a subclass" do
154159
before do
155160
class ::SubDummy < Dummy; end

spec/support/deprecations.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
RSpec.configure do |config|
2+
config.before(:all) do
3+
ActiveSupport::Deprecation.silenced = true
4+
end
5+
config.before(:each) do
6+
Paperclip::Deprecations.stubs(:active_model_version).returns("4.2")
7+
Paperclip::Deprecations.stubs(:aws_sdk_version).returns("2.0.0")
8+
end
9+
end

0 commit comments

Comments
 (0)