Forum: RSpec how to test this view with Rspec

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ffd881829651935d986c52d12279befb?d=identicon&s=25 Zhenning Guan (rubyernewbie)
on 2009-03-14 14:12
= flash_messages
- @user = User.find(1)
- if current_user == @user
  %new_forum= link_to 'new forum', new_forum_path

- @forum.each do |f|
  .group
    = link_to f.name, forum_path(f)
    - if current_user == @user
      = link_to 'edit', edit_forum_path(f)
      = link_to 'destroy', forum_path(f), :method => :delete

==
does anyone have some good example?
978ed7ca309d5495078702096f9add03?d=identicon&s=25 Thomas r. Koll (tomk32)
on 2009-03-14 15:21
(Received via mailing list)
Am 14.03.2009 um 14:12 schrieb Zhenning Guan:

> = flash_messages
> - @user = User.find(1)

move that to the controller or a helper. always.
and if you try to find the admin with that, add a flag on the user
so you can write current_user.admin?


 > - @forum.each do |f|
 >   .group
 >     = link_to f.name, forum_path(f)

Am I wrong or shouldn't that read:
- @forums.each do |f|

And do yourself a favour and write forum not f. Otherwise easily
mistaken as a form.


> does anyone have some good example?

About testing. Test with a current_user (e.g.
template.should_receive(:current_user).and_return(User.find(2)),
with an admin and without any user at all.
And of course test with @forums being empty, a special response for
that case would be nice.

ciao, tom

--
Thomas R. "TomK32" Koll || http://tomk32.de || http://ananasblau.com
just a geek trying to change the world
Skype: TomK32 || Mail: tomk32@gmx.de
http://flickr.com/people/tomk32
This topic is locked and can not be replied to.