jasoncodes / activerecord_views

Automatic PostgreSQL database view creation for ActiveRecord
MIT License
35 stars 10 forks source link

Transactional fixtures #15

Closed twe4ked closed 1 year ago

twe4ked commented 9 years ago

Hey :)

I had a bit of trouble getting a view working in test mode with use_transactional_fixtures set to true. I looked at Dart Scores (https://github.com/ennova/dartscores/commit/2a2b02ac8c0b493873ec4a2f310590986aeaa8f4) and tried switching to DatabaseCleaner and that fixed my issue. Can you please explain the problem? I think I kind of get it but I'd love a proper explanation. Thanks

Edit: Scratch that, still having trouble. Will update. Edit 2: Nothing to do with DatabaseCleaner, I wasn't explicitly calling the view's class.

jasoncodes commented 9 years ago

Do you have any suggestions on how section of the README describing this could be made clearer? This seems to be a tricky bit to get right.

twe4ked commented 9 years ago

I was wrong (maybe) about not explicitly calling the view's class. It's not a dependant view. I still can't get it to work without DatabaseCleaner. I'm not sure how I got to the point of my “Edit 2” yesterday.

Edit: Just noticed I do have a explicit call to the class at the top of my spec in a before block. If I remove it my first spec fails even though it's using the association to the view. Is that normal?

jasoncodes commented 9 years ago

Are you able to post a sample project that reproduces your issue?

twe4ked commented 9 years ago

This is a fairly new project. I can try do a clean one if you like. You may just see the problem I'm having though. https://github.com/twe4ked/halcyonladder/commit/a57fc9928d3b230631946ecb4f6603b6ecc04a9a

jasoncodes commented 9 years ago

There seems to be a problem where the open test transaction is being lost when the view model is loaded. Weird. I’ll have to see if I can reproduce it in a ARV unit test.

twe4ked commented 9 years ago

Thanks :)

twe4ked commented 9 years ago

It seems if the view class gets called explicitly from the specs more than once I run into issues. I've now got a call in the before suite.

jasoncodes commented 1 year ago

Had another little look at this and I haven’t been able to reproduce it.

twe4ked commented 1 year ago

I guess I haven't touched that project since checks watch 2015. I'll close this out. The current app where I'm using this gem is working fine with use_transactional_fixtures = true. Thanks for taking another look!