-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathimport_mailer_test.rb
More file actions
61 lines (46 loc) · 1.9 KB
/
Copy pathimport_mailer_test.rb
File metadata and controls
61 lines (46 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require "test_helper"
class ImportMailerTest < ActionMailer::TestCase
test "completed" do
email = ImportMailer.completed(identities(:david), accounts(:"37s"))
assert_emails 1 do
email.deliver_now
end
assert_equal [ "david@37signals.com" ], email.to
assert_equal "Your Fizzy account import is done", email.subject
assert_match accounts(:"37s").slug, email.body.encoded
end
test "failed with no reason" do
import = Account::Import.create!(account: Current.account, identity: identities(:david), status: :failed)
email = ImportMailer.failed(import)
assert_emails 1 do
email.deliver_now
end
assert_equal [ "david@37signals.com" ], email.to
assert_equal "Your Fizzy account import failed", email.subject
assert_match "corrupted export data", email.body.encoded
end
test "failed with conflict reason" do
import = Account::Import.create!(account: Current.account, identity: identities(:david), status: :failed, failure_reason: :conflict)
email = ImportMailer.failed(import)
assert_emails 1 do
email.deliver_now
end
assert_match "account you are trying to import already exists", email.body.encoded
end
test "failed with invalid_export reason" do
import = Account::Import.create!(account: Current.account, identity: identities(:david), status: :failed, failure_reason: :invalid_export)
email = ImportMailer.failed(import)
assert_emails 1 do
email.deliver_now
end
assert_match "isn't a Fizzy account export", email.body.encoded
end
test "failed with insufficient_disk_space reason" do
import = Account::Import.create!(account: Current.account, identity: identities(:david), status: :failed, failure_reason: :insufficient_disk_space)
email = ImportMailer.failed(import)
assert_emails 1 do
email.deliver_now
end
assert_match "twice the export file", email.body.encoded
end
end