Sha256: c15954881a87be4568c288ca6a9b9c1e60fd488262e41be93e40a1a4f224da67

Contents?: true

Size: 1.48 KB

Versions: 4

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe DeviseAuthy::PasswordsController do
  include Devise::TestHelpers

  before :each do
    request.env["devise.mapping"] = Devise.mappings[:user]
  end

  context "when the user has authy enabled" do

    describe "Reset password" do
      it "Should redirect to verify token view" do
        user = create_user(:authy_id => 1)
        user.reset_password_token = User.reset_password_token
        user.reset_password_sent_at = Time.now.utc
        user.authy_enabled = true
        user.save

        put :update, :user => { :reset_password_token => user.reset_password_token, :password => "password", :password_confirmation => "password" }

        user.reload
        user.last_sign_in_at.should be_nil
        response.should redirect_to(root_url)
      end
    end
  end

  context "when the user don't have 2FA" do
    describe "Reset password" do
      it "Should sign in the user" do
        user = create_user
        user.reset_password_token = User.reset_password_token
        user.reset_password_sent_at = Time.now.utc
        user.save

        last_sign_in_at = user.last_sign_in_at

        put :update, :user => { :reset_password_token => user.reset_password_token, :password => "password", :password_confirmation => "password" }
        response.should redirect_to(root_url)

        user.reload
        user.last_sign_in_at.should_not be_nil
        flash[:notice].should == "Your password was changed successfully. You are now signed in."
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise-authy-1.7.0 spec/controllers/passwords_controller_spec.rb
devise-authy-1.6.0 spec/controllers/passwords_controller_spec.rb
devise-authy-1.5.3 spec/controllers/passwords_controller_spec.rb
devise-authy-1.5.2 spec/controllers/passwords_controller_spec.rb