From ec88af0cc0304aeb212163ac706311129bb7310b Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 18 Jul 2023 13:53:09 +0100 Subject: [PATCH 1/6] FIX: also delete Category Cust Fld for wizrds with names of mult words --- lib/custom_wizard/template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/custom_wizard/template.rb b/lib/custom_wizard/template.rb index 59a9998e..9fa197f7 100644 --- a/lib/custom_wizard/template.rb +++ b/lib/custom_wizard/template.rb @@ -64,7 +64,7 @@ class CustomWizard::Template ensure_wizard_upload_references!(wizard_id) PluginStore.remove(CustomWizard::PLUGIN_NAME, wizard.id) 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 = CategoryCustomField.where(name: 'create_topic_wizard', value: wizard.name.parameterize.underscore) related_custom_fields.destroy_all end From c26a89a78a724aa82188816efa366c799b5c33b2 Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 18 Jul 2023 14:05:09 +0100 Subject: [PATCH 2/6] fix test --- spec/requests/custom_wizard/admin/wizard_controller_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/requests/custom_wizard/admin/wizard_controller_spec.rb b/spec/requests/custom_wizard/admin/wizard_controller_spec.rb index 04884b49..7986f565 100644 --- a/spec/requests/custom_wizard/admin/wizard_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/wizard_controller_spec.rb @@ -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: template['name'] }) } + let(:category) { Fabricate(:category, custom_fields: { create_topic_wizard: template['name'].parameterize.underscore }) } before do CustomWizard::Template.save(template, skip_jobs: true) @@ -41,11 +41,11 @@ describe CustomWizard::AdminWizardController do end 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) + expect(CategoryCustomField.find_by(category_id: category.id, name: 'create_topic_wizard', value: template['name'].parameterize.underscore)).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(name: 'create_topic_wizard', value: template['name'])).to eq(nil) + expect(CategoryCustomField.find_by(name: 'create_topic_wizard', value: template['name'].parameterize.underscore)).to eq(nil) end it "saves wizard templates" do From ec739d04509366b88648b7ac9ad9a6e4d71a898c Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 18 Jul 2023 14:06:16 +0100 Subject: [PATCH 3/6] bump patch --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index d6a77bba..018ce629 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-custom-wizard # about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more. -# version: 2.4.14 +# version: 2.4.15 # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos # url: https://github.com/paviliondev/discourse-custom-wizard # contact_emails: development@pavilion.tech From 609df3368032fd4ac7e88d0e1d18aab9d7ed2659 Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 18 Jul 2023 14:29:39 +0100 Subject: [PATCH 4/6] downcase name for category cstm setting --- lib/custom_wizard/template.rb | 2 +- spec/requests/custom_wizard/admin/wizard_controller_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/custom_wizard/template.rb b/lib/custom_wizard/template.rb index 9fa197f7..aa4e2fcd 100644 --- a/lib/custom_wizard/template.rb +++ b/lib/custom_wizard/template.rb @@ -64,7 +64,7 @@ class CustomWizard::Template ensure_wizard_upload_references!(wizard_id) PluginStore.remove(CustomWizard::PLUGIN_NAME, wizard.id) clear_user_wizard_redirect(wizard_id, after_time: !!wizard.after_time) - related_custom_fields = CategoryCustomField.where(name: 'create_topic_wizard', value: wizard.name.parameterize.underscore) + related_custom_fields = CategoryCustomField.where(name: 'create_topic_wizard', value: wizard.name.parameterize.underscore.downcase) related_custom_fields.destroy_all end diff --git a/spec/requests/custom_wizard/admin/wizard_controller_spec.rb b/spec/requests/custom_wizard/admin/wizard_controller_spec.rb index 7986f565..2ec2da10 100644 --- a/spec/requests/custom_wizard/admin/wizard_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/wizard_controller_spec.rb @@ -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: template['name'].parameterize.underscore }) } + let(:category) { Fabricate(:category, custom_fields: { create_topic_wizard: template['name'].parameterize.underscore.downcase }) } before do CustomWizard::Template.save(template, skip_jobs: true) @@ -41,11 +41,11 @@ describe CustomWizard::AdminWizardController do end 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'].parameterize.underscore)).not_to eq(nil) + expect(CategoryCustomField.find_by(category_id: category.id, name: 'create_topic_wizard', value: template['name'].parameterize.underscore.downcase)).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(name: 'create_topic_wizard', value: template['name'].parameterize.underscore)).to eq(nil) + expect(CategoryCustomField.find_by(name: 'create_topic_wizard', value: template['name'].parameterize.underscore.downcase)).to eq(nil) end it "saves wizard templates" do From 3fe1a7c7e8c263e6eed6b09aaf85ce3368665aa1 Mon Sep 17 00:00:00 2001 From: merefield Date: Wed, 19 Jul 2023 09:23:48 +0100 Subject: [PATCH 5/6] remove redundant downcasing --- lib/custom_wizard/template.rb | 2 +- spec/requests/custom_wizard/admin/wizard_controller_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/custom_wizard/template.rb b/lib/custom_wizard/template.rb index aa4e2fcd..9fa197f7 100644 --- a/lib/custom_wizard/template.rb +++ b/lib/custom_wizard/template.rb @@ -64,7 +64,7 @@ class CustomWizard::Template ensure_wizard_upload_references!(wizard_id) PluginStore.remove(CustomWizard::PLUGIN_NAME, wizard.id) clear_user_wizard_redirect(wizard_id, after_time: !!wizard.after_time) - related_custom_fields = CategoryCustomField.where(name: 'create_topic_wizard', value: wizard.name.parameterize.underscore.downcase) + related_custom_fields = CategoryCustomField.where(name: 'create_topic_wizard', value: wizard.name.parameterize.underscore) related_custom_fields.destroy_all end diff --git a/spec/requests/custom_wizard/admin/wizard_controller_spec.rb b/spec/requests/custom_wizard/admin/wizard_controller_spec.rb index 2ec2da10..7986f565 100644 --- a/spec/requests/custom_wizard/admin/wizard_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/wizard_controller_spec.rb @@ -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: template['name'].parameterize.underscore.downcase }) } + let(:category) { Fabricate(:category, custom_fields: { create_topic_wizard: template['name'].parameterize.underscore }) } before do CustomWizard::Template.save(template, skip_jobs: true) @@ -41,11 +41,11 @@ describe CustomWizard::AdminWizardController do end 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'].parameterize.underscore.downcase)).not_to eq(nil) + expect(CategoryCustomField.find_by(category_id: category.id, name: 'create_topic_wizard', value: template['name'].parameterize.underscore)).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(name: 'create_topic_wizard', value: template['name'].parameterize.underscore.downcase)).to eq(nil) + expect(CategoryCustomField.find_by(name: 'create_topic_wizard', value: template['name'].parameterize.underscore)).to eq(nil) end it "saves wizard templates" do From a34262626735f45d630184c04748671c23805d1f Mon Sep 17 00:00:00 2001 From: merefield Date: Wed, 19 Jul 2023 11:14:08 +0100 Subject: [PATCH 6/6] stick to one method for text conversion --- lib/custom_wizard/template.rb | 2 +- spec/requests/custom_wizard/admin/wizard_controller_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/custom_wizard/template.rb b/lib/custom_wizard/template.rb index 9fa197f7..9674f64a 100644 --- a/lib/custom_wizard/template.rb +++ b/lib/custom_wizard/template.rb @@ -64,7 +64,7 @@ class CustomWizard::Template ensure_wizard_upload_references!(wizard_id) PluginStore.remove(CustomWizard::PLUGIN_NAME, wizard.id) clear_user_wizard_redirect(wizard_id, after_time: !!wizard.after_time) - related_custom_fields = CategoryCustomField.where(name: 'create_topic_wizard', value: wizard.name.parameterize.underscore) + related_custom_fields = CategoryCustomField.where(name: 'create_topic_wizard', value: wizard.name.parameterize(separator: "_")) related_custom_fields.destroy_all end diff --git a/spec/requests/custom_wizard/admin/wizard_controller_spec.rb b/spec/requests/custom_wizard/admin/wizard_controller_spec.rb index 7986f565..c94007e2 100644 --- a/spec/requests/custom_wizard/admin/wizard_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/wizard_controller_spec.rb @@ -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: template['name'].parameterize.underscore }) } + let(:category) { Fabricate(:category, custom_fields: { create_topic_wizard: template['name'].parameterize(separator: "_") }) } before do CustomWizard::Template.save(template, skip_jobs: true) @@ -41,11 +41,11 @@ describe CustomWizard::AdminWizardController do end 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'].parameterize.underscore)).not_to eq(nil) + expect(CategoryCustomField.find_by(category_id: category.id, name: 'create_topic_wizard', value: template['name'].parameterize(separator: "_"))).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(name: 'create_topic_wizard', value: template['name'].parameterize.underscore)).to eq(nil) + expect(CategoryCustomField.find_by(name: 'create_topic_wizard', value: template['name'].parameterize(separator: "_"))).to eq(nil) end it "saves wizard templates" do