25 more passing tests

This commit is contained in:
zhitomirskiyi 2010-12-19 21:41:09 -08:00
parent 51083e9659
commit e3f7bd319b
3 changed files with 7 additions and 9 deletions

View file

@ -12,6 +12,8 @@ class Contact < ActiveRecord::Base
has_many :aspect_memberships
has_many :aspects, :through => :aspect_memberships
validate :not_contact_for_self
validates_uniqueness_of :person_id, :scope => :user_id
def dispatch_request
request = self.generate_request
self.user.push_to_people(request, [self.person])
@ -19,12 +21,12 @@ class Contact < ActiveRecord::Base
end
def generate_request
Request.new(:sender => self.user, :recipient => self.person)
Request.new(:sender => self.user.person, :recipient => self.person)
end
private
def not_contact_for_self
if person.owner == user
if person_id && person.owner == user
errors[:base] << 'Cannot create self-contact'
end
end

View file

@ -96,13 +96,13 @@ class Person < ActiveRecord::Base
def exported_key= new_key
raise "Don't change a key" if serialized_public_key
@serialized_public_key = new_key
serialized_public_key = new_key
end
#database calls
def self.by_account_identifier(identifier)
identifier = identifier.strip.downcase.gsub('acct:', '')
self.first(:diaspora_handle => identifier)
self.where(:diaspora_handle => identifier).first
end
def self.local_by_account_identifier(identifier)
@ -113,7 +113,7 @@ class Person < ActiveRecord::Base
def self.build_from_webfinger(profile, hcard)
return nil if profile.nil? || !profile.valid_diaspora_profile?
new_person = Person.new
new_person.exported_key = profile.public_key
new_person.serialized_public_key = profile.public_key
new_person.guid = profile.guid
new_person.diaspora_handle = profile.account
new_person.url = profile.seed_location

View file

@ -1,10 +1,6 @@
test:
adapter: mysql2
database: diaspora_test
user: root
password: password
development:
adapter: mysql2
database: diaspora_development
user: root
password: password