|
| 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 |
0 commit comments