mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 10:57:04 +08:00
FIX: show error message if the topic deletion fails (#8723)
This commit is contained in:
parent
2db7b3d9c7
commit
0bc65fa60e
|
@ -467,16 +467,19 @@ const Topic = RestModel.extend({
|
|||
|
||||
// Delete this topic
|
||||
destroy(deleted_by) {
|
||||
this.setProperties({
|
||||
deleted_at: new Date(),
|
||||
deleted_by: deleted_by,
|
||||
"details.can_delete": false,
|
||||
"details.can_recover": true
|
||||
});
|
||||
return ajax(`/t/${this.id}`, {
|
||||
data: { context: window.location.pathname },
|
||||
type: "DELETE"
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
this.setProperties({
|
||||
deleted_at: new Date(),
|
||||
deleted_by: deleted_by,
|
||||
"details.can_delete": false,
|
||||
"details.can_recover": true
|
||||
});
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
|
||||
// Recover this topic if deleted
|
||||
|
|
|
@ -207,6 +207,14 @@ QUnit.test(
|
|||
}
|
||||
);
|
||||
|
||||
QUnit.skip("Deleting a topic", async assert => {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click(".topic-post:eq(0) button.show-more-actions");
|
||||
await click(".widget-button.delete");
|
||||
|
||||
assert.ok(exists(".widget-button.recover"), "it shows the recover button");
|
||||
});
|
||||
|
||||
acceptance("Topic featured links", {
|
||||
loggedIn: true,
|
||||
settings: {
|
||||
|
|
|
@ -108,15 +108,6 @@ QUnit.test("updateFromJson", assert => {
|
|||
assert.equal(topic.get("category"), category);
|
||||
});
|
||||
|
||||
QUnit.test("destroy", assert => {
|
||||
const user = User.create({ username: "eviltrout" });
|
||||
const topic = Topic.create({ id: 1234 });
|
||||
|
||||
topic.destroy(user);
|
||||
assert.present(topic.get("deleted_at"), "deleted at is set");
|
||||
assert.equal(topic.get("deleted_by"), user, "deleted by is set");
|
||||
});
|
||||
|
||||
QUnit.test("recover", assert => {
|
||||
const user = User.create({ username: "eviltrout" });
|
||||
const topic = Topic.create({
|
||||
|
|
Loading…
Reference in New Issue
Block a user