aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-21 16:55:04 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-21 16:55:04 -0700
commit87a319cd0c51cbc8f6bc8e3d11ab9e30a96ac628 (patch)
tree6def8b66cac5408333fa0cad4198a6f787f81dda /activerecord
parentf5de56f53768bf07a337c9bf32b397a9d3e61cf0 (diff)
downloadrails-87a319cd0c51cbc8f6bc8e3d11ab9e30a96ac628.tar.gz
rails-87a319cd0c51cbc8f6bc8e3d11ab9e30a96ac628.tar.bz2
rails-87a319cd0c51cbc8f6bc8e3d11ab9e30a96ac628.zip
testing new_record? and converting to an attribute
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/session_store.rb8
-rw-r--r--activerecord/test/cases/session_store/sql_bypass.rb5
2 files changed, 8 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/session_store.rb b/activerecord/lib/active_record/session_store.rb
index 5de812962a..17f09d64b0 100644
--- a/activerecord/lib/active_record/session_store.rb
+++ b/activerecord/lib/active_record/session_store.rb
@@ -231,7 +231,9 @@ module ActiveRecord
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 @@ module ActiveRecord
@new_record = @marshaled_data.nil?
end
- def new_record?
- @new_record
- end
-
# Lazy-unmarshal session state.
def data
unless @data
diff --git a/activerecord/test/cases/session_store/sql_bypass.rb b/activerecord/test/cases/session_store/sql_bypass.rb
index 5484c34f7d..cea5e4eabe 100644
--- a/activerecord/test/cases/session_store/sql_bypass.rb
+++ b/activerecord/test/cases/session_store/sql_bypass.rb
@@ -17,6 +17,11 @@ module ActiveRecord
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