Skip to content

Commit

Permalink
fix eql? method
Browse files Browse the repository at this point in the history
  • Loading branch information
le0pard committed Sep 13, 2024
1 parent b338cd4 commit 8475772
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/ransack/nodes/condition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,13 @@ def eql?(other)
self.attributes == other.attributes &&
self.predicate == other.predicate &&
self.values == other.values &&
self.combinator == other.combinator
self.combinator == other.combinator &&
self.name == other.name
end
alias :== :eql?

def hash
[attributes, predicate, values, combinator].hash
[attributes, predicate, values, combinator, name].hash
end

def predicate_name=(name)
Expand Down
5 changes: 4 additions & 1 deletion spec/ransack/nodes/condition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ module Nodes
Ransack.configure { |c| c.default_predicate = 'eq' }
end

specify { expect(subject).to eq Condition.extract(Context.for(Person), 'full_name_eq', Person.first.name) }
specify do
expect(subject).not_to be_nil
expect(subject.predicate.name).to eq 'eq'
end
end
end
end
Expand Down

0 comments on commit 8475772

Please sign in to comment.