text_article_test.rb
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "#{File.dirname(__FILE__)}/../test_helper"
require_relative '../../lib/nested_helper/profile'
class TextArticleTest < ActionController::TestCase
include ElasticsearchTestHelper
def indexed_models
[TextArticle]
end
should 'index searchable fields for TextArticle model' do
TextArticle::SEARCHABLE_FIELDS.each do |key, value|
assert_includes indexed_fields(TextArticle), key
end
end
should 'index control fields for TextArticle model' do
TextArticle::control_fields.each do |key, value|
assert_includes indexed_fields(TextArticle), key
assert_equal indexed_fields(TextArticle)[key][:type], value[:type] || 'string'
end
end
should 'respond with should method to return public text_article' do
assert TextArticle.respond_to? :should
end
should 'respond with especific sort' do
assert TextArticle.respond_to? :especific_sort
end
should 'respond with get_sort_by to order especific sort' do
assert TextArticle.respond_to? :get_sort_by
end
should 'return hash to sort by most commented' do
more_active_hash = {:comments_count => {order: :desc}}
assert_equal more_active_hash, TextArticle.get_sort_by(:more_comments)
end
should 'return hash to sort by more popular' do
more_popular_hash = {:hits => {order: :desc}}
assert_equal more_popular_hash, TextArticle.get_sort_by(:more_popular)
end
should 'respond with nested_filter' do
assert TextArticle.respond_to? :nested_filter
end
should 'have NestedProfile_filter in nested_filter' do
assert TextArticle.nested_filter.include? NestedProfile.filter
end
end