Force wrappers name as symbols.
This commit is contained in:
parent
f8095800ec
commit
f1b9d2dfc3
|
@ -117,7 +117,7 @@ module SimpleForm
|
||||||
|
|
||||||
# Retrieves a given wrapper
|
# Retrieves a given wrapper
|
||||||
def self.wrapper(name)
|
def self.wrapper(name)
|
||||||
if wrapper = @@wrappers[name]
|
if wrapper = @@wrappers[name.to_sym]
|
||||||
wrapper
|
wrapper
|
||||||
else
|
else
|
||||||
raise WrapperNotFound, "Couldn't find wrapper with name #{name}"
|
raise WrapperNotFound, "Couldn't find wrapper with name #{name}"
|
||||||
|
@ -134,7 +134,7 @@ module SimpleForm
|
||||||
if block_given?
|
if block_given?
|
||||||
options = args.extract_options!
|
options = args.extract_options!
|
||||||
name = args.first || :default
|
name = args.first || :default
|
||||||
@@wrappers[name] = build(options, &block)
|
@@wrappers[name.to_sym] = build(options, &block)
|
||||||
else
|
else
|
||||||
@@wrappers
|
@@wrappers
|
||||||
end
|
end
|
||||||
|
|
|
@ -113,6 +113,15 @@ class WrapperTest < ActionView::TestCase
|
||||||
assert_select "section.custom_wrapper div.another_wrapper input.string"
|
assert_select "section.custom_wrapper div.another_wrapper input.string"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'access wrappers with indifferent access' do
|
||||||
|
swap_wrapper :another do
|
||||||
|
with_form_for @user, :name, :wrapper => "another"
|
||||||
|
assert_select "section.custom_wrapper div.another_wrapper label"
|
||||||
|
assert_select "section.custom_wrapper div.another_wrapper input.string"
|
||||||
|
output_buffer.replace ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
test 'raise error when wrapper not found' do
|
test 'raise error when wrapper not found' do
|
||||||
assert_raise SimpleForm::WrapperNotFound do
|
assert_raise SimpleForm::WrapperNotFound do
|
||||||
with_form_for @user, :name, :wrapper => :not_found
|
with_form_for @user, :name, :wrapper => :not_found
|
||||||
|
|
Loading…
Reference in New Issue