views:

27

answers:

1

I am trying to load a fixture for my tests which has a password column (binary datatype). The tool i am using uses EzCrypto gem for encrypting and decrypting passwords before they are stored/retrieved. Now if my column is binary i thought rails would automatically store the password as encrypted - but all i get is:

1) Error: test_is_working(FirstTest): RuntimeError: Failed to decode the field. Incorrect key? /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.11/lib/will_paginate/finder.rb:170:in method_missing' unit/first_test.rb:8:insetup'

2) Error: test_sanity(FirstTest): RuntimeError: Failed to decode the field. Incorrect key? unit/first_test.rb:8:in `setup'

Fixture file looks like this:
first_hussle:
    type: FirstAccount
    user: jsewq
    username: [email protected]
    password: 'abc123'

any clues?

A: 

You need to use ezcrypto to encrypt the password in your fixture. Assuming that your fixture is for the users table and that you've got a user_crypto_provider.rb file / class defined ...

password: <%= UserCryptoProvider.encrypt('abc123') %>

HTH, Bill

Bill Walton