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

Commit

Permalink
styling tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
yodarjun authored and Jon Yurek committed Aug 27, 2015
1 parent 17ecc58 commit ece46f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/paperclip/has_attached_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def add_active_record_callbacks
@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
Expand Down
13 changes: 7 additions & 6 deletions spec/paperclip/has_attached_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
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
Expand Down

0 comments on commit ece46f4

Please sign in to comment.