diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-02 17:56:18 -0800 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-02 17:56:18 -0800 |
commit | c54392872f024d55e8a23ead3065e6119a52b234 (patch) | |
tree | 905aee0f7c40436ff41979227e9eb72e4a6840ba /spec | |
parent | 86550ef2bee377a5e4134dc63dedb138bb9ab7dc (diff) | |
download | rails-c54392872f024d55e8a23ead3065e6119a52b234.tar.gz rails-c54392872f024d55e8a23ead3065e6119a52b234.tar.bz2 rails-c54392872f024d55e8a23ead3065e6119a52b234.zip |
introduced engine dependency for sql strategies
- hacked in default engine for scalars -- BAD
Diffstat (limited to 'spec')
-rw-r--r-- | spec/active_relation/unit/primitives/attribute_spec.rb | 6 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/join_spec.rb | 6 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/table_spec.rb | 11 | ||||
-rw-r--r-- | spec/active_relation/unit/session/session_spec.rb | 10 | ||||
-rw-r--r-- | spec/spec_helper.rb | 3 |
5 files changed, 31 insertions, 5 deletions
diff --git a/spec/active_relation/unit/primitives/attribute_spec.rb b/spec/active_relation/unit/primitives/attribute_spec.rb index 8b4f52c432..95c972d814 100644 --- a/spec/active_relation/unit/primitives/attribute_spec.rb +++ b/spec/active_relation/unit/primitives/attribute_spec.rb @@ -51,6 +51,12 @@ module ActiveRelation end end + describe '#engine' do + it "delegates to its relation" do + Attribute.new(@relation, :id).engine.should == @relation.engine + end + end + describe Attribute::Congruence do describe '=~' do it "obtains if the attributes are identical" do diff --git a/spec/active_relation/unit/relations/join_spec.rb b/spec/active_relation/unit/relations/join_spec.rb index 532dc08753..64d41effc5 100644 --- a/spec/active_relation/unit/relations/join_spec.rb +++ b/spec/active_relation/unit/relations/join_spec.rb @@ -38,6 +38,12 @@ module ActiveRelation end end + describe '#engine' do + it "delegates to a relation's engine" do + Join.new("INNER JOIN", @relation1, @relation2, @predicate).engine.should == @relation1.engine + end + end + describe 'with simple relations' do describe '#attributes' do it 'combines the attributes of the two relations' do diff --git a/spec/active_relation/unit/relations/table_spec.rb b/spec/active_relation/unit/relations/table_spec.rb index 5c7fa35e63..8f14ce33cf 100644 --- a/spec/active_relation/unit/relations/table_spec.rb +++ b/spec/active_relation/unit/relations/table_spec.rb @@ -80,5 +80,16 @@ module ActiveRelation hash[Table.new(:users)].should == 1 end end + + describe '#engine' do + it "defaults to global engine" do + Table.engine = engine = Engine.new + Table.new(:users).engine.should == engine + end + + it "can be specified" do + Table.new(:users, engine = Engine.new).engine.should == engine + end + end end end
\ No newline at end of file diff --git a/spec/active_relation/unit/session/session_spec.rb b/spec/active_relation/unit/session/session_spec.rb index 118b99948c..1ac69976b5 100644 --- a/spec/active_relation/unit/session/session_spec.rb +++ b/spec/active_relation/unit/session/session_spec.rb @@ -40,19 +40,19 @@ module ActiveRelation describe '#create' do it "executes an insertion on the connection" do - mock(@session.connection).insert(@insert.to_sql) + mock(@insert.engine).insert(@insert.to_sql) @session.create(@insert) end end describe '#read' do it "executes an selection on the connection" do - mock(@session.connection).select_all(@select.to_sql).once + mock(@select.engine).select_all(@select.to_sql).once @session.read(@select) end it "is memoized" do - mock(@session.connection).select_all(@select.to_sql).once + mock(@select.engine).select_all(@select.to_sql).once @session.read(@select) @session.read(@select) end @@ -60,14 +60,14 @@ module ActiveRelation describe '#update' do it "executes an update on the connection" do - mock(@session.connection).update(@update.to_sql) + mock(@update.engine).update(@update.to_sql) @session.update(@update) end end describe '#delete' do it "executes a delete on the connection" do - mock(@session.connection).delete(@delete.to_sql) + mock(@delete.engine).delete(@delete.to_sql) @session.delete(@delete) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 59202dc9f0..cd9c8e96cb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,4 +28,7 @@ end Spec::Runner.configure do |config| config.include(BeLikeMatcher) config.mock_with :rr + config.before do + ActiveRelation::Table.engine = ActiveRecord::Base.connection + end end
\ No newline at end of file |