mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Force wrappers name as symbols.
This commit is contained in:
parent
f8095800ec
commit
f1b9d2dfc3
2 changed files with 13 additions and 4 deletions
|
@ -117,7 +117,7 @@ module SimpleForm
|
|||
|
||||
# Retrieves a given wrapper
|
||||
def self.wrapper(name)
|
||||
if wrapper = @@wrappers[name]
|
||||
if wrapper = @@wrappers[name.to_sym]
|
||||
wrapper
|
||||
else
|
||||
raise WrapperNotFound, "Couldn't find wrapper with name #{name}"
|
||||
|
@ -132,9 +132,9 @@ module SimpleForm
|
|||
# and store it in the given name.
|
||||
def self.wrappers(*args, &block)
|
||||
if block_given?
|
||||
options = args.extract_options!
|
||||
name = args.first || :default
|
||||
@@wrappers[name] = build(options, &block)
|
||||
options = args.extract_options!
|
||||
name = args.first || :default
|
||||
@@wrappers[name.to_sym] = build(options, &block)
|
||||
else
|
||||
@@wrappers
|
||||
end
|
||||
|
|
|
@ -113,6 +113,15 @@ class WrapperTest < ActionView::TestCase
|
|||
assert_select "section.custom_wrapper div.another_wrapper input.string"
|
||||
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
|
||||
assert_raise SimpleForm::WrapperNotFound do
|
||||
with_form_for @user, :name, :wrapper => :not_found
|
||||
|
|
Loading…
Reference in a new issue