Skip to content

Commit

Permalink
Fixes #23932 - Fixes failing application job tests for some plugins
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adamruzicka authored and iNecas committed Jun 14, 2018
1 parent c50b21e commit 30aa03f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/unit/application_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

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) }
Expand Down

0 comments on commit 30aa03f

Please sign in to comment.