From 2f3c8eb28322e3431a2de4e9b8a97fbf2dc1f6f1 Mon Sep 17 00:00:00 2001
From: Allen Gilliland <agilliland@gmail.com>
Date: Wed, 11 Nov 2015 10:31:00 -0800
Subject: [PATCH] automatically set the admin-email setting to the email
 address of the first user during setup.

---
 src/metabase/api/setup.clj       |  1 +
 test/metabase/api/setup_test.clj | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/metabase/api/setup.clj b/src/metabase/api/setup.clj
index d24a375458c..2e9f4659da9 100644
--- a/src/metabase/api/setup.clj
+++ b/src/metabase/api/setup.clj
@@ -42,6 +42,7 @@
     (set-user-password (:id new-user) password)
     ;; set a couple preferences
     (setting/set :site-name site_name)
+    (setting/set :admin-email email)
     (setting/set :anon-tracking-enabled (or allow_tracking "true"))
     ;; setup database (if needed)
     (when (driver/is-engine? engine)
diff --git a/test/metabase/api/setup_test.clj b/test/metabase/api/setup_test.clj
index 9daf4c723af..804d3a70e6e 100644
--- a/test/metabase/api/setup_test.clj
+++ b/test/metabase/api/setup_test.clj
@@ -4,6 +4,7 @@
             [metabase.db :refer :all]
             [metabase.http-client :as http]
             (metabase.models [session :refer [Session]]
+                             [setting :as setting]
                              [user :refer [User]])
             [metabase.setup :as setup]
             (metabase.test [data :refer :all]
@@ -14,10 +15,11 @@
 ;; Check that we can create a new superuser via setup-token
 (let [user-name (random-name)]
   (expect-eval-actual-first
-    (match-$ (->> (sel :one User :email (str user-name "@metabase.com"))
-               (:id)
-               (sel :one Session :user_id))
+    [(match-$ (->> (sel :one User :email (str user-name "@metabase.com"))
+                  (:id)
+                  (sel :one Session :user_id))
       {:id $id})
+     (str user-name "@metabase.com")]
     (let [resp (http/client :post 200 "setup" {:token (setup/token-create)
                                                :prefs {:site_name "Metabase Test"}
                                                :user  {:first_name user-name
@@ -27,7 +29,7 @@
       ;; reset our setup token
       (setup/token-create)
       ;; return api response
-      resp)))
+      [resp (setting/get :admin-email)])))
 
 
 ;; Test input validations
-- 
GitLab