Note that there are some explanatory texts on larger screens.

plurals
  1. POAuthlogic edit_password_reset_url in Functional / Integration Tests
    primarykey
    data
    text
    <p>I am trying to implement some tests to validate the behavior for Authlogic password resets as explained in <a href="http://www.binarylogic.com/2008/11/16/tutorial-reset-passwords-with-authlogic/" rel="nofollow noreferrer">http://www.binarylogic.com/2008/11/16/tutorial-reset-passwords-with-authlogic/</a></p> <p>I am using Authlogic, Shoulda, Webrat and Factory Girl and here's my test:</p> <pre><code>require 'test_helper' class PasswordResetTest &lt; ActionController::IntegrationTest setup :activate_authlogic context "A registered user" do setup do @reggie = Factory(:reggie) end should "not allow logged in users to change password" do visit signin_path fill_in 'Email', :with =&gt; @reggie.email fill_in 'Password', :with =&gt; @reggie.password click_button 'Sign In' assert_equal controller.session['user_credentials'], @reggie.persistence_token visit change_password_path assert_equal account_path, path assert_match /must be logged out/, flash[:notice] visit signout_path assert_equal controller.session['user_credentials'], nil visit change_password_path assert_equal change_password_path, path end should "allow logged out users to change password" do visit signout_path assert_equal controller.session['user_credentials'], nil visit change_password_path assert_template :new fill_in 'email', :with =&gt; @reggie.email click_button 'Reset my password' assert_match /Please check your email/, flash[:notice] assert !ActionMailer::Base.deliveries.empty? sent = ActionMailer::Base.deliveries.first assert_equal [@reggie.email], sent.to assert_match /Password Reset Instructions/, sent.subject assert_not_nil @reggie.perishable_token #TODO p "Perishable Token #{@reggie.perishable_token}" assert_match assigns[:edit_password_reset_url], sent.body end end end </code></pre> <p>In the last 2 lines of the test, I am trying to make sure the link sent out has the right perishable_token and it always comes up different between the printed Perishable Token and the token in the link sent out.</p> <p>How should I test this behavior?</p> <p>Thanks, Siva</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload