Message from discussion
Writin Test case
Received: by 10.50.100.193 with SMTP id fa1mr2985803igb.5.1353067595445;
Fri, 16 Nov 2012 04:06:35 -0800 (PST)
X-BeenThere: rubyonrails-talk@googlegroups.com
Received: by 10.50.184.228 with SMTP id ex4ls920601igc.41.canary; Fri, 16 Nov
2012 04:05:47 -0800 (PST)
Received: by 10.50.193.198 with SMTP id hq6mr1181677igc.10.1353067547824;
Fri, 16 Nov 2012 04:05:47 -0800 (PST)
Date: Fri, 16 Nov 2012 04:05:46 -0800 (PST)
From: Avi <aavinash.beh...@gmail.com>
To: rubyonrails-talk@googlegroups.com
Message-Id: <9e6af446-87ba-4328-a34f-4d06cc26489b@googlegroups.com>
In-Reply-To: <CAJ9B1dOQMGkPkyLO4eNHLQkLLG1VTfNG=N+Cg2tpouvjQaiKZQ@mail.gmail.com>
References: <CAJ9B1dOQMGkPkyLO4eNHLQkLLG1VTfNG=N+Cg2tpouvjQaiKZQ@mail.gmail.com>
Subject: Re: Writin Test case
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_1672_19294222.1353067546806"
------=_Part_1672_19294222.1353067546806
Content-Type: multipart/alternative;
boundary="----=_Part_1673_7970537.1353067546806"
------=_Part_1673_7970537.1353067546806
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
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
>
------=_Part_1673_7970537.1353067546806
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
Hello,<div><br></div><div>How to pass dynamic data to the controller from a test case?<br><br>On Thursday, November 15, 2012 2:01:32 PM UTC+5:30, Avi wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Hello,<div><br></div><div>I am new to writing test cases in ruby on rails.</div><div>This is a controller code</div><div><br></div><div>I am using "test_helper" in our application.</div><div><br></div><div>def edit</div>
<div> @user = User.find_by_token(params[:id]<wbr>)</div><div><br></div><div> if @user</div><div> if @user.sent_at < 24.hours.ago</div><div> redirect_to root_url, :alert => "Expired"</div><div>
elsif @user.status == "Active"</div><div> redirect_to root_url, :alert => "Invitation"</div><div> else</div><div> @user.status = "Active"</div><div> if @user.save</div>
<div> redirect_to root_url, :notice => "Activated"</div><div> else</div><div> redirect_to root_url, :alert => "Problem"</div><div> end </div><div> end</div>
<div>
end</div><div>end </div><div><div><br></div>How to write testcase for this?
</div><div><br></div><div>Thanks.</div><div>Avi</div>
</blockquote></div>
------=_Part_1673_7970537.1353067546806--
------=_Part_1672_19294222.1353067546806--