diff options
-rw-r--r-- | lib/arel/nodes/casted.rb | 4 | ||||
-rw-r--r-- | test/nodes/test_casted.rb | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/arel/nodes/casted.rb b/lib/arel/nodes/casted.rb index 9fa02955ef..543374d695 100644 --- a/lib/arel/nodes/casted.rb +++ b/lib/arel/nodes/casted.rb @@ -10,6 +10,10 @@ module Arel def nil?; @val.nil?; end + def hash + [@class, @val, @attribute].hash + end + def eql? other self.class == other.class && self.val == other.val && diff --git a/test/nodes/test_casted.rb b/test/nodes/test_casted.rb new file mode 100644 index 0000000000..6d775e17ec --- /dev/null +++ b/test/nodes/test_casted.rb @@ -0,0 +1,16 @@ +require 'helper' + +module Arel + module Nodes + describe Casted do + describe '#hash' do + it 'is equal when eql? returns true' do + one = Casted.new 1, 2 + also_one = Casted.new 1, 2 + + assert_equal one.hash, also_one.hash + end + end + end + end +end |