-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sender validation and from address could mismatch, due that reason, d…
…elay notification now allows setting up custom from address
- Loading branch information
Showing
4 changed files
with
9 additions
and
21 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module MailHandler | ||
VERSION = '1.0.35' | ||
VERSION = '1.0.36' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,13 +105,14 @@ Console notification is a good option if you are testing email delivery and want | |
To add console or email notifications, to your email searching all you need to do is: | ||
|
||
``` ruby | ||
email_receiver.add_observer(MailHandler::Receiving::Notification::Email.new(email_sender, contacts)) | ||
email_receiver.add_observer(MailHandler::Receiving::Notification::Email.new(email_sender, from, contacts)) | ||
email_receiver.add_observer(MailHandler::Receiving::Notification::Console.new) | ||
``` | ||
|
||
For email notifications, the parameters you need are: | ||
|
||
* `email_sender` - email sender you will use for sending an email (it should be one of senders described below) | ||
* `from` - email address from which email is sent | ||
* `contacts` - list of contacts to receive the notification (for example: `[email protected], [email protected]` | ||
|
||
# Email sending | ||
|
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 |
---|---|---|
|
@@ -4,74 +4,60 @@ | |
|
||
let(:search) { double('search') } | ||
let(:sender) { double('sender') } | ||
let(:notification) { MailHandler::Receiving::Notification::Email.new(sender, '[email protected]',1) } | ||
let(:notification) { MailHandler::Receiving::Notification::Email.new(sender, '[email protected]', '[email protected]',1) } | ||
|
||
before(:each) do | ||
|
||
allow(sender).to receive(:send_email) { true } | ||
allow(search).to receive(:max_duration) { 5 } | ||
|
||
end | ||
|
||
it '.create' do | ||
|
||
aggregate_failures "init details" do | ||
|
||
expect(notification.min_time_to_notify).to eq 1 | ||
expect(notification.max_time_to_notify).to eq nil | ||
expect(notification.contacts).to eq '[email protected]' | ||
expect(notification.sender).to eq sender | ||
|
||
end | ||
|
||
end | ||
|
||
it '.notify' do | ||
|
||
allow(search).to receive(:started_at) { Time.now } | ||
notification.notify(search) | ||
expect(notification.max_time_to_notify).to eq search.max_duration | ||
|
||
end | ||
|
||
context 'states' do | ||
|
||
it 'no delay' do | ||
|
||
allow(search).to receive(:started_at) { Time.now } | ||
notification.notify(search) | ||
expect(notification.current_state).to be_kind_of MailHandler::Receiving::Notification::NoDelay | ||
|
||
end | ||
|
||
it 'delayed' do | ||
|
||
allow(search).to receive(:started_at) { Time.now - 2} | ||
allow(search).to receive(:result) { false } | ||
allow(notification).to receive(:send_email) { } | ||
notification.notify(search) | ||
expect(notification.current_state).to be_kind_of MailHandler::Receiving::Notification::Delay | ||
|
||
end | ||
|
||
it 'received' do | ||
|
||
allow(search).to receive(:started_at) { Time.now - 2} | ||
allow(search).to receive(:result) { true } | ||
allow(notification).to receive(:send_email) { } | ||
notification.notify(search) | ||
expect(notification.current_state).to be_kind_of MailHandler::Receiving::Notification::Received | ||
|
||
end | ||
|
||
it 'max delayed' do | ||
|
||
allow(search).to receive(:started_at) { Time.now - 10} | ||
allow(search).to receive(:result) { false } | ||
allow(notification).to receive(:send_email) { } | ||
notification.notify(search) | ||
expect(notification.current_state).to be_kind_of MailHandler::Receiving::Notification::MaxDelay | ||
|
||
end | ||
|
||
end | ||
|