Displaying 1 result from an estimated 1 matches for "test_create_with_us".
Did you mean:
test_create_with_user
2006 May 04
2
Testing associations
...odel.
# user_test.rb
def test_add_post
u = users(:first)
before_articles = u.articles.count
u.articles << Article.new(:title => "Title", :body => "Body")
u.reload
assert_equal before_articles + 1, u.articles.count
end
# article_test.rb
def test_create_with_user
a = Article.new(:title => "Title", :body => "Body", :user => users(:first))
assert a.save
a.reload
assert_equal users(:first), a.user
end
The thing that bugs me is that in my unit test for article I have to
include the users fixtures. As my domain...