Sha256: 31826ca89ed86f2f0032859dc2c282aac18c454f46a4e29bbb1eeee52a7c9e58

Contents?: true

Size: 803 Bytes

Versions: 5

Compression:

Stored size: 803 Bytes

Contents

require 'association_key_holder_test'

class EncUser < ActiveRecord::Base
  set_table_name "users"
  encrypt :name
end

class RawUser < ActiveRecord::Base
  set_table_name "users"
end

class EncryptTest < AssociationKeyHolderTest
  def setup
    @key_holder=EncUser.create 
  end
  
  def test_should_retain_session_key_on_reload
    key=EzCrypto::Key.generate
    key_holder.set_session_key key
    assert_not_nil key_holder.session_key
    assert_equal key.raw,key_holder.session_key.raw
    
    key_holder.name="bob"
    key_holder.save
    
    assert_equal "bob",key_holder.name
    
    found=EncUser.find key_holder.id
    assert_equal key_holder.name,found.name
    
    raw=RawUser.find key_holder.id
    assert_not_nil raw.name
    assert_not_equal key_holder.name,raw.name
    
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ezcrypto-0.6 test/encrypt_test.rb
ezcrypto-0.6.1 test/encrypt_test.rb
ezcrypto-0.7 test/encrypt_test.rb
ezcrypto-0.5 test/encrypt_test.rb
ezcrypto-0.6.2 test/encrypt_test.rb