From 511f571ae5a76a9d927167eef8499e04cdc69511 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 23 Aug 2010 15:01:39 -0700 Subject: [PATCH] Specs mostly pass again --- app/models/post.rb | 5 ----- app/models/user.rb | 4 ++-- spec/controllers/groups_controller_spec.rb | 2 +- spec/controllers/people_controller_spec.rb | 1 + spec/models/post_spec.rb | 21 --------------------- 5 files changed, 4 insertions(+), 29 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 8f30586a0..0ab355968 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -29,11 +29,6 @@ class Post self.create params end -#Querying - def self.newest_for(person) - self.where(:person_id => person.id, :order => '_id desc') - end - #ENCRYPTION xml_accessor :creator_signature key :creator_signature, String diff --git a/app/models/user.rb b/app/models/user.rb index a867f5973..3ed7d5d67 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -337,8 +337,8 @@ class User end def setup_person - self.person.serialized_key = generate_key.export - self.person.email = email + self.person.serialized_key ||= generate_key.export + self.person.email ||= email self.person.save! end diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 6bfce5434..36773fd98 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -4,7 +4,7 @@ describe GroupsController do render_views before do @user = Factory.create(:user) - @user.person.save + @user.group(:name => "lame-os") @person = Factory.create(:person) request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index f039e0101..0bca73e18 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -7,6 +7,7 @@ describe PeopleController do request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) sign_in :user, @user + @user.group(:name => "lame-os") end it "index should yield search results for substring of person name" do diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index c6196b0f0..608c17ba7 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -5,27 +5,6 @@ describe Post do @user = Factory.create(:user, :email => "bob@aol.com") @user.person.save end - - describe "newest" do - before do - @person_one = Factory.create(:person, :email => "some@dudes.com") - @person_two = Factory.create(:person, :email => "other@dudes.com") - (2..4).each { |n| Factory.create(:status_message, :message => "test #{n}", :person => @person_one) } - (5..8).each { |n| Factory.create(:status_message, :message => "test #{n}", :person => @user.person)} - (9..11).each { |n| Factory.create(:status_message, :message => "test #{n}", :person => @person_two) } - - Factory.create(:status_message, :person => @user) - Factory.create(:status_message, :person => @user) - end - - it "should give the most recent status_message title and body from owner" do - status_message = StatusMessage.newest_for(@user.person) - status_message.person.email.should == @user.person.email - status_message.class.should == StatusMessage - status_message.message.should == "test 8" - end - - end describe 'xml' do it 'should serialize to xml with its person' do