RS, IZ; Profiles are now embedded
This commit is contained in:
parent
f680c4b71e
commit
335f202e2b
10 changed files with 17 additions and 28 deletions
|
|
@ -14,7 +14,7 @@ class Person
|
||||||
key :active, Boolean, :default => false
|
key :active, Boolean, :default => false
|
||||||
key :key_fingerprint, String
|
key :key_fingerprint, String
|
||||||
|
|
||||||
one :profile, :class_name => 'Profile', :foreign_key => :person_id
|
one :profile, :class_name => 'Profile'
|
||||||
many :posts, :class_name => 'Post', :foreign_key => :person_id
|
many :posts, :class_name => 'Post', :foreign_key => :person_id
|
||||||
|
|
||||||
timestamps!
|
timestamps!
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class Profile
|
class Profile
|
||||||
include MongoMapper::Document
|
include MongoMapper::EmbeddedDocument
|
||||||
include ROXML
|
include ROXML
|
||||||
|
|
||||||
xml_accessor :first_name
|
xml_accessor :first_name
|
||||||
|
|
@ -8,10 +8,6 @@ class Profile
|
||||||
key :first_name, String
|
key :first_name, String
|
||||||
key :last_name, String
|
key :last_name, String
|
||||||
|
|
||||||
key :person_id, ObjectId
|
validates_presence_of :first_name, :last_name
|
||||||
|
|
||||||
belongs_to :person
|
|
||||||
|
|
||||||
validates_presence_of :first_name, :last_name, :person_id
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
# Create seed user
|
# Create seed user
|
||||||
user = User.create( :email => "tom@joindiaspora.com", :password => "aaaaaa", :profile => Profile.create( :first_name => "Diaspora", :last_name => "Tom" ))
|
user = User.create( :email => "tom@joindiaspora.com", :password => "aaaaaa", :profile => Profile.new( :first_name => "Diaspora", :last_name => "Tom" ))
|
||||||
|
|
||||||
names = [ ["George", "Washington"],
|
names = [ ["George", "Washington"],
|
||||||
["John", "Adams"],
|
["John", "Adams"],
|
||||||
|
|
@ -31,7 +31,7 @@ names = [ ["George", "Washington"],
|
||||||
|
|
||||||
# Make people
|
# Make people
|
||||||
(1..10).each { |n|
|
(1..10).each { |n|
|
||||||
People.create( :email => "b#{n}@joindiaspora.com", :url => "http://b#{n}.joindiaspora.com/", :profile => Profile.create(:first_name => names[n-1][0], :last_name => names[n-1][1]))
|
People.create( :email => "b#{n}@joindiaspora.com", :url => "http://b#{n}.joindiaspora.com/", :profile => Profile.new(:first_name => names[n-1][0], :last_name => names[n-1][1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
# Populate feed
|
# Populate feed
|
||||||
|
|
|
||||||
|
|
@ -54,11 +54,11 @@ def create(backer_number, password)
|
||||||
email = backer_info[backer_number][2].gsub(/ /,'').downcase
|
email = backer_info[backer_number][2].gsub(/ /,'').downcase
|
||||||
user = User.create( :email => "#{email}@joindiaspora.com",
|
user = User.create( :email => "#{email}@joindiaspora.com",
|
||||||
:password => "#{email+backer_info[backer_number][0].to_s}",
|
:password => "#{email+backer_info[backer_number][0].to_s}",
|
||||||
:profile => Profile.create( :first_name => backer_info[backer_number][1], :last_name => backer_info[backer_number][2] ),
|
:profile => Profile.new( :first_name => backer_info[backer_number][1], :last_name => backer_info[backer_number][2] ),
|
||||||
:url=> "#{email}.joindiaspora.com")
|
:url=> "#{email}.joindiaspora.com")
|
||||||
|
|
||||||
# Make connection with Diaspora Tom
|
# Make connection with Diaspora Tom
|
||||||
Person.create( :email => "tom@joindiaspora.com", :url => "http://tom.joindiaspora.com/", :active => true, :profile => Profile.create(:first_name => "Alexander", :last_name => "Hamiltom"))
|
Person.create( :email => "tom@joindiaspora.com", :url => "http://tom.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => "Alexander", :last_name => "Hamiltom"))
|
||||||
# Make people
|
# Make people
|
||||||
|
|
||||||
(0..10).each { |n|
|
(0..10).each { |n|
|
||||||
|
|
@ -66,7 +66,7 @@ def create(backer_number, password)
|
||||||
Person.create( :email => "#{email}@joindiaspora.com",
|
Person.create( :email => "#{email}@joindiaspora.com",
|
||||||
:url => "http://#{email}.joindiaspora.com/",
|
:url => "http://#{email}.joindiaspora.com/",
|
||||||
:active => true,
|
:active => true,
|
||||||
:profile => Profile.create(:first_name => backer_info[n][1], :last_name => backer_info[n][2])) unless n == backer_number
|
:profile => Profile.new(:first_name => backer_info[n][1], :last_name => backer_info[n][2])) unless n == backer_number
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
# Create seed user
|
# Create seed user
|
||||||
user = User.create( :email => "robert@joindiaspora.com", :password => "monkey", :profile => Profile.create( :first_name => "bobert", :last_name => "brin" ))
|
user = User.create( :email => "robert@joindiaspora.com", :password => "monkey", :profile => Profile.new( :first_name => "bobert", :last_name => "brin" ))
|
||||||
|
|
||||||
names = [ ["George", "Washington"],
|
names = [ ["George", "Washington"],
|
||||||
["John", "Adams"],
|
["John", "Adams"],
|
||||||
|
|
@ -52,7 +52,7 @@ names = [ ["George", "Washington"],
|
||||||
# Make people
|
# Make people
|
||||||
(0..10).each { |n|
|
(0..10).each { |n|
|
||||||
email = names[n][1].gsub(/ /,'').downcase
|
email = names[n][1].gsub(/ /,'').downcase
|
||||||
Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.create(:first_name => names[n][0], :last_name => names[n][1]))
|
Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => names[n][0], :last_name => names[n][1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
# Create seed user
|
# Create seed user
|
||||||
user = User.create( :email => "tom@joindiaspora.com", :password => "evankorth", :url => "http://tom.joindiaspora.com/", :profile => Profile.create( :first_name => "Alexander", :last_name => "Hamiltom" ))
|
user = User.create( :email => "tom@joindiaspora.com", :password => "evankorth", :url => "http://tom.joindiaspora.com/", :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
|
||||||
|
|
||||||
names = [ ["George", "Washington"],
|
names = [ ["George", "Washington"],
|
||||||
["John", "Adams"],
|
["John", "Adams"],
|
||||||
|
|
@ -52,7 +52,7 @@ names = [ ["George", "Washington"],
|
||||||
# Make people
|
# Make people
|
||||||
(0..10).each { |n|
|
(0..10).each { |n|
|
||||||
email = names[n][1].gsub(/ /,'').downcase
|
email = names[n][1].gsub(/ /,'').downcase
|
||||||
Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.create(:first_name => names[n][0], :last_name => names[n][1]))
|
Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => names[n][0], :last_name => names[n][1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ describe DashboardsController do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user)
|
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user)
|
||||||
@user = Factory.create(:user, :profile => Profile.create( :first_name => "bob", :last_name => "smith"))
|
@user = Factory.create(:user, :profile => Profile.new( :first_name => "bob", :last_name => "smith"))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "on index sets a variable containing all a user's friends when a user is signed in" do
|
it "on index sets a variable containing all a user's friends when a user is signed in" do
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ GPGME::check_version({})
|
||||||
Factory.define :profile do |p|
|
Factory.define :profile do |p|
|
||||||
p.first_name "Robert"
|
p.first_name "Robert"
|
||||||
p.last_name "Grimm"
|
p.last_name "Grimm"
|
||||||
p.person Person.new( :email => "bob@aol.com" )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.define :person do |p|
|
Factory.define :person do |p|
|
||||||
|
|
|
||||||
|
|
@ -7,25 +7,19 @@ describe Profile do
|
||||||
|
|
||||||
describe 'requirements' do
|
describe 'requirements' do
|
||||||
it "should include a first name" do
|
it "should include a first name" do
|
||||||
@person.profile = Factory.build(:profile, :person => @person, :first_name => nil)
|
@person.profile = Factory.build(:profile,:first_name => nil)
|
||||||
@person.profile.valid?.should be false
|
@person.profile.valid?.should be false
|
||||||
@person.profile.first_name = "Bob"
|
@person.profile.first_name = "Bob"
|
||||||
@person.profile.valid?.should be true
|
@person.profile.valid?.should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should include a last name" do
|
it "should include a last name" do
|
||||||
@person.profile = Factory.build(:profile, :person => @person, :last_name => nil)
|
@person.profile = Factory.build(:profile, :last_name => nil)
|
||||||
@person.profile.valid?.should be false
|
@person.profile.valid?.should be false
|
||||||
@person.profile.last_name = "Smith"
|
@person.profile.last_name = "Smith"
|
||||||
@person.profile.valid?.should be true
|
@person.profile.valid?.should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should include a person" do
|
|
||||||
profile = Factory.build(:profile, :person => nil)
|
|
||||||
profile.valid?.should be false
|
|
||||||
profile.person = @person
|
|
||||||
profile.valid?.should be true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ describe 'user encryption' do
|
||||||
@u.save
|
@u.save
|
||||||
@person = Factory.create(:person,
|
@person = Factory.create(:person,
|
||||||
:key_fingerprint => GPGME.list_keys("Remote Friend").first.subkeys.first.fpr,
|
:key_fingerprint => GPGME.list_keys("Remote Friend").first.subkeys.first.fpr,
|
||||||
:profile => Profile.create(:first_name => 'Remote',
|
:profile => Profile.new(:first_name => 'Remote',
|
||||||
:last_name => 'Friend'),
|
:last_name => 'Friend'),
|
||||||
:email => 'somewhere@else.com',
|
:email => 'somewhere@else.com',
|
||||||
:url => 'http://distant-example.com/',
|
:url => 'http://distant-example.com/',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue