# Testing and has\_many Questions

**URL:** <https://www.ruby-forum.com/t/testing-and-has-many-questions/124714>\
**Category:** Rails\
**Created:** [January 1, 2008, 5:33pm UTC](https://www.ruby-forum.com/t/testing-and-has-many-questions/124714 "2008-01-01T17:33:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [January 1, 2008, 5:33pm UTC](https://www.ruby-forum.com/t/testing-and-has-many-questions/124714/1 "2008-01-01T17:33:29Z")

</div>

To unit test the models’ functionality, I realized I need to call  
save. That said, I wondered if save in test causes the model to be  
stored in the database. If so, what should I do to avoid this  
problem? Should I just call Model.destroy\_all at the end?

Second, to test controllers’ functionality, is it possible to set the  
params and session hash? If not, how do you test controller  
functionality?

Also, many of my models uses has\_many and belongs\_to. What’s the  
difference between the following methods: count, size, length.

---

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [January 1, 2008, 5:53pm UTC](https://www.ruby-forum.com/t/testing-and-has-many-questions/124714/2 "2008-01-01T17:53:22Z")

</div>

I don’t know how I double-posted, but anyway…I have one more  
question I overlooked.

I have several models created by the line “ruby script/generate model  
two\_words”. How should I program the view forms in this case? Since  
the controller would call this model as “TwoWords”, should the form be  
\<% form\_for :twoWords, @this\_variable do |form| %\> … \<%end%\>, or  
should I stick with the intentional name \<% form\_for :two\_words,  
@this\_variable do |form| %\> … \<%end%\>. In either cases, where would  
the params be set in this form? In params[:two\_words]?
