mailhandler 1.0.35 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce6a144521ea4123b5695c64ea2e6d35225405cd
4
- data.tar.gz: 8c33ce15af819275d7ccb7cae0247586ac7cda18
3
+ metadata.gz: 5e3e402f4b95ef68f6d3e14782e9df18f45a7ff0
4
+ data.tar.gz: 6285982ac47bfafa48410c2a1c98f6d21c3f0510
5
5
  SHA512:
6
- metadata.gz: 1e128fa32f6e094999bf2a745461a81fa6e762f2037edbe74be223fd7271b68aa8b37515315af6265613a00e631fc4e79bbb4e6f5b72aabeae5fcbd8ae73f010
7
- data.tar.gz: da4d35f2fcd17dd90a231b6df1af27f08313468dcc103a5a3253ffd6ec91109f27b851170080219d16f710954f89201ad24ae571743667fc61c22800295a8009
6
+ metadata.gz: e132dcab6529c17c696390bac5c052d92ea91d8d718715d575a28342da1f85b57d6bdd370b737c5494ae82c0e64f9cc279287d825b11c0fbfee24e2d44554524
7
+ data.tar.gz: 3daf78e47d35f23add73b1484667f1b5f9b54385013924ae3ce2ee56778bca044856a4b256665dfb342efc83ab0e41558307eb64e97ee6ec1199e519ad6ed4c0
data/.gitignore CHANGED
@@ -3,4 +3,5 @@
3
3
  **/*.DS_Store
4
4
  **/*.idea
5
5
  Gemfile.lock
6
+ *.gem
6
7
 
@@ -11,17 +11,19 @@ module MailHandler
11
11
  class Email
12
12
 
13
13
  attr_reader :sender,
14
+ :from,
14
15
  :contacts,
15
16
  :min_time_to_notify,
16
17
  :max_time_to_notify,
17
18
  :current_state
18
19
 
19
- def initialize(sender, contacts, min_time_to_notify = 60)
20
+ def initialize(sender, from, to, min_time_to_notify = 60)
20
21
 
21
22
  @min_time_to_notify = min_time_to_notify
22
23
 
23
24
  @sender = sender
24
- @contacts = contacts
25
+ @from = from
26
+ @contacts = to
25
27
  init_state
26
28
  set_content_handler(EmailContent.new)
27
29
 
@@ -44,8 +46,7 @@ module MailHandler
44
46
  def send_email(type, search)
45
47
 
46
48
  verify_email_type(type)
47
- content = @content_handler.retrieve(type, search.options, Time.now - search.started_at,
48
- sender.dispatcher.username, contacts)
49
+ content = @content_handler.retrieve(type, search.options, Time.now - search.started_at, from, contacts)
49
50
  sender.send_email content
50
51
 
51
52
  end
@@ -1,3 +1,3 @@
1
1
  module MailHandler
2
- VERSION = '1.0.35'
2
+ VERSION = '1.0.36'
3
3
  end
data/readme.md CHANGED
@@ -105,13 +105,14 @@ Console notification is a good option if you are testing email delivery and want
105
105
  To add console or email notifications, to your email searching all you need to do is:
106
106
 
107
107
  ``` ruby
108
- email_receiver.add_observer(MailHandler::Receiving::Notification::Email.new(email_sender, contacts))
108
+ email_receiver.add_observer(MailHandler::Receiving::Notification::Email.new(email_sender, from, contacts))
109
109
  email_receiver.add_observer(MailHandler::Receiving::Notification::Console.new)
110
110
  ```
111
111
 
112
112
  For email notifications, the parameters you need are:
113
113
 
114
114
  * `email_sender` - email sender you will use for sending an email (it should be one of senders described below)
115
+ * `from` - email address from which email is sent
115
116
  * `contacts` - list of contacts to receive the notification (for example: `john@example.com, igor@example.com`
116
117
 
117
118
  # Email sending
@@ -4,74 +4,60 @@ describe MailHandler::Receiving::Notification::Email do
4
4
 
5
5
  let(:search) { double('search') }
6
6
  let(:sender) { double('sender') }
7
- let(:notification) { MailHandler::Receiving::Notification::Email.new(sender, 'igor@example.com',1) }
7
+ let(:notification) { MailHandler::Receiving::Notification::Email.new(sender, 'from@example.com', 'igor@example.com',1) }
8
8
 
9
9
  before(:each) do
10
-
11
10
  allow(sender).to receive(:send_email) { true }
12
11
  allow(search).to receive(:max_duration) { 5 }
13
-
14
12
  end
15
13
 
16
14
  it '.create' do
17
15
 
18
16
  aggregate_failures "init details" do
19
-
20
17
  expect(notification.min_time_to_notify).to eq 1
21
18
  expect(notification.max_time_to_notify).to eq nil
22
19
  expect(notification.contacts).to eq 'igor@example.com'
23
20
  expect(notification.sender).to eq sender
24
-
25
21
  end
26
22
 
27
23
  end
28
24
 
29
25
  it '.notify' do
30
-
31
26
  allow(search).to receive(:started_at) { Time.now }
32
27
  notification.notify(search)
33
28
  expect(notification.max_time_to_notify).to eq search.max_duration
34
-
35
29
  end
36
30
 
37
31
  context 'states' do
38
32
 
39
33
  it 'no delay' do
40
-
41
34
  allow(search).to receive(:started_at) { Time.now }
42
35
  notification.notify(search)
43
36
  expect(notification.current_state).to be_kind_of MailHandler::Receiving::Notification::NoDelay
44
-
45
37
  end
46
38
 
47
39
  it 'delayed' do
48
-
49
40
  allow(search).to receive(:started_at) { Time.now - 2}
50
41
  allow(search).to receive(:result) { false }
51
42
  allow(notification).to receive(:send_email) { }
52
43
  notification.notify(search)
53
44
  expect(notification.current_state).to be_kind_of MailHandler::Receiving::Notification::Delay
54
-
55
45
  end
56
46
 
57
47
  it 'received' do
58
-
59
48
  allow(search).to receive(:started_at) { Time.now - 2}
60
49
  allow(search).to receive(:result) { true }
61
50
  allow(notification).to receive(:send_email) { }
62
51
  notification.notify(search)
63
52
  expect(notification.current_state).to be_kind_of MailHandler::Receiving::Notification::Received
64
-
65
53
  end
66
54
 
67
55
  it 'max delayed' do
68
-
69
56
  allow(search).to receive(:started_at) { Time.now - 10}
70
57
  allow(search).to receive(:result) { false }
71
58
  allow(notification).to receive(:send_email) { }
72
59
  notification.notify(search)
73
60
  expect(notification.current_state).to be_kind_of MailHandler::Receiving::Notification::MaxDelay
74
-
75
61
  end
76
62
 
77
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailhandler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.35
4
+ version: 1.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Balos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-15 00:00:00.000000000 Z
11
+ date: 2018-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail