Skip to content

Commit

Permalink
Added test + fix for callbacks for destroy.
Browse files Browse the repository at this point in the history
Change-Id: If25863ddeaf2a3a8744d19dcc13dddbe62b45e0b
Reviewed-on: http://review.couchbase.org/41660
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
  • Loading branch information
Archit Baweja authored and avsej committed Sep 25, 2014
1 parent 3b27f90 commit 2d65fb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/couchbase/active_model.rb
Expand Up @@ -10,8 +10,8 @@ def self.included(base)
include ::ActiveModel::Validations::Callbacks
include ::ActiveModel::Dirty

define_model_callbacks :create, :update, :delete, :save, :initialize
[:save, :create, :update, :delete, :initialize].each do |meth|
define_model_callbacks :create, :update, :delete, :destroy, :save, :initialize
[:save, :create, :update, :delete, :destroy, :initialize].each do |meth|
class_eval <<-EOC
alias #{meth}_without_callbacks #{meth}
def #{meth}(*args, &block)
Expand Down
3 changes: 2 additions & 1 deletion test/test_active_model_integration.rb
Expand Up @@ -70,7 +70,8 @@ def test_callbacks
:after_initialize, :before_create, :around_create,
:after_create, :before_delete, :around_delete,
:after_delete, :before_save, :around_save, :after_save,
:before_update, :around_update, :after_update
:before_update, :around_update, :after_update,
:before_destroy, :around_destroy, :after_destroy
].each do |callback|
assert ActiveObj.respond_to?(callback), "Model doesn't support callback: #{callback}"
end
Expand Down

0 comments on commit 2d65fb5

Please sign in to comment.