From 388ec0d5b6d1549abed15802d6bdbfc8b1c05294 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sun, 9 Apr 2017 08:45:01 -0400 Subject: [PATCH] Search cleanup (#1333) * 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 --- app/models/account.rb | 12 ++++---- app/models/tag.rb | 4 +-- spec/models/account_spec.rb | 55 +++++++++++++++++++++++++++++++++++++ spec/models/tag_spec.rb | 11 ++++++++ 4 files changed, 74 insertions(+), 8 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index cbba8b5b6d..c59c760095 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -203,7 +203,7 @@ class Account < ApplicationRecord end def triadic_closures(account, limit = 5) - sql = < results.last.rank + end + end + describe '.find_local' do before do Fabricate(:account, username: 'Alice') diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 360bbc16de..7a5b8ec897 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -12,4 +12,15 @@ RSpec.describe Tag, type: :model 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