blob: 003510e6070982e1b6445603ab5ed48696651eff (
plain)
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
|
# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminPublicBodyChangeRequestsController, "editing a change request" do
it "should render the edit template" do
change_request = FactoryGirl.create(:add_body_request)
get :edit, :id => change_request.id
response.should render_template("edit")
end
end
describe AdminPublicBodyChangeRequestsController, 'updating a change request' do
before do
@change_request = FactoryGirl.create(:add_body_request)
end
it 'should close the change request' do
post :update, { :id => @change_request.id }
PublicBodyChangeRequest.find(@change_request.id).is_open.should == false
end
context 'when a response and subject are passed' do
it 'should send a response email to the user who requested the change' do
post :update, { :id => @change_request.id,
:response => 'Thanks but no',
:subject => 'Your request' }
deliveries = ActionMailer::Base.deliveries
deliveries.size.should == 1
mail = deliveries[0]
mail.subject.should == 'Your request'
mail.to.should == [@change_request.get_user_email]
mail.body.should =~ /Thanks but no/
end
end
context 'when no response or subject are passed' do
it 'should send a response email to the user who requested the change' do
post :update, { :id => @change_request.id }
deliveries = ActionMailer::Base.deliveries
deliveries.size.should == 0
end
end
end
|