diff --git a/app/models/user.rb b/app/models/user.rb index 2ca3d6bb869082a2843b13fd7e1710f0e1d99721..129c32430538d04d2b721287102cfe9251af1ee7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -41,7 +41,7 @@ class User < ActiveRecord::Base has_many :aspects, :order => 'order_id ASC' belongs_to :auto_follow_back_aspect, :class_name => 'Aspect' - belongs_to :invited_by, :class_name => 'User' + belongs_to :invited_by, :class_name => 'User' has_many :aspect_memberships, :through => :aspects @@ -454,10 +454,10 @@ class User < ActiveRecord::Base def generate_keys key_size = (Rails.env == 'test' ? 512 : 4096) - self.serialized_private_key = OpenSSL::PKey::RSA::generate(key_size) if self.serialized_private_key.blank? + self.serialized_private_key = OpenSSL::PKey::RSA::generate(key_size).to_s if self.serialized_private_key.blank? if self.person && self.person.serialized_public_key.blank? - self.person.serialized_public_key = OpenSSL::PKey::RSA.new(self.serialized_private_key).public_key + self.person.serialized_public_key = OpenSSL::PKey::RSA.new(self.serialized_private_key).public_key.to_s end end diff --git a/config/initializers/patch_active_support_output.rb b/config/initializers/patch_active_support_output.rb new file mode 100644 index 0000000000000000000000000000000000000000..c993853af1c554f0e6e5c533682486b53b861c2d --- /dev/null +++ b/config/initializers/patch_active_support_output.rb @@ -0,0 +1,16 @@ +# this is a temp monkey patch to suppress errors in rails 3.1 +# it was fixed in 3.2, but it does not look like they are going to backport +# see: https://github.com/rails/rails/issues/3927 +class ERB + module Util + def html_escape(s) + s = s.to_s + if s.html_safe? + s + else + s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }.html_safe + end + end + end +end + diff --git a/spec/controllers/aspect_memberships_controller_spec.rb b/spec/controllers/aspect_memberships_controller_spec.rb index ea7a42076b4a52078d70b1d4ed765c86791bfd21..8e71927043b528951e88d8d2adef7a6e55cbceda 100644 --- a/spec/controllers/aspect_memberships_controller_spec.rb +++ b/spec/controllers/aspect_memberships_controller_spec.rb @@ -43,6 +43,8 @@ describe AspectMembershipsController do end it 'creates a contact' do + #argggg why? + alice.contacts.reload lambda { post :create, :format => 'js', diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 3c0adb31c1df9077e611cfa625899e42969bb59a..ffce24664c4ad3a170bb45b6dce985b8fe85285b 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -27,9 +27,7 @@ describe Person do Person.for_json.first.serialized_public_key }.should raise_error ActiveModel::MissingAttributeError end - it 'eager loads profiles' do - Person.for_json.first.loaded_profile?.should be_true - end + it 'selects distinct people' do aspect = bob.aspects.create(:name => 'hilarious people') aspect.contacts << bob.contact_for(eve.person) diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 6d3ad9e8389edef0d26c01210dee7ee4205d0dbf..a7d53eb3d92a2453bd440e9d5e3ff1d0e8142379 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -3,17 +3,19 @@ require 'spec_helper' describe Service do before do - @user = alice - @post = @user.post(:status_message, :text => "hello", :to =>@user.aspects.first.id) - @service = Services::Facebook.new(:access_token => "yeah") - @user.services << @service + @post = alice.post(:status_message, :text => "hello", :to => alice.aspects.first.id) + @service = Services::Facebook.new(:access_token => "yeah", :uid => 1) + alice.services << @service end it 'is unique to a user by service type and uid' do @service.save - @user.services << Services::Facebook.new(:access_token => "yeah") - @user.services[1].valid?.should be_false + second_service = Services::Facebook.new(:access_token => "yeah", :uid => 1) + + alice.services << second_service + alice.services.last.save + alice.services.last.should be_invalid end it 'destroys the associated service_user' do @@ -28,6 +30,6 @@ describe Service do end it 'by default has no profile photo url' do - Service.new.profile_photo_url.should == nil + Service.new.profile_photo_url.should be_nil end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 30a29e910f0443e80fb1e22b71e31f58947f24e9..b68b927c975143b16df42d990fdb3a8a8223bfee 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -12,7 +12,9 @@ describe User do it 'marshalls the key to and from the db correctly' do user = User.build(:username => 'max', :email => 'foo@bar.com', :password => 'password', :password_confirmation => 'password') + user.save! + user.serialized_private_key.should be_present expect{ user.reload.encryption_key