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