diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a50b4b2eef22be56157d29aabd1a46bb264dcfca..fb3a568d11cb63400ea095d3bbbb6b1e5984c6d4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -68,8 +68,9 @@ class UsersController < ApplicationController user = User.find_by_username(params[:username]) if user + posts = Post.where(:author_id => user.person.id, :public => true).order('created_at DESC') director = Diaspora::Director.new - ostatus_builder = Diaspora::OstatusBuilder.new(user) + ostatus_builder = Diaspora::OstatusBuilder.new(user, posts) render :xml => director.build(ostatus_builder), :content_type => 'application/atom+xml' else diff --git a/lib/diaspora/ostatus_builder.rb b/lib/diaspora/ostatus_builder.rb index ba8cbd7fa8c47c54ae25aeac9457b7d90194a24c..9fd8d733de97be2105b3aee3bbffda7d6e813664 100644 --- a/lib/diaspora/ostatus_builder.rb +++ b/lib/diaspora/ostatus_builder.rb @@ -21,9 +21,9 @@ module Diaspora class OstatusBuilder include Diaspora::Webhooks - def initialize(user) + def initialize(user, posts) @user = user - @posts = Post.where(:author_id => @user.person.id, :public => true) + @posts = posts end def create_headers diff --git a/spec/lib/diaspora/ostatus_builder.rb b/spec/lib/diaspora/ostatus_builder.rb index 687443104b0bfbac838abbaf99d7a29211db45fb..d9b437ec86f41e66ffd1358af0a3c732a49d7fdb 100644 --- a/spec/lib/diaspora/ostatus_builder.rb +++ b/spec/lib/diaspora/ostatus_builder.rb @@ -22,11 +22,10 @@ describe Diaspora::OstatusBuilder do arr << s end } - let!(:atom) { director = Diaspora::Director.new; director.build(Diaspora::OstatusBuilder.new(user)) } + let!(:atom) { director = Diaspora::Director.new; director.build(Diaspora::OstatusBuilder.new(user, public_status_messages)) } it 'should include a users posts' do public_status_messages.each{ |status| atom.should include status.message } - private_status_messages.each{ |status| atom.should_not include status.message } end end