Skip to content

Commit

Permalink
Add to_model method to session
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Johnson <bjohnson@binarylogic.com>
  • Loading branch information
m4n authored and binarylogic committed Sep 12, 2009
1 parent f8cd29c commit e8b3ee7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/authlogic/session/active_record_trickery.rb
Expand Up @@ -50,6 +50,11 @@ module InstanceMethods
def new_record?
new_session?
end

# For rails >= 3.0
def to_model
self
end
end
end
end
Expand Down
11 changes: 10 additions & 1 deletion test/session_test/active_record_trickery_test.rb
Expand Up @@ -15,13 +15,22 @@ def test_human_name
def test_self_and_descendents_from_active_record
assert_equal [UserSession], UserSession.self_and_descendents_from_active_record
end

def test_self_and_descendants_from_active_record
assert_equal [UserSession], UserSession.self_and_descendants_from_active_record
end
end

class InstanceMethodsTest < ActiveSupport::TestCase
def test_new_record
session = UserSession.new
assert session.new_record?
end

def test_to_model
session = UserSession.new
assert session, session.to_model
end
end
end
end
end

0 comments on commit e8b3ee7

Please sign in to comment.