Commit ece46f46 by Arjun Anand Committed by Jon Yurek

styling tweaks

parent 17ecc58a
......@@ -92,7 +92,9 @@ module Paperclip
@klass.send(:after_save) { send(name).send(:save) }
@klass.send(:before_destroy) { send(name).send(:queue_all_for_delete) }
if @klass.respond_to?(:after_commit)
@klass.send(:after_commit, :on => :destroy) { send(name).send(:flush_deletes) }
@klass.send(:after_commit, on: :destroy) do
send(name).send(:flush_deletes)
end
else
@klass.send(:after_destroy) { send(name).send(:flush_deletes) }
end
......
......@@ -38,12 +38,13 @@ describe Paperclip::HasAttachedFile do
assert_adding_attachment('avatar').defines_callback('after_commit')
end
it 'defines an after_commit callback if the class allows after_commit callbacks' do
assert_adding_attachment('avatar').defines_callback('after_commit')
end
it 'defines an after_destroy callback if the class does not allow after_commit callbacks' do
assert_adding_attachment('avatar', :unstub_methods => [:after_commit]).defines_callback('after_destroy')
context 'when the class does not allow after_commit callbacks' do
it 'defines an after_destroy callback' do
assert_adding_attachment(
'avatar',
unstub_methods: [:after_commit]
).defines_callback('after_destroy')
end
end
it 'defines the Paperclip-specific callbacks' do
......
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