mirror of
https://github.com/discourse/discourse.git
synced 2025-03-30 16:15:36 +08:00
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)
|
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
|
end
|
||||||
|
|
||||||
def start_advanced_track
|
def start_advanced_track
|
||||||
|
@ -303,6 +303,30 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
|||||||
)
|
)
|
||||||
end
|
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
|
describe 'when user replies to the topic' do
|
||||||
it 'should create the right reply' do
|
it 'should create the right reply' do
|
||||||
narrative.set_data(user, narrative.get_data(user).merge(
|
narrative.set_data(user, narrative.get_data(user).merge(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user