Skip to content

Commit 6561dbe

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 6561dbe

4 files changed

Lines changed: 6 additions & 6 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/services/make_form_live_service_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
it "makes the English form live" do
6565
expect {
6666
make_form_live_service.make_language_live
67-
}.to change(current_form, :state).to("live")
67+
}.to change(current_form, :state).to("live_with_draft")
6868
.and change(FormDocument.where(form: current_form, tag: "live", language: "en"), :count).by(1)
6969
.and not_change(FormDocument.where(form: current_form, tag: "live", language: "cy"), :count)
7070
end
@@ -80,7 +80,7 @@
8080
let(:language) { "cy" }
8181

8282
context "when the form has a live English version" do
83-
let(:current_form) { create :form, :ready_for_live, :with_welsh_translation}
83+
let(:current_form) { create :form, :ready_for_live, :with_welsh_translation }
8484

8585
before do
8686
current_form.make_english_version_live!

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)