/
request_mailer_spec.rb
52 lines (43 loc) · 1.54 KB
/
request_mailer_spec.rb
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
require 'spec_helper'
#require 'ruby-debug'
describe RequestMailer do
fixtures :all
context "notifying missing reimbursements with a narrow threshold" do
before(:each) do
@mcount = ActionMailer::Base.deliveries.size
Request.notify_missing_reimbursement 1.day, 10.days
@request = requests(:luke_for_yavin)
@mail = ActionMailer::Base.deliveries.last
end
it "should mail requester" do
ActionMailer::Base.deliveries.size.should == @mcount + 1
@mail.to.should == [@request.user.email]
end
it "should have the correct subject" do
@mail.subject.should == "Missing reimbursement for #{@request.title}"
end
it "should include request url in the mail body" do
@mail.body.encoded.should match "http.+/requests/#{@request.id}"
end
end
context "notifying missing reimbursements with a big threshold" do
before(:each) do
@mcount = ActionMailer::Base.deliveries.size
Request.notify_missing_reimbursement 10.days, 11.days
end
it "should mail nobody" do
ActionMailer::Base.deliveries.size.should == @mcount
end
end
context "notifying missing reimbursements based on reimbursement deadline" do
before(:each) do
@mcount = ActionMailer::Base.deliveries.size
event = events(:yavin_hackaton)
event.update_attribute(:reimbursement_creation_deadline, 10.days.since)
Request.notify_missing_reimbursement 10.days, 11.days
end
it "should mail requester" do
ActionMailer::Base.deliveries.size.should == @mcount + 1
end
end
end