FIX: deleting a flagged post issue

cf. http://meta.discourse.org/t/deleting-a-flagged-post-issue/10061

The bug was only happening when you were about the delete the first post, which means deleting the entire topic.
This commit is contained in:
Régis Hanol
2013-10-02 16:59:57 +02:00
parent 7caefded86
commit af96ef2994
8 changed files with 26 additions and 8 deletions

View File

@ -0,0 +1,19 @@
module("Discourse.FlaggedPost");
test('delete first post', function() {
this.stub(Discourse, 'ajax');
Discourse.FlaggedPost.create({ id: 1, topic_id: 2, post_number: 1 })
.deletePost();
ok(Discourse.ajax.calledWith("/t/2", { type: 'DELETE', cache: false }), "it deleted the topic");
});
test('delete second post', function() {
this.stub(Discourse, 'ajax');
Discourse.FlaggedPost.create({ id: 1, topic_id: 2, post_number: 2 })
.deletePost();
ok(Discourse.ajax.calledWith("/posts/1", { type: 'DELETE', cache: false }), "it deleted the post");
});