diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 4676b0cfd..caa15d52d 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -57,8 +57,11 @@ class PhotosController < ApplicationController aspects = current_user.aspects_from_ids(params[:photo][:aspect_ids]) - current_user.add_to_streams(@photo, aspects) - current_user.dispatch_post(@photo, :to => params[:photo][:aspect_ids]) unless @photo.pending + + unless @photo.pending + current_user.add_to_streams(@photo, aspects) + current_user.dispatch_post(@photo, :to => params[:photo][:aspect_ids]) + end if params[:photo][:set_profile_photo] profile_params = {:image_url => @photo.url(:thumb_large), diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 1d4f97491..91ce37bce 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -27,11 +27,14 @@ class StatusMessagesController < ApplicationController if !photos.empty? @status_message.photos += photos for photo in photos + was_pending = photo.pending photo.public = public_flag photo.pending = false photo.save - current_user.add_to_streams(photo, aspects) - current_user.dispatch_post(photo) + if was_pending + current_user.add_to_streams(photo, aspects) + current_user.dispatch_post(photo) + end end end diff --git a/app/models/photo.rb b/app/models/photo.rb index d169f8044..2c541d76a 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -51,7 +51,11 @@ class Photo < Post end def status_message_guid - self.status_message.guid + if self.status_message + self.status_message.guid + else + nil + end end def status_message_guid= new_sm_guid diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index af73677a8..7d5ad293a 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -83,8 +83,8 @@ describe StatusMessagesController do fixture_filename = 'button.png' fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', fixture_filename) - @photo1 = @user1.build_post(:photo, :user_file=> File.open(fixture_name), :to => @aspect1.id) - @photo2 = @user1.build_post(:photo, :user_file=> File.open(fixture_name), :to => @aspect1.id) + @photo1 = @user1.build_post(:photo, :pending => true, :user_file=> File.open(fixture_name), :to => @aspect1.id) + @photo2 = @user1.build_post(:photo, :pending => true, :user_file=> File.open(fixture_name), :to => @aspect1.id) @photo1.save! @photo2.save!