Skip to content

Commit 89d4e46

Browse files
committed
Retain draft state when English version is made live
When we make the English version of a form live, we want the form state to be 'live_with_draft' rather than 'live' - this reflects the fact that the form still has changes to be made live.
1 parent 8dd7751 commit 89d4e46

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

app/state_machines/form_state_machine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module FormStateMachine
3737
before :before_make_english_live
3838
after :after_make_english_live
3939

40-
transitions from: %i[draft live live_with_draft archived_with_draft], to: :live, guard: :can_make_english_version_live?
40+
transitions from: %i[draft live live_with_draft archived_with_draft], to: :live_with_draft, guard: :can_make_english_version_live?
4141
end
4242

4343
event :make_welsh_version_live do

spec/requests/forms/make_language_live_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
expect {
8181
post(make_language_live_path(form_id: form.id, language:), params: form_params)
8282
}.to change { FormDocument.where(language:).count }.by(1)
83-
.and change { form.reload.state }.to("live")
83+
.and change { form.reload.state }.to("live_with_draft")
8484
end
8585

8686
it "sets the English FormDocument's live_at time to be equal to the form's updated_at time" do
@@ -127,7 +127,7 @@
127127
expect {
128128
post(make_language_live_path(form_id: form.id, language:), params: form_params)
129129
}.to change { FormDocument.where(language:).count }.by(1)
130-
.and change { form.reload.state }.to("live")
130+
.and change { form.reload.state }.to("live_with_draft")
131131
end
132132
end
133133
end

spec/state_machines/form_state_machine_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def after_archive; end
118118
end
119119

120120
it "transitions to live state" do
121-
expect(form).to transition_from(form_state).to(:live).on_event(:make_english_version_live)
121+
expect(form).to transition_from(form_state).to(:live_with_draft).on_event(:make_english_version_live)
122122
end
123123

124124
it "calls the before_make_english_live callback" do

0 commit comments

Comments
 (0)