diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-02 17:05:06 -0800 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-02 17:05:06 -0800 |
commit | 86550ef2bee377a5e4134dc63dedb138bb9ab7dc (patch) | |
tree | 50726fc4904437eeb83ab7ad999ced774e253f71 /spec/active_relation/unit/session | |
parent | 92db013ba3ee4d0a9d92281e614d05f064c22e15 (diff) | |
download | rails-86550ef2bee377a5e4134dc63dedb138bb9ab7dc.tar.gz rails-86550ef2bee377a5e4134dc63dedb138bb9ab7dc.tar.bz2 rails-86550ef2bee377a5e4134dc63dedb138bb9ab7dc.zip |
new concept of session boundaries
Diffstat (limited to 'spec/active_relation/unit/session')
-rw-r--r-- | spec/active_relation/unit/session/session_spec.rb | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/spec/active_relation/unit/session/session_spec.rb b/spec/active_relation/unit/session/session_spec.rb index ddd748334a..118b99948c 100644 --- a/spec/active_relation/unit/session/session_spec.rb +++ b/spec/active_relation/unit/session/session_spec.rb @@ -4,13 +4,29 @@ module ActiveRelation describe Session do before do @relation = Table.new(:users) - @session = Session.instance + @session = Session.new end - describe Singleton do - it "is a singleton" do - Session.instance.should be_equal(Session.instance) - lambda { Session.new }.should raise_error + describe '::start' do + describe '::instance' do + it "it is a singleton within the started session" do + Session.start do + Session.new.should == Session.new + end + end + + it "is a singleton across nested sessions" do + Session.start do + outside = Session.new + Session.start do + Session.new.should == outside + end + end + end + + it "manufactures new sessions outside of the started session" do + Session.new.should_not == Session.new + end end end @@ -23,28 +39,34 @@ module ActiveRelation end describe '#create' do - it "should execute an insertion on the connection" do + it "executes an insertion on the connection" do mock(@session.connection).insert(@insert.to_sql) @session.create(@insert) end end describe '#read' do - it "should execute an selection on the connection" do - mock(@session.connection).select_all(@select.to_sql) + it "executes an selection on the connection" do + mock(@session.connection).select_all(@select.to_sql).once + @session.read(@select) + end + + it "is memoized" do + mock(@session.connection).select_all(@select.to_sql).once + @session.read(@select) @session.read(@select) end end describe '#update' do - it "should execute an update on the connection" do + it "executes an update on the connection" do mock(@session.connection).update(@update.to_sql) @session.update(@update) end end describe '#delete' do - it "should execute a delete on the connection" do + it "executes a delete on the connection" do mock(@session.connection).delete(@delete.to_sql) @session.delete(@delete) end |