FIX: Generate webhook payloads before destroy events (#6325)

This commit is contained in:
Vinoth Kannan
2018-10-05 14:23:59 +05:30
committed by Guo Xiang Tan
parent 5b630f3188
commit 8430ea927e
11 changed files with 90 additions and 29 deletions

View File

@@ -424,6 +424,16 @@ describe PostDestroyer do
}.to_not change { author.topic_count }
expect(author.post_count).to eq(0) # also unchanged
end
it 'triggers the extensibility events' do
events = DiscourseEvent.track_events { PostDestroyer.new(admin, first_post).destroy }.last(2)
expect(events[0][:event_name]).to eq(:post_destroyed)
expect(events[0][:params].first).to eq(first_post)
expect(events[1][:event_name]).to eq(:topic_destroyed)
expect(events[1][:params].first).to eq(first_post.topic)
end
end
context 'deleting the second post in a topic' do
@@ -502,6 +512,13 @@ describe PostDestroyer do
it "creates a new user history entry" do
expect { subject }.to change { UserHistory.count }.by(1)
end
it 'triggers a extensibility event' do
events = DiscourseEvent.track_events { subject }
expect(events[0][:event_name]).to eq(:post_destroyed)
expect(events[0][:params].first).to eq(post)
end
end
end