MS DG; verifys implemented, but need more tests
This commit is contained in:
parent
92e5622247
commit
7ea3fe5bf1
3 changed files with 21 additions and 5 deletions
|
|
@ -24,7 +24,6 @@ module Diaspora
|
||||||
xml.aspects {
|
xml.aspects {
|
||||||
user.aspects.each do |aspect|
|
user.aspects.each do |aspect|
|
||||||
xml.aspect {
|
xml.aspect {
|
||||||
xml._id aspect.id
|
|
||||||
xml.name aspect.name
|
xml.name aspect.name
|
||||||
|
|
||||||
xml.person_ids {
|
xml.person_ids {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ module Diaspora
|
||||||
def verify(user, person, people, aspects, posts)
|
def verify(user, person, people, aspects, posts)
|
||||||
verify_user(user)
|
verify_user(user)
|
||||||
verify_person_for_user(user, person)
|
verify_person_for_user(user, person)
|
||||||
|
verified_posts = verify_posts(posts, person)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_user(user)
|
def verify_user(user)
|
||||||
|
|
@ -31,8 +33,16 @@ module Diaspora
|
||||||
true
|
true
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
@ -68,7 +78,6 @@ module Diaspora
|
||||||
a = Nokogiri::XML.parse(x.to_s)
|
a = Nokogiri::XML.parse(x.to_s)
|
||||||
|
|
||||||
aspect = Aspect.new
|
aspect = Aspect.new
|
||||||
aspect.id = a.xpath('/aspect/_id').text
|
|
||||||
aspect.name = a.xpath('/aspect/name').text
|
aspect.name = a.xpath('/aspect/name').text
|
||||||
aspect.post_ids = a.xpath('/aspect/post_ids/post_id').collect(&: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)
|
aspect.person_ids = a.xpath('/aspect/person_ids/person_id').collect(&:text)
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,14 @@ describe Diaspora::Importer do
|
||||||
user = Factory.build(:user)
|
user = Factory.build(:user)
|
||||||
importer.verify_person_for_user(user, user.person)
|
importer.verify_person_for_user(user, user.person)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
describe '#verify_posts' do
|
||||||
|
it 'should make sure all found posts are owned by the user' do
|
||||||
|
1.should ==2
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue