block_head 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1e38fcca27dada17d3423f2a0e62dde337695bf
|
4
|
+
data.tar.gz: 628586da4b3987d87bc6f3946eadabdcee1748e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee6af40430cdeeaef9fd1c7626a1c19a6da03847911e7d1805ead20f552dc4c30e65466ed4d08cd409f7b2bff47587b2b35108eacf21d747c3d2b690b1cafc9a
|
7
|
+
data.tar.gz: 64ff68e99b9d72b3fc9c905a23c1bceca6aa0538db1fdddbc1b7f6ed5e0f440480ad8a077c0527061acf33f2ddeddd2db34d6a1c4ab2e1f6902749c2ddee418a
|
@@ -5,14 +5,18 @@ class DomainInterceptor
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def delivering_email(message)
|
8
|
-
|
8
|
+
unless destination_has_valid_domain?(message)
|
9
|
+
message.to = default_recipient
|
10
|
+
end
|
9
11
|
end
|
10
12
|
|
11
13
|
private
|
12
14
|
|
13
15
|
def destination_has_valid_domain?(message)
|
14
|
-
|
15
|
-
|
16
|
+
message.to.any? do |recipient|
|
17
|
+
recipient_domain = recipient.split("@")[1]
|
18
|
+
domains.include?(recipient_domain)
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
22
|
attr_reader :domains, :default_recipient
|
data/lib/block_head/version.rb
CHANGED
@@ -5,18 +5,18 @@ require 'spec_helper'
|
|
5
5
|
describe DomainInterceptor do
|
6
6
|
subject(:interceptor) { DomainInterceptor.new([domain], default_recipient) }
|
7
7
|
let(:default_recipient) { "default@gust.com" }
|
8
|
-
let(:domain) { "
|
8
|
+
let(:domain) { "hotmail.com" }
|
9
9
|
|
10
10
|
describe "#delivering_email" do
|
11
11
|
let(:message) { double(:message) }
|
12
12
|
|
13
13
|
before do
|
14
|
-
allow(message).to receive(:to) { destination_address }
|
14
|
+
allow(message).to receive(:to) { [destination_address] }
|
15
15
|
allow(message).to receive(:to=)
|
16
16
|
end
|
17
17
|
|
18
18
|
context "when the given email matches any of the domains given" do
|
19
|
-
let(:destination_address) { "noah@
|
19
|
+
let(:destination_address) { "noah@hotmail.com" }
|
20
20
|
|
21
21
|
it "does not manipulate the destination of the given email" do
|
22
22
|
interceptor.delivering_email(message)
|