Skip to content

Commit

Permalink
Merge branch 'main' into feature/GO-368-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomáš Durčák committed Sep 20, 2024
2 parents 901e018 + 22343bd commit 25c6d2a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 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: 4 additions & 1 deletion app/models/govbox/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Govbox::Message < ApplicationRecord
EGOV_DOCUMENT_CLASS = 'EGOV_DOCUMENT'
EGOV_NOTIFICATION_CLASS = 'EGOV_NOTIFICATION'
COLLAPSED_BY_DEFAULT_MESSAGE_CLASSES = ['ED_DELIVERY_REPORT', 'POSTING_CONFIRMATION', 'POSTING_INFORMATION']
GENERAL_AGENDA_SCHEMA = 'http://schemas.gov.sk/form/App.GeneralAgenda/1.9'

DELIVERY_NOTIFICATION_TAG = 'delivery_notification'

Expand Down Expand Up @@ -51,7 +52,9 @@ def self.create_message_with_thread!(govbox_message)
end

def replyable?
folder.inbox? && [EGOV_DOCUMENT_CLASS, EGOV_NOTIFICATION_CLASS].include?(payload["class"])
folder.inbox? &&
[EGOV_DOCUMENT_CLASS, EGOV_NOTIFICATION_CLASS].include?(payload["class"]) &&
Upvs::ServiceWithFormAllowRule.where(institution_uri: payload["sender_uri"]).where(schema_url: GENERAL_AGENDA_SCHEMA).any?
end

def collapsed?
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 25c6d2a

Please sign in to comment.