Fix #3430: Accept the search[id] param in all controllers.
* Allow every controller to take the `search[id]` param. * Parse the `search[id]` param the same way that the `id:<N>` metatag is parsed. So `search[id]=1,2,3`, `search[id]=<42`, `search[id]=1..10`, for example, are all accepted.
This commit is contained in:
19
test/unit/application_record.rb
Normal file
19
test/unit/application_record.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ApplicationRecordTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@tags = FactoryGirl.create_list(:tag, 3, post_count: 1)
|
||||
end
|
||||
|
||||
context "ApplicationRecord#search" do
|
||||
should "support the id param" do
|
||||
assert_equal([@tags.first], Tag.search(id: @tags.first.id))
|
||||
end
|
||||
|
||||
should "support ranges in the id param" do
|
||||
assert_equal(@tags.reverse, Tag.search(id: ">=1"))
|
||||
assert_equal(@tags.reverse, Tag.search(id: "#{@tags[0].id}..#{@tags[2].id}"))
|
||||
assert_equal(@tags.reverse, Tag.search(id: @tags.map(&:id).join(",")))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user