FIX: Remove tag plugin code from tag hashtag check.
This commit is contained in:
parent
3f4f1ee032
commit
bf683178a8
|
@ -28,7 +28,7 @@ export function linkSeenTagHashtags($elem) {
|
|||
|
||||
if ($hashtags.length) {
|
||||
const tagValues = $hashtags.map((_, hashtag) => {
|
||||
return $(hashtag).text().substr(1).replace(`${TAG_HASHTAG_POSTFIX}`, "");
|
||||
return $(hashtag).text().substr(1).replace(TAG_HASHTAG_POSTFIX, "");
|
||||
});
|
||||
|
||||
if (tagValues.length) {
|
||||
|
|
|
@ -177,8 +177,8 @@ class TagsController < ::ApplicationController
|
|||
def check_hashtag
|
||||
tag_values = params[:tag_values].each(&:downcase!)
|
||||
|
||||
valid_tags = TopicCustomField.where(name: DiscourseTagging::TAGS_FIELD_NAME, value: tag_values).map do |tag|
|
||||
{ value: tag.value, url: "#{Discourse.base_url}/tags/#{tag.value}" }
|
||||
valid_tags = Tag.where(name: tag_values).map do |tag|
|
||||
{ value: tag.name, url: tag.full_url }
|
||||
end.compact
|
||||
|
||||
render json: { valid: valid_tags }
|
||||
|
|
|
@ -34,6 +34,10 @@ class Tag < ActiveRecord::Base
|
|||
def self.include_tags?
|
||||
SiteSetting.tagging_enabled && SiteSetting.show_filter_by_tag
|
||||
end
|
||||
|
||||
def full_url
|
||||
"#{Discourse.base_url}/tags/#{self.name}"
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe "Tags" do
|
||||
before do
|
||||
SiteSetting.tagging_enabled = true
|
||||
end
|
||||
|
||||
describe "checking tag hashtags" do
|
||||
let(:tag) { Fabricate(:tag, name: 'test') }
|
||||
|
||||
it "should return the right response" do
|
||||
get "/tags/check.json", { tag_values: [tag.name] }
|
||||
|
||||
expect(response).to be_success
|
||||
|
||||
tag = JSON.parse(response.body)["valid"].first
|
||||
expect(tag["value"]).to eq('test')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue