diff test/functional/welcome_controller_test.rb @ 511:107d36338b70 live

Merge from branch "cannam"
author Chris Cannam
date Thu, 14 Jul 2011 10:43:07 +0100
parents 051f544170fe
children cbb26bc654de
line wrap: on
line diff
--- a/test/functional/welcome_controller_test.rb	Thu Jun 09 16:51:06 2011 +0100
+++ b/test/functional/welcome_controller_test.rb	Thu Jul 14 10:43:07 2011 +0100
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-require File.dirname(__FILE__) + '/../test_helper'
+require File.expand_path('../../test_helper', __FILE__)
 require 'welcome_controller'
 
 # Re-raise errors caught by the controller.
@@ -67,4 +67,28 @@
     assert_equal 'text/plain', @response.content_type
     assert @response.body.match(%r{^Disallow: /projects/ecookbook/issues\r?$})
   end
+  
+  def test_warn_on_leaving_unsaved_turn_on
+    user = User.find(2)
+    user.pref.warn_on_leaving_unsaved = '1'
+    user.pref.save!
+    @request.session[:user_id] = 2
+    
+    get :index
+    assert_tag 'script',
+      :attributes => {:type => "text/javascript"},
+      :content => %r{new WarnLeavingUnsaved}
+  end
+  
+  def test_warn_on_leaving_unsaved_turn_off
+    user = User.find(2)
+    user.pref.warn_on_leaving_unsaved = '0'
+    user.pref.save!
+    @request.session[:user_id] = 2
+    
+    get :index
+    assert_no_tag 'script',
+      :attributes => {:type => "text/javascript"},
+      :content => %r{new WarnLeavingUnsaved}
+  end
 end