     :visits (sut/new-visits))
    {:visits {:db :db}}))
 
+(defn include-handler [f]
+  (let [visits (:visits cts/*system*)
+        handler (make-handler (vhosts-model [:* (sut/visit-routes visits)]))]
+    (binding [*handler* handler]
+      (f))))
+
 (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]))
+  (cts/with-transaction-fixture [:visits :db :spec])
+  include-handler)
 
 (s/def example-visit :- m/Visit
   "Minimally-defined visit for our testing purposes"


(deftest update-visits-entry-exists
  (testing "PUT /visits/<id> (<id> existed already)"
    (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)
          location (get-in @(handler create-request) [:headers "location"])
          put-body (assoc example-visit :cafe_name "Updated Café")
          put-request (mock/json-body (mock/request :put location) put-body)
          put-response @(handler put-request)]
      (is (= 204 (:status put-response))))))

(deftest update-visits-entry-does-not-exist
  (testing "PUT /visits/<id> (<id> doesn't exist)"
    (let [visits (:visits cts/*system*)
          visit-routes (vhosts-model [:* (sut/visit-routes visits)])
          put-handler (make-handler visit-routes)
          put-body (-> example-visit (assoc :id 0) (assoc :cafe_name "Updated Café"))
          put-request (mock/json-body (mock/request :put "/visits/0") put-body)
          put-response @(put-handler put-request)]
      (is (= 404 (:status put-response))))))

(deftest update-visits-invalid-data


(deftest delete-visits-id-exists
    (testing "DELETE /visits/<someid> (existing entry)"
      (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)
            get-request (mock/request :get location)
            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 [delete-request (mock/request :delete "/visits/0")
          delete-response @(*handler* delete-request)]
      (is (= 204 (:status delete-response))))))
