File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -193,14 +193,14 @@ def parse_string_arrays(value, singular_filter)
193193 # Find the quoted strings
194194 quotes = value . scan ( /{{.*?}}/ )
195195 # remove them from the rest
196- quotes . each { |q | value . gsub! ( q , "" ) }
196+ non_quotes = quotes . inject ( value ) { |v , q | v . gsub ( q , "" ) }
197197 # remove the quote characters from the quoted strings
198198 quotes . each { |q | q . gsub! ( "{{" , "" ) . gsub! ( "}}" , "" ) }
199199 # merge everything back together into an array
200200 value = if singular_filter
201- Array ( value ) + quotes
201+ Array ( non_quotes ) + quotes
202202 else
203- Array ( value . split ( "," ) ) + quotes
203+ Array ( non_quotes . split ( "," ) ) + quotes
204204 end
205205 # remove any blanks that are left
206206 value . reject! { |v | v . length . zero? }
Original file line number Diff line number Diff line change @@ -29,6 +29,20 @@ def self.name
2929 expect ( records . map ( &:id ) ) . to eq ( [ employee1 . id ] )
3030 end
3131
32+ context "retains filtering value" do
33+ it "when value includes curly brackets" do
34+ params [ :filter ] = { first_name : "{{John}}" }
35+ records
36+ expect ( params [ :filter ] ) . to eq ( first_name : "{{John}}" )
37+ end
38+
39+ it "when value does not include curly brackets" do
40+ params [ :filter ] = { first_name : "John" }
41+ records
42+ expect ( params [ :filter ] ) . to eq ( first_name : "John" )
43+ end
44+ end
45+
3246 context "when filter is type hash" do
3347 before do
3448 resource . filter :by_json , :hash do
You can’t perform that action at this time.
0 commit comments