Active Topics Memberlist Calendar Search Help | |
Register Login |
One Stop Testing Forum : Types Of Software Testing @ OneStopTesting : Functional Testing @ OneStopTesting |
Topic: How do i write functional tests which include the |
|
Author | Message |
Shiv Kumar
Newbie Joined: 23Feb2007 Online Status: Offline Posts: 1 |
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
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 Post Resume: Click here to Upload your Resume & Apply for Jobs |
|
IP Logged | |
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 |
© Vyom Technosoft Pvt. Ltd. All Rights Reserved.