-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5009113
commit ce7a6b3
Showing
6 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,7 +158,6 @@ ActionMailer::Base.default from: 'Boxroom <[email protected]>' | |
The engine is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). | ||
|
||
## Roadmap: | ||
- tests for notifications | ||
- support s3 | ||
- batch actions | ||
- tag files | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,10 +33,13 @@ | |
# The :test delivery method accumulates sent emails in the | ||
# ActionMailer::Base.deliveries array. | ||
config.action_mailer.delivery_method = :test | ||
config.active_job.queue_adapter = :inline | ||
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } | ||
|
||
# Print deprecation notices to the stderr. | ||
config.active_support.deprecation = :stderr | ||
|
||
# Raises error for missing translations | ||
# config.action_view.raise_on_missing_translations = true | ||
ActionMailer::Base.default from: 'Boxroom <[email protected]>' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
require 'test_helper' | ||
|
||
class NotificationTest < ActiveSupport::TestCase | ||
def setup | ||
clear_root_folder | ||
do_cleanup | ||
end | ||
|
||
test 'notify file was created in folder' do | ||
folder = create(:folder, notify_emails: '[email protected]') | ||
file = create(:user_file, folder: folder) | ||
|
||
Boxroom::UserFile::NotifyCreate.(params: {id: file.id}) | ||
email = ActionMailer::Base.deliveries.last | ||
assert_nil email | ||
|
||
folder.update_attribute :notify_create, true | ||
|
||
Boxroom::UserFile::NotifyCreate.(params: {id: file.id}) | ||
|
||
email = ActionMailer::Base.deliveries.last | ||
|
||
assert email != nil | ||
assert_equal ['[email protected]'], email.to | ||
assert_equal I18n.t(:file_added), email.subject | ||
assert_equal true, email.body.to_s.include?(file.attachment_file_name) | ||
assert_equal true, email.body.to_s.include?(folder.name) | ||
end | ||
|
||
test 'notify file was updated in folder' do | ||
folder = create(:folder, notify_emails: '[email protected]') | ||
file = create(:user_file, folder: folder) | ||
|
||
Boxroom::UserFile::NotifyUpdate.(params: {id: file.id}) | ||
email = ActionMailer::Base.deliveries.last | ||
assert_nil email | ||
|
||
folder.update_attribute :notify_update, true | ||
|
||
Boxroom::UserFile::NotifyUpdate.(params: {id: file.id}) | ||
|
||
email = ActionMailer::Base.deliveries.last | ||
|
||
assert email != nil | ||
assert_equal ['[email protected]'], email.to | ||
assert_equal I18n.t(:file_updated), email.subject | ||
assert_equal true, email.body.to_s.include?(file.attachment_file_name) | ||
assert_equal true, email.body.to_s.include?(folder.name) | ||
end | ||
|
||
test 'notify file was deleted in folder' do | ||
folder = create(:folder, notify_emails: '[email protected]') | ||
file = create(:user_file, folder: folder) | ||
|
||
Boxroom::UserFile::NotifyRemove.(params: {id: file.id}) | ||
email = ActionMailer::Base.deliveries.last | ||
assert_nil email | ||
|
||
folder.update_attribute :notify_remove, true | ||
|
||
Boxroom::UserFile::NotifyRemove.(params: {id: file.id}) | ||
|
||
email = ActionMailer::Base.deliveries.last | ||
|
||
assert email != nil | ||
assert_equal ['[email protected]'], email.to | ||
assert_equal I18n.t(:file_removed), email.subject | ||
assert_equal true, email.body.to_s.include?(file.attachment_file_name) | ||
assert_equal true, email.body.to_s.include?(folder.name) | ||
end | ||
|
||
test 'notification sent to many recipients' do | ||
folder = create(:folder, notify_emails: '[email protected], [email protected]', notify_create: true) | ||
file = create(:user_file, folder: folder) | ||
|
||
Boxroom::UserFile::NotifyCreate.(params: {id: file.id}) | ||
|
||
assert_equal 2, ActionMailer::Base.deliveries.size | ||
end | ||
end |