을 실행되지 않습니다 잘못된. User#invite_user!
가 왜액티브 콜백은 다음 사양을 감안할 때
# Check the before_validation callback options:
participation.user # nil
participation.valid? # true
participation.user # User{id: nil}
# Check the before_create callback options:
participation.user_exists? # false
participation.mark_for_invitation # true
# Check the after_create callback options:
participation.marked_for_invitation? # true
# After all this I expect the "invite_user!" to be called:
participation.stub(:invite_user!) { puts "Doesn't get called :(" }
participation.save! # => true, Nothing is printed, which is consistent with the spec
participation.user_id # => 11, so the user has been saved
당신은 문제를 발견 할 수를 호출되지 않습니다 다음은 실패 사양에서 "콘솔"출력은?
rspec 및 레일 버전을 제공해주십시오. 해당 코드에는 명백한 문제가 없습니다. – Sigurd
after_create 콜백 대신 after_save를 사용하면 작동합니까? – John
실제로 그렇습니다. –