Project

General

Profile

« Previous | Next » 

Revision 30aa03f4

Added by Adam Ruzicka almost 6 years ago

Fixes #23932 - Fixes failing application job tests for some plugins

The tests were failing with:
Sequel::DatabaseError: PG::DuplicateTable:
ERROR: relation "dynflow_execution_plans" already exists

This failure was probably caused by forcing initialization of the
Dynflow world in a before test block.

View differences:

test/unit/application_job_test.rb
class ApplicationJobTest < ActiveSupport::TestCase
describe '.spawn_if_missing' do
# Force world initialization before stubbing,
# otherwise CreateRssNotifications would be triggered
# on first call to world
before { world }
let(:job_class) { ApplicationJob }
let(:world) { Foreman::Application.dynflow.world }
# Using real world led to various issues, let's stub it out
let(:world) do
persistence = mock()
persistence.stubs(:find_execution_plans).returns([])
persistence.stubs(:load_delayed_plan)
OpenStruct.new(:persistence => persistence)
end
def stub_delayed_plans_with_serialized_args(*args)
execution_plans = args.each_with_index.map { |_, index| OpenStruct.new(:id => index) }

Also available in: Unified diff