Skip to content

Commit

Permalink
Merge pull request #464 from alphagov/allow-archived-forms-to-be-made…
Browse files Browse the repository at this point in the history
…-live

Allow archived forms to be made live
  • Loading branch information
DavidBiddle authored Mar 27, 2024
2 parents 145bea6 + 3db6b1f commit 8ae0224
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/state_machines/form_state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module FormStateMachine
made_live_forms.create!(json_form_blob: form_blob.to_json, created_at: live_at)
end

transitions from: %i[draft live_with_draft], to: :live, guard: proc { ready_for_live }
transitions from: %i[draft live_with_draft archived archived_with_draft], to: :live, guard: proc { ready_for_live }
end

event :create_draft_from_live_form do
Expand Down
24 changes: 24 additions & 0 deletions spec/state_machines/form_state_machine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@ class FakeForm < Form
it_behaves_like "transition to live state", FakeForm, :live_with_draft
end
end

context "when form is archived" do
let(:form) { FakeForm.new(state: :archived) }

it "does not transition to live state by default" do
expect(form).not_to transition_from(:archived).to(:live).on_event(:make_live)
end

context "when all sections are completed" do
it_behaves_like "transition to live state", FakeForm, :archived
end
end

context "when form is archived_with_draft" do
let(:form) { FakeForm.new(state: :archived_with_draft) }

it "does not transition to live state by default" do
expect(form).not_to transition_from(:archived_with_draft).to(:live).on_event(:make_live)
end

context "when all sections are completed" do
it_behaves_like "transition to live state", FakeForm, :archived_with_draft
end
end
end

describe ".create_draft_from_live_form" do
Expand Down

0 comments on commit 8ae0224

Please sign in to comment.