Permalink
Browse files

testing new_record? and converting to an attribute

  • Loading branch information...
1 parent f5de56f commit 87a319cd0c51cbc8f6bc8e3d11ab9e30a96ac628 @tenderlove tenderlove committed Jul 21, 2010
@@ -231,7 +231,9 @@ def drop_table!
end
end
- attr_reader :session_id
+ attr_reader :session_id, :new_record
+ alias :new_record? :new_record
+
attr_writer :data
# Look for normal and marshaled data, self.find_by_session_id's way of
@@ -244,10 +246,6 @@ def initialize(attributes)
@new_record = @marshaled_data.nil?
end
- def new_record?
- @new_record
- end
-
# Lazy-unmarshal session state.
def data
unless @data
@@ -17,6 +17,11 @@ def test_create_table
SqlBypass.drop_table!
assert !Session.table_exists?
end
+
+ def test_new_record?
+ s = SqlBypass.new :data => 'foo', :session_id => 10
+ assert s.new_record?, 'this is a new record!'
+ end
end
end
end

0 comments on commit 87a319c

Please sign in to comment.