Flesh out these specs before modifying the code.

Darren Cauthon 9 years ago
parent
commit
1ce3a7f798
1 changed files with 23 additions and 6 deletions
  1. 23 6
      spec/models/agents/webhook_agent_spec.rb

+ 23 - 6
spec/models/agents/webhook_agent_spec.rb

@@ -38,12 +38,29 @@ describe Agents::WebhookAgent do
38 38
       expect(out).to eq(['Not Authorized', 401])
39 39
     end
40 40
 
41
-    it "should only accept POSTs" do
42
-      out = nil
43
-      expect {
44
-        out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "get", "text/html")
45
-      }.to change { Event.count }.by(0)
46
-      expect(out).to eq(['Please use POST requests only', 401])
41
+    describe "receiving events" do
42
+
43
+      context "default settings" do
44
+
45
+        it "should not accept GET" do
46
+          out = nil
47
+          expect {
48
+            out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "get", "text/html")
49
+          }.to change { Event.count }.by(0)
50
+          expect(out).to eq(['Please use POST requests only', 401])
51
+        end
52
+
53
+        it "should accept POST" do
54
+          out = nil
55
+          expect {
56
+            out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "post", "text/html")
57
+          }.to change { Event.count }.by(1)
58
+          expect(out).to eq(['Event Created', 201])
59
+        end
60
+
61
+      end
62
+
47 63
     end
64
+
48 65
   end
49 66
 end