diff options
author | Azul <azul@leap.se> | 2012-12-03 14:02:16 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-12-03 14:02:16 +0100 |
commit | 1b411de39f38eb0925cf255e941545933f227759 (patch) | |
tree | 1fd0a6980d67e99820052d409ac82339ff101368 /users/test/support/auth_test_helper.rb | |
parent | 2a928455f9dcefa465b80b79768ba1d1a423e6e9 (diff) |
refactored tests with new find_record helper
find_record User will return a stubbed user record and make sure User.find_by_id(user.id) returns the same so it can be used in controllers.
Diffstat (limited to 'users/test/support/auth_test_helper.rb')
-rw-r--r-- | users/test/support/auth_test_helper.rb | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/users/test/support/auth_test_helper.rb b/users/test/support/auth_test_helper.rb index e0b673a..f3506ae 100644 --- a/users/test/support/auth_test_helper.rb +++ b/users/test/support/auth_test_helper.rb @@ -10,8 +10,8 @@ module AuthTestHelper end end - def login(user_or_method_hash = nil) - @current_user = stub_user(user_or_method_hash) + def login(user_or_method_hash = {}) + @current_user = stub_record(User, user_or_method_hash) unless @current_user.respond_to? :is_admin? @current_user.stubs(:is_admin?).returns(false) end @@ -28,19 +28,6 @@ module AuthTestHelper end end - protected - - # Will create a stub user for logging in from either - # * a hash of methods to stub - # * a user record - # * nil -> create a user record stub - def stub_user(user_or_method_hash) - if user_or_method_hash.is_a?(Hash) - stub_record User, user_or_method_hash - else - user_or_method_hash || stub_record(User) - end - end end class ActionController::TestCase |