Sha256: 5894f6cc645bd3a8724f0fc941b484107661a235662508240689d9cee237917c
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
require "spec_helper" describe SimpleAuth, "compatibility mode" do before do SimpleAuth::Config.model = :customer load "./lib/simple_auth/compat.rb" require "customer" end after :all do mod = SimpleAuth::ActiveRecord::InstanceMethods mod.send :remove_method, :password= 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 it "assigns password_digest" do customer = Customer.create(password: "test") expect(customer.password_digest).to be_present end it "sets password" do customer = Customer.create(password: "test", password_confirmation: "test") expect(customer.password).to eql("test") end it "sets password confirmation" do customer = Customer.create(password: "test", password_confirmation: "test") expect(customer.password_confirmation).to eql("test") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_auth-2.0.4 | spec/simple_auth/compat_spec.rb |
simple_auth-2.0.3 | spec/simple_auth/compat_spec.rb |