mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
FIX: better handling of missing welcome topic in wizard (#6606)
This commit is contained in:
@ -3999,6 +3999,7 @@ en:
|
|||||||
|
|
||||||
introduction:
|
introduction:
|
||||||
title: "Introduction"
|
title: "Introduction"
|
||||||
|
disabled: "We couldn’t find any Welcome Topic. Create a topic with `Welcome to Discourse` as title to fix this issue."
|
||||||
|
|
||||||
fields:
|
fields:
|
||||||
welcome:
|
welcome:
|
||||||
|
@ -46,6 +46,9 @@ class Wizard
|
|||||||
@wizard.append_step('introduction') do |step|
|
@wizard.append_step('introduction') do |step|
|
||||||
introduction = IntroductionUpdater.new(@wizard.user)
|
introduction = IntroductionUpdater.new(@wizard.user)
|
||||||
|
|
||||||
|
if @wizard.completed_steps?('introduction') && !introduction.get_summary
|
||||||
|
step.disabled = true
|
||||||
|
else
|
||||||
step.add_field(id: 'welcome', type: 'textarea', required: true, value: introduction.get_summary)
|
step.add_field(id: 'welcome', type: 'textarea', required: true, value: introduction.get_summary)
|
||||||
|
|
||||||
step.on_update do |updater|
|
step.on_update do |updater|
|
||||||
@ -58,6 +61,7 @@ class Wizard
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@wizard.append_step('privacy') do |step|
|
@wizard.append_step('privacy') do |step|
|
||||||
locked = SiteSetting.login_required? && SiteSetting.invite_only?
|
locked = SiteSetting.login_required? && SiteSetting.invite_only?
|
||||||
|
@ -37,4 +37,36 @@ describe Wizard::Builder do
|
|||||||
expect(invites_step.disabled).to be_truthy
|
expect(invites_step.disabled).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'introduction step' do
|
||||||
|
let(:wizard) { Wizard::Builder.new(moderator).build }
|
||||||
|
let(:introduction_step) { wizard.steps.find { |s| s.id == 'introduction' } }
|
||||||
|
|
||||||
|
context 'step has not been completed' do
|
||||||
|
it 'enables the step' do
|
||||||
|
expect(introduction_step.disabled).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'step has been completed' do
|
||||||
|
before do
|
||||||
|
wizard = Wizard::Builder.new(moderator).build
|
||||||
|
introduction_step = wizard.steps.find { |s| s.id == 'introduction' }
|
||||||
|
|
||||||
|
# manually sets the step as completed
|
||||||
|
logger = StaffActionLogger.new(moderator)
|
||||||
|
logger.log_wizard_step(introduction_step)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'disables step if no welcome topic' do
|
||||||
|
expect(introduction_step.disabled).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'enables step if welcome topic is present' do
|
||||||
|
topic = Fabricate(:topic, title: 'Welcome to Discourse')
|
||||||
|
welcome_post = Fabricate(:post, topic: topic, raw: "this will be the welcome topic post\n\ncool!")
|
||||||
|
|
||||||
|
expect(introduction_step.disabled).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user