Skip to content

Commit

Permalink
Revert "Merge pull request opf#14992 from opf/chore/53122/replace-con…
Browse files Browse the repository at this point in the history
…currency-check-with-good-job"

This reverts commit 7b02616, reversing
changes made to 024376a.
  • Loading branch information
Eric-Guo committed Mar 20, 2024
1 parent 8853263 commit d0a73fd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 110 deletions.
4 changes: 3 additions & 1 deletion app/contracts/settings/working_days_params_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def working_days_are_present
end

def unique_job
WorkPackages::ApplyWorkingDaysChangeJob.new.check_concurrency do
if GoodJob::Job
.where(finished_at: nil)
.exists?(job_class: WorkPackages::ApplyWorkingDaysChangeJob.name)
errors.add :base, :previous_working_day_changes_unprocessed
end
end
Expand Down
42 changes: 0 additions & 42 deletions app/workers/job_concurrency.rb

This file was deleted.

5 changes: 0 additions & 5 deletions app/workers/work_packages/apply_working_days_change_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@
#++

class WorkPackages::ApplyWorkingDaysChangeJob < ApplicationJob
include JobConcurrency
queue_with_priority :above_normal

good_job_control_concurrency_with(
total_limit: 1
)

def perform(user_id:, previous_working_days:, previous_non_working_days:)
user = User.find(user_id)

Expand Down
13 changes: 4 additions & 9 deletions spec/contracts/settings/working_days_params_contract_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

RSpec.describe Settings::WorkingDaysParamsContract do
include_context 'ModelContract shared context'
shared_let(:current_user) { create(:admin) }
let(:setting) { Setting }
let(:current_user) { build_stubbed(:admin) }
let(:params) { { working_days: [1] } }
let(:contract) do
described_class.new(setting, current_user, params:)
Expand All @@ -46,16 +46,11 @@
include_examples 'contract is invalid', base: :working_days_are_missing
end

context 'with an ApplyWorkingDaysChangeJob already existing',
with_good_job: WorkPackages::ApplyWorkingDaysChangeJob do
context 'with an ApplyWorkingDaysChangeJob already existing' do
let(:params) { { working_days: [1, 2, 3] } }

before do
WorkPackages::ApplyWorkingDaysChangeJob
.set(wait: 10.minutes) # GoodJob executes inline job without wait immediately
.perform_later(user_id: current_user.id,
previous_non_working_days: [],
previous_working_days: [1, 2, 3, 4])
ActiveJob::Base.disable_test_adapter
WorkPackages::ApplyWorkingDaysChangeJob.perform_later
end

include_examples 'contract is invalid', base: :previous_working_day_changes_unprocessed
Expand Down
53 changes: 0 additions & 53 deletions spec/support/shared/with_good_job.rb

This file was deleted.

0 comments on commit d0a73fd

Please sign in to comment.