diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2024-04-28 06:40:12 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2024-04-28 06:40:12 +0000 |
commit | b5c48c1d973c501de61e7cbd1b6f8ad9ac1f112d (patch) | |
tree | 203b7eefea0cd8aa4af4e1555e89a9ac4f03efdf /test/unit/journal_observer_test.rb | |
parent | e4fcfc6990a724cacd6d4e978ee051735769f180 (diff) | |
download | redmine-b5c48c1d973c501de61e7cbd1b6f8ad9ac1f112d.tar.gz redmine-b5c48c1d973c501de61e7cbd1b6f8ad9ac1f112d.zip |
Adds an option to send email notification when an attachment is added (#40569).
Patch by Mizuki ISHIKAWA (#ishikawa999).
git-svn-id: https://svn.redmine.org/redmine/trunk@22790 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/journal_observer_test.rb')
-rw-r--r-- | test/unit/journal_observer_test.rb | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/unit/journal_observer_test.rb b/test/unit/journal_observer_test.rb index 0452d66c3..ed6931893 100644 --- a/test/unit/journal_observer_test.rb +++ b/test/unit/journal_observer_test.rb @@ -23,7 +23,7 @@ class JournalObserverTest < ActiveSupport::TestCase fixtures :issues, :issue_statuses, :journals, :journal_details, :projects, :projects_trackers, :trackers, :enabled_modules, :enumerations, :users, :user_preferences, :email_addresses, :roles, :members, :member_roles, - :versions, :issue_categories + :versions, :issue_categories, :attachments def setup User.current = nil @@ -198,4 +198,34 @@ class JournalObserverTest < ActiveSupport::TestCase assert_equal 0, ActionMailer::Base.deliveries.size end end + + def test_create_should_send_email_notification_with_issue_attachment_added + set_tmp_attachments_directory + with_settings :notified_events => %w(issue_attachment_added) do + user = User.find_by_login('jsmith') + issue = issues(:issues_001) + issue.init_journal(user) + issue.save_attachments( + { 'p0' => {'file' => mock_file_with_options(:original_filename => 'upload')} } + ) + + assert issue.save + assert_equal 2, ActionMailer::Base.deliveries.size + end + end + + def test_create_should_not_send_email_notification_without_issue_attachment_added + set_tmp_attachments_directory + with_settings :notified_events => [] do + user = User.find_by_login('jsmith') + issue = issues(:issues_001) + issue.init_journal(user) + issue.save_attachments( + { 'p0' => {'file' => mock_file_with_options(:original_filename => 'upload')} } + ) + + assert issue.save + assert_equal 0, ActionMailer::Base.deliveries.size + end + end end |