Skip to content
Extraits de code Groupes Projets
Valider 5bb4ee5d rédigé par danielvincent's avatar danielvincent
Parcourir les fichiers

DG IZ; posting now ensures aspect ownership.

parent 4fe4326e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -105,7 +105,10 @@ class User ...@@ -105,7 +105,10 @@ class User
end end
aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId
raise ArgumentError.new("You must post to someone.") if aspect_ids.nil? || aspect_ids.empty? raise ArgumentError.new("You must post to someone.") if aspect_ids.nil? || aspect_ids.empty?
aspect_ids.each{ |aspect_id|
raise ArgumentError.new("Cannot post to an aspect you do not own.") unless self.aspects.find(aspect_id) }
post = build_post(class_name, options) post = build_post(class_name, options)
......
...@@ -30,6 +30,10 @@ describe User do ...@@ -30,6 +30,10 @@ describe User do
proc {@user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/ proc {@user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/
end end
it 'should not be able to post to someone elses aspect' do
proc {@user.post(:status_message, :message => "heyheyhey", :to => @aspect2.id)}.should raise_error /Cannot post to an aspect you do not own./
end
it 'should put the post in the aspect post array' do it 'should put the post in the aspect post array' do
post = @user.post(:status_message, :message => "hey", :to => @aspect.id) post = @user.post(:status_message, :message => "hey", :to => @aspect.id)
@aspect.reload @aspect.reload
......
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