benzelano / test_lh_import

1 stars 0 forks source link

update_attributes doesn't trigger transitions on nested has_many :machines #169

Closed benzelano closed 13 years ago

benzelano commented 13 years ago

Morgan Christiansson opened this issue

Like stated above.

Will try to write a testcase for it. But basically it seems .state_event_changed? doesn’t exist and .changed? doesn’t return true so update_attributes doesn’t try to save the nested models.

original LH ticket

This ticket has 0 attachment(s).

benzelano commented 13 years ago

Morgan Christiansson commented

I committed a test here: https://github.com/morganchristiansson/state_machine/commit/268bf65651a054cd0206c9ee36acd7c45a2b9bb6

Also I’m surprise that calling @table.children.map(&:id) before update_attributes decides whether :state_event is set after update_attributes.

Let me know if you want more details or a cleaner test. Previous tests I’ve submitted have been rewritten anyway, so I thought I wouldn’t spend too much time perfecting them.

Thanks!

benzelano commented 13 years ago

Morgan -

Thanks for the heads up! I believe this may very well be an integration issue with ActiveRecord whereby a change to that attribute doesn’t mark the record as dirty and, as a result, doesn’t case the children to get saved. I’ll have to take a look at that one in the coming weeks.

benzelano commented 13 years ago

Morgan Christiansson commented

Thanks for your reply.

With an upgrade to rails 2.3.11 my coworker experienced even more test failures with the state machines updated through update_attributes. I’ll post an update when I have a chance to look at it.

Thanks, Morgan

benzelano commented 13 years ago

(from [31d8143969a7225926a9db034823991af38c2b2e]) Fix objects not getting marked as dirty in all integrations when #{attribute}_event is set [#69 state:resolved] https://github.com/pluginaweek/state_machine/commit/31d8143969a7225926a9db034823991af38c2b2e