Sha256: b4a9adbc78ce2fc3ef27ddcb9eb7f09917dd823c22a160b0e171d5ab980b342a

Contents?: true

Size: 1.81 KB

Versions: 5

Compression:

Stored size: 1.81 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class Muck::PasswordResetsControllerTest < ActionController::TestCase

  tests Muck::PasswordResetsController

   context "user sessions controller" do
     setup do
       @user = Factory(:user)
     end
    context "get new" do
      setup do
        get :new
      end
      should_respond_with :success
      should_render_template :new
    end
    context "find user using email and send email message" do
      setup do
        post :create, :reset_password => { :email => @user.email } 
      end
      should "send password reset instructions" do
        assert_sent_email do |email|
          email.to.include?(@user.email)
        end
      end      
      should_redirect_to("login") { login_path }
    end
    context "bad email - fail to reset password" do
      setup do
        post :create, :reset_password => { :email => 'quentin@bad_email_example.com' }
      end
      should_respond_with :success
      should_render_template :new
    end
    context "get edit" do
      setup do
        get :edit, :id => @user.perishable_token
      end
      should_respond_with :success
      should_render_template :edit
    end
    context "PUT update" do
      setup do
        put :update, :id => @user.perishable_token, :user => {:password => "foobar", :password_confirmation => "foobar" }
      end
      should_redirect_to("user account") { account_path }
    end
    context "PUT update - password mismatch" do
      setup do
        put :update, :id => @user.perishable_token, :user => {:password => "foobar", :password_confirmation => "foobarbaz"}
      end
      should "fail to update user password because passwords do not match" do
        assert assigns(:user).errors.on(:password)
      end
      should_respond_with :success
      should_render_template :edit
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
muck-users-0.1.8 test/rails_root/test/functional/password_resets_controller_test.rb
muck-users-0.1.9 test/rails_root/test/functional/password_resets_controller_test.rb
muck-users-0.1.10 test/rails_root/test/functional/password_resets_controller_test.rb
muck-users-0.1.11 test/rails_root/test/functional/password_resets_controller_test.rb
muck-users-0.1.12 test/rails_root/test/functional/password_resets_controller_test.rb