ref: master
plugins/elasticsearch/test/unit/community_test.rb
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 |
require_relative '../test_helper' class CommunityTest < ActiveSupport::TestCase include ElasticsearchTestHelper def indexed_models [Community] end should 'index searchable fields for Community model' do Community::SEARCHABLE_FIELDS.each do |key, value| assert_includes indexed_fields(Community), key end end should 'index control fields for Community model' do Community::control_fields.each do |key, value| assert_includes indexed_fields(Community), key assert_equal indexed_fields(Community)[key][:type], value[:type] || 'string' end end should 'respond with should method to return public community' do assert Community.respond_to? :should end should 'respond with specific sort' do assert Community.respond_to? :specific_sort end should 'respond with get_sort_by to order specific sort' do assert Community.respond_to? :get_sort_by end should 'return hash to sort by more_active' do more_active_hash = {:activities_count => {order: :desc}} assert_equal more_active_hash, Community.get_sort_by(:more_active) end should 'return hash to sort by more_popular' do more_popular_hash = {:members_count => {order: :desc}} assert_equal more_popular_hash, Community.get_sort_by(:more_popular) end end |