Sha256: 6ba3fdc99f38825638f5ee571e18829571737b407ea8cadfe0b8f30db9181b7d

Contents?: true

Size: 1.16 KB

Versions: 49

Compression:

Stored size: 1.16 KB

Contents

require 'rake'
require 'foreman_tasks_test_helper'

class GenerateTaskActionsTest < ActiveSupport::TestCase
  TASK_NAME = 'foreman_tasks:generate_task_actions'.freeze

  setup do
    Rake.application.rake_require 'foreman_tasks/tasks/generate_task_actions'

    Rake::Task.define_task(:environment)
    Rake::Task[TASK_NAME].reenable
  end

  let(:tasks) do
    (1..5).map { FactoryBot.build(:dynflow_task) }
  end

  it 'fixes the tasks' do
    label = 'a label'
    tasks
    ForemanTasks::Task.update_all(:action => nil)
    ForemanTasks::Task.any_instance.stubs(:to_label).returns(label)

    stdout, _stderr = capture_io do
      Rake.application.invoke_task TASK_NAME
    end

    assert_match(%r{Generating action for #{tasks.count} tasks}, stdout)
    ForemanTasks::Task.where(:action => label).count.must_equal tasks.count
    assert_match(%r{Processed #{tasks.count}/#{tasks.count} tasks}, stdout)
  end

  it 'fixes only tasks with missing action' do
    tasks
    ForemanTasks::Task.any_instance.expects(:save!).never

    stdout, _stderr = capture_io do
      Rake.application.invoke_task TASK_NAME
    end

    assert_match(%r{Generating action for 0 tasks}, stdout)
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
foreman-tasks-0.15.10 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.16.1 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.17.0 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.15.9 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.15.8 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.14.6 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.15.7 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.16.0 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.15.6 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.15.5 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.15.4 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.15.3 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.15.2 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.15.1 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.15.0 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.14.5 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.14.4 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.14.3 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.14.2 test/tasks/generate_task_actions_test.rb
foreman-tasks-0.14.1 test/tasks/generate_task_actions_test.rb