Skip to content

Instantly share code, notes, and snippets.

@varyonic
Last active August 29, 2015 14:08
Show Gist options
  • Save varyonic/542c37648de91a02402a to your computer and use it in GitHub Desktop.
Save varyonic/542c37648de91a02402a to your computer and use it in GitHub Desktop.
Deprecated but working version of form_buffers removed by https://github.com/activeadmin/activeadmin/pull/3486
module ActiveAdmin
module Views
class ActiveAdminForm
class DeprecatedFormBufferSubstitute
def initialize(form)
@form = form
end
def << (value)
@form.text_node value.html_safe
end
end
def form_buffers
warn "DEPRECATION WARNING: 'form_buffers' is no longer needed."
@form_buffers ||= [DeprecatedFormBufferSubstitute.new(self)]
end
end
end
end
context "with deprecated form_buffers workaround" do
let :body do
build_form do |f|
f.inputs
f.form_buffers.last << '<span>appended to last form buffer</span>'
f.actions
end
end
it "should allow injection of html" do
expect(body).to have_tag 'span', 'appended to last form buffer'
expect(body.index('form buffer')).to be > body.index('label')
expect(body.index('form buffer')).to be < body.index('Cancel')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment