Post photos without text

This commit is contained in:
Raphael Sofaer 2011-03-07 09:49:34 -08:00
parent 80a3a3446a
commit 909a198380
3 changed files with 13 additions and 4 deletions

View file

@ -21,6 +21,9 @@ class StatusMessagesController < ApplicationController
@status_message = current_user.build_post(:status_message, params[:status_message])
aspects = current_user.aspects_from_ids(params[:aspect_ids])
if !photos.empty?
@status_message.photos << photos
end
if @status_message.save
Rails.logger.info("event=create type=status_message chars=#{params[:status_message][:message].length}")
@ -31,14 +34,12 @@ class StatusMessagesController < ApplicationController
if !photos.empty?
for photo in photos
was_pending = photo.pending
photo.public = public_flag
photo.pending = false
@status_message.photos << photo
if was_pending
current_user.add_to_streams(photo, aspects)
current_user.dispatch_post(photo)
end
end
photos.update_all(:pending => false, :public => public_flag)
end
respond_to do |format|
@ -47,6 +48,9 @@ class StatusMessagesController < ApplicationController
format.mobile{ redirect_to :back}
end
else
if !photos.empty?
photos.update_all(:status_message_id => nil)
end
respond_to do |format|
format.js { render :json =>{:errors => @status_message.errors.full_messages}, :status => 406 }
format.html {redirect_to :back}

View file

@ -127,6 +127,11 @@ describe StatusMessagesController do
@hash = status_message_hash
@hash[:photos] = [@photo1.id.to_s, @photo2.id.to_s]
end
it "will post a photo without text" do
@hash.delete :message
post :create, @hash
response.should be_redirect
end
it "dispatches all referenced photos" do
@user1.should_receive(:dispatch_post).exactly(3).times
post :create, @hash

View file

@ -43,7 +43,7 @@ describe StatusMessage do
photo.save!
n.photos << photo
n.valid?
n.valid?.should be_true
n.errors.full_messages.should == []
end