Skip to content

Commit

Permalink
Reimbusement reminder sent only to requester
Browse files Browse the repository at this point in the history
Conflicts:
	app/models/request.rb
  • Loading branch information
ancorgs committed Jul 2, 2014
1 parent 7aa414a commit 3ec9218
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 1 addition & 2 deletions app/models/request.rb
Expand Up @@ -202,8 +202,7 @@ def self.notify_missing_reimbursement(after_end_threshold, before_deadline_thres
candidate_events.includes(:requests).each do |e|
e.requests.each do |r|
if r.lacks_reimbursement?
users = [r.user] + [:tsp, :assistant]
RequestMailer::notify_to(users, :missing_reimbursement, r)
RequestMailer::notify_to([r.user], :missing_reimbursement, r)
end
end
end
Expand Down
18 changes: 11 additions & 7 deletions spec/models/request_mailer_spec.rb
Expand Up @@ -9,16 +9,20 @@
@mcount = ActionMailer::Base.deliveries.size
Request.notify_missing_reimbursement 1.day, 10.days
@request = requests(:luke_for_yavin)
@mails = ActionMailer::Base.deliveries[-3..-1]
@mail = ActionMailer::Base.deliveries.last
end

it "should mail requester, tsp and assistant" do
ActionMailer::Base.deliveries.size.should == @mcount + 3
@mails.map(&:to).flatten.should include @request.user.email
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
@mails.first.body.encoded.should match "http.+/requests/#{@request.id}"
@mail.body.encoded.should match "http.+/requests/#{@request.id}"
end
end

Expand All @@ -41,8 +45,8 @@
Request.notify_missing_reimbursement 10.days, 11.days
end

it "should mail requester, tsp and assistant" do
ActionMailer::Base.deliveries.size.should == @mcount+3
it "should mail requester" do
ActionMailer::Base.deliveries.size.should == @mcount + 1
end
end
end

0 comments on commit 3ec9218

Please sign in to comment.