Active TopicsActive Topics  Display List of Forum MembersMemberlist  CalendarCalendar  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin


 One Stop Testing ForumTypes Of Software Testing @ OneStopTestingFunctional Testing @ OneStopTesting

Message Icon Topic: How do i write functional tests which include the

Post Reply Post New Topic
Author Message
Shiv Kumar
Newbie
Newbie


Joined: 23Feb2007
Online Status: Offline
Posts: 1
Quote Shiv Kumar Replybullet Topic: How do i write functional tests which include the
    Posted: 23Feb2007 at 3:43pm

How do i write functional tests which include the concept of a user?

Most web applications today have a user and authentication system. Rails has many login / authentication systems including: User Engine, Login Engine, Simple HTTP Auth, Authorization, Authenticates Via Typekey, ActiveRBAC, ACL System, and htpasswd. My favorite is Rick Olson’s acts_as_authenticated. Unfortunately, the existing testing rails documentation doesn’t cover how to test users for any of the systems.

In this how to, i’m assuming that you are going to be using acts_as_authenticated. The concepts and most of the code are applicable to the other login/authentication/user systems.


What is a logged in user?

If you’re using plugin like acts_as_authenticated, you might not be sure how rails tracks user information between requests. Rails generates a cookie with a unique id for the session. Each user when they view the site get a sessid cookie. That tracks their use through out the site. On the server site there is a shared collection of these session id’s and a ruby object which maintains the actual session information. Rails supports storing the session information on the file system as temp files, via active record in the database, in a memcache memory only database, or via a distributed ruby DRB simple object store.

The session object is loaded up and available in your environment. You can set new data on it, just by doing session[:favorite_color] = 'light blue'. The next request by that user and you can check the value of session[:favorite_color]. You can put full model objects in to a user’s session hash, but it’s not a good idea. Most session stores start choking if you give them to much data.

The acts_as_authenticated plugin stores just the user id in session hash. A user is considered logged in if the session[:user] has a valid user id in it. To set a user, we simply need to set the value of session[:user] to be the user id we want.




Post Resume: Click here to Upload your Resume & Apply for Jobs

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.289 seconds.
Vyom is an ISO 9001:2000 Certified Organization

© Vyom Technosoft Pvt. Ltd. All Rights Reserved.

Privacy Policy | Terms and Conditions
Job Interview Questions | Placement Papers | Free SMS | Freshers Jobs | MBA Forum | Learn SAP | Web Hosting