mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
FIX: poll builder should ignore empty lines
Although pollOptionsCount skips empty lines, pollOutput inserts empty lines. Skip them instead. Signed-off-by: Loic Dachary <loic@dachary.org>
This commit is contained in:
@ -111,7 +111,9 @@ export default Ember.Controller.extend({
|
|||||||
output += `${pollHeader}\n`;
|
output += `${pollHeader}\n`;
|
||||||
|
|
||||||
if (pollOptions.length > 0 && !isNumber) {
|
if (pollOptions.length > 0 && !isNumber) {
|
||||||
output += `${pollOptions.split("\n").map(option => `* ${option}`).join("\n")}\n`;
|
pollOptions.split("\n").forEach(option => {
|
||||||
|
if (option.length !== 0) output += `* ${option}\n`;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
output += '[/poll]';
|
output += '[/poll]';
|
||||||
|
@ -210,7 +210,7 @@ test("multiple pollOutput", function() {
|
|||||||
isMultiple: true,
|
isMultiple: true,
|
||||||
pollType: controller.get("multiplePollType"),
|
pollType: controller.get("multiplePollType"),
|
||||||
pollMin: 1,
|
pollMin: 1,
|
||||||
pollOptions: "1\n2"
|
pollOptions: "\n\n1\n\n2"
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(controller.get("pollOutput"), "[poll type=multiple min=1 max=2]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
equal(controller.get("pollOutput"), "[poll type=multiple min=1 max=2]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||||
|
Reference in New Issue
Block a user