Merge pull request #2820 from internetee/update_test_coverage/app/models/concerns/contact/archivable

added new test
This commit is contained in:
Timo Võhmar 2025-07-29 16:16:16 +03:00 committed by GitHub
commit 97c4d3e4a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,6 +68,30 @@ class ArchivableContactTest < ActiveSupport::TestCase
registrar.notifications.last.text)
end
def test_write_to_registrar_log_creates_log_file
contact = archivable_contact
registrar = contact.registrar
log_dir = '/tmp/test_logs'
ENV['contact_archivation_log_file_dir'] = log_dir
# Using Stub to avoid creating the log file in the filesystem
FileUtils.stub(:mkdir_p, true) do
file_mock = Minitest::Mock.new
file_mock.expect(:write, nil) do |arg|
arg.to_s.include?(contact.code)
end
file_mock.expect(:close, nil)
File.stub(:new, file_mock) do
contact.archive(extra_log: true, verified: true, notify: false)
end
assert_mock file_mock
end
end
private
def archivable_contact