Sha256: 148aed5eba61359bdf41075cfc623d8673c1cb5a9e73c0a94a88037b0048ba4b

Contents?: true

Size: 1.85 KB

Versions: 13

Compression:

Stored size: 1.85 KB

Contents

require 'foreman_tasks_test_helper'

class DashboardTableFilterTest < ActiveSupport::TestCase
  before do
    ::ForemanTasks::Task.delete_all
  end

  describe ForemanTasks::DashboardTableFilter do
    before do
      @tasks_builder = HistoryTasksBuilder.new
      @scope = ForemanTasks::Task.all
      @tasks_builder.build
    end

    let :subject do
      ForemanTasks::DashboardTableFilter.new(@scope, params)
    end

    let :filtered_scope do
      subject.scope
    end

    describe 'by result' do
      let(:params) { { result: 'warning' } }

      it 'filters' do
        _(filtered_scope.count).must_equal @tasks_builder.distribution['stopped'][:by_result]['warning'][:total]
      end
    end

    describe 'by state' do
      let(:params) { { state: 'running' } }

      it 'filters' do
        _(filtered_scope.count).must_equal @tasks_builder.distribution['running'][:total]
      end
    end

    describe 'recent' do
      let(:params) do
        { state: 'running',
          time_horizon: 'H24',
          time_mode: 'recent' }
      end

      it 'filters' do
        _(filtered_scope.count).must_equal @tasks_builder.distribution['running'][:recent]
      end
    end

    describe 'recent week time horizon' do
      let(:params) do
        { state: 'running',
          time_horizon: 'week',
          time_mode: 'recent' }
      end

      it 'filters' do
        _(filtered_scope.count).must_equal @tasks_builder.distribution['running'][:recent]
      end
    end

    describe 'older' do
      let(:params) do
        { state: 'running',
          time_horizon: 'H24',
          time_mode: 'older' }
      end

      it 'filters' do
        old_tasks_count = @tasks_builder.distribution['running'][:total] -
                          @tasks_builder.distribution['running'][:recent]
        _(filtered_scope.count).must_equal old_tasks_count
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
foreman-tasks-3.0.6 test/unit/dashboard_table_filter_test.rb
foreman-tasks-5.0.0 test/unit/dashboard_table_filter_test.rb
foreman-tasks-4.1.2 test/unit/dashboard_table_filter_test.rb
foreman-tasks-4.1.1 test/unit/dashboard_table_filter_test.rb
foreman-tasks-4.0.1 test/unit/dashboard_table_filter_test.rb
foreman-tasks-4.1.0 test/unit/dashboard_table_filter_test.rb
foreman-tasks-3.0.5 test/unit/dashboard_table_filter_test.rb
foreman-tasks-4.0.0 test/unit/dashboard_table_filter_test.rb
foreman-tasks-3.0.4 test/unit/dashboard_table_filter_test.rb
foreman-tasks-3.0.3 test/unit/dashboard_table_filter_test.rb
foreman-tasks-3.0.2 test/unit/dashboard_table_filter_test.rb
foreman-tasks-3.0.1 test/unit/dashboard_table_filter_test.rb
foreman-tasks-3.0.0 test/unit/dashboard_table_filter_test.rb