Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

adapt active job specs

ulferts9911932e5168
diff --git a/modules/meeting/app/models/journal/meeting_agenda_item_journal.rb b/modules/meeting/app/models/journal/meeting_agenda_item_journal.rb
index 155c6178231..0a36e33a60b 100644
--- a/modules/meeting/app/models/journal/meeting_agenda_item_journal.rb
+++ b/modules/meeting/app/models/journal/meeting_agenda_item_journal.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
diff --git a/modules/meeting/app/models/meeting_agenda_item.rb b/modules/meeting/app/models/meeting_agenda_item.rb
index e51d4fc1eb8..0299b0819c1 100644
--- a/modules/meeting/app/models/meeting_agenda_item.rb
+++ b/modules/meeting/app/models/meeting_agenda_item.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
diff --git a/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb b/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb
index 8e3656fe8d0..de162fff13d 100644
--- a/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb
+++ b/modules/meeting/spec/services/recurring_meetings/update_service_integration_spec.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -97,13 +98,13 @@ RSpec.describe RecurringMeetings::UpdateService, "integration", type: :model do
end
end
- context "when updating the frequency and start_time" do
+ context "when updating the frequency and start_time",
+ with_good_job: RecurringMeetings::InitNextOccurrenceJob do
let(:params) do
{ start_time: Time.zone.today + 2.days + 11.hours }
end
before do
- ActiveJob::Base.disable_test_adapter
RecurringMeetings::InitNextOccurrenceJob
.set(wait_until: Time.zone.today + 1.day + 10.hours)
.perform_later(series)
diff --git a/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb b/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb
index 73684682c11..231e68702c5 100644
--- a/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb
+++ b/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb
@@ -31,7 +31,7 @@
require "spec_helper"
require_module_spec_helper
-RSpec.describe Storages::CopyProjectFoldersJob, :job, :webmock, with_good_job_batches: [Storages::CopyProjectFoldersJob] do
+RSpec.describe Storages::CopyProjectFoldersJob, :job, :webmock, with_good_job: Storages::CopyProjectFoldersJob do
include ActiveJob::TestHelper
let(:storage) { create(:nextcloud_storage, :as_automatically_managed) }
@@ -227,7 +227,10 @@ RSpec.describe Storages::CopyProjectFoldersJob, :job, :webmock, with_good_job_ba
described_class.perform_later(source:, target:, work_packages_map:)
end
GoodJob.perform_inline
- job = GoodJob::Job.order(:created_at).last
+ job = GoodJob::Job
+ .where(job_class: "Storages::CopyProjectFoldersJob")
+ .order(:created_at)
+ .last
expect(job.executions_count).to eq(3)
expect(job.serialized_params["exception_executions"]["[Storages::Errors::PollingRequired]"]).to eq(2)
diff --git a/modules/storages/spec/workers/storages/manage_storage_integrations_job_spec.rb b/modules/storages/spec/workers/storages/manage_storage_integrations_job_spec.rb
index 663f9b022ee..6a2d1ef96a4 100644
--- a/modules/storages/spec/workers/storages/manage_storage_integrations_job_spec.rb
+++ b/modules/storages/spec/workers/storages/manage_storage_integrations_job_spec.rb
@@ -33,9 +33,8 @@ require_module_spec_helper
RSpec.describe Storages::ManageStorageIntegrationsJob, type: :job do
describe ".debounce" do
- context "when has been debounced by other thread" do
- before { ActiveJob::Base.disable_test_adapter }
-
+ context "when has been debounced by other thread",
+ with_good_job_batches: [described_class] do
it "does not change the number of enqueued jobs" do
expect(GoodJob::Job.count).to eq(0)
expect(described_class.perform_later.successfully_enqueued?).to be(true)
diff --git a/spec/workers/notifications/schedule_date_alerts_notifications_job_spec.rb b/spec/workers/notifications/schedule_date_alerts_notifications_job_spec.rb
index d179de7bd9c..ddcc2b19186 100644
--- a/spec/workers/notifications/schedule_date_alerts_notifications_job_spec.rb
+++ b/spec/workers/notifications/schedule_date_alerts_notifications_job_spec.rb
@@ -28,7 +28,10 @@
require "spec_helper"
-RSpec.describe Notifications::ScheduleDateAlertsNotificationsJob, type: :job, with_ee: %i[date_alerts] do
+RSpec.describe Notifications::ScheduleDateAlertsNotificationsJob,
+ type: :job,
+ with_ee: %i[date_alerts],
+ with_good_job_batches: [Notifications::CreateDateAlertsNotificationsJob] do
shared_let(:project) { create(:project, name: "main") }
# Paris and Berlin are both UTC+01:00 (CET) or UTC+02:00 (CEST)
shared_let(:timezone_paris) { ActiveSupport::TimeZone["Europe/Paris"] }
@@ -52,10 +55,6 @@ RSpec.describe Notifications::ScheduleDateAlertsNotificationsJob, type: :job, wi
end
end
- before do
- ActiveJob::Base.disable_test_adapter
- end
-
def set_predecessor_cron_time(cron_at)
GoodJob::Job
.where(id: scheduled_predecessor_job.job_id)
diff --git a/spec/workers/notifications/schedule_reminder_mails_job_spec.rb b/spec/workers/notifications/schedule_reminder_mails_job_spec.rb
index 38c8d1c1ff7..14ffa6f1a83 100644
--- a/spec/workers/notifications/schedule_reminder_mails_job_spec.rb
+++ b/spec/workers/notifications/schedule_reminder_mails_job_spec.rb
@@ -28,7 +28,10 @@
require "spec_helper"
-RSpec.describe Notifications::ScheduleReminderMailsJob, type: :job do
+RSpec.describe Notifications::ScheduleReminderMailsJob,
+ type: :job,
+ with_good_job_batches: [Mails::ReminderJob,
+ Notifications::ScheduleReminderMailsJob] do
let(:scheduled_job) do
described_class.perform_later.tap do |job|
set_cron_time(job, job_cron_at)
@@ -47,9 +50,6 @@ RSpec.describe Notifications::ScheduleReminderMailsJob, type: :job do
let(:ids) { [23, 42] }
before do
- # We need to access the job as stored in the database to get at the scheduled_at time persisted there
- ActiveJob::Base.disable_test_adapter
-
scope = instance_double(ActiveRecord::Relation)
allow(User).to receive(:having_reminder_mail_to_send).and_return(scope)
allow(scope).to receive(:pluck).with(:id).and_return(ids)