##// END OF EJS Templates
Stub Mailer with mocha....
Jean-Philippe Lang -
r9462:f6882cd69e65
parent child
Show More
@@ -20,23 +20,9 require File.expand_path('../../test_helper', __FILE__)
20 class AdminControllerTest < ActionController::TestCase
20 class AdminControllerTest < ActionController::TestCase
21 fixtures :projects, :users, :roles
21 fixtures :projects, :users, :roles
22
22
23 class TestDelivery
24 def initialize(*)
25 end
26
27 def deliver!(mail)
28 raise 'Some error message'
29 end
30 end
31
32 def setup
23 def setup
33 User.current = nil
24 User.current = nil
34 @request.session[:user_id] = 1 # admin
25 @request.session[:user_id] = 1 # admin
35 @old_delivery_method = ActionMailer::Base.delivery_method
36 end
37
38 def teardown
39 ActionMailer::Base.delivery_method = @old_delivery_method
40 end
26 end
41
27
42 def test_index
28 def test_index
@@ -112,7 +98,7 class AdminControllerTest < ActionController::TestCase
112 end
98 end
113
99
114 def test_test_email_failure_should_display_the_error
100 def test_test_email_failure_should_display_the_error
115 ActionMailer::Base.delivery_method = TestDelivery
101 Mailer.stubs(:test_email).raises(Exception, 'Some error message')
116 get :test_email
102 get :test_email
117 assert_redirected_to '/settings/edit?tab=notifications'
103 assert_redirected_to '/settings/edit?tab=notifications'
118 assert_match /Some error message/, flash[:error]
104 assert_match /Some error message/, flash[:error]
General Comments 0
You need to be logged in to leave comments. Login now