Quickfixed federation of StatusMessages with photos only (no text)
This commit is contained in:
parent
bdeae54c6c
commit
8cfb854fab
6 changed files with 17 additions and 13 deletions
|
|
@ -19,7 +19,10 @@ class StatusMessage < Post
|
||||||
xml_attr :raw_message
|
xml_attr :raw_message
|
||||||
|
|
||||||
has_many :photos, :dependent => :destroy, :foreign_key => :status_message_guid, :primary_key => :guid
|
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_accessible :text, :provider_display_name
|
||||||
attr_accessor :oembed_url
|
attr_accessor :oembed_url
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class Stream::Soup < Stream::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def aspect_posts_ids
|
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
|
end
|
||||||
|
|
||||||
def followed_tag_ids
|
def followed_tag_ids
|
||||||
|
|
|
||||||
|
|
@ -122,10 +122,11 @@ describe StatusMessagesController do
|
||||||
StatusMessage.first.provider_display_name.should == 'mobile'
|
StatusMessage.first.provider_display_name.should == 'mobile'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends the errors in the body on js' do
|
# disabled to fix federation
|
||||||
post :create, status_message_hash.merge!(:format => 'js', :status_message => {:text => ''})
|
# it 'sends the errors in the body on js' do
|
||||||
response.body.should include('Status message requires a message or at least one photo')
|
# post :create, status_message_hash.merge!(:format => 'js', :status_message => {:text => ''})
|
||||||
end
|
# response.body.should include('Status message requires a message or at least one photo')
|
||||||
|
# end
|
||||||
|
|
||||||
context 'with photos' do
|
context 'with photos' do
|
||||||
before do
|
before do
|
||||||
|
|
|
||||||
|
|
@ -57,19 +57,19 @@ describe Stream::Aspect do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is called with 3 types' do
|
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)
|
@alice.should_receive(:visible_shareables).with(Post, hash_including(:type=> ['StatusMessage', 'Reshare', 'ActivityStreams::Photo'])).and_return(stub.as_null_object)
|
||||||
stream.posts
|
stream.posts
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'respects ordering' do
|
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)
|
@alice.should_receive(:visible_shareables).with(Post, hash_including(:order => 'created_at DESC')).and_return(stub.as_null_object)
|
||||||
stream.posts
|
stream.posts
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'respects max_time' do
|
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)
|
@alice.should_receive(:visible_shareables).with(Post, hash_including(:max_time => instance_of(Time))).and_return(stub.as_null_object)
|
||||||
stream.posts
|
stream.posts
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,10 @@ describe StatusMessage do
|
||||||
end
|
end
|
||||||
it "should have either a message or at least one photo" do
|
it "should have either a message or at least one photo" do
|
||||||
n = Factory.build(:status_message, :text => nil)
|
n = Factory.build(:status_message, :text => nil)
|
||||||
n.valid?.should be_false
|
# n.valid?.should be_false
|
||||||
|
|
||||||
n.text = ""
|
# n.text = ""
|
||||||
n.valid?.should be_false
|
# n.valid?.should be_false
|
||||||
|
|
||||||
n.text = "wales"
|
n.text = "wales"
|
||||||
n.valid?.should be_true
|
n.valid?.should be_true
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ describe User do
|
||||||
time = Time.now
|
time = Time.now
|
||||||
Time.stub(:now).and_return(time)
|
Time.stub(:now).and_return(time)
|
||||||
alice.send(:prep_opts, Post, {}).should == {
|
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',
|
:order => 'created_at DESC',
|
||||||
:limit => 15,
|
:limit => 15,
|
||||||
:hidden => false,
|
:hidden => false,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue