File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ def page_collection
165165 } . compact )
166166 end
167167
168- if params [ :url ]
168+ if params [ :url ] . present? && params [ :url ] != '*'
169169 query = params [ :url ]
170170 collection = collection . joins ( :urls )
171171 if query . include? '*'
Original file line number Diff line number Diff line change @@ -117,6 +117,28 @@ def chunk_size_in_url(url)
117117 'Results included pages not matching filtered URL'
118118 end
119119
120+ test 'filtering URL with empty string is the same as no filter' do
121+ sign_in users ( :alice )
122+ all_ids = Page . all . pluck ( :uuid ) . sort
123+ get '/api/v0/pages/?url='
124+ body_json = JSON . parse @response . body
125+ ids = body_json [ 'data' ] . pluck ( 'uuid' ) . sort
126+
127+ assert_equal all_ids , ids
128+ assert_not ids . empty?
129+ end
130+
131+ test 'filtering URL with "*" is the same as no filter' do
132+ sign_in users ( :alice )
133+ all_ids = Page . all . pluck ( :uuid ) . sort
134+ get '/api/v0/pages/?url=*'
135+ body_json = JSON . parse @response . body
136+ ids = body_json [ 'data' ] . pluck ( 'uuid' ) . sort
137+
138+ assert_equal all_ids , ids
139+ assert_not ids . empty?
140+ end
141+
120142 test 'can filter pages by version source_type' do
121143 sign_in users ( :alice )
122144 get api_v0_pages_path ( source_type : 'pagefreezer' )
You can’t perform that action at this time.
0 commit comments