-
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathtag_test.rb
More file actions
23 lines (17 loc) · 644 Bytes
/
tag_test.rb
File metadata and controls
23 lines (17 loc) · 644 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'test_helper'
class TagTest < ActiveSupport::TestCase
include CommunityRelatedHelper
test 'is community related' do
assert_community_related(Tag)
end
test 'search should correctly order tags' do
term = 'us'
tags = Tag.search(term).to_a
name_match_sorted = tags.select { |t| t.name.include?(term) }.sort { |a, b| a.name <=> b.name }
excerpt_match_sorted = tags.select { |t| t.excerpt&.include?(term) }.sort { |a, b| a.name <=> b.name }
sorted_tags = name_match_sorted + excerpt_match_sorted
sorted_tags.each_with_index do |tag, idx|
assert_equal tag.name, tags[idx].name
end
end
end