DG IZ Created the profile model & friend view now shows the information
This commit is contained in:
parent
2ac4759067
commit
b5b9c647d7
11 changed files with 48 additions and 45 deletions
|
|
@ -7,6 +7,7 @@ class FriendsController < ApplicationController
|
|||
|
||||
def show
|
||||
@friend = Friend.where(:id => params[:id]).first
|
||||
@friend_profile = @friend.profile
|
||||
@friend_posts = Post.where(:person_id => @friend.id).sort(:created_at.desc)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,15 @@ class Person
|
|||
include ROXML
|
||||
|
||||
xml_accessor :email
|
||||
xml_accessor :real_name
|
||||
|
||||
key :email, String
|
||||
key :real_name, String
|
||||
|
||||
one :profile, :class_name => 'Profile', :foreign_key => :person_id
|
||||
many :posts, :class_name => 'Post', :foreign_key => :person_id
|
||||
|
||||
validates_presence_of :email, :real_name, :profile
|
||||
validates_presence_of :email
|
||||
|
||||
def real_name
|
||||
self.profile.first_name + " " + self.profile.last_name
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ class Profile
|
|||
key :first_name, String
|
||||
key :last_name, String
|
||||
|
||||
belongs_to :person, :class_name => "Person"
|
||||
key :person_id, ObjectId
|
||||
|
||||
validates_presence_of :first_name, :last_name, :person
|
||||
belongs_to :person
|
||||
|
||||
validates_presence_of :first_name, :last_name, :person_id
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ class User < Person
|
|||
Comment.new(:person_id => self.id, :text => text, :post => options[:on]).save
|
||||
end
|
||||
|
||||
validates_presence_of :profile
|
||||
|
||||
before_validation :do_bad_things
|
||||
def do_bad_things
|
||||
|
|
|
|||
12
app/views/bookmarks/_form.html.haml
Normal file
12
app/views/bookmarks/_form.html.haml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
= form_for @bookmark do |f|
|
||||
= f.error_messages
|
||||
%p
|
||||
= f.label :title
|
||||
%br
|
||||
= f.text_field :title
|
||||
%p
|
||||
= f.label :link
|
||||
%br
|
||||
= f.text_field :link
|
||||
%p
|
||||
= f.submit
|
||||
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
= form_for @friend do |f|
|
||||
= f.error_messages
|
||||
%p
|
||||
= f.label :real_name
|
||||
%br
|
||||
= f.text_field :real_name
|
||||
%p
|
||||
= f.label :email
|
||||
%br
|
||||
|
|
|
|||
|
|
@ -1,5 +1,22 @@
|
|||
%h1= "#{@friend.real_name}'s network stream"
|
||||
%h1= "#{@friend.real_name}"
|
||||
|
||||
- if @friend_profile
|
||||
%p
|
||||
%b First Name
|
||||
%p
|
||||
= @friend_profile.first_name
|
||||
%p
|
||||
%b Last Name
|
||||
%p
|
||||
= @friend_profile.last_name
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
- if @friend.posts
|
||||
%h3 stream
|
||||
%ul#stream
|
||||
- for post in @friend_posts
|
||||
= render type_partial(post), :post => post
|
||||
|
|
|
|||
|
|
@ -6,17 +6,15 @@
|
|||
Factory.define :profile do |p|
|
||||
p.first_name "Robert"
|
||||
p.last_name "Grimm"
|
||||
p.person Person.new( :email => "bob@aol.com", :real_name => "Bob" )
|
||||
p.person Person.new( :email => "bob@aol.com" )
|
||||
end
|
||||
|
||||
Factory.define :person do |p|
|
||||
p.email "bob@aol.com"
|
||||
p.real_name "Bob"
|
||||
p.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" )
|
||||
end
|
||||
|
||||
Factory.define :user do |u|
|
||||
u.real_name 'Bob Smith'
|
||||
u.sequence(:email) {|n| "bob#{n}@aol.com"}
|
||||
u.password "bluepin7"
|
||||
u.password_confirmation "bluepin7"
|
||||
|
|
@ -24,7 +22,6 @@ Factory.define :user do |u|
|
|||
end
|
||||
|
||||
Factory.define :friend do |f|
|
||||
f.real_name 'John Doe'
|
||||
f.email 'max@max.com'
|
||||
f.url 'http://max.com/'
|
||||
f.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" )
|
||||
|
|
|
|||
|
|
@ -2,18 +2,13 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|||
|
||||
describe Friend do
|
||||
|
||||
it 'should require a diaspora username and diaspora url' do
|
||||
describe 'requirements' do
|
||||
it 'should include a url' do
|
||||
n = Factory.build(:friend, :url => nil)
|
||||
n.valid?.should be false
|
||||
n.url = "http://max.com/"
|
||||
n.valid?.should be true
|
||||
end
|
||||
|
||||
it 'should require a real name' do
|
||||
n = Factory.build(:friend, :real_name => nil)
|
||||
n.valid?.should be false
|
||||
n.real_name = "John Smith"
|
||||
n.valid?.should be true
|
||||
end
|
||||
|
||||
it 'should validate its url' do
|
||||
|
|
|
|||
|
|
@ -1,12 +1,4 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Person do
|
||||
|
||||
it 'should require a profile' do
|
||||
person = Factory.build(:person, :profile => nil)
|
||||
person.valid?.should be false
|
||||
person.profile = Factory.build(:profile)
|
||||
person.valid?.should be true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,20 +1,9 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe User do
|
||||
it "should require a real name" do
|
||||
u = Factory.build(:user, :real_name => nil)
|
||||
u.valid?.should be false
|
||||
u.real_name = "John Smith"
|
||||
u.valid?.should be true
|
||||
end
|
||||
it "should create a valid user with the factory" do
|
||||
u = Factory.build(:user)
|
||||
u.valid?.should be true
|
||||
end
|
||||
it "should be a person" do
|
||||
n = Person.count
|
||||
Factory.create(:user)
|
||||
Person.count.should == n+1
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue