diff --git a/app/models/invitation.rb b/app/models/invitation.rb index e600f8a0a..23dcb2c9e 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -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' diff --git a/config/initializers/patch_openssl_pkey.rb b/config/initializers/patch_openssl_pkey.rb new file mode 100644 index 000000000..ef6b1ddfe --- /dev/null +++ b/config/initializers/patch_openssl_pkey.rb @@ -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 + + diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a3abdba86..6177a88de 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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 {