From 32a8dcf19fa555fa2a8867d7dc9b7cc3025957d9 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Fri, 28 Apr 2023 16:15:48 +0200 Subject: [PATCH 1/4] Add cron schedule to Custom Wizard workflow --- .github/workflows/discourse-plugin.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/discourse-plugin.yml b/.github/workflows/discourse-plugin.yml index f5cf62e5..13850e3e 100644 --- a/.github/workflows/discourse-plugin.yml +++ b/.github/workflows/discourse-plugin.yml @@ -5,6 +5,8 @@ on: branches: - main pull_request: + schedule: + - cron: "0 0 * * *" jobs: ci: From caab850127c8e63a8cd9813455fcc6d585423cb1 Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 1 May 2023 21:49:44 +0100 Subject: [PATCH 2/4] FIX: failing log spec --- lib/custom_wizard/log.rb | 4 ++-- spec/serializers/custom_wizard/log_serializer_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/custom_wizard/log.rb b/lib/custom_wizard/log.rb index cb5b78c7..ed9624e1 100644 --- a/lib/custom_wizard/log.rb +++ b/lib/custom_wizard/log.rb @@ -15,13 +15,13 @@ class CustomWizard::Log @username = attrs['username'] end - def self.create(wizard_id, action, username, message) + def self.create(wizard_id, action, username, message, date = Time.now) log_id = SecureRandom.hex(12) PluginStore.set('custom_wizard_log', log_id.to_s, { - date: Time.now, + date: date, wizard_id: wizard_id, action: action, username: username, diff --git a/spec/serializers/custom_wizard/log_serializer_spec.rb b/spec/serializers/custom_wizard/log_serializer_spec.rb index 7dd1db0f..cad4a85b 100644 --- a/spec/serializers/custom_wizard/log_serializer_spec.rb +++ b/spec/serializers/custom_wizard/log_serializer_spec.rb @@ -4,7 +4,7 @@ describe CustomWizard::LogSerializer do fab!(:user) { Fabricate(:user) } it 'should return log attributes' do - CustomWizard::Log.create('first-test-wizard', 'perform_first_action', 'first_test_user', 'First log message') + CustomWizard::Log.create('first-test-wizard', 'perform_first_action', 'first_test_user', 'First log message', 1.day.ago) CustomWizard::Log.create('second-test-wizard', 'perform_second_action', 'second_test_user', 'Second log message') json_array = ActiveModel::ArraySerializer.new( From 8b443e0f087614fc6d7b60fd7cda40e691717df0 Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 1 May 2023 21:52:10 +0100 Subject: [PATCH 3/4] bump patch --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index ab596540..8d5d1a89 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.3.1 +# version: 2.3.2 # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever # url: https://github.com/paviliondev/discourse-custom-wizard # contact_emails: development@pavilion.tech From 4c784d98e6c76c22d201ef1fa26977ffc66cb418 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Wed, 3 May 2023 11:01:54 +0200 Subject: [PATCH 4/4] Add not equals support to mapper --- .../discourse/lib/wizard-mapper.js.es6 | 1 + config/locales/client.en.yml | 1 + lib/custom_wizard/mapper.rb | 1 + plugin.rb | 2 +- spec/components/custom_wizard/mapper_spec.rb | 13 +++++++++++++ spec/fixtures/mapper/inputs.json | 15 +++++++++++++++ 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 index c398eaf4..9037bec5 100644 --- a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 @@ -35,6 +35,7 @@ function inputTypesContent(options = {}) { const connectors = { pair: [ "equal", + "not_equal", "greater", "less", "greater_or_equal", diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 8a856636..98519335 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -324,6 +324,7 @@ en: then: "then" set: "set" equal: '=' + not_equal: '!=' greater: '>' less: '<' greater_or_equal: '>=' diff --git a/lib/custom_wizard/mapper.rb b/lib/custom_wizard/mapper.rb index 4e18ad01..66a10736 100644 --- a/lib/custom_wizard/mapper.rb +++ b/lib/custom_wizard/mapper.rb @@ -30,6 +30,7 @@ class CustomWizard::Mapper OPERATORS = { equal: '==', + not_equal: "!=", greater: '>', less: '<', greater_or_equal: '>=', diff --git a/plugin.rb b/plugin.rb index 8d5d1a89..b90e0965 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.3.2 +# version: 2.3.3 # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever # url: https://github.com/paviliondev/discourse-custom-wizard # contact_emails: development@pavilion.tech diff --git a/spec/components/custom_wizard/mapper_spec.rb b/spec/components/custom_wizard/mapper_spec.rb index 510632a9..3e0e6ce6 100644 --- a/spec/components/custom_wizard/mapper_spec.rb +++ b/spec/components/custom_wizard/mapper_spec.rb @@ -291,6 +291,19 @@ describe CustomWizard::Mapper do end end + it "handles not equal pairs" do + expect(CustomWizard::Mapper.new( + inputs: inputs['not_equals_pair'], + data: data, + user: user1 + ).perform).to eq(true) + expect(CustomWizard::Mapper.new( + inputs: inputs['not_equals_pair'], + data: data, + user: user2 + ).perform).to eq(false) + end + it "handles greater than pairs" do expect(CustomWizard::Mapper.new( inputs: inputs['greater_than_pair'], diff --git a/spec/fixtures/mapper/inputs.json b/spec/fixtures/mapper/inputs.json index 3fd406a4..2ef81a28 100644 --- a/spec/fixtures/mapper/inputs.json +++ b/spec/fixtures/mapper/inputs.json @@ -195,6 +195,21 @@ ] } ], + "not_equals_pair": [ + { + "type": "validation", + "pairs": [ + { + "index": 0, + "key": "trust_level", + "key_type": "user_field", + "value": "1", + "value_type": "text", + "connector": "not_equal" + } + ] + } + ], "greater_than_pair": [ { "type": "validation",