Skip to content

Commit

Permalink
Add empty WHN markdown field and update existing live forms
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBiddle committed Nov 20, 2023
1 parent 1093b47 commit 273bc81
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class AddWhatHappensNextMarkdownToForms < ActiveRecord::Migration[7.0]
def change
add_column :forms, :what_happens_next_markdown, :text

reversible do |direction|
Form.find_each do |form|
if form.made_live_forms.present?
made_live_form = form.made_live_forms.last
form_blob = JSON.parse(made_live_form.json_form_blob, symbolize_names: true)

direction.up do
form_blob[:what_happens_next_markdown] = nil
end
direction.down do
form_blob.delete(:what_happens_next_markdown)
end

made_live_form.update!(json_form_blob: form_blob.to_json)
end
end
end
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spec/models/form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
"declaration_section_completed",
"pages",
"page_order",
"what_happens_next_markdown",
)
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/request/api/v1/forms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
form_slug: "test-form-1",
start_page: nil,
what_happens_next_text: nil,
what_happens_next_markdown: nil,
support_email: nil,
support_phone: nil,
support_url: nil,
Expand Down

0 comments on commit 273bc81

Please sign in to comment.