Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
38a3193a61
9 changed files with 22 additions and 27 deletions
|
|
@ -11,7 +11,7 @@ class AspectsController < ApplicationController
|
|||
|
||||
def index
|
||||
if params[:a_ids]
|
||||
@aspects = current_user.aspects.where(:id => params[:a_ids]).includes(:contacts) #linit 16
|
||||
@aspects = current_user.aspects.where(:id => params[:a_ids]).includes(:contacts)
|
||||
else
|
||||
@aspects = current_user.aspects.includes(:contacts)
|
||||
end
|
||||
|
|
@ -25,7 +25,7 @@ class AspectsController < ApplicationController
|
|||
post_ids = @aspects.map{|a| a.post_ids}.flatten!
|
||||
|
||||
@posts = StatusMessage.joins(:aspects).where(:pending => false,
|
||||
:aspects => {:id => @aspect_ids}).includes(:person, :comments, :photos).select('DISTINCT `posts`.*').paginate(
|
||||
:aspects => {:id => @aspect_ids}).includes(:person, :comments => :person, :photos).select('DISTINCT `posts`.*').paginate(
|
||||
:page => params[:page], :per_page => 15, :order => 'created_at DESC')
|
||||
|
||||
@contacts = current_user.contacts.includes(:person).where(:pending => false)
|
||||
|
|
@ -70,13 +70,13 @@ class AspectsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@aspect = current_user.aspects.where(:id => params[:id]).first
|
||||
@aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts => :person).first
|
||||
redirect_to aspects_path('a_ids[]' => @aspect.id)
|
||||
end
|
||||
|
||||
def edit
|
||||
@aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts).first
|
||||
@contacts = current_user.contacts.where(:pending => false)
|
||||
@aspect = current_user.aspects.where(:id => params[:id]).first
|
||||
@contacts = current_user.contacts.includes(:person).where(:pending => false)
|
||||
unless @aspect
|
||||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||
else
|
||||
|
|
@ -88,9 +88,9 @@ class AspectsController < ApplicationController
|
|||
|
||||
def manage
|
||||
@aspect = :manage
|
||||
@contacts = current_user.contacts.where(:pending => false)
|
||||
@remote_requests = Request.where(:recipient_id => current_user.person.id)
|
||||
@aspects = @all_aspects.includes(:contacts)
|
||||
@contacts = current_user.contacts.includes(:person).where(:pending => false)
|
||||
@remote_requests = Request.where(:recipient_id => current_user.person.id).includes(:sender)
|
||||
@aspects = @all_aspects.includes(:contacts => :person)
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class PhotosController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@photo = current_user.visible_photos.where(:id => params[:id]).first
|
||||
@photo = current_user.visible_photos.where(:id => params[:id]).includes(:person, :status_message => :photos).first
|
||||
if @photo
|
||||
@parent = @photo.status_message
|
||||
|
||||
|
|
@ -152,8 +152,8 @@ class PhotosController < ApplicationController
|
|||
end
|
||||
|
||||
@object_aspect_ids = []
|
||||
if @parent.aspects
|
||||
@object_aspect_ids = @parent.aspects.map{|a| a.id}
|
||||
if @parent_aspects = @parent.aspects.where(:user_id => current_user.id)
|
||||
@object_aspect_ids = @parent_aspects.map{|a| a.id}
|
||||
end
|
||||
|
||||
@ownership = current_user.owns? @photo
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class PostsController < ApplicationController
|
|||
skip_before_filter :set_locale
|
||||
|
||||
def show
|
||||
@post = Post.where(:id => params[:id], :public => true).first
|
||||
@post = Post.where(:id => params[:id], :public => true).includes(:person, :comments => :person).first
|
||||
|
||||
if @post
|
||||
@landing_page = true
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class PublicsController < ApplicationController
|
|||
caches_page :host_meta
|
||||
|
||||
def hcard
|
||||
@person = Person.where(:guid => params[:guid])
|
||||
@person = Person.where(:guid => params[:guid]).first
|
||||
unless @person.nil? || @person.owner.nil?
|
||||
render 'publics/hcard'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class Comment < ActiveRecord::Base
|
||||
default_scope :include => :person
|
||||
require File.join(Rails.root, 'lib/diaspora/web_socket')
|
||||
require File.join(Rails.root, 'lib/youtube_titles')
|
||||
include YoutubeTitles
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class Contact < ActiveRecord::Base
|
||||
default_scope :include => :person
|
||||
belongs_to :user
|
||||
validates_presence_of :user
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class Post < ActiveRecord::Base
|
||||
default_scope :include => [:person, :comments]
|
||||
require File.join(Rails.root, 'lib/encryptable')
|
||||
require File.join(Rails.root, 'lib/diaspora/web_socket')
|
||||
include ApplicationHelper
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ class Request < ActiveRecord::Base
|
|||
include Diaspora::Webhooks
|
||||
include ROXML
|
||||
|
||||
default_scope :include => :sender
|
||||
|
||||
xml_accessor :sender_handle
|
||||
xml_accessor :recipient_handle
|
||||
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@ describe PublicsController do
|
|||
render_views
|
||||
|
||||
let(:user) { Factory.create(:user) }
|
||||
let(:person) { Factory(:person) }
|
||||
let(:person) { Factory.create(:person) }
|
||||
|
||||
describe '#receive' do
|
||||
let(:xml) { "<walruses></walruses>" }
|
||||
|
||||
it 'succeeds' do
|
||||
post :receive, "id" => user.person.id.to_s, "xml" => xml
|
||||
post :receive, "guid" => user.person.guid.to_s, "xml" => xml
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'enqueues a receive job' do
|
||||
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, user.id, xml).once
|
||||
post :receive, "id" => user.person.id.to_s, "xml" => xml
|
||||
post :receive, "guid" => user.person.guid.to_s, "xml" => xml
|
||||
end
|
||||
|
||||
it 'unescapes the xml before sending it to receive_salmon' do
|
||||
|
|
@ -34,33 +34,33 @@ describe PublicsController do
|
|||
|
||||
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, user.id, enc_xml).once
|
||||
|
||||
post :receive, "id" => user.person.id.to_s, "xml" => CGI::escape(enc_xml)
|
||||
post :receive, "guid" => user.person.guid.to_s, "xml" => CGI::escape(enc_xml)
|
||||
end
|
||||
|
||||
it 'returns a 422 if no xml is passed' do
|
||||
post :receive, "id" => person.id.to_s
|
||||
post :receive, "guid" => person.guid.to_s
|
||||
response.code.should == '422'
|
||||
end
|
||||
|
||||
it 'returns a 404 if no user is found' do
|
||||
post :receive, "id" => person.id.to_s, "xml" => xml
|
||||
post :receive, "guid" => person.guid.to_s, "xml" => xml
|
||||
response.should be_not_found
|
||||
end
|
||||
end
|
||||
|
||||
describe '#hcard' do
|
||||
it "succeeds" do
|
||||
post :hcard, "id" => user.person.id.to_s
|
||||
post :hcard, "guid" => user.person.guid.to_s
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'sets the person' do
|
||||
post :hcard, "id" => user.person.id.to_s
|
||||
post :hcard, "guid" => user.person.guid.to_s
|
||||
assigns[:person].should == user.person
|
||||
end
|
||||
|
||||
it 'does not query by user id' do
|
||||
post :hcard, "id" => user.id.to_s
|
||||
post :hcard, "guid" => user.id.to_s
|
||||
assigns[:person].should be_nil
|
||||
response.should be_not_found
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue