mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 22:34:37 +08:00
FIX: Do not show bootbox if post has no replies. (#7866)
When we delete a post that has replies, we show a modal asking if the user wants to delete the post, the post and its direct replies or the post and all its replies. If replies are deleted before a post, that modal would ask the user if they want to delete the post and 0 replies. That commit ensure we skip the modal and directly delete the post in this case.
This commit is contained in:

committed by
Régis Hanol

parent
22e2631f29
commit
c4d1833588
@ -511,3 +511,42 @@ QUnit.test("topVisibleChanged", function(assert) {
|
||||
"it should work with a post-placehodler"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"deletePost - no modal is shown if post does not have replies",
|
||||
function(assert) {
|
||||
/* global server */
|
||||
server.get("/posts/2/reply-ids.json", () => {
|
||||
return [200, { "Content-Type": "application/json" }, []];
|
||||
});
|
||||
|
||||
let destroyed;
|
||||
const post = Ember.Object.create({
|
||||
id: 2,
|
||||
post_number: 2,
|
||||
can_delete: true,
|
||||
reply_count: 3,
|
||||
destroy: () => {
|
||||
destroyed = true;
|
||||
return Ember.RSVP.Promise.resolve();
|
||||
}
|
||||
});
|
||||
|
||||
const postStream = Ember.Object.create({
|
||||
stream: [2, 3, 4],
|
||||
posts: [post, { id: 3 }, { id: 4 }]
|
||||
});
|
||||
|
||||
const currentUser = Ember.Object.create({ staff: true });
|
||||
const model = Topic.create({ postStream });
|
||||
const controller = this.subject({ model, currentUser });
|
||||
|
||||
const done = assert.async();
|
||||
controller.send("deletePost", post);
|
||||
|
||||
Ember.run.next(() => {
|
||||
assert.ok(destroyed, "post was destroyed");
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Reference in New Issue
Block a user