replyr 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/replyr/reply_email.rb +6 -5
- data/lib/replyr/version.rb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +3965 -0
- data/test/replyr/reply_address_test.rb +2 -2
- data/test/replyr/reply_email_test.rb +35 -11
- metadata +1 -1
@@ -40,7 +40,7 @@ describe Replyr::ReplyAddress do
|
|
40
40
|
|
41
41
|
describe '#token_valid?' do
|
42
42
|
before do
|
43
|
-
@address = Replyr::ReplyAddress.new(
|
43
|
+
@address = Replyr::ReplyAddress.new(Comment.create, User.create)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'return true if the passed token is valid' do
|
@@ -54,7 +54,7 @@ describe Replyr::ReplyAddress do
|
|
54
54
|
|
55
55
|
describe '#ensure_valid_token!' do
|
56
56
|
before do
|
57
|
-
@address = Replyr::ReplyAddress.new(
|
57
|
+
@address = Replyr::ReplyAddress.new(Comment.create, User.create)
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'throws exception if token is invalid' do
|
@@ -3,17 +3,41 @@ require_relative '../test_helper'
|
|
3
3
|
require 'mail'
|
4
4
|
|
5
5
|
describe Replyr::ReplyEmail do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
describe "#new" do
|
7
|
+
it 'parses plain message object correctly' do
|
8
|
+
mail = Mail.read('test/replyr/emails/reply_plain.eml')
|
9
|
+
reply_email = Replyr::ReplyEmail.new(mail)
|
10
|
+
assert_equal "wursttheke@me.com", reply_email.from
|
11
|
+
assert_equal "Das ist wunderschön", reply_email.stripped_body
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'parses multipart message object correctly' do
|
15
|
+
mail = Mail.read('test/replyr/emails/reply_multipart.eml')
|
16
|
+
reply_email = Replyr::ReplyEmail.new(mail)
|
17
|
+
assert_equal "wursttheke@me.com", reply_email.from
|
18
|
+
assert_equal "Das ist wunderschön", reply_email.stripped_body
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#process' do
|
23
|
+
it 'returns false if mail is invalid' do
|
24
|
+
mail = Mail.read('test/replyr/emails/reply_plain.eml')
|
25
|
+
reply_email = Replyr::ReplyEmail.new(mail)
|
26
|
+
assert_equal false, reply_email.process
|
27
|
+
end
|
28
|
+
|
29
|
+
it "processes mail if it's valid and return true" do
|
30
|
+
address = Replyr::ReplyAddress.new(Comment.create, User.create).address
|
31
|
+
mail = Mail.read('test/replyr/emails/reply_plain.eml')
|
32
|
+
mail.to = address # set correct address
|
33
|
+
reply_email = Replyr::ReplyEmail.new(mail)
|
34
|
+
|
35
|
+
assert true, reply_email.is_reply_email?
|
12
36
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
37
|
+
comment_count = Comment.count
|
38
|
+
assert_equal true, reply_email.process
|
39
|
+
assert_equal comment_count + 1, Comment.count
|
40
|
+
end
|
41
|
+
|
18
42
|
end
|
19
43
|
end
|