0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00

added more specs and fixed formatting

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-10-30 16:03:30 +05:30
Ursprung c1481e2ad4
Commit dec5f5b5ce
2 geänderte Dateien mit 30 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -23,7 +23,7 @@ module CustomWizardGuardian
def creating_wizard(topic) def creating_wizard(topic)
wizard_id = topic.wizard_created.presence wizard_id = topic.wizard_created.presence
wizard = CustomWizard::Builder.new(wizard_id, @user).build if wizard_id wizard = CustomWizard::Builder.new(wizard_id, @user).build if wizard_id
return wizard.presence wizard.presence
end end
def wizard_can_create_topic_on_category?(wizard, topic) def wizard_can_create_topic_on_category?(wizard, topic)

Datei anzeigen

@ -65,4 +65,31 @@ describe ::Guardian do
expect(user.guardian.send(:wizard_user_can_create_topic_on_category?, topic)).to be_falsey expect(user.guardian.send(:wizard_user_can_create_topic_on_category?, topic)).to be_falsey
end end
end end
context "the wizard can't create a topic in the category" do
it "restricts editing the topic first post" do
wizard = CustomWizard::Builder.new(@template[:id], user).build
wizard.create_updater(
wizard.steps.first.id,
step_1_field_1: "Topic Title",
step_1_field_2: "topic body"
).update
wizard.create_updater(wizard.steps.second.id, {}).update
wizard.create_updater(wizard.steps.last.id,
step_3_field_3: category.id
).update
topic = Topic.where(
title: "Topic Title",
category_id: category.id
).first
new_category = Fabricate(:category)
topic.category_id = new_category.id
topic.save
topic.reload
expect(user.guardian.send(:wizard_user_can_create_topic_on_category?, topic)).to be_falsey
end
end
end end