Quickfixed federation of StatusMessages with photos only (no text)

This commit is contained in:
Manuel Schölling 2011-10-16 00:12:01 +02:00
parent bdeae54c6c
commit 8cfb854fab
6 changed files with 17 additions and 13 deletions

View file

@ -19,7 +19,10 @@ class StatusMessage < Post
xml_attr :raw_message
has_many :photos, :dependent => :destroy, :foreign_key => :status_message_guid, :primary_key => :guid
validate :presence_of_content
# TODO: disabling presence_of_content() (and its specs in status_message_controller_spec.rb:125) is a quick and dirty fix for federation
# a StatusMessage is federated before its photos are so presence_of_content() fails erroneously if no text is present
#validate :presence_of_content
attr_accessible :text, :provider_display_name
attr_accessor :oembed_url

View file

@ -30,7 +30,7 @@ class Stream::Soup < Stream::Base
end
def aspect_posts_ids
@aspect_posts_ids ||= user.visible_post_ids(:limit => 15, :order => "#{order} DESC", :max_time => max_time, :all_aspects? => true, :by_members_of => aspect_ids)
@aspect_posts_ids ||= user.visible_shareable_ids(Post, :limit => 15, :order => "#{order} DESC", :max_time => max_time, :all_aspects? => true, :by_members_of => aspect_ids)
end
def followed_tag_ids

View file

@ -122,10 +122,11 @@ describe StatusMessagesController do
StatusMessage.first.provider_display_name.should == 'mobile'
end
it 'sends the errors in the body on js' do
post :create, status_message_hash.merge!(:format => 'js', :status_message => {:text => ''})
response.body.should include('Status message requires a message or at least one photo')
end
# disabled to fix federation
# it 'sends the errors in the body on js' do
# post :create, status_message_hash.merge!(:format => 'js', :status_message => {:text => ''})
# response.body.should include('Status message requires a message or at least one photo')
# end
context 'with photos' do
before do

View file

@ -57,19 +57,19 @@ describe Stream::Aspect do
end
it 'is called with 3 types' do
stream = AspectStream.new(@alice, [1,2], :order => 'created_at')
stream = Stream::Aspect.new(@alice, [1,2], :order => 'created_at')
@alice.should_receive(:visible_shareables).with(Post, hash_including(:type=> ['StatusMessage', 'Reshare', 'ActivityStreams::Photo'])).and_return(stub.as_null_object)
stream.posts
end
it 'respects ordering' do
stream = AspectStream.new(@alice, [1,2], :order => 'created_at')
stream = Stream::Aspect.new(@alice, [1,2], :order => 'created_at')
@alice.should_receive(:visible_shareables).with(Post, hash_including(:order => 'created_at DESC')).and_return(stub.as_null_object)
stream.posts
end
it 'respects max_time' do
stream = AspectStream.new(@alice, [1,2], :max_time => 123)
stream = Stream::Aspect.new(@alice, [1,2], :max_time => 123)
@alice.should_receive(:visible_shareables).with(Post, hash_including(:max_time => instance_of(Time))).and_return(stub.as_null_object)
stream.posts
end

View file

@ -88,10 +88,10 @@ describe StatusMessage do
end
it "should have either a message or at least one photo" do
n = Factory.build(:status_message, :text => nil)
n.valid?.should be_false
# n.valid?.should be_false
n.text = ""
n.valid?.should be_false
# n.text = ""
# n.valid?.should be_false
n.text = "wales"
n.valid?.should be_true

View file

@ -146,7 +146,7 @@ describe User do
time = Time.now
Time.stub(:now).and_return(time)
alice.send(:prep_opts, Post, {}).should == {
:type => BaseStream::TYPES_OF_POST_IN_STREAM,
:type => Stream::Base::TYPES_OF_POST_IN_STREAM,
:order => 'created_at DESC',
:limit => 15,
:hidden => false,