replyr 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -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(User.create, Comment.create)
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(User.create, Comment.create)
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
- it 'parses plain message object correctly' do
7
- mail = Mail.read('test/replyr/emails/reply_plain.eml')
8
- reply_email = Replyr::ReplyEmail.new(mail)
9
- assert_equal "wursttheke@me.com", reply_email.from
10
- assert_equal "Das ist wunderschön", reply_email.stripped_body
11
- end
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
- it 'parses multipart message object correctly' do
14
- mail = Mail.read('test/replyr/emails/reply_multipart.eml')
15
- reply_email = Replyr::ReplyEmail.new(mail)
16
- assert_equal "wursttheke@me.com", reply_email.from
17
- assert_equal "Das ist wunderschön", reply_email.stripped_body
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: replyr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Wüllner