diff --git a/app/assets/javascripts/markdown_editor.js.coffee b/app/assets/javascripts/markdown_editor.js.coffee
index e7c982afd..1874da5aa 100644
--- a/app/assets/javascripts/markdown_editor.js.coffee
+++ b/app/assets/javascripts/markdown_editor.js.coffee
@@ -4,6 +4,7 @@ App.MarkdownEditor =
textarea_content = element.find('textarea').val()
result = md.render(textarea_content)
element.find('#markdown-preview').html(result)
+ element.find('#markdown-result input').val(result)
initialize: ->
$('.markdown-editor').each ->
diff --git a/app/controllers/admin/legislation/draft_versions_controller.rb b/app/controllers/admin/legislation/draft_versions_controller.rb
index 921e838b3..8c20374d9 100644
--- a/app/controllers/admin/legislation/draft_versions_controller.rb
+++ b/app/controllers/admin/legislation/draft_versions_controller.rb
@@ -36,7 +36,8 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
:changelog,
:status,
:final_version,
- :body
+ :body,
+ :body_html
)
end
end
diff --git a/app/views/admin/legislation/draft_versions/_form.html.erb b/app/views/admin/legislation/draft_versions/_form.html.erb
index edcad5993..fb61ca3d1 100644
--- a/app/views/admin/legislation/draft_versions/_form.html.erb
+++ b/app/views/admin/legislation/draft_versions/_form.html.erb
@@ -69,6 +69,9 @@
+
+ <%= f.hidden_field :body_html, label: false %>
+
diff --git a/db/migrate/20161213144031_add_body_html_to_draft_versions.rb b/db/migrate/20161213144031_add_body_html_to_draft_versions.rb
new file mode 100644
index 000000000..c0a05c809
--- /dev/null
+++ b/db/migrate/20161213144031_add_body_html_to_draft_versions.rb
@@ -0,0 +1,5 @@
+class AddBodyHtmlToDraftVersions < ActiveRecord::Migration
+ def change
+ add_column :legislation_draft_versions, :body_html, :text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index ba661579a..7dcecb776 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20161205110441) do
+ActiveRecord::Schema.define(version: 20161213144031) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -238,6 +238,7 @@ ActiveRecord::Schema.define(version: 20161205110441) do
t.datetime "hidden_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.text "body_html"
end
add_index "legislation_draft_versions", ["hidden_at"], name: "index_legislation_draft_versions_on_hidden_at", using: :btree
diff --git a/spec/features/admin/legislation/draft_versions_spec.rb b/spec/features/admin/legislation/draft_versions_spec.rb
index 3bc1c057a..287b119ac 100644
--- a/spec/features/admin/legislation/draft_versions_spec.rb
+++ b/spec/features/admin/legislation/draft_versions_spec.rb
@@ -35,7 +35,7 @@ feature 'Admin legislation draft versions' do
end
context 'Create' do
- scenario 'Valid legislation draft_version' do
+ scenario 'Valid legislation draft version' do
process = create(:legislation_process, title: 'An example legislation process')
visit admin_root_path
@@ -63,4 +63,34 @@ feature 'Admin legislation draft versions' do
expect(page).to have_content 'Version 3'
end
end
+
+ context 'Update' do
+ scenario 'Valid legislation draft version', :js do
+ process = create(:legislation_process, title: 'An example legislation process')
+ draft_version = create(:legislation_draft_version, title: 'Version 1', process: process)
+
+ visit admin_root_path
+
+ within('#side_menu') do
+ click_link "Collaborative Legislation"
+ end
+
+ click_link "All"
+
+ expect(page).to have_content 'An example legislation process'
+
+ click_link 'An example legislation process'
+ click_link 'Text'
+
+ click_link 'Version 1'
+
+ fill_in 'legislation_draft_version_title', with: 'Version 1b'
+ fill_in 'legislation_draft_version_body', with: '# Version 1 body\r\nParagraph\r\n>Quote'
+
+ click_button 'Save changes'
+
+ expect(page).to have_content 'Version 1b'
+ expect(draft_version.reload.body_html).to eq("Version 1 body\\r\\nParagraph\\r\\n>Quote
\r\n")
+ end
+ end
end