Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 02:30:28 +01:00
Add corresponding code to help pass test
Dieser Commit ist enthalten in:
Ursprung
1662ff166d
Commit
4449ab7aff
2 geänderte Dateien mit 6 neuen und 4 gelöschten Zeilen
|
@ -26,6 +26,8 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
|
|||
|
||||
def remove
|
||||
if CustomWizard::Template.remove(@wizard.id)
|
||||
related_custom_fields = CategoryCustomField.where(name: 'create_topic_wizard', value: @wizard.name)
|
||||
related_custom_fields.destroy_all
|
||||
render json: success_json
|
||||
else
|
||||
render json: failed_json
|
||||
|
|
|
@ -5,7 +5,7 @@ describe CustomWizard::AdminWizardController do
|
|||
fab!(:user1) { Fabricate(:user) }
|
||||
fab!(:user2) { Fabricate(:user) }
|
||||
let(:template) { get_wizard_fixture("wizard") }
|
||||
let(:category) { Fabricate(:category, custom_fields: { create_topic_wizard: "wizard" }) }
|
||||
let(:category) { Fabricate(:category, custom_fields: { create_topic_wizard: template['name'] }) }
|
||||
|
||||
before do
|
||||
CustomWizard::Template.save(template, skip_jobs: true)
|
||||
|
@ -40,12 +40,12 @@ describe CustomWizard::AdminWizardController do
|
|||
expect(response.parsed_body['steps'].length).to eq(3)
|
||||
end
|
||||
|
||||
it "removes wizard templates" do
|
||||
expect(CategoryCustomField.find_by(category_id: category.id, name: 'create_topic_wizard')).not_to eq(nil)
|
||||
it "removes wizard templates and make sure create_topic_wizard settings for that wizard are removed from Categories" do
|
||||
expect(CategoryCustomField.find_by(category_id: category.id, name: 'create_topic_wizard', value: template['name'])).not_to eq(nil)
|
||||
delete "/admin/wizards/wizard/#{template['id']}.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(CustomWizard::Template.exists?(template['id'])).to eq(false)
|
||||
expect(CategoryCustomField.find_by(category_id: category.id, name: 'create_topic_wizard')).to eq(nil)
|
||||
expect(CategoryCustomField.find_by(name: 'create_topic_wizard', value: template['name'])).to eq(nil)
|
||||
end
|
||||
|
||||
it "saves wizard templates" do
|
||||
|
|
Laden …
In neuem Issue referenzieren