Merge pull request #10181 from demarches-simplifiees/fix-open-procedures-with-closing-reason

task(procedure): fix open procedures with closing reason
This commit is contained in:
mfo 2024-03-22 16:24:10 +01:00 committed by GitHub
commit b8a9a594ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View file

@ -0,0 +1,18 @@
# frozen_string_literal: true
module Maintenance
class FixOpenProceduresWithClosingReasonTask < MaintenanceTasks::Task
def collection
Procedure
.with_discarded
.where
.not(aasm_state: [:close, :depubliee])
.where
.not(closing_reason: nil)
end
def process(procedure)
procedure.update!(closing_reason: nil)
end
end
end

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
require "rails_helper"
module Maintenance
RSpec.describe FixOpenProceduresWithClosingReasonTask do
describe "#process" do
subject(:process) { described_class.process(procedure) }
let(:procedure) { create(:procedure, :published) }
before do
procedure.update_column(:closing_reason, 'internal_procedure')
end
it do
subject
expect(procedure.closing_reason).to be_nil
end
end
end
end