Sha256: fc55f7c255dcc4be9a6d1e7a177018063a272fd0c727ad57ba64ca09e2e186c4

Contents?: true

Size: 734 Bytes

Versions: 4

Compression:

Stored size: 734 Bytes

Contents

require 'test_plugin_helper'

class ForemanRemoteExecutionForemanTasksCleanerExtensionsTest < ActiveSupport::TestCase
  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 => 'id = 1').delete
    JobInvocation.where(:id => job.id).must_be :empty?
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_remote_execution-1.4.5 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-1.4.4 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-1.4.3 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
foreman_remote_execution-1.4.2 test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb