Fix exception that is raised if after_commit callback hooks are absent

This is the same issue that is fixed by https://github.com/thoughtbot/paperclip/pull/1425 but because we needed it asap, I added tests for this.