From e5b7ff31b2d64ddd8e6c3ea8036bddea7c46ebe0 Mon Sep 17 00:00:00 2001
From: luciajanikova <19lucia99@gmail.com>
Date: Mon, 28 Oct 2024 11:34:30 +0100
Subject: [PATCH] Add tests
---
app/controllers/message_drafts_controller.rb | 1 -
test/fixtures/message_object_data.yml | 4 ++++
test/fixtures/message_objects.yml | 2 +-
test/fixtures/messages.yml | 9 ++++++++-
test/models/message_object_test.rb | 9 +++++++++
test/system/message_drafts_test.rb | 15 +++++++++++++++
6 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/app/controllers/message_drafts_controller.rb b/app/controllers/message_drafts_controller.rb
index 9a54a3f1..ecbaa9c2 100644
--- a/app/controllers/message_drafts_controller.rb
+++ b/app/controllers/message_drafts_controller.rb
@@ -13,7 +13,6 @@ def submit
if @message.submit
redirect_to message_thread_path(@message.thread), notice: "Správa bola zaradená na odoslanie"
else
- # TODO FIX: Tato hlaska sa zobrazuje aj ked je object oznaceny ako to_be_signed, ale nebol este podpisany
redirect_to message_thread_path(@message.thread), alert: @message.not_submittable_errors.join(', ')
end
end
diff --git a/test/fixtures/message_object_data.yml b/test/fixtures/message_object_data.yml
index b01660fc..dc7c8cf0 100644
--- a/test/fixtures/message_object_data.yml
+++ b/test/fixtures/message_object_data.yml
@@ -12,6 +12,10 @@ draft_two:
message_object: ssd_main_general_draft_two_form
blob: predmettext
+draft_three:
+ message_object: ssd_main_draft_to_be_signed2_draft_form
+ blob: predmettext
+
empty_draft:
message_object: ssd_main_empty_draft_form
blob:
diff --git a/test/fixtures/message_objects.yml b/test/fixtures/message_objects.yml
index 4358c11f..8d9448df 100644
--- a/test/fixtures/message_objects.yml
+++ b/test/fixtures/message_objects.yml
@@ -70,7 +70,7 @@ ssd_main_draft_to_be_signed_draft_two_form:
ssd_main_draft_to_be_signed2_draft_form:
message: ssd_main_draft_to_be_signed2_draft
name: MyString
- mimetype: MyString
+ mimetype: application/x-eform-xml
object_type: FORM
ssd_main_draft_to_be_signed3_draft_one_form:
diff --git a/test/fixtures/messages.yml b/test/fixtures/messages.yml
index 1c2dce92..2681ae48 100644
--- a/test/fixtures/messages.yml
+++ b/test/fixtures/messages.yml
@@ -216,7 +216,7 @@ ssd_main_draft_to_be_signed_draft_two:
author: basic
ssd_main_draft_to_be_signed2_draft:
- type: MessageDraft
+ type: Upvs::MessageDraft
uuid: <%= SecureRandom.uuid %>
title: MyStringDraft3
html_visualization: MyString
@@ -225,6 +225,13 @@ ssd_main_draft_to_be_signed2_draft:
replyable: false
metadata:
status: created
+ sktalk_class: EGOV_APPLICATION
+ posp_id: App.GeneralAgenda
+ posp_version: 1.9
+ message_type: App.GeneralAgenda
+ correlation_id: <%= SecureRandom.uuid %>
+ recipient_uri:
+ ico://sk/12345678
author: basic
ssd_main_draft_to_be_signed3_draft:
diff --git a/test/models/message_object_test.rb b/test/models/message_object_test.rb
index 7d0f4c04..ed4e361a 100644
--- a/test/models/message_object_test.rb
+++ b/test/models/message_object_test.rb
@@ -206,6 +206,15 @@ class MessageObjectTest < ActiveSupport::TestCase
assert_not object.message.thread.tags.include?(tenant.signed_tag!)
end
+ test "before_destroy callback deletes SignatureRequested Tag from message thread (if no more objects with SignatureRequestedFromTag present)" do
+ message_object = message_objects(:ssd_main_draft_to_be_signed2_draft_form)
+ message_thread = message_object.message.thread
+
+ message_object.destroy
+
+ assert_equal false, message_thread.tags.reload.include?(message_thread.tenant.signature_requested_tag!)
+ end
+
test "before_destroy callback keeps object related tags for message thread (if another objects with the tag present in the message)" do
tenant = tenants(:ssd)
signer = users(:basic_two)
diff --git a/test/system/message_drafts_test.rb b/test/system/message_drafts_test.rb
index c29b01a0..24e8e6cb 100644
--- a/test/system/message_drafts_test.rb
+++ b/test/system/message_drafts_test.rb
@@ -56,4 +56,19 @@ class MessageDraftsTest < ApplicationSystemTestCase
refute_selector(thread_in_listing_selector(thread_general))
refute_selector(thread_in_listing_selector(thread_issue))
end
+
+ test "message is not submitted and flash message is shown when user tries to send message without requested signatures present" do
+ message_thread = message_threads(:ssd_main_draft_to_be_signed2)
+ message_draft = messages(:ssd_main_draft_to_be_signed2_draft)
+
+ visit message_thread_path(message_thread)
+
+ within("#upvs_message_draft_#{message_draft.id}") do
+ assert_button "Odoslať"
+
+ click_button "Odoslať"
+ end
+
+ assert_text "Pred odoslaním podpíšte všetky dokumenty na podpis"
+ end
end