Hello, I''m writing functional tests for an application where the controller methods are preempted with, before_filter :login_required Does anyone have an example of how to handle a pre-requisite of this sort for this type of test. Thank you, Aaron
On Tue, Jun 21, 2005, Aaron Johnson wrote:> I''m writing functional tests for an application where > the controller methods are preempted with, > > before_filter :login_required > > Does anyone have an example of how to handle > a pre-requisite of this sort for this type of test.As I recall, the Salted Login Generator''s functional tests work that way. You might want to check out how they work. Ben
> I''m writing functional tests for an application where > the controller methods are preempted with, > > before_filter :login_required > > Does anyone have an example of how to handle > a pre-requisite of this sort for this type of test.>From http://wiki.rubyonrails.com/rails/show/LoginGenerator:* ... test my controllers that require login? If you want to simply fake the tests into thinking the user is logged in, this seems to do the trick : @request.session[:user] = true -- rick http://techno-weenie.net
There''s a good section in the Agile Beta Book on functional testing that includes situations like this. Ben On Jun 21, 2005, at 2:13 PM, Aaron Johnson wrote:> Hello, > > I''m writing functional tests for an application where > the controller methods are preempted with, > > before_filter :login_required > > Does anyone have an example of how to handle > a pre-requisite of this sort for this type of test. > > Thank you, > Aaron > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Rick Olson <technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:>>From http://wiki.rubyonrails.com/rails/show/LoginGenerator: > > * ... test my controllers that require login? > If you want to simply fake the tests into thinking the user is logged > in, this seems to do the trick : > > @request.session[:user] = trueYou can also assign it a real user object too: @request.session[:user] = User.find(@admin.id) -- doug-jGAhs73c5XxeoWH0uzbU5w@public.gmane.org