Sha256: 0a8d3594737506b1fb73c2b8db743a9c623a4346b5721938342f1d2c48d1f56c

Contents?: true

Size: 1.76 KB

Versions: 8

Compression:

Stored size: 1.76 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, :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, :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

8 entries across 8 versions & 1 rubygems

Version Path
muck-users-0.1.4 test/rails_root/test/functional/password_resets_controller_test.rb
muck-users-0.1.5 test/rails_root/test/functional/password_resets_controller_test.rb
muck-users-0.1.6 test/rails_root/test/functional/password_resets_controller_test.rb
muck-users-0.1.7 test/rails_root/test/functional/password_resets_controller_test.rb
muck-users-0.1.3 test/functional/password_resets_controller_test.rb
muck-users-0.1.2 test/functional/password_resets_controller_test.rb
muck-users-0.1.1 test/functional/password_resets_controller_test.rb
muck-users-0.1.0 test/functional/password_resets_controller_test.rb