mirror of
https://github.com/discourse/discourse.git
synced 2025-03-20 05:41:58 +08:00
DEV: Apply code review.
This commit is contained in:
parent
56890efd7a
commit
b585f7f336
@ -6,6 +6,7 @@ export default Ember.Controller.extend({
|
||||
text: null,
|
||||
elided: null,
|
||||
format: null,
|
||||
loading: null,
|
||||
|
||||
actions: {
|
||||
run() {
|
||||
|
@ -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>
|
||||
|
||||
|
@ -89,7 +89,7 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
textarea {
|
||||
.email-body {
|
||||
width: 95%;
|
||||
height: 150px;
|
||||
font-family: monospace;
|
||||
|
@ -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"
|
||||
|
@ -184,4 +184,28 @@ describe Admin::EmailController do
|
||||
expect(incoming['error']).to eq(I18n.t("emails.incoming.unrecognized_error"))
|
||||
end
|
||||
end
|
||||
|
||||
describe '#advanced_test' do
|
||||
it 'should ...' do
|
||||
email = <<~EMAIL
|
||||
From: "somebody" <somebody@example.com>
|
||||
To: someone@example.com
|
||||
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.
|
||||
EMAIL
|
||||
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
|
||||
end
|
||||
end
|
||||
|
41
test/javascripts/acceptance/admin-emails-test.js.es6
Normal file
41
test/javascripts/acceptance/admin-emails-test.js.es6
Normal file
@ -0,0 +1,41 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Admin - Emails", { loggedIn: true });
|
||||
|
||||
const email = `
|
||||
From: "somebody" <somebody@example.com>
|
||||
To: someone@example.com
|
||||
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."
|
||||
);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user