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 :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
|
||||
|
||||
timestamps!
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class Profile
|
||||
include MongoMapper::Document
|
||||
include MongoMapper::EmbeddedDocument
|
||||
include ROXML
|
||||
|
||||
xml_accessor :first_name
|
||||
|
|
@ -8,10 +8,6 @@ class Profile
|
|||
key :first_name, String
|
||||
key :last_name, String
|
||||
|
||||
key :person_id, ObjectId
|
||||
|
||||
belongs_to :person
|
||||
|
||||
validates_presence_of :first_name, :last_name, :person_id
|
||||
validates_presence_of :first_name, :last_name
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
require 'config/environment'
|
||||
|
||||
# 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"],
|
||||
["John", "Adams"],
|
||||
|
|
@ -31,7 +31,7 @@ names = [ ["George", "Washington"],
|
|||
|
||||
# Make people
|
||||
(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
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@ def create(backer_number, password)
|
|||
email = backer_info[backer_number][2].gsub(/ /,'').downcase
|
||||
user = User.create( :email => "#{email}@joindiaspora.com",
|
||||
: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")
|
||||
|
||||
# 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
|
||||
|
||||
(0..10).each { |n|
|
||||
|
|
@ -66,7 +66,7 @@ def create(backer_number, password)
|
|||
Person.create( :email => "#{email}@joindiaspora.com",
|
||||
:url => "http://#{email}.joindiaspora.com/",
|
||||
: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
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
require 'config/environment'
|
||||
|
||||
# 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"],
|
||||
["John", "Adams"],
|
||||
|
|
@ -52,7 +52,7 @@ names = [ ["George", "Washington"],
|
|||
# Make people
|
||||
(0..10).each { |n|
|
||||
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'
|
||||
|
||||
# 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"],
|
||||
["John", "Adams"],
|
||||
|
|
@ -52,7 +52,7 @@ names = [ ["George", "Washington"],
|
|||
# Make people
|
||||
(0..10).each { |n|
|
||||
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
|
||||
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
|
||||
|
||||
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|
|
||||
p.first_name "Robert"
|
||||
p.last_name "Grimm"
|
||||
p.person Person.new( :email => "bob@aol.com" )
|
||||
end
|
||||
|
||||
Factory.define :person do |p|
|
||||
|
|
|
|||
|
|
@ -7,25 +7,19 @@ describe Profile do
|
|||
|
||||
describe 'requirements' 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.first_name = "Bob"
|
||||
@person.profile.valid?.should be true
|
||||
end
|
||||
|
||||
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.last_name = "Smith"
|
||||
@person.profile.valid?.should be true
|
||||
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
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ describe 'user encryption' do
|
|||
@u.save
|
||||
@person = Factory.create(:person,
|
||||
:key_fingerprint => GPGME.list_keys("Remote Friend").first.subkeys.first.fpr,
|
||||
:profile => Profile.create(:first_name => 'Remote',
|
||||
:last_name => 'Friend'),
|
||||
:profile => Profile.new(:first_name => 'Remote',
|
||||
:last_name => 'Friend'),
|
||||
:email => 'somewhere@else.com',
|
||||
:url => 'http://distant-example.com/',
|
||||
:key_fingerprint => '57F553EE2C230991566B7C60D3638485F3960087')
|
||||
|
|
|
|||
Loading…
Reference in a new issue