|
6 | 6 |
|
7 | 7 | describe "GET 'new' for a single user email" do |
8 | 8 | it "returns http success" do |
9 | | - get 'new', user: Array(user) |
| 9 | + get :new, user: Array(user) |
10 | 10 | response.should be_success |
11 | 11 | end |
12 | 12 | end |
13 | 13 |
|
14 | 14 | describe "GET 'new' for a diffusion" do |
15 | 15 | it "returns http success" do |
16 | | - get 'new', user: Array(users) |
| 16 | + get :new, user: Array(users) |
17 | 17 | response.should be_success |
18 | 18 | end |
19 | 19 | end |
20 | 20 |
|
21 | 21 | describe "POST 'create' for a single user email" do |
22 | | - it "returns http success" do |
| 22 | + before :each do |
23 | 23 | @message = Fabricate.build(:message) |
24 | | - post 'create', message: @message |
25 | | - response.should be_success |
26 | | - #We expect after send a message that the deliveries raise one |
27 | | - expect { MessageMailer.new_message(@message, @message.email).deliver }.to change { ActionMailer::Base.deliveries.size }.by(1) |
| 24 | + end |
| 25 | + |
| 26 | + it 'delivers the email' do |
| 27 | + expect { |
| 28 | + post :create, message: @message |
| 29 | + }.to change {ActionMailer::Base.deliveries.size}.by(1) |
| 30 | + end |
| 31 | + |
| 32 | + describe 'delivered message' do |
| 33 | + before :each do |
| 34 | + post :create, message: @message |
| 35 | + end |
| 36 | + |
| 37 | + it "returns http success" do |
| 38 | + response.should be_redirect |
| 39 | + end |
| 40 | + |
| 41 | + it 'delivers the mail with the subject that we wanted to' do |
| 42 | + ActionMailer::Base.deliveries.last.subject.should == @message.subject |
| 43 | + end |
| 44 | + |
| 45 | + it 'delivers the mail with the body that we wanted to' do |
| 46 | + ActionMailer::Base.deliveries.last.body.to_s.should match @message.body |
| 47 | + end |
28 | 48 | end |
29 | 49 | end |
30 | 50 |
|
31 | 51 | describe "POST 'create' for a diffusion" do |
32 | 52 | it "returns http success" do |
33 | 53 | @diffusion = Fabricate.build(:diffusion) |
34 | | - post 'create', message: @diffusion |
35 | | - response.should be_success |
36 | | - |
37 | | - @before_send = ActionMailer::Base.deliveries.size |
38 | | - @diffusion.email.each do |email| |
39 | | - MessageMailer.new_message(@diffusion, email).deliver |
40 | | - end |
41 | | - ActionMailer::Base.deliveries.size.should eq @before_send + @diffusion.email.size |
| 54 | + expect { |
| 55 | + post 'create', message: @diffusion |
| 56 | + }.to change {ActionMailer::Base.deliveries.size}.by(@diffusion.email.size) |
42 | 57 | end |
43 | 58 | end |
44 | 59 | end |
0 commit comments