Skip Discobot flag tutorial if `allow_flagging_staff` is disabled.

https://meta.discourse.org/t/interacting-with-discobot/96574
This commit is contained in:
Guo Xiang Tan 2018-09-07 08:33:27 +08:00
parent 3dea48f1d9
commit c1c9637b39
2 changed files with 17 additions and 0 deletions

View File

@ -95,6 +95,7 @@ module DiscourseNarrativeBot
},
tutorial_flag: {
prerequisite: Proc.new { SiteSetting.allow_flagging_staff },
next_state: :tutorial_search,
next_instructions: Proc.new { I18n.t("#{I18N_KEY}.search.instructions", base_uri: Discourse.base_uri) },
flag: {

View File

@ -401,6 +401,22 @@ describe DiscourseNarrativeBot::NewUserNarrative do
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_flag)
end
describe 'when allow_flagging_staff is false' do
it 'should go to the right state' do
SiteSetting.allow_flagging_staff = false
post.update!(raw: skip_trigger)
DiscourseNarrativeBot::TrackSelector.new(
:reply,
user,
post_id: post.id
).select
expect(narrative.get_data(user)[:state].to_sym)
.to eq(:tutorial_search)
end
end
end
end