 
 (deftest delete-visits-id-exists
     (testing "DELETE /visits/<someid> (existing entry)"
-      (let [visits (:visits cts/*system*)
-            visit-routes (vhosts-model [:* (sut/visit-routes visits)])
-            handler (make-handler visit-routes)
-            create-request (mock/json-body (mock/request :post "/visits") example-visit)
-            create-response @(handler create-request)
+      (let [create-request (mock/json-body (mock/request :post "/visits") example-visit)
+            create-response @(*handler* create-request)
             location (get-in create-response [:headers "location"])
             delete-request (mock/request :delete location)
-            delete-response @(handler delete-request)
+            delete-response @(*handler* delete-request)
             get-request (mock/request :get location)
-            get-response @(handler get-request)]
+            get-response @(*handler* get-request)]
         (is (= 204 (:status delete-response)))
         (is (= 404 (:status get-response))))))
 
 (deftest delete-visits-id-does-not-exist
   (testing "DELETE /visits/<id> (<id> doesn't exist)"
-    (let [visits (:visits cts/*system*)
-          visit-routes (vhosts-model [:* (sut/visit-routes visits)])
-          handler (make-handler visit-routes)
-          delete-request (mock/request :delete "/visits/0")
-          delete-response @(handler delete-request)]
+    (let [delete-request (mock/request :delete "/visits/0")
+          delete-response @(*handler* delete-request)]
       (is (= 204 (:status delete-response))))))

    :visits (sut/new-visits))
   {:visits {:db :db}}))

(t/use-fixtures :once schema.test/validate-schemas)
(t/use-fixtures :each
  (cts/with-system-fixture test-system)
  (cts/with-transaction-fixture [:visits :db :spec]))

(s/def example-visit :- m/Visit
  "Minimally-defined visit for our testing purposes"


(deftest create-visits-invalid-data
  (testing "POST /visits (invalid data)"
    (let [request (mock/json-body (mock/request :post "/visits") {})
          response @(*handler* request)]
      (is (= 400 (:status response))))))

(deftest list-visits-no-entries-yet
  (testing "GET /visits (no entries yet)"
    (let [request (mock/json-body (mock/request :get "/visits") {})
          response @(*handler* request)]
      (is (= 200 (:status response)))
      (is (= {:data []} (parse-string (bs/to-string (:body response)) keyword))))))

(deftest list-visits-entries-exist
  (testing "Get /visits (a couple of entries)"
    (let [numtimes 2
          _ (dotimes [_ numtimes]
              @(*handler* (mock/json-body (mock/request :post "/visits") example-visit)))
          list-request (mock/request :get "/visits")
          list-response @(*handler* list-request)
          list-body (:data (parse-string (bs/to-string (:body list-response)) keyword))]
      (is (= 200 (:status list-response)))
      (is (= numtimes (count list-body)))
