Commit df77c3b

mo khan <mo@mokhan.ca>
2021-07-11 03:11:22
test: extract payload into fixture file
1 parent 11696ab
Changed files (2)
test
controllers
fixtures
files
webhooks
test/controllers/githubs_controller_test.rb
@@ -2,36 +2,7 @@ require "test_helper"
 
 class GithubsControllerTest < ActionDispatch::IntegrationTest
   test "accepts a new app installation webhook" do
-    post '/github', params: {
-      "zen": "Design for failure.",
-      "hook_id": 306990071,
-      "hook": {
-        "type": "App",
-        "id": 306990071,
-        "name": "web",
-        "active": true,
-        "events": [
-          "commit_comment",
-          "create",
-          "delete",
-          "meta",
-          "pull_request",
-          "pull_request_review",
-          "pull_request_review_comment",
-          "workflow_dispatch",
-          "workflow_run"
-        ],
-        "config": {
-          "content_type": "json",
-          "insecure_ssl": "0",
-          "url": "https://f92dbf01bd27.ngrok.io/gh/hook/"
-        },
-        "updated_at": "2021-07-11T02:15:28Z",
-        "created_at": "2021-07-11T02:15:28Z",
-        "app_id": 125988,
-        "deliveries_url": "https://api.github.com/app/hook/deliveries"
-      }
-    }
+    post '/github', params: JSON.parse(file_fixture("webhooks/app.json").read)
 
     assert_response :no_content
   end
test/fixtures/files/webhooks/app.json
@@ -0,0 +1,30 @@
+{
+  "zen": "Design for failure.",
+  "hook_id": 306990071,
+  "hook": {
+    "type": "App",
+    "id": 306990071,
+    "name": "web",
+    "active": true,
+    "events": [
+      "commit_comment",
+      "create",
+      "delete",
+      "meta",
+      "pull_request",
+      "pull_request_review",
+      "pull_request_review_comment",
+      "workflow_dispatch",
+      "workflow_run"
+    ],
+    "config": {
+      "content_type": "json",
+      "insecure_ssl": "0",
+      "url": "https://f92dbf01bd27.ngrok.io/gh/hook/"
+    },
+    "updated_at": "2021-07-11T02:15:28Z",
+    "created_at": "2021-07-11T02:15:28Z",
+    "app_id": 125988,
+    "deliveries_url": "https://api.github.com/app/hook/deliveries"
+  }
+}