diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-28 09:33:51 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-28 09:33:51 -0700 |
commit | 03a0002d9f8fde60bd4ce87e7f5979eddc0ad3a4 (patch) | |
tree | 4c1917121bd4c356734677704b3cf6741a43566d | |
parent | f962fb70a07722483d4443d40805e6e2dd791fa1 (diff) | |
download | rails-03a0002d9f8fde60bd4ce87e7f5979eddc0ad3a4.tar.gz rails-03a0002d9f8fde60bd4ce87e7f5979eddc0ad3a4.tar.bz2 rails-03a0002d9f8fde60bd4ce87e7f5979eddc0ad3a4.zip |
#hash #eql? and #== were only used in tests. removed them and wrote better tests
-rw-r--r-- | lib/arel/algebra/relations/operations/join.rb | 14 | ||||
-rw-r--r-- | spec/algebra/unit/relations/join_spec.rb | 7 | ||||
-rw-r--r-- | spec/algebra/unit/relations/relation_spec.rb | 22 |
3 files changed, 17 insertions, 26 deletions
diff --git a/lib/arel/algebra/relations/operations/join.rb b/lib/arel/algebra/relations/operations/join.rb index 72b4c9b8fe..bfb7727313 100644 --- a/lib/arel/algebra/relations/operations/join.rb +++ b/lib/arel/algebra/relations/operations/join.rb @@ -15,10 +15,6 @@ module Arel relation1.name end - def hash - @hash ||= :relation1.hash - end - def attributes @attributes ||= (relation1.externalize.attributes | relation2.externalize.attributes).bind(self) end @@ -61,16 +57,6 @@ module Arel end end - def == other - super || Join === other && - relation1 == other.relation1 && - relation2 == other.relation2 && - predicates == other.predicates - end - - # FIXME remove this. :'( - alias :eql? :== - def eval result = [] relation1.call.each do |row1| diff --git a/spec/algebra/unit/relations/join_spec.rb b/spec/algebra/unit/relations/join_spec.rb index 5fa3269052..54034a2e32 100644 --- a/spec/algebra/unit/relations/join_spec.rb +++ b/spec/algebra/unit/relations/join_spec.rb @@ -8,13 +8,6 @@ module Arel @predicate = @relation1[:id].eq(@relation2[:user_id]) end - describe 'hashing' do - it 'implements hash equality' do - InnerJoin.new(@relation1, @relation2, @predicate) \ - .should hash_the_same_as(InnerJoin.new(@relation1, @relation2, @predicate)) - end - end - describe '#attributes' do it 'combines the attributes of the two relations' do join = InnerJoin.new(@relation1, @relation2, @predicate) diff --git a/spec/algebra/unit/relations/relation_spec.rb b/spec/algebra/unit/relations/relation_spec.rb index 4e25de73d1..40b8c6585a 100644 --- a/spec/algebra/unit/relations/relation_spec.rb +++ b/spec/algebra/unit/relations/relation_spec.rb @@ -32,14 +32,23 @@ module Arel describe '#join' do describe 'when given a relation' do it "manufactures an inner join operation between those two relations" do - @relation.join(@relation).on(@predicate). \ - should == InnerJoin.new(@relation, @relation, @predicate) + join = @relation.join(@relation).on(@predicate) + join.relation1.should == @relation + join.relation2.should == @relation + join.predicates.should == [@predicate] + join.should be_kind_of(InnerJoin) end end describe "when given a string" do it "manufactures a join operation with the string passed through" do - @relation.join(arbitrary_string = "ASDF").should == StringJoin.new(@relation, arbitrary_string) + arbitrary_string = "ASDF" + + join = @relation.join(arbitrary_string) + join.relation1.should == @relation + join.relation2.should == arbitrary_string + join.predicates.should == [] + join.should be_kind_of StringJoin end end @@ -52,8 +61,11 @@ module Arel describe '#outer_join' do it "manufactures a left outer join operation between those two relations" do - @relation.outer_join(@relation).on(@predicate). \ - should == OuterJoin.new(@relation, @relation, @predicate) + join = @relation.outer_join(@relation).on(@predicate) + join.relation1.should == @relation + join.relation2.should == @relation + join.predicates.should == [@predicate] + join.should be_kind_of OuterJoin end end end |