mongoid/mongoid — Issue #1752: callbacks triggered twice
Author: apneadiving
Created: 2012-02-22 21:27:17+00:00
State: open

I've seen many closed issues concerning callbacks triggered twice but they are quite old so I decided to post this issue.

In my update to Rails 3.2, I've made the step from mongoid 2.2.4 to 2.4.4 and some specs now fail.

Willing to know what version of Mongoid make the spec fail, I've done things the iterative way:

* v. 2.2.4, specs pass
* direct update to 2.4.4, specs fail
* v. 2.3.0, specs pass
* v. 2.3.5, bundler complained, skipped
* v. 2.3.4, specs pass
* v. 2.4.0, specs fail

The situation is the folowing: I use `state_machine` and I want a `Document` to change it's state from `waiting_assignment` to `in_progress`. `Document` is embedded in `Project`.

Basically, I just need to trigger an event which will do this for me: change state and save, `document.status_progress`

Besides, I've an around_filter:

around_save :on_progress, :if => lambda {|doc| code_here }

My spec is the following:

document.should_receive :on_progress
document.status_progress

And it fails with the following message:

Failure/Error: document.should_receive :on_progress
(#).on_progress(any args)
expected: 1 time
received: 2 times

If you need more info, please tell me.