A platform for community discussion. Free, open, simple.
DEV: Apply code review.
Bianca Nenciub585f7f33635
diff --git a/app/assets/javascripts/admin/controllers/admin-email-advanced-test.js.es6 b/app/assets/javascripts/admin/controllers/admin-email-advanced-test.js.es6index 2f9084b3641..34b2d7b049c 100644--- a/app/assets/javascripts/admin/controllers/admin-email-advanced-test.js.es6+++ b/app/assets/javascripts/admin/controllers/admin-email-advanced-test.js.es6@@ -6,6 +6,7 @@ export default Ember.Controller.extend({text: null,elided: null,format: null,+ loading: null,actions: {run() {diff --git a/app/assets/javascripts/admin/templates/email-advanced-test.hbs b/app/assets/javascripts/admin/templates/email-advanced-test.hbsindex 2fc02adeadc..4a300602bd3 100644--- a/app/assets/javascripts/admin/templates/email-advanced-test.hbs+++ b/app/assets/javascripts/admin/templates/email-advanced-test.hbs@@ -2,7 +2,7 @@<div class='email-advanced-test'><label for="email">{{i18n 'admin.email.advanced_test.email'}}</label>- {{textarea name="email" value=email class="advanced-test"}}+ {{textarea name="email" value=email class="email-body"}}<button class='btn' {{action "run"}}>{{i18n 'admin.email.advanced_test.run'}}</button></div>diff --git a/app/assets/stylesheets/common/admin/emails.scss b/app/assets/stylesheets/common/admin/emails.scssindex 6be0f2bb2e4..732f3d40bb1 100644--- a/app/assets/stylesheets/common/admin/emails.scss+++ b/app/assets/stylesheets/common/admin/emails.scss@@ -89,7 +89,7 @@display: block;}- textarea {+ .email-body {width: 95%;height: 150px;font-family: monospace;diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex e1cad513213..201668125fe 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -3415,7 +3415,7 @@ en:preview_digest: "Preview Summary"advanced_test:title: "Advanced Test"- desc: "See how Discourse processes recieved emails. To be able to correctly process the email, please paste below the whole original email message."+ desc: "See how Discourse processes received emails. To be able to correctly process the email, please paste below the whole original email message."email: "Original message"run: "Run Test"text: "Selected Text Body"diff --git a/spec/requests/admin/email_controller_spec.rb b/spec/requests/admin/email_controller_spec.rbindex a6d30ba958f..3df6f3a0342 100644--- a/spec/requests/admin/email_controller_spec.rb+++ b/spec/requests/admin/email_controller_spec.rb@@ -184,4 +184,28 @@ describe Admin::EmailController doexpect(incoming['error']).to eq(I18n.t("emails.incoming.unrecognized_error"))endend++ describe '#advanced_test' do+ it 'should ...' do+ email = <<~EMAIL+ From: "somebody" <[email protected]>+ To: [email protected]+ Date: Mon, 3 Dec 2018 00:00:00 -0000+ Subject: This is some subject+ Content-Type: text/plain; charset="UTF-8"++ Hello, this is a test!++ ---++ This part should be elided.+ post "/admin/email/advanced-test.json", params: { email: email }+ expect(response.status).to eq(200)+ incoming = JSON.parse(response.body)+ expect(incoming['format']).to eq(1)+ expect(incoming['text']).to eq("Hello, this is a test!")+ expect(incoming['elided']).to eq("---\n\nThis part should be elided.")+ end+ endenddiff --git a/test/javascripts/acceptance/admin-emails-test.js.es6 b/test/javascripts/acceptance/admin-emails-test.js.es6new file mode 100644index 00000000000..f44cf638e91--- /dev/null+++ b/test/javascripts/acceptance/admin-emails-test.js.es6@@ -0,0 +1,41 @@+import { acceptance } from "helpers/qunit-helpers";++acceptance("Admin - Emails", { loggedIn: true });++const email = `+From: "somebody" <[email protected]>+To: [email protected]+Date: Mon, 3 Dec 2018 00:00:00 -0000+Subject: This is some subject+Content-Type: text/plain; charset="UTF-8"++Hello, this is a test!++---++This part should be elided.`.trim();++QUnit.test("shows selected and elided text", async assert => {+ // prettier-ignore+ server.post("/admin/email/advanced-test", () => { // eslint-disable-line no-undef+ return [+ 200,+ { "Content-Type": "application/json" },+ {+ format: 1,+ text: "Hello, this is a test!",+ elided: "---\n\nThis part should be elided.",+ }+ ];+ });++ await visit("/admin/email/advanced-test");+ await fillIn("textarea.email-body", email);+ await click(".email-advanced-test button");++ assert.equal(find(".text pre").text(), "Hello, this is a test!");+ assert.equal(+ find(".elided pre").text(),+ "---\n\nThis part should be elided."+ );+});