From 35429d105bd5bbed1f16ea3918bea3f8d3e10198 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 19 Dec 2015 17:15:52 +0100 Subject: [PATCH] write tests for unescape --- .../receive_controller_spec.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spec/controllers/diaspora_federation/receive_controller_spec.rb b/spec/controllers/diaspora_federation/receive_controller_spec.rb index 2ec50da..9f77fce 100644 --- a/spec/controllers/diaspora_federation/receive_controller_spec.rb +++ b/spec/controllers/diaspora_federation/receive_controller_spec.rb @@ -15,6 +15,13 @@ module DiasporaFederation post :public, xml: "" expect(response.code).to eq("200") end + + it "unescapes the xml before sending it to the callback" do + expect(DiasporaFederation.callbacks).to receive(:trigger) + .with(:queue_public_receive, "") + + post :public, xml: CGI::escape("") + end end describe "POST #private" do @@ -32,7 +39,7 @@ module DiasporaFederation expect(response.code).to eq("422") end - it "returns a 200 if receive! reports no errors" do + it "returns a 200 if the callback returned true" do expect(DiasporaFederation.callbacks).to receive(:trigger) .with(:queue_private_receive, "any-guid", "") .and_return(true) @@ -40,6 +47,14 @@ module DiasporaFederation post :private, guid: "any-guid", xml: "" expect(response.code).to eq("200") end + + it "unescapes the xml before sending it to the callback" do + expect(DiasporaFederation.callbacks).to receive(:trigger) + .with(:queue_private_receive, "any-guid", "") + .and_return(true) + + post :private, guid: "any-guid", xml: CGI::escape("") + end end end end