Skip to content
Extraits de code Groupes Projets
Valider a054a358 rédigé par theworldbright's avatar theworldbright Validation de Jonne Haß
Parcourir les fichiers

Catch Diaspora::NotMine on post controller

closes #6533
parent bf42cc17
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -20,6 +20,10 @@ class PostsController < ApplicationController
end
end
rescue_from Diaspora::NotMine do
render text: "You are not allowed to do that", status: 403
end
def show
post_service = PostService.new(id: params[:id], user: current_user)
post_service.mark_user_notifications
......
......@@ -135,5 +135,15 @@ describe PostsController, type: :controller do
message = alice.post(:status_message, text: "hey", to: alice.aspects.first.id)
delete :destroy, format: :js, id: message.id
end
context "when Diaspora::NotMine is raised by retract post" do
it "will respond with a 403" do
expect(post_service_double).to receive(:retract_post).and_raise(Diaspora::NotMine)
message = alice.post(:status_message, text: "hey", to: alice.aspects.first.id)
delete :destroy, format: :js, id: message.id
expect(response.body).to eq("You are not allowed to do that")
expect(response.status).to eq(403)
end
end
end
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