Permalink
Browse files

Merge pull request #1 from mikz/master

Ruby 1.8 compatability
  • Loading branch information...
2 parents e492b65 + 2a135d0 commit 58aff48782b0a8923f5f9afc6df743c0d2d5223b @exviva committed Jun 15, 2012
Showing with 13 additions and 11 deletions.
  1. +2 −0 CHANGELOG.md
  2. +1 −1 Rakefile
  3. +1 −1 lib/paperclip/storage/tmp.rb
  4. +1 −1 spec/fixtures/user.rb
  5. +7 −7 spec/lib/paperclip/storage/tmp_spec.rb
  6. +1 −1 spec/support/active_record.rb
View
2 CHANGELOG.md
@@ -1,5 +1,7 @@
## Not released yet:
+* Ruby 1.8 compatability: use `Tempfile#path` when opening new file
+ instead passing `Tempfile` directly.
* Rewind the file queued for write before returning it
* Unlink the file **and** close the file descriptor when clearing
the attachments
View
2 Rakefile
@@ -4,4 +4,4 @@ require "bundler/gem_tasks"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
-task default: :spec
+task :default => :spec
View
2 lib/paperclip/storage/tmp.rb
@@ -20,7 +20,7 @@ def to_file(style_name = default_style)
@queued_for_write[style_name].rewind
@queued_for_write[style_name]
elsif exists?(style_name)
- File.new(Tmp.fs[path(style_name)], 'rb')
+ File.new(Tmp.fs[path(style_name)].path, 'rb')
end
end
View
2 spec/fixtures/user.rb
@@ -1,3 +1,3 @@
class User < ActiveRecord::Base
- has_attached_file :avatar, storage: :tmp
+ has_attached_file :avatar, :storage => :tmp
end
View
14 spec/lib/paperclip/storage/tmp_spec.rb
@@ -7,7 +7,7 @@
[proc { user.avatar }, proc { user.reload.avatar }].each do |subject_proc|
describe 'assigning an attachment' do
- let(:user) { User.create!(avatar: avatar_file) }
+ let(:user) { User.create!(:avatar => avatar_file) }
subject(&subject_proc)
it { should exist }
@@ -23,7 +23,7 @@
end
it 'copies the assigned file' do
- File.read(subject.to_file).should eq(File.read(avatar_file))
+ File.read(subject.to_file.path).should eq(File.read(avatar_file.path))
end
it 'stores the file in an imagemagick-friendly way' do
@@ -39,17 +39,17 @@
end
it 'can handle assignment from File' do
- new_user = User.new(avatar: avatar_file)
+ new_user = User.new(:avatar => avatar_file)
new_user.avatar_file_name.should eq('hey_mom_its_me.png')
end
it 'can persist assignment from File' do
- new_user = User.create!(avatar: avatar_file)
+ new_user = User.create!(:avatar => avatar_file)
new_user.reload.avatar_file_name.should eq('hey_mom_its_me.png')
end
it 'can handle assignment from Paperclip::Attachment' do
- new_user = User.new(avatar: subject)
+ new_user = User.new(:avatar => subject)
new_user.avatar_file_name.should eq('hey_mom_its_me.png')
end
end
@@ -67,7 +67,7 @@
end
describe 'destroying an attachment' do
- let(:user) { User.create!(avatar: avatar_file) }
+ let(:user) { User.create!(:avatar => avatar_file) }
subject do
@path_before_destroy = user.avatar.to_file.path
user.destroy
@@ -84,7 +84,7 @@
end
describe 'clear' do
- let(:user) { User.create!(avatar: avatar_file) }
+ let(:user) { User.create!(:avatar => avatar_file) }
subject { Paperclip::Storage::Tmp.clear }
it 'deletes files' do
View
2 spec/support/active_record.rb
@@ -2,7 +2,7 @@
ActiveRecord::Base.send(:include, Paperclip::Glue)
require 'fixtures/user'
-ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
+ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
ActiveRecord::Schema.define do
create_table :users do |t|

0 comments on commit 58aff48

Please sign in to comment.