Sha256: fe585067b6a008102258d62877628878ff93bb1d1a93092f1fee7e48f7af803a

Contents?: true

Size: 742 Bytes

Versions: 3

Compression:

Stored size: 742 Bytes

Contents

require 'spec_helper'

describe User do
  let!(:user) { create(:user) }

  describe '#masquerade!' do
    it 'should cache special key on masquerade' do
      SecureRandom.should_receive(:base64).with(16).and_return("secure_key")
      Rails.cache.should_receive(:write).with("users:secure_key:masquerade", user.id, :expires_in => 10.seconds)

      user.masquerade!
    end
  end

  describe '#find_by_masquerade_key' do
    it 'should be possible to find user by generate masquerade key' do
      user.masquerade!

      Rails.cache.should_receive(:read).with("users:#{user.masquerade_key}:masquerade").and_return(user.id)

      new_user = User.find_by_masquerade_key(user.masquerade_key)

      new_user.should == user
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise_masquerade-0.0.3 spec/models/user_spec.rb
devise_masquerade-0.0.2 spec/models/user_spec.rb
devise_masquerade-0.0.1 spec/models/user_spec.rb