File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ def ==(comparison_object)
40
40
self.attributes == comparison_object.attributes
41
41
end
42
42
alias :eql? :==
43
+ def hash
44
+ attributes.hash
45
+ end
43
46
RUBY
44
47
45
48
self . hierarchy_class . table_name = hierarchy_table_name
Original file line number Diff line number Diff line change @@ -130,6 +130,15 @@ def nuke_db
130
130
TagHierarchy . find_all_by_ancestor_id ( @root . id ) . should == root_hiers
131
131
TagHierarchy . find_all_by_descendant_id ( @root . id ) . should == root_hiers
132
132
end
133
+
134
+ it "should have different hash codes for each hierarchy model" do
135
+ hashes = TagHierarchy . all . map ( &:hash )
136
+ hashes . should =~ hashes . uniq
137
+ end
138
+
139
+ it "should return the same hash code for equal hierarchy models" do
140
+ TagHierarchy . first . hash . should == TagHierarchy . first . hash
141
+ end
133
142
end
134
143
135
144
it "performs as the readme says it does" do
You can’t perform that action at this time.
0 commit comments