parent
bf42cc17f1
commit
a054a35863
2 changed files with 14 additions and 0 deletions
|
|
@ -20,6 +20,10 @@ class PostsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rescue_from Diaspora::NotMine do
|
||||||
|
render text: "You are not allowed to do that", status: 403
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
post_service = PostService.new(id: params[:id], user: current_user)
|
post_service = PostService.new(id: params[:id], user: current_user)
|
||||||
post_service.mark_user_notifications
|
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)
|
message = alice.post(:status_message, text: "hey", to: alice.aspects.first.id)
|
||||||
delete :destroy, format: :js, id: message.id
|
delete :destroy, format: :js, id: message.id
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue