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
|
def remove
|
||||||
if CustomWizard::Template.remove(@wizard.id)
|
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
|
render json: success_json
|
||||||
else
|
else
|
||||||
render json: failed_json
|
render json: failed_json
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe CustomWizard::AdminWizardController do
|
||||||
fab!(:user1) { Fabricate(:user) }
|
fab!(:user1) { Fabricate(:user) }
|
||||||
fab!(:user2) { Fabricate(:user) }
|
fab!(:user2) { Fabricate(:user) }
|
||||||
let(:template) { get_wizard_fixture("wizard") }
|
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
|
before do
|
||||||
CustomWizard::Template.save(template, skip_jobs: true)
|
CustomWizard::Template.save(template, skip_jobs: true)
|
||||||
|
@ -40,12 +40,12 @@ describe CustomWizard::AdminWizardController do
|
||||||
expect(response.parsed_body['steps'].length).to eq(3)
|
expect(response.parsed_body['steps'].length).to eq(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "removes wizard templates" do
|
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')).not_to eq(nil)
|
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"
|
delete "/admin/wizards/wizard/#{template['id']}.json"
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(CustomWizard::Template.exists?(template['id'])).to eq(false)
|
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
|
end
|
||||||
|
|
||||||
it "saves wizard templates" do
|
it "saves wizard templates" do
|
||||||
|
|
Laden …
In neuem Issue referenzieren