Merge branch 'friend-refactor' of github.com:diaspora/diaspora_rails into friend-refactor

This commit is contained in:
maxwell 2010-08-09 19:05:12 -07:00
commit 68c4de6c16
16 changed files with 59 additions and 46 deletions

View file

@ -19,6 +19,7 @@ class ApplicationController < ActionController::Base
@groups = current_user.groups
@friends = current_user.friends if current_user
@latest_status_message = StatusMessage.newest_for(current_user) if current_user
@group = params[:group] ? Group.first(:id => params[:group]) : Group.first
end
def count_requests

View file

@ -3,6 +3,12 @@ class DashboardsController < ApplicationController
include ApplicationHelper
def index
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
if params[:group]
@people_ids = @group.people.map {|p| p.id}
@posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC'
else
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
end
end
end

View file

@ -31,12 +31,6 @@ module ApplicationHelper
end
end
def link_to_person(user)
person = user.person
puts person.inspect
link_to person.real_name, person_path(person)
end
def owner_image_tag
person_image_tag(User.owner)
end

View file

@ -26,9 +26,9 @@ class Album
def self.mine_or_friends(friend_param, current_user)
if friend_param
Album.where(:person_id.ne => current_user.id)
Album.where(:person_id.ne => current_user.person.id)
else
Album.where(:person_id => current_user.id)
Album.where(:person_id => current_user.person.id)
end
end

View file

@ -5,7 +5,7 @@
.right#add_album_button
= link_to 'New Album', "#", :class => "button"
#add_album_box.contextual_pane
#add_album_pane.contextual_pane
= render "albums/new_album"
.sub_header

View file

@ -5,10 +5,10 @@
= @album.name
-if current_user.owns? @album
.button.right#add_photos_button
.button.right#add_photo_button
= link_to 'Add Photos', '#'
#add_photo_box.contextual_pane
#add_photo_pane.contextual_pane
= render "photos/new_photo", :photo => @photo, :album => @album
.sub_header

View file

@ -3,7 +3,7 @@
= person_image_tag(post.person)
%span.from
= link_to_person post.person
= link_to post.person.real_name, post.person
%b wrote a new blog post
%br
%b= post.title

View file

@ -33,7 +33,7 @@
#session_action
- if user_signed_in?
= link_to_person current_user
= link_to current_user.real_name, current_user.person
|
= link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count)
|

View file

@ -2,7 +2,7 @@
= person_image_tag(post.person)
%span.from
= link_to_person post.person
= link_to post.person.real_name, post.person
%b
posted a new photo to
= link_to post.album.name, object_path(post.album)

View file

@ -1,8 +1,10 @@
= form_for @request do |f|
= form_for Request.new do |f|
= f.error_messages
Enter a Diaspora URL, Diaspora username, or random email address:
.field_with_submit
= f.text_field :destination_url
= f.hidden_field :group, :value => @group.id
= f.submit

View file

@ -1,13 +1,20 @@
#group
%ul
- for group in @groups
%li= link_to group.name, group_path(group)
%li= link_to group.name, root_path(:group =>group.id)
%li.new_group= link_to "NEW GROUP", new_group_path
%li#add_group_button.new_group= link_to "NEW GROUP", "#"
#friend_pictures
- for friend in @friends
= person_image_link(friend)
#add_group_pane.contextual_pane
= render "groups/new_group"
.add_new
= link_to "+", requests_path
- if @group
#friend_pictures
- for friend in @group.people
= person_image_link(friend)
#add_request_button.add_new
= link_to "+", "#"
#add_request_pane.contextual_pane
= render "requests/new_request"

View file

@ -39,7 +39,13 @@ module Diaspora
end
def people_with_permissions
self.person.owner.friends.all
begin
friends = self.person.owner.friends
friends ||= []
rescue
Rails.logger.fatal("IOUASDVJOISDNVPOIJSDVOUIDSGPUOID")
[]
end
end
def self.build_xml_for(posts)

View file

@ -81,21 +81,22 @@ $(document).ready(function(){
});
//buttons//////
$("#add_photos_button").toggle(
function(){
$("#add_photo_box").fadeIn(300);
},function(){
$("#add_photo_box").fadeOut(200);
function pane_toggler_button( name ) {
$("#add_" + name + "_button").toggle(
function(evt){
evt.preventDefault();
$("#add_" + name + "_pane").fadeIn(300);
},function(evt){
evt.preventDefault();
$("#add_" + name +"_pane").fadeOut(200);
}
);
}
$("#add_album_button").toggle(
function(){
$("#add_album_box").fadeIn(300);
},function(){
$("#add_album_box").fadeOut(200);
}
);
pane_toggler_button("album");
pane_toggler_button("group");
pane_toggler_button("photo");
pane_toggler_button("request");
$("input[type='submit']").addClass("button");

View file

@ -13,28 +13,24 @@ describe 'SocketsController' do
end
it 'should unstub the websockets' do
WebSocket.initialize_channel
WebSocket.initialize_channels
@controller.class.should == SocketsController
end
it 'should add a new subscriber to the websockets channel' do
WebSocket.initialize_channel
@controller.new_subscriber.should == 1
end
describe 'actionhash' do
before do
@message = @user.post :status_message, :message => "post through user for victory"
end
it 'should actionhash posts' do
json = @controller.action_hash(@message)
json = @controller.action_hash(@user.id, @message)
json.include?(@message.message).should be_true
json.include?('status_message').should be_true
end
it 'should actionhash retractions' do
retraction = Retraction.for @message
json = @controller.action_hash(retraction)
json = @controller.action_hash(@user.id, retraction)
json.include?('retraction').should be_true
json.include?("html\":null").should be_true
end

View file

@ -45,7 +45,7 @@ describe Comment do
end
it 'should send a user comment on his own post to lots of people' do
allowed_urls = @user_status.people_with_permissions.map!{|x| x = x.url + "receive/"}
allowed_urls = @user_status.people_with_permissions.map{|x| x = x.url + "receive/"}
message_queue.should_receive(:add_post_request).with(allowed_urls, anything)
@user.comment "yo", :on => @user_status
end

View file

@ -25,8 +25,8 @@ describe Post do
(5..8).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @user.person)}
(9..11).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @person_two)}
Factory.create(:status_message)
Factory.create(:bookmark)
Factory.create(:status_message, :person => @user)
Factory.create(:bookmark, :person => @user)
end
it "should give the most recent blog title and body from owner" do