From 78ac87fed5c6e73ccaf070d28e80685820a74d03 Mon Sep 17 00:00:00 2001 From: luciajanikova <19lucia99@gmail.com> Date: Mon, 16 Sep 2024 15:52:01 +0200 Subject: [PATCH] Update signature requesting logic --- app/models/fs/message_draft.rb | 4 ++-- test/fixtures/groups.yml | 5 +++++ test/fixtures/tag_groups.yml | 4 ++++ test/fixtures/tags.yml | 16 ++++++++++++++++ test/models/fs/message_draft_test.rb | 12 +++++++++--- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/app/models/fs/message_draft.rb b/app/models/fs/message_draft.rb index eeb34a859..df66f84a7 100644 --- a/app/models/fs/message_draft.rb +++ b/app/models/fs/message_draft.rb @@ -77,8 +77,8 @@ def self.create_and_validate_with_fs_form(form_files: [], author:, fs_client: Fs message.thread.box.tenant.signed_externally_tag!.assign_to_message_object(form_object) if form_object.is_signed? if form_object.to_be_signed && !form_object.is_signed? - author.signature_requested_from_tag&.assign_to_message_object(form_object) - author.signature_requested_from_tag&.assign_to_thread(message.thread) + message.thread.box.tenant.signer_group.signature_requested_from_tag&.assign_to_message_object(form_object) + message.thread.box.tenant.signer_group.signature_requested_from_tag&.assign_to_thread(message.thread) end MessageObjectDatum.create( diff --git a/test/fixtures/groups.yml b/test/fixtures/groups.yml index e4da79245..5137aa621 100644 --- a/test/fixtures/groups.yml +++ b/test/fixtures/groups.yml @@ -59,3 +59,8 @@ accountants_basic_user: name: Basic user 2 type: UserGroup tenant: accountants + +accountants_signers: + name: Accountants signers + type: SignerGroup + tenant: accountants diff --git a/test/fixtures/tag_groups.yml b/test/fixtures/tag_groups.yml index e48e8425d..2b00667b4 100644 --- a/test/fixtures/tag_groups.yml +++ b/test/fixtures/tag_groups.yml @@ -36,6 +36,10 @@ finance_ssd_signer_user2: tag: ssd_finance group: ssd_signer_user2 +accountants_signers_signature_requested: + tag: accountants_signers_signature_requested + group: accountants_signers + drafts_accountants_basic_user: tag: accountants_basic_user_drafts group: accountants_basic_user diff --git a/test/fixtures/tags.yml b/test/fixtures/tags.yml index 04768cfbe..87330fdab 100644 --- a/test/fixtures/tags.yml +++ b/test/fixtures/tags.yml @@ -228,6 +228,22 @@ accountants_everything: visible: false tenant: accountants +accountants_signature_requested: + name: Na podpis + type: SignatureRequestedTag + visible: true + tenant: accountants + icon: pencil + color: yellow + +accountants_signers_signature_requested: + name: 'Na podpis: Podpisovatelia' + type: SignatureRequestedFromTag + visible: true + tenant: accountants + icon: pencil + color: yellow + accountants_externally: name: SignedExternally type: SignedExternallyTag diff --git a/test/models/fs/message_draft_test.rb b/test/models/fs/message_draft_test.rb index ed1bcccae..3e3b435f4 100644 --- a/test/models/fs/message_draft_test.rb +++ b/test/models/fs/message_draft_test.rb @@ -7,6 +7,8 @@ class Fs::MessageDraftTest < ActiveSupport::TestCase include ActionDispatch::TestProcess::FixtureFile test "create_and_validate_with_fs_form method schedules Fs::ValidateMessageDraftJob" do + author = users(:accountants_basic) + fs_api = Minitest::Mock.new fs_api.expect :parse_form, { "subject" => "1122334455", @@ -14,10 +16,14 @@ class Fs::MessageDraftTest < ActiveSupport::TestCase }, [file_fixture("fs/dic1122334455_fs3055_781__sprava_dani_2023.xml").read] - FsEnvironment.fs_client.stub :api, fs_api do - assert_enqueued_with(job: Fs::ValidateMessageDraftJob) do - Fs::MessageDraft.create_and_validate_with_fs_form(form_files: [fixture_file_upload("fs/dic1122334455_fs3055_781__sprava_dani_2023.xml", "application/xml")], author: users(:accountants_basic)) + FsEnvironment.fs_client.stub :api, fs_api do + assert_enqueued_with(job: Fs::ValidateMessageDraftJob) do + Fs::MessageDraft.create_and_validate_with_fs_form(form_files: [fixture_file_upload("fs/dic1122334455_fs3055_781__sprava_dani_2023.xml", "application/xml")], author: author) end end + + message_draft = Fs::MessageDraft.last + assert message_draft.form_object.tags.include?(author.tenant.signer_group.signature_requested_from_tag) + assert message_draft.thread.tags.include?(author.tenant.signer_group.signature_requested_from_tag) end end