Merge branch 'master' of github.com:diaspora/diaspora_rails into pivots
Conflicts: app/models/user.rb
This commit is contained in:
commit
b99a86e6bd
9 changed files with 22 additions and 48 deletions
|
|
@ -2,7 +2,7 @@ class GroupsController < ApplicationController
|
|||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@posts = current_user.posts.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
@posts = current_user.raw_visible_posts.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
end
|
||||
|
||||
def create
|
||||
|
|
|
|||
|
|
@ -12,12 +12,11 @@ class PeopleController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@person= current_user.visible_person_by_id(params[:id])
|
||||
|
||||
@person_profile = @person.profile
|
||||
@person_posts = Post.where(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
|
||||
@person = current_user.visible_person_by_id(params[:id])
|
||||
@profile = @person.profile
|
||||
@posts = Post.find_all_by_person_id(@person.id).paginate :page => params[:page], :order => 'created_at DESC'
|
||||
@latest_status_message = StatusMessage.newest_for(@person)
|
||||
@post_count = @person_posts.count
|
||||
@post_count = @posts.count
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
|
|||
|
|
@ -67,6 +67,6 @@ class Album
|
|||
end
|
||||
|
||||
def propagate_retraction
|
||||
Retraction.for(self).notify_people
|
||||
self.person.owner.retract(self)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,20 +20,17 @@ class Person
|
|||
belongs_to :owner, :class_name => 'User'
|
||||
one :profile, :class_name => 'Profile'
|
||||
|
||||
many :posts, :class_name => 'Post', :foreign_key => :person_id
|
||||
many :albums, :class_name => 'Album', :foreign_key => :person_id
|
||||
|
||||
|
||||
timestamps!
|
||||
|
||||
before_destroy :remove_all_traces
|
||||
before_validation :clean_url
|
||||
validates_presence_of :email, :url, :profile, :serialized_key
|
||||
validates_format_of :url, :with =>
|
||||
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
|
||||
|
||||
|
||||
after_destroy :remove_all_traces
|
||||
|
||||
|
||||
def self.search(query)
|
||||
Person.all('$where' => "function() { return this.email.match(/^#{query}/i) ||
|
||||
|
|
@ -92,11 +89,9 @@ class Person
|
|||
self.url = self.url + '/' if self.url[-1,1] != '/'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_all_traces
|
||||
self.posts.delete_all
|
||||
Post.all(:person_id => id).each{|p| p.delete}
|
||||
Album.all(:person_id => id).each{|p| p.delete}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ class User
|
|||
######### Posts and Such ###############
|
||||
|
||||
def retract( post )
|
||||
post.unsocket_from_uid(self.id) if post.respond_to? :unsocket_from_uid
|
||||
retraction = Retraction.for(post)
|
||||
retraction.creator_signature = retraction.sign_with_key( encryption_key )
|
||||
retraction.notify_people
|
||||
|
|
@ -269,7 +270,7 @@ class User
|
|||
self.save
|
||||
|
||||
groups = groups_with_person(object.person)
|
||||
object.socket_to_uid(id, :group_id => groups.first.id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
||||
object.socket_to_uid(id, :group_id => group.id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
%h1
|
||||
= @person.real_name
|
||||
- unless @person.id == current_user.id
|
||||
.button.right
|
||||
= link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete
|
||||
.right
|
||||
= link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete, :class => "button"
|
||||
|
||||
%ul
|
||||
-unless @person_posts.first.nil?
|
||||
-unless @posts.first.nil?
|
||||
%li
|
||||
%i= "last seen: #{how_long_ago(@person_posts.first)}"
|
||||
%i= "last seen: #{how_long_ago(@posts.first)}"
|
||||
%li
|
||||
%i= "friends since: #{how_long_ago(@person)}"
|
||||
%li
|
||||
|
|
@ -26,11 +26,11 @@
|
|||
%span="posted: #{how_long_ago(@latest_status_message)}"
|
||||
|
||||
.span-20.last
|
||||
- if @person.posts
|
||||
- if @posts
|
||||
%h3= "stream - #{@post_count} item(s)"
|
||||
%ul#stream
|
||||
- for post in @person_posts
|
||||
- for post in @posts
|
||||
= render type_partial(post), :post => post
|
||||
= will_paginate @person_posts
|
||||
= will_paginate @posts
|
||||
- else
|
||||
%h3 no posts to display!
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ describe Person do
|
|||
person_message = Factory.create(:status_message, :person => @person)
|
||||
person_two = Factory.create(:person)
|
||||
|
||||
@person.owns? (person_message).should be true
|
||||
@person.owns?(person_message).should be true
|
||||
person_two.owns?(person_message).should be false
|
||||
end
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ describe Person do
|
|||
|
||||
person.destroy
|
||||
|
||||
Post.count.should == 1
|
||||
Post.count.should == 1
|
||||
Comment.all.count.should == 4
|
||||
status_message.comments.count.should == 4
|
||||
end
|
||||
|
|
@ -77,7 +77,7 @@ describe Person do
|
|||
request = @user.send_friend_request_to @person.receive_url, @group.id
|
||||
request2 = @user2.send_friend_request_to @person.receive_url, @group2.id
|
||||
|
||||
@user.activate_friend (@person, @group)
|
||||
@user.activate_friend(@person, @group)
|
||||
@user2.activate_friend(@person, @group2)
|
||||
|
||||
@user.reload
|
||||
|
|
|
|||
|
|
@ -27,27 +27,6 @@ describe Post do
|
|||
|
||||
end
|
||||
|
||||
describe "stream" do
|
||||
before do
|
||||
@owner = Factory.build(:user)
|
||||
@person_one = Factory.create(:person, :email => "some@dudes.com")
|
||||
@person_two = Factory.create(:person, :email => "other@dudes.com")
|
||||
|
||||
Factory.create(:status_message, :message => "puppies", :created_at => Time.now+1, :person => @owner.person)
|
||||
Factory.create(:status_message, :message => "http://reddit.com", :created_at => Time.now+2, :person => @person_one)
|
||||
Factory.create(:status_message, :message => "kittens", :created_at => Time.now+3, :person => @person_two)
|
||||
Factory.create(:status_message, :message => "Bear's body", :created_at => Time.now+4, :person => @owner.person)
|
||||
Factory.create(:status_message, :message => "Google", :created_at => Time.now+5, :person => @person_two)
|
||||
end
|
||||
|
||||
it "should get all posts for a specified user" do
|
||||
person_posts = @person_one.posts
|
||||
person_posts.count.should == 1
|
||||
|
||||
person_posts = @person_two.posts
|
||||
person_posts.count.should == 2
|
||||
end
|
||||
end
|
||||
describe 'xml' do
|
||||
it 'should serialize to xml with its person' do
|
||||
message = Factory.create(:status_message, :person => @user.person)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ describe User do
|
|||
StatusMessage.all.size.should == 0
|
||||
@user.receive( xml )
|
||||
|
||||
person.posts.first.message.should == 'store this!'
|
||||
Post.all(:person_id => person.id).first.message.should == 'store this!'
|
||||
StatusMessage.all.size.should == 1
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue