Skip to content
Snippets Groups Projects
Unverified Commit 0dbdb60e authored by Cam Saul's avatar Cam Saul
Browse files

Use middleware impl for test util fn bind-current-user

parent c97e4c2a
No related branches found
No related tags found
No related merge requests found
......@@ -4,8 +4,8 @@
[metabase
[config :as config]
[http-client :as http]
[middleware :as middleware]
[util :as u]]
[metabase.api.common :as api]
[metabase.core.initialization-status :as init-status]
[metabase.models.user :as user :refer [User]]
[toucan.db :as db])
......@@ -166,11 +166,7 @@
(defn do-with-test-user
"Call `f` with various `metabase.api.common` dynamic vars bound to the test User named by `user-kwd`."
[user-kwd f]
(binding [api/*current-user* (delay (User (user->id user-kwd)))
api/*current-user-id* (user->id user-kwd)
api/*is-superuser?* (db/select-one-field :is_superuser User :id (user->id user-kwd))
api/*current-user-permissions-set* (delay (user/permissions-set (user->id user-kwd)))]
(f)))
((middleware/bind-current-user (fn [_] (f))) {:metabase-user-id (user->id user-kwd)}))
(defmacro with-test-user
"Call `body` with various `metabase.api.common` dynamic vars like `*current-user*` bound to the test User named by
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment