FIX: Show 'emails disabled' to staff users when disabled for non-staff (#7187)

FIX: Show ‘emails disabled’ to staff users when disabled for non-staff (#7187)

diff --git a/app/assets/javascripts/discourse/components/global-notice.js.es6 b/app/assets/javascripts/discourse/components/global-notice.js.es6
index 0a506cb..e59fb08 100644
--- a/app/assets/javascripts/discourse/components/global-notice.js.es6
+++ b/app/assets/javascripts/discourse/components/global-notice.js.es6
@@ -25,8 +25,7 @@ export default Ember.Component.extend(
 
       if (
         this.siteSettings.disable_emails === "yes" ||
-        (this.siteSettings.disable_emails === "non-staff" &&
-          !(this.currentUser && this.currentUser.get("staff")))
+        this.siteSettings.disable_emails === "non-staff"
       ) {
         notices.push([I18n.t("emails_are_disabled"), "alert-emails-disabled"]);
       }
diff --git a/test/javascripts/acceptance/email-notice-test.js.es6 b/test/javascripts/acceptance/email-notice-test.js.es6
new file mode 100644
index 0000000..be496da
--- /dev/null
+++ b/test/javascripts/acceptance/email-notice-test.js.es6
@@ -0,0 +1,28 @@
+import { acceptance } from "helpers/qunit-helpers";
+
+acceptance("Email Disabled Banner", {
+  loggedIn: true
+});
+
+QUnit.test("shows banner when required", async assert => {
+  Discourse.SiteSettings.disable_email = "no";
+  await visit("/");
+  assert.notOk(
+    exists(".alert-emails-disabled"),
+    "alert is not displayed when email enabled"
+  );
+
+  Discourse.SiteSettings.disable_email = "yes";
+  await visit("/");
+  assert.notOk(
+    exists(".alert-emails-disabled"),
+    "alert is displayed when email disabled"
+  );
+
+  Discourse.SiteSettings.disable_email = "non-staff";
+  await visit("/");
+  assert.notOk(
+    exists(".alert-emails-disabled"),
+    "alert is displayed when email disabled for non-staff"
+  );
+});

GitHub sha: acc121fd

2 Likes

I realised that the tests I added aren’t actually testing anything properly. Will fix

2 Likes

DEV: Correct email disabled banner tests