mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 19:29:34 +08:00
FIX: Skip poll tutorial if user cannot create polls (#9058)
This commit is contained in:
@ -82,7 +82,7 @@ module DiscourseNarrativeBot
|
|||||||
},
|
},
|
||||||
|
|
||||||
tutorial_poll: {
|
tutorial_poll: {
|
||||||
prerequisite: Proc.new { SiteSetting.poll_enabled },
|
prerequisite: Proc.new { SiteSetting.poll_enabled && @user.has_trust_level?(SiteSetting.poll_minimum_trust_level_to_create) },
|
||||||
next_state: :tutorial_details,
|
next_state: :tutorial_details,
|
||||||
next_instructions: Proc.new { I18n.t("#{I18N_KEY}.details.instructions", i18n_post_args) },
|
next_instructions: Proc.new { I18n.t("#{I18N_KEY}.details.instructions", i18n_post_args) },
|
||||||
reply: {
|
reply: {
|
||||||
|
@ -556,12 +556,29 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'when poll is disabled' do
|
describe 'when user cannot create polls' do
|
||||||
before do
|
it 'should create the right reply (polls disabled)' do
|
||||||
SiteSetting.poll_enabled = false
|
SiteSetting.poll_enabled = false
|
||||||
|
|
||||||
|
TopicUser.change(
|
||||||
|
user.id,
|
||||||
|
topic.id,
|
||||||
|
notification_level: TopicUser.notification_levels[:tracking]
|
||||||
|
)
|
||||||
|
|
||||||
|
expected_raw = <<~RAW
|
||||||
|
#{I18n.t('discourse_narrative_bot.advanced_user_narrative.change_topic_notification_level.reply', base_uri: '')}
|
||||||
|
|
||||||
|
#{I18n.t('discourse_narrative_bot.advanced_user_narrative.details.instructions', base_uri: '')}
|
||||||
|
RAW
|
||||||
|
|
||||||
|
expect(Post.last.raw).to eq(expected_raw.chomp)
|
||||||
|
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_details)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should create the right reply' do
|
it 'should create the right reply (insufficient trust level)' do
|
||||||
|
user.update(trust_level: 0)
|
||||||
|
|
||||||
TopicUser.change(
|
TopicUser.change(
|
||||||
user.id,
|
user.id,
|
||||||
topic.id,
|
topic.id,
|
||||||
|
Reference in New Issue
Block a user