DG MS; importer now takes params for username, password, and diaspora handle
This commit is contained in:
parent
f04934cbae
commit
a86d965079
2 changed files with 18 additions and 10 deletions
|
|
@ -9,21 +9,21 @@ module Diaspora
|
||||||
self.class.send(:include, strategy)
|
self.class.send(:include, strategy)
|
||||||
end
|
end
|
||||||
|
|
||||||
def commit(user, person, aspects, people, posts)
|
def commit(user, person, aspects, people, posts, opts = {})
|
||||||
filter = verify_and_clean(user, person, people, aspects, posts)
|
filter = verify_and_clean(user, person, people, aspects, posts)
|
||||||
#assume data is good
|
#assume data is good
|
||||||
|
|
||||||
# to go
|
# to go
|
||||||
user.email = "tits@tits.tits"
|
user.email = opts[:email]
|
||||||
user.password= "megatits@tits.tits"
|
user.password= opts[:password]
|
||||||
user.password_confirmation = "megatits@tits.tits"
|
user.password_confirmation = opts[:pasword_confirmation]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
user.person = person
|
user.person = person
|
||||||
|
|
||||||
|
|
||||||
user.person.diaspora_handle = "obby@foo.com"
|
user.person.diaspora_handle = opts[:diaspora_handle]
|
||||||
|
|
||||||
user.visible_post_ids = filter[:whitelist].keys
|
user.visible_post_ids = filter[:whitelist].keys
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ module Diaspora
|
||||||
|
|
||||||
|
|
||||||
people.each do |p|
|
people.each do |p|
|
||||||
p.save! #if filter[:people].include? person.id
|
p.save! if filter[:people].include? p.id.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -121,7 +121,7 @@ module Diaspora
|
||||||
|
|
||||||
module Parsers
|
module Parsers
|
||||||
module XML
|
module XML
|
||||||
def execute(xml)
|
def execute(xml, opts = {})
|
||||||
doc = Nokogiri::XML.parse(xml)
|
doc = Nokogiri::XML.parse(xml)
|
||||||
|
|
||||||
user, person = parse_user_and_person(doc)
|
user, person = parse_user_and_person(doc)
|
||||||
|
|
@ -130,7 +130,7 @@ module Diaspora
|
||||||
posts = parse_posts(doc)
|
posts = parse_posts(doc)
|
||||||
|
|
||||||
user
|
user
|
||||||
commit(user, person, aspects, people, posts)
|
commit(user, person, aspects, people, posts, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_user_and_person(doc)
|
def parse_user_and_person(doc)
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,11 @@ describe Diaspora::Importer do
|
||||||
|
|
||||||
it 'should import a user' do
|
it 'should import a user' do
|
||||||
pending
|
pending
|
||||||
user = @importer.execute(@xml)
|
user = @importer.execute(@xml,
|
||||||
|
:email => "bob@bob.com",
|
||||||
|
:password => "bobbybob",
|
||||||
|
:password => "bobbybob",
|
||||||
|
:diaspora_handle => "bob@diaspora.com")
|
||||||
user.class.should == User
|
user.class.should == User
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -200,7 +204,11 @@ describe Diaspora::Importer do
|
||||||
User.count.should == 0
|
User.count.should == 0
|
||||||
Person.count.should == 0
|
Person.count.should == 0
|
||||||
|
|
||||||
@importer.execute(@xml)
|
@importer.execute(@xml,
|
||||||
|
:email => "bob@bob.com",
|
||||||
|
:password => "bobbybob",
|
||||||
|
:password => "bobbybob",
|
||||||
|
:diaspora_handle => "bob@diaspora.com")
|
||||||
|
|
||||||
User.count.should == 1
|
User.count.should == 1
|
||||||
n = User.first
|
n = User.first
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue