Rails Rspec testing not saving a transactional model

Posted by NolanDC on Stack Overflow See other posts from Stack Overflow or by NolanDC
Published on 2010-05-27T17:26:16Z Indexed on 2010/05/27 17:31 UTC
Read the original article Hit count: 158

Filed under:
|
|

I'm currently testing my Rails controllers using RSpec. In one controller, I have a model that uses transactions, so that it will not be saved unless another nested model (whose data is filled in using fields_for) is also saved correctly.

The tests hit a snag when they reach the transaction. Some debugging output proves that the model is valid and ready to save. However, upon entering the transaction block, the model does not save. Even stranger, the code never reaches the else clause of "if model.save" (It does, however, enter the transaction block).

I can only assume this is a problem with my testing a transactional model.

Any ideas/hints/solutions?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about transactions