From 61b47ed8d0f27e63d3e2712fea13faabfc79da2b Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Sat, 25 Feb 2012 14:47:56 +0300 Subject: [PATCH] except :as from label_html options --- lib/simple_form/form_builder.rb | 2 +- test/form_builder/label_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/simple_form/form_builder.rb b/lib/simple_form/form_builder.rb index 793e1104..c4c5c1b4 100644 --- a/lib/simple_form/form_builder.rb +++ b/lib/simple_form/form_builder.rb @@ -303,7 +303,7 @@ module SimpleForm return super if args.first.is_a?(String) || block_given? options = args.extract_options!.dup - options[:label_html] = options.except(:label, :required) + options[:label_html] = options.except(:label, :required, :as) column = find_attribute_column(attribute_name) input_type = default_input_type(attribute_name, column, options) diff --git a/test/form_builder/label_test.rb b/test/form_builder/label_test.rb index aa56f6a0..75277773 100644 --- a/test/form_builder/label_test.rb +++ b/test/form_builder/label_test.rb @@ -13,6 +13,12 @@ class LabelTest < ActionView::TestCase assert_select 'label.string[for=user_name]', /Name/ end + test 'builder should generate a label for the boolean attrbiute' do + with_label_for @user, :name, :as => :boolean + assert_select 'label.boolean[for=user_name]', /Name/ + assert_no_select 'label[as=boolean]' + end + test 'builder should generate a label componet tag with a clean HTML' do with_label_for @user, :name assert_no_select 'label.string[label_html]'