Merge branch 'friend-refactor' of github.com:diaspora/diaspora_rails into friend-refactor
This commit is contained in:
commit
68c4de6c16
16 changed files with 59 additions and 46 deletions
|
|
@ -19,6 +19,7 @@ class ApplicationController < ActionController::Base
|
||||||
@groups = current_user.groups
|
@groups = current_user.groups
|
||||||
@friends = current_user.friends if current_user
|
@friends = current_user.friends if current_user
|
||||||
@latest_status_message = StatusMessage.newest_for(current_user) 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
|
end
|
||||||
|
|
||||||
def count_requests
|
def count_requests
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,12 @@ class DashboardsController < ApplicationController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def index
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,6 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
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
|
def owner_image_tag
|
||||||
person_image_tag(User.owner)
|
person_image_tag(User.owner)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ class Album
|
||||||
|
|
||||||
def self.mine_or_friends(friend_param, current_user)
|
def self.mine_or_friends(friend_param, current_user)
|
||||||
if friend_param
|
if friend_param
|
||||||
Album.where(:person_id.ne => current_user.id)
|
Album.where(:person_id.ne => current_user.person.id)
|
||||||
else
|
else
|
||||||
Album.where(:person_id => current_user.id)
|
Album.where(:person_id => current_user.person.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
.right#add_album_button
|
.right#add_album_button
|
||||||
= link_to 'New Album', "#", :class => "button"
|
= link_to 'New Album', "#", :class => "button"
|
||||||
|
|
||||||
#add_album_box.contextual_pane
|
#add_album_pane.contextual_pane
|
||||||
= render "albums/new_album"
|
= render "albums/new_album"
|
||||||
|
|
||||||
.sub_header
|
.sub_header
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
= @album.name
|
= @album.name
|
||||||
|
|
||||||
-if current_user.owns? @album
|
-if current_user.owns? @album
|
||||||
.button.right#add_photos_button
|
.button.right#add_photo_button
|
||||||
= link_to 'Add Photos', '#'
|
= link_to 'Add Photos', '#'
|
||||||
|
|
||||||
#add_photo_box.contextual_pane
|
#add_photo_pane.contextual_pane
|
||||||
= render "photos/new_photo", :photo => @photo, :album => @album
|
= render "photos/new_photo", :photo => @photo, :album => @album
|
||||||
|
|
||||||
.sub_header
|
.sub_header
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
= person_image_tag(post.person)
|
= person_image_tag(post.person)
|
||||||
|
|
||||||
%span.from
|
%span.from
|
||||||
= link_to_person post.person
|
= link_to post.person.real_name, post.person
|
||||||
%b wrote a new blog post
|
%b wrote a new blog post
|
||||||
%br
|
%br
|
||||||
%b= post.title
|
%b= post.title
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#session_action
|
#session_action
|
||||||
- if user_signed_in?
|
- 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)
|
= link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count)
|
||||||
|
|
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
= person_image_tag(post.person)
|
= person_image_tag(post.person)
|
||||||
|
|
||||||
%span.from
|
%span.from
|
||||||
= link_to_person post.person
|
= link_to post.person.real_name, post.person
|
||||||
%b
|
%b
|
||||||
posted a new photo to
|
posted a new photo to
|
||||||
= link_to post.album.name, object_path(post.album)
|
= link_to post.album.name, object_path(post.album)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
= form_for @request do |f|
|
= form_for Request.new do |f|
|
||||||
= f.error_messages
|
= f.error_messages
|
||||||
|
|
||||||
|
|
||||||
Enter a Diaspora URL, Diaspora username, or random email address:
|
Enter a Diaspora URL, Diaspora username, or random email address:
|
||||||
.field_with_submit
|
.field_with_submit
|
||||||
= f.text_field :destination_url
|
= f.text_field :destination_url
|
||||||
|
= f.hidden_field :group, :value => @group.id
|
||||||
= f.submit
|
= f.submit
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,20 @@
|
||||||
#group
|
#group
|
||||||
%ul
|
%ul
|
||||||
- for group in @groups
|
- 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
|
#add_group_pane.contextual_pane
|
||||||
- for friend in @friends
|
= render "groups/new_group"
|
||||||
= person_image_link(friend)
|
|
||||||
|
|
||||||
.add_new
|
- if @group
|
||||||
= link_to "+", requests_path
|
#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"
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,13 @@ module Diaspora
|
||||||
end
|
end
|
||||||
|
|
||||||
def people_with_permissions
|
def people_with_permissions
|
||||||
self.person.owner.friends.all
|
begin
|
||||||
|
friends = self.person.owner.friends
|
||||||
|
friends ||= []
|
||||||
|
rescue
|
||||||
|
Rails.logger.fatal("IOUASDVJOISDNVPOIJSDVOUIDSGPUOID")
|
||||||
|
[]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.build_xml_for(posts)
|
def self.build_xml_for(posts)
|
||||||
|
|
|
||||||
|
|
@ -81,21 +81,22 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
//buttons//////
|
//buttons//////
|
||||||
$("#add_photos_button").toggle(
|
function pane_toggler_button( name ) {
|
||||||
function(){
|
$("#add_" + name + "_button").toggle(
|
||||||
$("#add_photo_box").fadeIn(300);
|
function(evt){
|
||||||
},function(){
|
evt.preventDefault();
|
||||||
$("#add_photo_box").fadeOut(200);
|
$("#add_" + name + "_pane").fadeIn(300);
|
||||||
|
},function(evt){
|
||||||
|
evt.preventDefault();
|
||||||
|
$("#add_" + name +"_pane").fadeOut(200);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$("#add_album_button").toggle(
|
pane_toggler_button("album");
|
||||||
function(){
|
pane_toggler_button("group");
|
||||||
$("#add_album_box").fadeIn(300);
|
pane_toggler_button("photo");
|
||||||
},function(){
|
pane_toggler_button("request");
|
||||||
$("#add_album_box").fadeOut(200);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$("input[type='submit']").addClass("button");
|
$("input[type='submit']").addClass("button");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,28 +13,24 @@ describe 'SocketsController' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should unstub the websockets' do
|
it 'should unstub the websockets' do
|
||||||
WebSocket.initialize_channel
|
WebSocket.initialize_channels
|
||||||
@controller.class.should == SocketsController
|
@controller.class.should == SocketsController
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should add a new subscriber to the websockets channel' do
|
|
||||||
WebSocket.initialize_channel
|
|
||||||
@controller.new_subscriber.should == 1
|
|
||||||
end
|
|
||||||
describe 'actionhash' do
|
describe 'actionhash' do
|
||||||
before do
|
before do
|
||||||
@message = @user.post :status_message, :message => "post through user for victory"
|
@message = @user.post :status_message, :message => "post through user for victory"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should actionhash posts' do
|
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?(@message.message).should be_true
|
||||||
json.include?('status_message').should be_true
|
json.include?('status_message').should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should actionhash retractions' do
|
it 'should actionhash retractions' do
|
||||||
retraction = Retraction.for @message
|
retraction = Retraction.for @message
|
||||||
json = @controller.action_hash(retraction)
|
json = @controller.action_hash(@user.id, retraction)
|
||||||
json.include?('retraction').should be_true
|
json.include?('retraction').should be_true
|
||||||
json.include?("html\":null").should be_true
|
json.include?("html\":null").should be_true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ describe Comment do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should send a user comment on his own post to lots of people' do
|
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)
|
message_queue.should_receive(:add_post_request).with(allowed_urls, anything)
|
||||||
@user.comment "yo", :on => @user_status
|
@user.comment "yo", :on => @user_status
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ describe Post do
|
||||||
(5..8).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @user.person)}
|
(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)}
|
(9..11).each { |n| Blog.create(:title => "title #{n}",:body => "test #{n}", :person => @person_two)}
|
||||||
|
|
||||||
Factory.create(:status_message)
|
Factory.create(:status_message, :person => @user)
|
||||||
Factory.create(:bookmark)
|
Factory.create(:bookmark, :person => @user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should give the most recent blog title and body from owner" do
|
it "should give the most recent blog title and body from owner" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue