I changed my search method to be apart of index:
def index
if params[:search]
@products = Search.products.with(params[:search])
else
@products = Product.find_valid
end
end
And changed my test accordingly and it passes.
Can anyone please have a look at my views_news test??
Thanks,
Elle
On Apr 23, 8:02 pm, elle <[email protected]> wrote:
> 2. I have a model for pages with a column whether it is a news pages
> or not (boolean)
> My test is:
> def views_news
> get "/news"
> assert_response :success
> assert_template "index"
> �...@news_months.each do |month, items|
> assert_tag :tag => "h3", :content => month
> for item in items
> assert_tag :tag => "li", :content => item.title
> end
> end
> check_news_links
> end
> -------------------
>
> The controller has the following:
> @news_months = @news.group_by { |t| t.created_at.beginning_of_month }
>
> And the viewer has:
> <% @news_months.each do |month, items| -%>
> <h3><%= month.strftime('%B %Y')%></h3>
> <ul>
> <% for item in items %>
> <li><%=link_to item.title, news_page_path(item) %></li>
> <% end -%>
> </ul>
> <% end -%>
>
> Error says:
> You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.each
>
> Now, once again, I understand the error. What I don't know is how to
> change the test so it can see each news item.
>
> 3. This is more a theoretical question but I wanted your advice on how
> much should I test for? how small a detail should I test for?
>
> I know the above are a lot of questions. Really appreciate your help.
>
> Thanks,
> Elle
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---