Skip to content

Commit

Permalink
Merge pull request #472 from slovensko-digital/GO-126/request_signatu…
Browse files Browse the repository at this point in the history
…re_from_signers_on_fs_drafts

GO-126 Update signature requesting logic
  • Loading branch information
luciajanikova authored Sep 16, 2024
2 parents 6a7ef9d + 78ac87f commit 8e78925
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/models/fs/message_draft.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ accountants_basic_user:
name: Basic user 2
type: UserGroup
tenant: accountants

accountants_signers:
name: Accountants signers
type: SignerGroup
tenant: accountants
4 changes: 4 additions & 0 deletions test/fixtures/tag_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions test/fixtures/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions test/models/fs/message_draft_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ 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",
"form_identifier" => "3055_781"
},
[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

0 comments on commit 8e78925

Please sign in to comment.