FIX: Recover post tutorial does not work when `SiteSetting.delete_removed_posts_after` is 0.
This commit is contained in:
parent
a6450f7377
commit
f8a46c510f
|
@ -144,7 +144,23 @@ module DiscourseNarrativeBot
|
|||
})
|
||||
|
||||
set_state_data(:post_id, post.id)
|
||||
PostDestroyer.new(@user, post, skip_bot: true).destroy
|
||||
|
||||
opts = { skip_bot: true }
|
||||
|
||||
if SiteSetting.delete_removed_posts_after < 1
|
||||
opts[:delete_removed_posts_after] = 1
|
||||
|
||||
# Flag it and defer so the stub doesn't get destroyed
|
||||
flag = PostAction.create!(
|
||||
user: self.discobot_user,
|
||||
post: post, post_action_type_id:
|
||||
PostActionType.types[:off_topic]
|
||||
)
|
||||
|
||||
PostAction.defer_flags!(post, self.discobot_user)
|
||||
end
|
||||
|
||||
PostDestroyer.new(@user, post, opts).destroy
|
||||
end
|
||||
|
||||
def start_advanced_track
|
||||
|
|
|
@ -303,6 +303,30 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
|||
)
|
||||
end
|
||||
|
||||
describe 'when posts are configured to be deleted immediately' do
|
||||
before do
|
||||
SiteSetting.delete_removed_posts_after = 0
|
||||
end
|
||||
|
||||
it 'should set up the tutorial correctly' do
|
||||
narrative.set_data(user,
|
||||
state: :tutorial_delete,
|
||||
topic_id: topic.id,
|
||||
track: described_class.to_s
|
||||
)
|
||||
|
||||
PostDestroyer.new(user, post).destroy
|
||||
|
||||
post = Post.last
|
||||
|
||||
expect(post.raw).to eq(I18n.t('js.post.deleted_by_author', count: 1))
|
||||
|
||||
PostDestroyer.destroy_stubs
|
||||
|
||||
expect(post.reload).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when user replies to the topic' do
|
||||
it 'should create the right reply' do
|
||||
narrative.set_data(user, narrative.get_data(user).merge(
|
||||
|
|
Loading…
Reference in New Issue