File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -127,10 +127,29 @@ def combinator=(val)
127
127
alias :m= :combinator=
128
128
alias :m :combinator
129
129
130
+
131
+ # == build_attribute
132
+ #
133
+ # This method was originally called from Nodes::Grouping#new_condition
134
+ # only, without arguments, without #valid? checking, to build a new
135
+ # grouping condition.
136
+ #
137
+ # After refactoring in 235eae3, it is now called from 2 places:
138
+ #
139
+ # 1. Nodes::Condition#attributes=, with +name+ argument passed or +name+
140
+ # and +ransacker_args+. Attributes are included only if #valid?.
141
+ #
142
+ # 2. Nodes::Grouping#new_condition without arguments. In this case, the
143
+ # #valid? conditional needs to be bypassed, otherwise nothing is
144
+ # built. The `name.nil?` conditional below currently does this.
145
+ #
146
+ # TODO: Add test coverage for this behavior and ensure that `name.nil?`
147
+ # isn't fixing issue #702 by introducing untested regressions.
148
+ #
130
149
def build_attribute ( name = nil , ransacker_args = [ ] )
131
150
Attribute . new ( @context , name , ransacker_args ) . tap do |attribute |
132
151
@context . bind ( attribute , attribute . name )
133
- self . attributes << attribute if attribute . valid?
152
+ self . attributes << attribute if name . nil? || attribute . valid?
134
153
if predicate && !negative?
135
154
@context . lock_association ( attribute . parent )
136
155
end
You can’t perform that action at this time.
0 commit comments