diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-12 15:40:06 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-12 15:40:06 -0700 |
commit | fff47a5a5e92eccf949785231d1f6953d6fdc640 (patch) | |
tree | e7e651d680bacc1542883b6a1c6c2ef21c3f2d1d /spec | |
parent | ea111521b7eb7456934a283d96f6eb986322baf2 (diff) | |
download | rails-fff47a5a5e92eccf949785231d1f6953d6fdc640.tar.gz rails-fff47a5a5e92eccf949785231d1f6953d6fdc640.tar.bz2 rails-fff47a5a5e92eccf949785231d1f6953d6fdc640.zip |
some memoizing and hash equality performance optimizations
Diffstat (limited to 'spec')
-rw-r--r-- | spec/arel/unit/primitives/attribute_spec.rb | 20 | ||||
-rw-r--r-- | spec/arel/unit/relations/insertion_spec.rb | 2 | ||||
-rw-r--r-- | spec/arel/unit/relations/update_spec.rb | 2 |
3 files changed, 8 insertions, 16 deletions
diff --git a/spec/arel/unit/primitives/attribute_spec.rb b/spec/arel/unit/primitives/attribute_spec.rb index e21a5902d5..7e0155f84d 100644 --- a/spec/arel/unit/primitives/attribute_spec.rb +++ b/spec/arel/unit/primitives/attribute_spec.rb @@ -4,7 +4,7 @@ module Arel describe Attribute do before do @relation = Table.new(:users) - @attribute = Attribute.new(@relation, :id) + @attribute = @relation[:id] end describe Attribute::Transformations do @@ -45,22 +45,21 @@ module Arel end describe Attribute::Congruence do - describe 'match?' do - + describe '#match?' do it "obtains if the attributes are identical" do - Attribute.new(@relation, :name).should be_match(Attribute.new(@relation, :name)) + @attribute.should be_match(@attribute) end it "obtains if the attributes have an overlapping history" do - Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name)).should be_match(Attribute.new(@relation, :name)) - Attribute.new(@relation, :name).should be_match(Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name))) + Attribute.new(@relation, :id, :ancestor => @attribute).should be_match(@attribute) + @attribute.should be_match(Attribute.new(@relation, :id, :ancestor => @attribute)) end end describe '/' do before do @aliased_relation = @relation.alias - @doubly_aliased_relation = @aliased_relation.alias.alias.alias.alias + @doubly_aliased_relation = @aliased_relation.alias end describe 'when dividing two identical attributes' do @@ -85,13 +84,6 @@ module Arel end end end - - describe 'hashing' do - it "implements hash equality" do - Attribute.new(@relation, 'name').should hash_the_same_as(Attribute.new(@relation, 'name')) - Attribute.new(@relation, 'name').should_not hash_the_same_as(Attribute.new(@relation, 'id')) - end - end end describe '#to_sql' do diff --git a/spec/arel/unit/relations/insertion_spec.rb b/spec/arel/unit/relations/insertion_spec.rb index 10b70a2036..0667aa665e 100644 --- a/spec/arel/unit/relations/insertion_spec.rb +++ b/spec/arel/unit/relations/insertion_spec.rb @@ -24,7 +24,7 @@ module Arel @insertion.to_sql.should be_like(" INSERT INTO `users` - (`users`.`id`, `users`.`name`) VALUES (1, 'nick') + (`users`.`name`, `users`.`id`) VALUES ('nick', 1) ") end diff --git a/spec/arel/unit/relations/update_spec.rb b/spec/arel/unit/relations/update_spec.rb index f411781392..976e88dddc 100644 --- a/spec/arel/unit/relations/update_spec.rb +++ b/spec/arel/unit/relations/update_spec.rb @@ -10,7 +10,7 @@ module Arel it "manufactures sql updating attributes when given multiple attributes" do Update.new(@relation, @relation[:id] => 1, @relation[:name] => "nick").to_sql.should be_like(" UPDATE `users` - SET `users`.`id` = 1, `users`.`name` = 'nick' + SET `users`.`name` = 'nick', `users`.`id` = 1 ") end |