Sha256: 0fcc72acb1291c69c5da6029f63e3051d90286c982fb6c0d03a6b9b4a124bc8d

Contents?: true

Size: 1.14 KB

Versions: 85

Compression:

Stored size: 1.14 KB

Contents

require 'test_plugin_helper'

class ForemanRemoteExecutionForemanTasksCleanerExtensionsTest < ActiveSupport::TestCase
  # Apply the same stubbing as in foreman-tasks
  before do
    # To stop dynflow from backing up actions, execution_plans and steps
    ForemanTasks.dynflow.world.persistence.adapter.stubs(:backup_to_csv)
    ForemanTasks::Cleaner.any_instance.stubs(:say) # Make the tests silent
    # Hack to make the tests pass due to ActiveRecord shenanigans
    ForemanTasks::Cleaner.any_instance.stubs(:delete_orphaned_dynflow_tasks)
  end

  it 'tries to delete associated job invocations' do
    job = FactoryBot.create(:job_invocation, :with_task)
    ForemanTasks::Cleaner.new(:filter => "id = #{job.task.id}").delete
    JobInvocation.where(:id => job.id).must_be :empty?
  end

  it 'removes orphaned job invocations' do
    job = FactoryBot.create(:job_invocation, :with_task)
    _(JobInvocation.where(:id => job.id).count).must_equal 1
    job.task.delete
    job.reload
    _(job.task).must_be :nil?
    _(job.task_id).wont_be :nil?
    ForemanTasks::Cleaner.new(:filter => '').delete
    JobInvocation.where(:id => job.id).must_be :empty?
  end
end

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
foreman_remote_execution-12.0.7 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-10.1.3 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-12.0.5 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-12.0.4 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-12.0.1 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-12.0.2 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-11.1.3 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-10.1.2 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-12.0.0 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-10.1.1 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-11.1.1 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-11.1.0 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-10.1.0 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-8.3.3 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-8.3.2 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-11.0.0 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-10.0.7 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-8.3.1 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-10.0.6 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-10.0.5 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb