MS DG; verifys implemented, but need more tests

This commit is contained in:
danielvincent 2010-10-12 18:53:12 -07:00
parent 92e5622247
commit 7ea3fe5bf1
3 changed files with 21 additions and 5 deletions

View file

@ -24,7 +24,6 @@ module Diaspora
xml.aspects {
user.aspects.each do |aspect|
xml.aspect {
xml._id aspect.id
xml.name aspect.name
xml.person_ids {

View file

@ -15,6 +15,8 @@ module Diaspora
def verify(user, person, people, aspects, posts)
verify_user(user)
verify_person_for_user(user, person)
verified_posts = verify_posts(posts, person)
end
def verify_user(user)
@ -31,8 +33,16 @@ module Diaspora
true
end
def verify_people(people)
def verify_posts(posts, person)
post_ids = posts.collect{|x| x.id}
posts_from_db = Post.find_all_by_id(post_id) #this query should be limited to only return post id and owner id
unauthorized_posts = posts_from_db.delete_if{|x| x.owner_id != person.id}t
unauthorized_post_ids = unauthorized_posts.collect{|x| x.id}
post_whitelist = post_ids - unauthorized_post_ids
end
end
@ -68,7 +78,6 @@ module Diaspora
a = Nokogiri::XML.parse(x.to_s)
aspect = Aspect.new
aspect.id = a.xpath('/aspect/_id').text
aspect.name = a.xpath('/aspect/name').text
aspect.post_ids = a.xpath('/aspect/post_ids/post_id').collect(&:text)
aspect.person_ids = a.xpath('/aspect/person_ids/person_id').collect(&:text)

View file

@ -49,6 +49,14 @@ describe Diaspora::Importer do
user = Factory.build(:user)
importer.verify_person_for_user(user, user.person)
end
end
describe '#verify_posts' do
it 'should make sure all found posts are owned by the user' do
1.should ==2
end
end