Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stubbed models which access the db inside a lock statement generate wrong error #719

Closed
timdiggins opened this issue Nov 3, 2014 · 1 comment

Comments

@timdiggins
Copy link
Contributor

When a stubbed model is inside a transaction it sometimes generates a difficult to decipher error.

It should give an error like:

RuntimeError: stubbed models are not allowed to access the database - Job#reload()
factory_girl-4.5.0/lib/factory_girl/strategy/stub.rb:48:in `reload'

However instead it gives an error:

ArgumentError: wrong number of arguments (1 for 0)
factory_girl-4.5.0/lib/factory_girl/strategy/stub.rb:47:in `reload'

This is because the def for reload in stub needs to include a (*args) as reload can be called with the args of the lock.

I could create a pull request for this (it's really easy) but would you welcome a PR without a spec?

@joshuaclayton
Copy link
Contributor

@red56 I'd welcome a PR but please add a spec for it. I'd take a peek at https://github.com/thoughtbot/factory_girl/blob/master/spec/factory_girl/strategy/stub_spec.rb to better understand how it's being tested currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants