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