Sha256: e7b36ae8ba5e262a3155b7b10d9cc7295bcebe42dc4bbb2a8d65ce97c7bf89a8

Contents?: true

Size: 954 Bytes

Versions: 1

Compression:

Stored size: 954 Bytes

Contents

require "spec_helper"

describe SimpleAuth, "compatibility mode" do
  before do
    SimpleAuth::Config.model = :customer
    require "simple_auth/compat"
    require "customer"
  end

  after do
    mod = SimpleAuth::ActiveRecord::InstanceMethods
    mod.send :remove_method, :password=
    mod.send :remove_method, :password_confirmation=
    mod.send :remove_method, :authenticate
  end

  it "finds user based on the hashing system" do
    password_salt = SecureRandom.hex
    password_hash = SimpleAuth::Config.crypter.call("test", password_salt)
    password_digest = BCrypt::Password.create(password_hash, cost: BCrypt::Engine::MIN_COST)

    ActiveRecord::Base.connection.execute <<-SQL
    INSERT INTO customers
      (email, login, password_digest, password_salt)
    VALUES
      ('john@example.org', 'johndoe', '#{password_digest}', '#{password_salt}')
    SQL

    expect(Customer.authenticate("johndoe", "test")).to be_a(Customer)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_auth-2.0.0 spec/simple_auth/compat_spec.rb