From 78fffbce7e9df11b5b4ebb02b54d9012e4624bc3 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Mon, 6 Jan 2014 14:08:38 -0300 Subject: [PATCH] MailconfController: make the functionals tests self contained --- test/functional/mailconf_controller_test.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/functional/mailconf_controller_test.rb b/test/functional/mailconf_controller_test.rb index ae2cf9d..0cbd6d8 100644 --- a/test/functional/mailconf_controller_test.rb +++ b/test/functional/mailconf_controller_test.rb @@ -2,16 +2,17 @@ require File.dirname(__FILE__) + '/../test_helper' class MailconfControllerTest < ActionController::TestCase - all_fixtures - def setup @controller = MailconfController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new + User.destroy_all + @user = create_user('ze') MailConf.stubs(:enabled?).returns(true) MailConf.stubs(:webmail_url).returns('http://web.mail.net/') end + attr_accessor :user should 'check if mail is enabled' do MailConf.expects(:enabled?).returns(false) @@ -29,7 +30,8 @@ class MailconfControllerTest < ActionController::TestCase end should 'not be edited by others' do - login_as('johndoe') + another = create_user('johndoe') + login_as(another.login) get :index, :profile => 'ze' assert_response 403 end @@ -43,7 +45,7 @@ class MailconfControllerTest < ActionController::TestCase should 'expose user to templates' do login_as('ze') get :index, :profile => 'ze' - assert_equal users(:ze), assigns(:user) + assert_equal user, assigns(:user) end should 'present enable/disable for e-mail use' do @@ -58,7 +60,7 @@ class MailconfControllerTest < ActionController::TestCase should 'display correctly the state false of e-mail enable/disable' do login_as('ze') - users(:ze).update_attributes!(:enable_email => false) + user.update_attributes!(:enable_email => false) get :index, :profile => 'ze' assert_tag :tag => 'a', :content => 'Enable e-Mail' assert_no_tag :tag => 'a', :content => 'Disable e-Mail', :attributes => { :href => '/myprofile/ze/mailconf/disable' } @@ -91,7 +93,7 @@ class MailconfControllerTest < ActionController::TestCase should 'save mail enable/disable as false' do login_as('ze') - assert users(:ze).enable_email! + assert user.enable_email! post :disable, :profile => 'ze' assert !Profile['ze'].user.enable_email end @@ -122,8 +124,8 @@ class MailconfControllerTest < ActionController::TestCase should 'not display input for enable/disable e-mail when has pending_enable_email' do login_as('ze') - users(:ze).update_attribute(:environment_id, Environment.default.id) - EmailActivation.create!(:requestor => users(:ze).person, :target => Environment.default) + user.update_attribute(:environment_id, Environment.default.id) + EmailActivation.create!(:requestor => user.person, :target => Environment.default) get :index, :profile => 'ze' assert_no_tag :tag => 'input', :attributes => {:name => 'user[enable_email]', :type => 'checkbox'} end -- libgit2 0.21.2