Warning on leaving a page with unsaved content in textarea (#2910).

The warning can be turned off in the user's preference.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4900 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2011-02-21 09:53:29 +00:00
parent 11c72f2823
commit 17591a3ea5
8 changed files with 85 additions and 1 deletions
@@ -67,4 +67,28 @@ class WelcomeControllerTest < ActionController::TestCase
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