Sha256: fcc4c9a67989e851bc3e59960ce6b9c43d48af952960235c09cf55ccff24a023

Contents?: true

Size: 1.04 KB

Versions: 62

Compression:

Stored size: 1.04 KB

Contents

require 'test_helper'

module Workarea
  module Admin
    class HelpSearchViewModelTest < TestCase
      def test_returns_the_recent_articles_in_each_category
        howto = Array.new(3) do
          create_help_article(name: 'Foo', category: 'Howto')
        end

        feature = Array.new(3) do
          create_help_article(name: 'Foo', category: 'Feature')
        end

        popular = Array.new(3) do
          create_help_article(name: 'Foo', category: 'Popular')
        end

        view_model = HelpSearchViewModel.new(Search::HelpSearch.new)
        results = view_model.top_articles_by_category

        assert_equal(howto.reverse, results['Howto'])
        assert_equal(feature.reverse, results['Feature'])
        assert_equal(popular.reverse, results['Popular'])
      end

      def test_does_not_include_empty_categories
        create_help_article(name: 'Foo', category: 'Popular').destroy

        view_model = HelpSearchViewModel.new(Search::HelpSearch.new)
        assert(view_model.top_articles_by_category.empty?)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.4.13 test/view_models/workarea/admin/help_search_view_model_test.rb
workarea-admin-3.4.12 test/view_models/workarea/admin/help_search_view_model_test.rb