Hello, I am new to writing test cases in ruby on rails. This is a controller code I am using "test_helper" in our application. def edit @user = User.find_by_token(params[:id]) if @user if @user.sent_at < 24.hours.ago redirect_to root_url, :alert => "Expired" elsif @user.status == "Active" redirect_to root_url, :alert => "Invitation" else @user.status = "Active" if @user.save redirect_to root_url, :notice => "Activated" else redirect_to root_url, :alert => "Problem" end end end end How to write testcase for this? Thanks. Avi -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Hello, How to pass dynamic data to the controller from a test case? On Thursday, November 15, 2012 2:01:32 PM UTC+5:30, Avi wrote:> > Hello, > > I am new to writing test cases in ruby on rails. > This is a controller code > > I am using "test_helper" in our application. > > def edit > @user = User.find_by_token(params[:id]) > > if @user > if @user.sent_at < 24.hours.ago > redirect_to root_url, :alert => "Expired" > elsif @user.status == "Active" > redirect_to root_url, :alert => "Invitation" > else > @user.status = "Active" > if @user.save > redirect_to root_url, :notice => "Activated" > else > redirect_to root_url, :alert => "Problem" > end > end > end > end > > How to write testcase for this? > > Thanks. > Avi >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/zyWh8XYQoXQJ. For more options, visit https://groups.google.com/groups/opt_out.
May i know which testing framework u r using ? Thanks Best Regards Fahim Babar Patel On Friday, November 16, 2012 5:35:46 PM UTC+5:30, Avi wrote:> > Hello, > > How to pass dynamic data to the controller from a test case? > > On Thursday, November 15, 2012 2:01:32 PM UTC+5:30, Avi wrote: >> >> Hello, >> >> I am new to writing test cases in ruby on rails. >> This is a controller code >> >> I am using "test_helper" in our application. >> >> def edit >> @user = User.find_by_token(params[:id]) >> >> if @user >> if @user.sent_at < 24.hours.ago >> redirect_to root_url, :alert => "Expired" >> elsif @user.status == "Active" >> redirect_to root_url, :alert => "Invitation" >> else >> @user.status = "Active" >> if @user.save >> redirect_to root_url, :notice => "Activated" >> else >> redirect_to root_url, :alert => "Problem" >> end >> end >> end >> end >> >> How to write testcase for this? >> >> Thanks. >> Avi >> >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/92QGSU-vNJsJ. For more options, visit https://groups.google.com/groups/opt_out.