Merge pull request #4534 from BrokenEagle/fix-4533

Fix the tag matches option
This commit is contained in:
evazion
2020-06-23 03:00:32 -05:00
committed by GitHub
2 changed files with 8 additions and 1 deletions

View File

@@ -33,7 +33,7 @@ class PostVersion < ApplicationRecord
end
def tag_matches(string)
tag = string.split(/\S+/)[0]
tag = string.match(/\S+/)[0]
return all if tag.nil?
tag = "*#{tag}*" unless tag =~ /\*/
where_ilike(:tags, tag)

View File

@@ -41,6 +41,13 @@ class PostVersionsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
assert_equal @post.versions[1].id, response.parsed_body[0]["id"].to_i
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
context "undo action" do