Skip to content

Commit

Permalink
Force wrappers name as symbols.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio Yamate committed Sep 27, 2011
1 parent f809580 commit f1b9d2d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/simple_form.rb
Expand Up @@ -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}"
Expand All @@ -132,9 +132,9 @@ class WrapperNotFound < StandardError
# 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
Expand Down
9 changes: 9 additions & 0 deletions test/form_builder/wrapper_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit f1b9d2d

Please sign in to comment.