added more specs and fixed formatting
Dieser Commit ist enthalten in:
Ursprung
c1481e2ad4
Commit
dec5f5b5ce
2 geänderte Dateien mit 30 neuen und 3 gelöschten Zeilen
|
@ -9,7 +9,7 @@ module CustomWizardGuardian
|
|||
end
|
||||
|
||||
def can_create_post?(parent)
|
||||
result = parent.present? ? wizard_user_can_create_topic_on_category?(parent) : false
|
||||
result = parent.present? ? wizard_user_can_create_topic_on_category?(parent) : false
|
||||
result || super
|
||||
end
|
||||
|
||||
|
@ -23,7 +23,7 @@ module CustomWizardGuardian
|
|||
def creating_wizard(topic)
|
||||
wizard_id = topic.wizard_created.presence
|
||||
wizard = CustomWizard::Builder.new(wizard_id, @user).build if wizard_id
|
||||
return wizard.presence
|
||||
wizard.presence
|
||||
end
|
||||
|
||||
def wizard_can_create_topic_on_category?(wizard, topic)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
require_relative '../plugin_helper'
|
||||
|
||||
describe ::Guardian do
|
||||
fab!(:user) {
|
||||
fab!(:user) {
|
||||
Fabricate(:user, name: "Angus", username: 'angus', email: "angus@email.com")
|
||||
}
|
||||
fab!(:category) { Fabricate(:category, name: 'cat1', slug: 'cat-slug') }
|
||||
|
@ -65,4 +65,31 @@ describe ::Guardian do
|
|||
expect(user.guardian.send(:wizard_user_can_create_topic_on_category?, topic)).to be_falsey
|
||||
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
|
||||
|
|
Laden …
In neuem Issue referenzieren