Jarkko Laine
2007-Nov-21 12:06 UTC
[rspec-users] Testing transactional updates in story runner
How do you guys test transactional updates with story runner? I have an action that needs to update four different models: Enrollment.transaction do @contact.update_addresses(params[:contact_address], params [:billing_address]) @enrollment.update_attributes!(params[:enrollment]) end The last update_attributes! will raise ActiveRecord::RecordNotValid if anything was invalid (it cascades to contact and further to addresses), and thus cause a rollback, so either all the updates go through or none of them. This works fine in development and production. However, in story runner the whole story is put inside a big transaction and further attempts to create or rollback transactions are ignored. This is of course nice from the performance point of view, but if you have code that depends on actual transactions in the app, you''re screwed. In my example the addresses would stay updated in the story runner''s eyes even though in real life the changes would be rolled back, thus making stories not what they''re supposed to be, end-to-end tests for the application stack. Has anyone found an elegant way to circumvent this with story runner? Cheers, //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi