fix a bug with openssl keys in development. note to future max and
rafi. never monkey patch anything on the top of a completely random model. never again. ever. TODO: look into replacing a monkey patch on a to_s in User#generate_key that makes the single test green, but my dell had a heart attack other places, that might just be sqlite3 or my dell
This commit is contained in:
parent
56cdb7a3ad
commit
7a5852e73a
3 changed files with 26 additions and 6 deletions
|
|
@ -2,12 +2,6 @@
|
|||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
#
|
||||
class OpenSSL::PKey::RSA
|
||||
def to_yaml
|
||||
self.to_s
|
||||
end
|
||||
end
|
||||
|
||||
class Invitation < ActiveRecord::Base
|
||||
|
||||
belongs_to :sender, :class_name => 'User'
|
||||
|
|
|
|||
14
config/initializers/patch_openssl_pkey.rb
Normal file
14
config/initializers/patch_openssl_pkey.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
#
|
||||
#
|
||||
#
|
||||
#Why? as of rails 3.0.4, objects are marshalled by calling to yaml, if it is a text field in the db. since we assume things are strings coming out, and pkey does not seem to define a to_yaml, it was getting set to nil
|
||||
class OpenSSL::PKey::RSA
|
||||
def to_yaml
|
||||
self.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -5,10 +5,22 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe User do
|
||||
|
||||
it 'should have a key' do
|
||||
alice.encryption_key.should_not be nil
|
||||
end
|
||||
|
||||
it 'the key should marshall to and from the db correctly' do
|
||||
user = User.build(:username => 'max', :email => 'foo@bar.com', :password => 'password', :password_confirmation => 'password')
|
||||
user.save!
|
||||
|
||||
expect{
|
||||
user.reload.encryption_key
|
||||
}.should_not raise_error
|
||||
|
||||
end
|
||||
|
||||
|
||||
describe 'overwriting people' do
|
||||
it 'does not overwrite old users with factory' do
|
||||
lambda {
|
||||
|
|
|
|||
Loading…
Reference in a new issue