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

Reloading models each run causes duplicates errors on models #141

Open
Dagnan opened this issue Sep 15, 2011 · 3 comments
Open

Reloading models each run causes duplicates errors on models #141

Dagnan opened this issue Sep 15, 2011 · 3 comments

Comments

@Dagnan
Copy link

Dagnan commented Sep 15, 2011

First, spork -d shows only config files so models are not preloaded.
I'm also using Spork with Test:Unit (actually Minitest, last version from Rubygems), Rails 3 (with Spork last rc) and Ruby 1.9.2.

I had to put a load instruction for all my models in Spork#each_run because not all files under /app/models where loaded (I have subdirectories).

But the behavior I get is when my models is invalid, errors are duplicates:

foo = Foo.new(:bar => '').valid? #=> false
foo.errors #=> {:bar => ["can't be blank", "can't be blank"]}

For now if I reload only models from /models subdirectories I get the expected behavior. But this is kind of ugly.

@nofxx
Copy link

nofxx commented Oct 15, 2011

Had the same issue here. Tryed every jujitso/workaround/patch myself thing to make spork 0.8.5 work w/o luck.
That one ([Rails.root, 'models/*.].each(&load.....) I call the load'em all, and its a bad idea! You'll get that double errors and plus some other glitches with "cache_classes = true" in test enviroment (fabrication and machinist don't behave nicely that way).

Try spork 0.9.0.rc9, it's all working perfect here, models reloading and no bugs, I dunno why (yet, just found out heh). Just did the trap load_models of mongoid.

@Dagnan
Copy link
Author

Dagnan commented Oct 15, 2011

I'm already using 0.9.0.rc9 :/

@nofxx
Copy link

nofxx commented Oct 15, 2011

Oh, sorry Dagnan, missed the "spork last rc".
Here's my spec_helper:
https://gist.github.com/1289242

Just to confirm: that's finally reloading my models and no glitches in rails 3.1.1, with cache_classes = true.
(besides bugs, cache_classes = false makes my 30s suite take 2:00 to run! major pita.

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