Merge pull request #4534 from BrokenEagle/fix-4533
Fix the tag matches option
This commit is contained in:
@@ -33,7 +33,7 @@ class PostVersion < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tag_matches(string)
|
def tag_matches(string)
|
||||||
tag = string.split(/\S+/)[0]
|
tag = string.match(/\S+/)[0]
|
||||||
return all if tag.nil?
|
return all if tag.nil?
|
||||||
tag = "*#{tag}*" unless tag =~ /\*/
|
tag = "*#{tag}*" unless tag =~ /\*/
|
||||||
where_ilike(:tags, tag)
|
where_ilike(:tags, tag)
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ class PostVersionsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal @post.versions[1].id, response.parsed_body[0]["id"].to_i
|
assert_equal @post.versions[1].id, response.parsed_body[0]["id"].to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "list all versions for search[tag_matches]" do
|
||||||
|
get post_versions_path, as: :json, params: { search: { tag_matches: "tagme" }}
|
||||||
|
assert_response :success
|
||||||
|
assert_equal @post.versions[0].id, response.parsed_body[0]["id"].to_i
|
||||||
|
assert_equal 1, response.parsed_body.length
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "undo action" do
|
context "undo action" do
|
||||||
|
|||||||
Reference in New Issue
Block a user