
Tests and (merb) controllers + belongs_to = red
Reported by mpd | September 19th, 2009 @ 03:27 AM | in 1.0.0
In a test, set a nullable belongs_to field to nil in a model via update, then request a controller action that sets that same field.
For the object within the controller, the field will show up as being set and remains set if you reload, as expected.
The object within the test, if you inspect it after that controller request, will still show nil in that field, even if reloaded.
The two objects do have different object ids.
Running on rspec 1.2.8 with sqlite3 database.
belongs_to :foo, :nullable => true
it "should set the foo attribute" do
@instance.update(:foo => nil)
request(url(:action_that_sets_foo), :method => 'POST', :params => {:instance => @instance})
@instance.foo.reload.should_not be_nil # fails
end
Comments and changes to this ticket
-
mpd September 19th, 2009 @ 04:01 AM
- Tag changed from 0.10.0, merb, merb_datamapper, specs, sqlite3, tests to 0.10.0, belo, belongs_to, merb, merb_datamapper, specs, sqlite3, tests
-
mpd September 19th, 2009 @ 04:01 AM
- Tag changed from 0.10.0, belo, belongs_to, merb, merb_datamapper, specs, sqlite3, tests to 0.10.0, belongs_to, merb, merb_datamapper, specs, sqlite3, tests
-
mpd September 19th, 2009 @ 03:46 PM
I just pushed a toy merb project containing a single spec that demonstrates this issue to http://github.com/xxx/dm10-controller-test
The failure only happens if the association was originally set within the test itself, then nullified, also within the test (which can happen when using sweatshop with a reasonably factored test suite).
-
mpd September 22nd, 2009 @ 03:10 PM
This makes sense, and thanks for checking this. This is the major showstopper for me on 0.10.0 right now (the rest can be worked around).
I will try putting your before/after repository set in and report the results here when I get home. All of these specs passed on 0.9.11.
-
mpd September 22nd, 2009 @ 08:44 PM
This greened around 25% of my remaining test failures, thank you!
It didn't solve it in every case, however, which seems strange. I still have about 70 failing specs, though, so maybe something else is involved. Will keep digging and update this if I find anything.
-
-
mpd September 25th, 2009 @ 08:11 PM
Will do.
I also originally had the issue where one thing would break many, many specs, but I'm getting to the one-offs now, and it's always a bit brutal when that happens ;)
thanks!
-
Martin Gamsjaeger (snusnu) March 25th, 2010 @ 09:21 AM
- State changed from new to unconfirmed
Any updates on this ticket? Can it be closed?
-
mpd March 25th, 2010 @ 12:43 PM
Probably closable. I dropped that project awhile ago but the suite is green so I'm guessing this has been solved.
-
Martin Gamsjaeger (snusnu) March 26th, 2010 @ 06:03 AM
- Milestone set to 1.0.0
- State changed from unconfirmed to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »