Rails Rspec testing not saving a transactional model
- by NolanDC
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?