Commit f1db7d7b by Jon Yurek

We can't work with isolated attachment objects anymore

parent 19a3bfc6
...@@ -6,3 +6,4 @@ gem 'jruby-openssl', :platform => :jruby ...@@ -6,3 +6,4 @@ gem 'jruby-openssl', :platform => :jruby
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
gem 'pry', :platform => :ruby gem 'pry', :platform => :ruby
gem 'pry-byebug', :platform => :ruby
...@@ -7,7 +7,7 @@ module Paperclip ...@@ -7,7 +7,7 @@ module Paperclip
module Defining module Defining
def define_paperclip_callbacks(*callbacks) def define_paperclip_callbacks(*callbacks)
define_callbacks *[callbacks, {:terminator => "result == false"}].flatten define_callbacks(*[callbacks, {:terminator => "result == false"}].flatten)
callbacks.each do |callback| callbacks.each do |callback|
eval <<-end_callbacks eval <<-end_callbacks
def before_#{callback}(*args, &blk) def before_#{callback}(*args, &blk)
......
...@@ -165,7 +165,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -165,7 +165,7 @@ class AttachmentTest < Test::Unit::TestCase
:default_style => 'default style', :default_style => 'default style',
:url_generator => mock_url_generator_builder) :url_generator => mock_url_generator_builder)
attachment_json = attachment.as_json attachment.as_json
assert mock_url_generator_builder.has_generated_url_with_style_name?('default style') assert mock_url_generator_builder.has_generated_url_with_style_name?('default style')
end end
...@@ -983,19 +983,16 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -983,19 +983,16 @@ class AttachmentTest < Test::Unit::TestCase
:path => ":rails_root/:attachment/:class/:style/:id/:basename.:extension" :path => ":rails_root/:attachment/:class/:style/:id/:basename.:extension"
}) })
FileUtils.rm_rf("tmp") FileUtils.rm_rf("tmp")
rebuild_model rebuild_model :styles => { :large => ["400x400", :jpg],
:medium => ["100x100", :jpg],
:small => ["32x32#", :jpg]},
:default_style => :small
@instance = Dummy.new @instance = Dummy.new
@instance.stubs(:id).returns 123 @instance.stubs(:id).returns 123
@file = File.new(fixture_file("uppercase.PNG"), 'rb') @file = File.new(fixture_file("uppercase.PNG"), 'rb')
styles = {:styles => { :large => ["400x400", :jpg], @attachment = @instance.avatar
:medium => ["100x100", :jpg],
:small => ["32x32#", :jpg]},
:default_style => :small}
@attachment = Paperclip::Attachment.new(:avatar,
@instance,
styles)
now = Time.now now = Time.now
Time.stubs(:now).returns(now) Time.stubs(:now).returns(now)
@attachment.assign(@file) @attachment.assign(@file)
...@@ -1027,7 +1024,8 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -1027,7 +1024,8 @@ class AttachmentTest < Test::Unit::TestCase
rebuild_model rebuild_model
@instance = Dummy.new @instance = Dummy.new
@instance.stubs(:id).returns 123 @instance.stubs(:id).returns 123
@attachment = Paperclip::Attachment.new(:avatar, @instance) # @attachment = Paperclip::Attachment.new(:avatar, @instance)
@attachment = @instance.avatar
@file = File.new(fixture_file("5k.png"), 'rb') @file = File.new(fixture_file("5k.png"), 'rb')
end end
...@@ -1045,7 +1043,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -1045,7 +1043,7 @@ class AttachmentTest < Test::Unit::TestCase
should 'clear out the previous assignment when assigned nil' do should 'clear out the previous assignment when assigned nil' do
@attachment.assign(@file) @attachment.assign(@file)
original_file = @attachment.queued_for_write[:original] @attachment.queued_for_write[:original]
@attachment.assign(nil) @attachment.assign(nil)
assert_nil @attachment.queued_for_write[:original] assert_nil @attachment.queued_for_write[:original]
end end
...@@ -1093,12 +1091,12 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -1093,12 +1091,12 @@ class AttachmentTest < Test::Unit::TestCase
context "when expecting three styles" do context "when expecting three styles" do
setup do setup do
styles = {:styles => { :large => ["400x400", :png], rebuild_model :styles => {
:medium => ["100x100", :gif], :large => ["400x400", :png],
:small => ["32x32#", :jpg]}} :medium => ["100x100", :gif],
@attachment = Paperclip::Attachment.new(:avatar, :small => ["32x32#", :jpg]
@instance, }
styles) @attachment = @instance.avatar
end end
context "and assigned a file" do context "and assigned a file" do
...@@ -1129,7 +1127,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -1129,7 +1127,7 @@ class AttachmentTest < Test::Unit::TestCase
[:small, 32, 32, "JPEG"]].each do |style| [:small, 32, 32, "JPEG"]].each do |style|
cmd = %Q[identify -format "%w %h %b %m" "#{@attachment.path(style.first)}"] cmd = %Q[identify -format "%w %h %b %m" "#{@attachment.path(style.first)}"]
out = `#{cmd}` out = `#{cmd}`
width, height, size, format = out.split(" ") width, height, _size, format = out.split(" ")
assert_equal style[1].to_s, width.to_s assert_equal style[1].to_s, width.to_s
assert_equal style[2].to_s, height.to_s assert_equal style[2].to_s, height.to_s
assert_equal style[3].to_s, format.to_s assert_equal style[3].to_s, format.to_s
......
...@@ -84,7 +84,7 @@ class HttpUrlProxyAdapterTest < Test::Unit::TestCase ...@@ -84,7 +84,7 @@ class HttpUrlProxyAdapterTest < Test::Unit::TestCase
teardown do teardown do
begin begin
@subject.close @subject.close
rescue Exception => e rescue Exception
binding.pry binding.pry
true true
end end
...@@ -95,7 +95,7 @@ class HttpUrlProxyAdapterTest < Test::Unit::TestCase ...@@ -95,7 +95,7 @@ class HttpUrlProxyAdapterTest < Test::Unit::TestCase
end end
should "not generate paths that include restricted characters" do should "not generate paths that include restricted characters" do
assert_no_match /:/, @subject.path assert_no_match(/:/, @subject.path)
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment