Sha256: f3bfdeb0e122702e6b5cca5b6e76694716e2ad3bd2fb86bde19f465880c2c119

Contents?: true

Size: 1.84 KB

Versions: 27

Compression:

Stored size: 1.84 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

27 entries across 27 versions & 1 rubygems

Version Path
foreman-tasks-2.0.3 test/unit/dashboard_table_filter_test.rb
foreman-tasks-2.0.2 test/unit/dashboard_table_filter_test.rb
foreman-tasks-1.1.3 test/unit/dashboard_table_filter_test.rb
foreman-tasks-1.1.2 test/unit/dashboard_table_filter_test.rb
foreman-tasks-2.0.1 test/unit/dashboard_table_filter_test.rb
foreman-tasks-2.0.0 test/unit/dashboard_table_filter_test.rb
foreman-tasks-1.2.0 test/unit/dashboard_table_filter_test.rb
foreman-tasks-1.1.1 test/unit/dashboard_table_filter_test.rb
foreman-tasks-1.1.0 test/unit/dashboard_table_filter_test.rb
foreman-tasks-0.17.6 test/unit/dashboard_table_filter_test.rb
foreman-tasks-1.0.1 test/unit/dashboard_table_filter_test.rb
foreman-tasks-1.0.0 test/unit/dashboard_table_filter_test.rb
foreman-tasks-0.17.5 test/unit/dashboard_table_filter_test.rb
foreman-tasks-0.17.4 test/unit/dashboard_table_filter_test.rb
foreman-tasks-0.17.3 test/unit/dashboard_table_filter_test.rb
foreman-tasks-0.17.2 test/unit/dashboard_table_filter_test.rb
foreman-tasks-0.16.3 test/unit/dashboard_table_filter_test.rb
foreman-tasks-0.17.1 test/unit/dashboard_table_filter_test.rb
foreman-tasks-0.15.11 test/unit/dashboard_table_filter_test.rb
foreman-tasks-0.16.2 test/unit/dashboard_table_filter_test.rb