Skip to content
Extraits de code Groupes Projets
Valider 909a1983 rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

Post photos without text

parent 80a3a344
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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}
......
......@@ -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
......
......@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter