Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
Merge pull request #255 from paviliondev/remove_category_custom_field_on_wizard_delete
FIX: ensure related create topic wizard setting is removed when wizard is deleted
Dieser Commit ist enthalten in:
Commit
33da03b63a
3 geänderte Dateien mit 7 neuen und 2 gelöschten Zeilen
|
@ -64,6 +64,8 @@ class CustomWizard::Template
|
||||||
ensure_wizard_upload_references!(wizard_id)
|
ensure_wizard_upload_references!(wizard_id)
|
||||||
PluginStore.remove(CustomWizard::PLUGIN_NAME, wizard.id)
|
PluginStore.remove(CustomWizard::PLUGIN_NAME, wizard.id)
|
||||||
clear_user_wizard_redirect(wizard_id, after_time: !!wizard.after_time)
|
clear_user_wizard_redirect(wizard_id, after_time: !!wizard.after_time)
|
||||||
|
related_custom_fields = CategoryCustomField.where(name: 'create_topic_wizard', value: wizard.name)
|
||||||
|
related_custom_fields.destroy_all
|
||||||
end
|
end
|
||||||
|
|
||||||
clear_cache_keys
|
clear_cache_keys
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
# name: discourse-custom-wizard
|
# name: discourse-custom-wizard
|
||||||
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
|
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
|
||||||
# version: 2.4.12
|
# version: 2.4.13
|
||||||
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
|
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
|
||||||
# url: https://github.com/paviliondev/discourse-custom-wizard
|
# url: https://github.com/paviliondev/discourse-custom-wizard
|
||||||
# contact_emails: development@pavilion.tech
|
# contact_emails: development@pavilion.tech
|
||||||
|
|
|
@ -5,6 +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: template['name'] }) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
CustomWizard::Template.save(template, skip_jobs: true)
|
CustomWizard::Template.save(template, skip_jobs: true)
|
||||||
|
@ -39,10 +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 whilst making 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"
|
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(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