Commit 78fffbce7e9df11b5b4ebb02b54d9012e4624bc3
Committed by
Rodrigo Souto
1 parent
d0894925
Exists in
master
and in
29 other branches
MailconfController: make the functionals tests self contained
Showing
1 changed file
with
10 additions
and
8 deletions
Show diff stats
test/functional/mailconf_controller_test.rb
... | ... | @@ -2,16 +2,17 @@ require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | |
3 | 3 | class MailconfControllerTest < ActionController::TestCase |
4 | 4 | |
5 | - all_fixtures | |
6 | - | |
7 | 5 | def setup |
8 | 6 | @controller = MailconfController.new |
9 | 7 | @request = ActionController::TestRequest.new |
10 | 8 | @response = ActionController::TestResponse.new |
9 | + User.destroy_all | |
10 | + @user = create_user('ze') | |
11 | 11 | |
12 | 12 | MailConf.stubs(:enabled?).returns(true) |
13 | 13 | MailConf.stubs(:webmail_url).returns('http://web.mail.net/') |
14 | 14 | end |
15 | + attr_accessor :user | |
15 | 16 | |
16 | 17 | should 'check if mail is enabled' do |
17 | 18 | MailConf.expects(:enabled?).returns(false) |
... | ... | @@ -29,7 +30,8 @@ class MailconfControllerTest < ActionController::TestCase |
29 | 30 | end |
30 | 31 | |
31 | 32 | should 'not be edited by others' do |
32 | - login_as('johndoe') | |
33 | + another = create_user('johndoe') | |
34 | + login_as(another.login) | |
33 | 35 | get :index, :profile => 'ze' |
34 | 36 | assert_response 403 |
35 | 37 | end |
... | ... | @@ -43,7 +45,7 @@ class MailconfControllerTest < ActionController::TestCase |
43 | 45 | should 'expose user to templates' do |
44 | 46 | login_as('ze') |
45 | 47 | get :index, :profile => 'ze' |
46 | - assert_equal users(:ze), assigns(:user) | |
48 | + assert_equal user, assigns(:user) | |
47 | 49 | end |
48 | 50 | |
49 | 51 | should 'present enable/disable for e-mail use' do |
... | ... | @@ -58,7 +60,7 @@ class MailconfControllerTest < ActionController::TestCase |
58 | 60 | |
59 | 61 | should 'display correctly the state false of e-mail enable/disable' do |
60 | 62 | login_as('ze') |
61 | - users(:ze).update_attributes!(:enable_email => false) | |
63 | + user.update_attributes!(:enable_email => false) | |
62 | 64 | get :index, :profile => 'ze' |
63 | 65 | assert_tag :tag => 'a', :content => 'Enable e-Mail' |
64 | 66 | assert_no_tag :tag => 'a', :content => 'Disable e-Mail', :attributes => { :href => '/myprofile/ze/mailconf/disable' } |
... | ... | @@ -91,7 +93,7 @@ class MailconfControllerTest < ActionController::TestCase |
91 | 93 | |
92 | 94 | should 'save mail enable/disable as false' do |
93 | 95 | login_as('ze') |
94 | - assert users(:ze).enable_email! | |
96 | + assert user.enable_email! | |
95 | 97 | post :disable, :profile => 'ze' |
96 | 98 | assert !Profile['ze'].user.enable_email |
97 | 99 | end |
... | ... | @@ -122,8 +124,8 @@ class MailconfControllerTest < ActionController::TestCase |
122 | 124 | |
123 | 125 | should 'not display input for enable/disable e-mail when has pending_enable_email' do |
124 | 126 | login_as('ze') |
125 | - users(:ze).update_attribute(:environment_id, Environment.default.id) | |
126 | - EmailActivation.create!(:requestor => users(:ze).person, :target => Environment.default) | |
127 | + user.update_attribute(:environment_id, Environment.default.id) | |
128 | + EmailActivation.create!(:requestor => user.person, :target => Environment.default) | |
127 | 129 | get :index, :profile => 'ze' |
128 | 130 | assert_no_tag :tag => 'input', :attributes => {:name => 'user[enable_email]', :type => 'checkbox'} |
129 | 131 | end | ... | ... |