diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 15:40:15 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 15:40:15 -0700 |
commit | 1a6a3a1c6aa2f75333edef9100951407c4f76f1f (patch) | |
tree | 9e7e524c63e8eeabbdd6ae74ed83cc3469bfca93 /spec | |
parent | 7f01134d1bdca70dcc9b16cf433894e7c8236815 (diff) | |
download | rails-1a6a3a1c6aa2f75333edef9100951407c4f76f1f.tar.gz rails-1a6a3a1c6aa2f75333edef9100951407c4f76f1f.tar.bz2 rails-1a6a3a1c6aa2f75333edef9100951407c4f76f1f.zip |
properly quoting array values
Diffstat (limited to 'spec')
-rw-r--r-- | spec/active_relation/unit/predicates/binary_spec.rb | 28 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/compound_spec.rb | 6 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/join_spec.rb | 9 |
3 files changed, 29 insertions, 14 deletions
diff --git a/spec/active_relation/unit/predicates/binary_spec.rb b/spec/active_relation/unit/predicates/binary_spec.rb index 13b3f10a8c..62d894b0fa 100644 --- a/spec/active_relation/unit/predicates/binary_spec.rb +++ b/spec/active_relation/unit/predicates/binary_spec.rb @@ -54,20 +54,22 @@ module ActiveRelation end describe 'when relating to an array' do - it 'manufactures sql with a list' do - pending - array = [1, 2, 3] - ConcreteBinary.new(@attribute1, array).to_sql.should be_like(" - `users`.`id` <=> (1,2,3) - ") + describe 'when given an arry of elements of the same type of the attribute' do + it 'manufactures sql with a list' do + array = [1, 2, 3] + ConcreteBinary.new(@attribute1, array.bind(@relation)).to_sql.should be_like(" + `users`.`id` <=> (1, 2, 3) + ") + end end - - it 'formats values in the array in the type of the attribute' do - pending - array = ['1-asdf', 2, 3] - ConcreteBinary.new(@attribute1, array).to_sql.should be_like(" - `users`.`id` <=> (1,2,3) - ") + + describe 'when given an array, the elements of which are not the same type as the attribute' do + it 'formats values in the array in the type of the attribute' do + array = ['1-asdf', 2, 3] + ConcreteBinary.new(@attribute1, array.bind(@relation)).to_sql.should be_like(" + `users`.`id` <=> (1, 2, 3) + ") + end end end diff --git a/spec/active_relation/unit/relations/compound_spec.rb b/spec/active_relation/unit/relations/compound_spec.rb index e8fcd12e2c..54a89f3f57 100644 --- a/spec/active_relation/unit/relations/compound_spec.rb +++ b/spec/active_relation/unit/relations/compound_spec.rb @@ -21,5 +21,11 @@ module ActiveRelation @compound_relation.attributes.should == @relation.attributes.collect { |a| a.bind(@compound_relation) } end end + + describe 'hashing' do + it 'implements hash equality' do + ConcreteCompound.new(@relation).should hash_the_same_as(ConcreteCompound.new(@relation)) + end + end end end
\ No newline at end of file diff --git a/spec/active_relation/unit/relations/join_spec.rb b/spec/active_relation/unit/relations/join_spec.rb index fefe069d7b..a0e94a5b65 100644 --- a/spec/active_relation/unit/relations/join_spec.rb +++ b/spec/active_relation/unit/relations/join_spec.rb @@ -24,6 +24,13 @@ module ActiveRelation Join.new("INNER JOIN", @relation1, @relation2, @predicate).should == Join.new("INNER JOIN", @relation2, @relation1, @predicate) end end + + describe 'hashing' do + it 'implements hash equality' do + Join.new("INNER JOIN", @relation1, @relation2, @predicate) \ + .should hash_the_same_as(Join.new("INNER JOIN", @relation1, @relation2, @predicate)) + end + end describe '#qualify' do it 'descends' do @@ -150,6 +157,6 @@ module ActiveRelation ") end end - end + end end end
\ No newline at end of file |