Sha256: 88cd4aa270eefd1bede372b819fef6e2cf909f56f8e1a59052a8a5351b24b2e8

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

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

module ORMAdaptersTests
  module ActiveRecordAdapterTests
    module ActsAsAuthenticTests
      class PasswordResetTest < ActiveSupport::TestCase
        def test_before_validation
          ben = users(:ben)
          old_password_reset_token = ben.password_reset_token
          assert ben.valid?
          assert_not_equal old_password_reset_token, ben.password_reset_token
          ben.reload
          assert_equal old_password_reset_token, ben.password_reset_token
          assert ben.save
          assert_not_equal old_password_reset_token, ben.password_reset_token
        end
        
        def test_find_using_password_reset_token
          ben = users(:ben)
          assert_nil User.find_using_password_reset_token("")
          assert_equal ben, User.find_using_password_reset_token(ben.password_reset_token)
          assert ben.class.connection.execute("update users set updated_at = '#{10.minutes.ago.to_s(:db)}' where id = '#{ben.id}';")
          assert_nil User.find_using_password_reset_token(ben.password_reset_token)
        end
        
        def test_reset_password_reset_token
          ben = users(:ben)
          old_password_reset_token = ben.password_reset_token
          ben.reset_password_reset_token
          assert_not_equal old_password_reset_token, ben.password_reset_token
          ben.reload
          assert_equal old_password_reset_token, ben.password_reset_token
          ben.reset_password_reset_token!
          ben.reload
          assert_not_equal old_password_reset_token, ben.password_reset_token
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authlogic-1.2.0 test/orm_adapters_tests/active_record_adapter_tests/acts_as_authentic_tests/password_reset_test.rb