posts: fix exception in random:1 filetype:png.
This commit is contained in:
@@ -966,11 +966,11 @@ class Post < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def random_up(key)
|
def random_up(key)
|
||||||
where("md5 < ?", key).reorder(md5: :desc).first
|
where("posts.md5 < ?", key).reorder(md5: :desc).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def random_down(key)
|
def random_down(key)
|
||||||
where("md5 >= ?", key).reorder(md5: :asc).first
|
where("posts.md5 >= ?", key).reorder(md5: :asc).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def sample(query, sample_size)
|
def sample(query, sample_size)
|
||||||
|
|||||||
@@ -1270,11 +1270,12 @@ class PostQueryBuilderTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "return posts for the random:<N> metatag" do
|
should "return posts for the random:<N> metatag" do
|
||||||
post = create(:post)
|
post = create(:post, media_asset: build(:media_asset, file_ext: "png"))
|
||||||
|
|
||||||
assert_tag_match([], "random:0")
|
assert_tag_match([], "random:0")
|
||||||
assert_tag_match([post], "random:1")
|
assert_tag_match([post], "random:1")
|
||||||
assert_tag_match([post], "random:1000")
|
assert_tag_match([post], "random:1000")
|
||||||
|
assert_tag_match([post], "random:1 filetype:png")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return posts ordered by a particular attribute" do
|
should "return posts ordered by a particular attribute" do
|
||||||
|
|||||||
Reference in New Issue
Block a user