388ec0d5b6
* Clean up SQL output in Tag and Account search methods * Add basic coverage for Tag.search_for * Add coverage for Account.search_for * Add coverage for Account.advanced_search_for
27 lines
743 B
Ruby
27 lines
743 B
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Tag, type: :model do
|
|
describe 'HASHTAG_RE' do
|
|
subject { Tag::HASHTAG_RE }
|
|
|
|
it 'does not match URLs with anchors with non-hashtag characters' do
|
|
expect(subject.match('Check this out https://medium.com/@alice/some-article#.abcdef123')).to be_nil
|
|
end
|
|
|
|
it 'does not match URLs with hashtag-like anchors' do
|
|
expect(subject.match('https://en.wikipedia.org/wiki/Ghostbusters_(song)#Lawsuit')).to be_nil
|
|
end
|
|
end
|
|
|
|
describe '.search_for' do
|
|
it 'finds tag records with matching names' do
|
|
tag = Fabricate(:tag, name: "match")
|
|
_miss_tag = Fabricate(:tag, name: "miss")
|
|
|
|
results = Tag.search_for("match")
|
|
|
|
expect(results).to eq [tag]
|
|
end
|
|
end
|
|
end
|