Displaying 2 results from an estimated 2 matches for "test_associations".
2006 Apr 26
1
Bug in validates_associated?
...MySQL 14.7, Ruby 1.8.4, Rails 1.1.2
MODEL:
class Office<ActiveRecord::Base
has_many :users
end
class User<ActiveRecord::Base
belongs_to :office
validates_presence_of :office_id
validates_associated :office
<....other stuff...>
end
UNIT_TEST test/unit/user_test.rb
def test_associations
u = User.new
u.office_id = 2222 # Invalid office id
assert !u.save # Expected because of the invalid office id
u.office_id = 2 # Valid office ID, found in fixtures
assert u.save # This works! So far, so good
u.office_id = 2222
assert !u.save # THIS SHOU...
2006 May 15
3
where do I put this test?
I''m trying to use TDD on a Rails app. So far (6 hours into it) things
are going well.
My data model is starting to get a little more complex now. I now
have two related tables and I want to make sure my tests cover input
validation, record creation, and the proper creation of the foreign key.
Do I put this into a test unit for the parent table''s model?
Or do I test this