diff options
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r-- | test/test_helper.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb index 66a6f2646..3c2cece7b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -114,6 +114,15 @@ class ActiveSupport::TestCase saved_settings.each {|k, v| Setting[k] = v} if saved_settings end + # Yields the block with user as the current user + def with_current_user(user, &block) + saved_user = User.current + User.current = user + yield + ensure + User.current = saved_user + end + def change_user_password(login, new_password) user = User.first(:conditions => {:login => login}) user.password, user.password_confirmation = new_password, new_password |