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

Commit

Permalink
Merge branch 'master' into interpolations_tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
dgynn committed Jul 18, 2015
2 parents 9c73526 + 947fbf6 commit e285c41
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 9 deletions.
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
* Ruby Versioning: Drop support for 1.9.3 (EOL'ed)
* Rails Versioning: Drop support for 4.0.0 (EOL'ed)

4.2.4:

* Rollback backwards incompatible change, allowing paperclip to run on
Ruby >= 1.9.2.

4.2.3:

* Fix dependency specifications (didn't work with Rails 4.1)
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ If you are dealing with pdf uploads or running the test suite, you'll also need
to install GhostScript. On Mac OS X, you can also install that using Homebrew:

brew install gs

If you're on Ubuntu, you'll want to run the following with apt-get:

sudo apt-get install imagemagick -y

### `file`

Expand Down Expand Up @@ -143,7 +147,7 @@ Paperclip is distributed as a gem, which is how it should be used in your app.
Include the gem in your Gemfile:

```ruby
gem "paperclip", "~> 4.2"
gem "paperclip", "~> 4.3"
```

If you're still using Rails 2.3.x, you should do this instead:
Expand Down
2 changes: 0 additions & 2 deletions lib/paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ def assign(uploaded_file)
# +#for(style_name, options_hash)+

def url(style_name = default_style, options = {})
return nil if @instance.new_record?

if options == true || options == false # Backwards compatibility.
@url_generator.for(style_name, default_options.merge(:timestamp => options))
else
Expand Down
2 changes: 1 addition & 1 deletion lib/paperclip/glue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.included(base)
base.extend ClassMethods
base.send :include, Callbacks
base.send :include, Validators
base.send :include, Schema
base.send :include, Schema if defined? ActiveRecord

locale_path = Dir.glob(File.dirname(__FILE__) + "/locales/*.{rb,yml}")
I18n.load_path += locale_path unless I18n.load_path.include?(locale_path)
Expand Down
2 changes: 1 addition & 1 deletion paperclip.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]

s.requirements << "ImageMagick"
s.required_ruby_version = ">= 2.0.0"
s.required_ruby_version = ">= 1.9.2"

s.add_dependency('activemodel', '>= 3.2.0')
s.add_dependency('activesupport', '>= 3.2.0')
Expand Down
7 changes: 3 additions & 4 deletions spec/paperclip/attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,16 @@

context "without an Attachment" do
before do
rebuild_model default_url: "default.url"
@dummy = Dummy.new
end

it "returns false when asked exists?" do
assert !@dummy.avatar.exists?
end

it "#url returns nil" do
assert_nil @dummy.avatar.url
it "#url returns the default_url" do
expect(@dummy.avatar.url).to eq "default.url"
end
end

Expand Down Expand Up @@ -1490,6 +1491,4 @@ def call(filename)
assert_file_exists(@path)
end
end

end

44 changes: 44 additions & 0 deletions spec/paperclip/glue_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# require "spec_helper"

describe Paperclip::Glue do
describe "when ActiveRecord does not exist" do
before do
ActiveRecordSaved = ActiveRecord
Object.send :remove_const, "ActiveRecord"
end

after do
ActiveRecord = ActiveRecordSaved
Object.send :remove_const, "ActiveRecordSaved"
end

it "does not fail" do
NonActiveRecordModel = Class.new
NonActiveRecordModel.send :include, Paperclip::Glue
Object.send :remove_const, "NonActiveRecordModel"
end
end

describe "when ActiveRecord does exist" do
before do
if Object.const_defined?("ActiveRecord")
@defined_active_record = false
else
ActiveRecord = :defined
@defined_active_record = true
end
end

after do
if @defined_active_record
Object.send :remove_const, "ActiveRecord"
end
end

it "does not fail" do
NonActiveRecordModel = Class.new
NonActiveRecordModel.send :include, Paperclip::Glue
Object.send :remove_const, "NonActiveRecordModel"
end
end
end

0 comments on commit e285c41

Please sign in to comment.