diff --git a/lib/engines/content_object_store/test/integration/content_block/editions_test.rb b/lib/engines/content_object_store/test/integration/content_block/editions_test.rb index 2af4b3a8c75..684d1bda982 100644 --- a/lib/engines/content_object_store/test/integration/content_block/editions_test.rb +++ b/lib/engines/content_object_store/test/integration/content_block/editions_test.rb @@ -5,6 +5,7 @@ class ContentObjectStore::ContentBlock::EditionsTest < ActionDispatch::Integrati include Capybara::DSL extend Minitest::Spec::DSL include ContentObjectStore::Engine.routes.url_helpers + include ContentObjectStore::IntegrationTestHelpers before do login_as_admin @@ -185,12 +186,6 @@ class ContentObjectStore::ContentBlock::EditionsTest < ActionDispatch::Integrati end end -def stub_request_for_schema(block_type) - schema = stub(id: "content_block_type", fields: %w[foo bar], name: "schema", body: {}, block_type:) - ContentObjectStore::ContentBlock::Schema.stubs(:find_by_block_type).with(block_type).returns(schema) - schema -end - def renders_errors(&block) content_block_edition = build(:content_block_edition, :email_address) ContentObjectStore::CreateEditionService.any_instance.expects(:call).raises(ActiveRecord::RecordInvalid, content_block_edition) diff --git a/lib/engines/content_object_store/test/integration/content_block/workflow_test.rb b/lib/engines/content_object_store/test/integration/content_block/workflow_test.rb index 64a3cefe1c1..04cfd10bd4f 100644 --- a/lib/engines/content_object_store/test/integration/content_block/workflow_test.rb +++ b/lib/engines/content_object_store/test/integration/content_block/workflow_test.rb @@ -6,6 +6,7 @@ class ContentObjectStore::ContentBlock::WorkflowTest < ActionDispatch::Integrati extend Minitest::Spec::DSL include SidekiqTestHelpers include ContentObjectStore::Engine.routes.url_helpers + include ContentObjectStore::IntegrationTestHelpers let(:details) do { @@ -176,11 +177,6 @@ def assert_edition_is_published(&block) end end -def stub_request_for_schema(block_type) - schema = stub(id: "content_block_type", fields: %w[foo bar], name: "schema", body: {}, block_type:) - ContentObjectStore::ContentBlock::Schema.stubs(:find_by_block_type).with(block_type).returns(schema) -end - def update_params(edition_id:, organisation_id:) { id: edition_id, diff --git a/lib/engines/content_object_store/test/support/integration_test_helpers.rb b/lib/engines/content_object_store/test/support/integration_test_helpers.rb new file mode 100644 index 00000000000..0bea536dec4 --- /dev/null +++ b/lib/engines/content_object_store/test/support/integration_test_helpers.rb @@ -0,0 +1,7 @@ +module ContentObjectStore::IntegrationTestHelpers + def stub_request_for_schema(block_type) + schema = stub(id: "content_block_type", fields: %w[foo bar], name: "schema", body: {}, block_type:) + ContentObjectStore::ContentBlock::Schema.stubs(:find_by_block_type).with(block_type).returns(schema) + schema + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index d23ddac0d7e..e4e5de0d31a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -27,6 +27,7 @@ end Dir[Rails.root.join("test/support/*.rb")].sort.each { |f| require f } +Dir[Rails.root.join("lib/engines/**/test/support/*.rb")].sort.each { |f| require f } Whitehall::Application.load_tasks if Rake::Task.tasks.empty?