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:
commit
b8a9a594ba
2 changed files with 39 additions and 0 deletions
|
@ -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
|
|
@ -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
|
Loading…
Reference in a new issue