Permalink
Browse files

Test the deprecation of :components option and silence warnings

  • Loading branch information...
1 parent cf6cde8 commit f1c42eada57b8ba43d15b4eaeb99344570017350 @rafaelfranca rafaelfranca committed Sep 15, 2011
Showing with 61 additions and 43 deletions.
  1. +37 −27 test/form_builder_test.rb
  2. +24 −16 test/inputs_test.rb
View
@@ -453,50 +453,60 @@ def with_association_for(object, *args)
# ONLY THE INPUT TAG
test "builder input_field should only render the input tag, nothing else" do
- with_concat_form_for(@user) do |f|
- f.input_field :name
+ ActiveSupport::Deprecation.silence do
+ with_concat_form_for(@user) do |f|
+ f.input_field :name
+ end
+ assert_select 'form > input.required.string'
+ assert_no_select 'div.string'
+ assert_no_select 'label'
+ assert_no_select '.hint'
end
- assert_select 'form > input.required.string'
- assert_no_select 'div.string'
- assert_no_select 'label'
- assert_no_select '.hint'
end
test 'builder input_field should allow overriding default input type' do
- with_concat_form_for(@user) do |f|
- f.input_field :name, :as => :text
- end
+ ActiveSupport::Deprecation.silence do
+ with_concat_form_for(@user) do |f|
+ f.input_field :name, :as => :text
+ end
- assert_no_select 'input#user_name'
- assert_select 'textarea#user_name.text'
+ assert_no_select 'input#user_name'
+ assert_select 'textarea#user_name.text'
+ end
end
test 'builder input_field should allow passing options to input tag' do
- with_concat_form_for(@user) do |f|
- f.input_field :name, :id => 'name_input', :class => 'name'
- end
+ ActiveSupport::Deprecation.silence do
+ with_concat_form_for(@user) do |f|
+ f.input_field :name, :id => 'name_input', :class => 'name'
+ end
- assert_select 'input.string.name#name_input'
+ assert_select 'input.string.name#name_input'
+ end
end
test 'builder input_field should generate an input tag with a clean HTML' do
- with_concat_form_for(@user) do |f|
- f.input_field :name, :as => :integer, :class => 'name'
- end
+ ActiveSupport::Deprecation.silence do
+ with_concat_form_for(@user) do |f|
+ f.input_field :name, :as => :integer, :class => 'name'
+ end
- assert_no_select 'input.integer[input_html]'
- assert_no_select 'input.integer[as]'
+ assert_no_select 'input.integer[input_html]'
+ assert_no_select 'input.integer[as]'
+ end
end
test 'builder collection input_field should generate input tag with a clean HTML' do
- with_concat_form_for(@user) do |f|
- f.input_field :status, :collection => ['Open', 'Closed'], :class => 'status', :label_method => :to_s, :value_method => :to_s
- end
+ ActiveSupport::Deprecation.silence do
+ with_concat_form_for(@user) do |f|
+ f.input_field :status, :collection => ['Open', 'Closed'], :class => 'status', :label_method => :to_s, :value_method => :to_s
+ end
- assert_no_select 'select.status[input_html]'
- assert_no_select 'select.status[collection]'
- assert_no_select 'select.status[label_method]'
- assert_no_select 'select.status[value_method]'
+ assert_no_select 'select.status[input_html]'
+ assert_no_select 'select.status[collection]'
+ assert_no_select 'select.status[label_method]'
+ assert_no_select 'select.status[value_method]'
+ end
end
# WITHOUT OBJECT
View
@@ -104,30 +104,38 @@ def with_input_for(object, attribute_name, type, options={})
end
end
+ test 'components option is deprecated' do
+ assert_deprecated(/The option :components of f\.input is deprecated/) do
+ with_input_for @user, :name, :string, :components => [:input]
+ end
+ end
+
test 'input should render components according to an optional :components option' do
- with_input_for @user, :name, :string, :components => [:input, :label]
- assert_select 'input + label'
+ ActiveSupport::Deprecation.silence do
+ with_input_for @user, :name, :string, :components => [:input, :label]
+ assert_select 'input + label'
- with_input_for @user, :age, :integer, :components => [:input, :label]
- assert_select 'input + label'
+ with_input_for @user, :age, :integer, :components => [:input, :label]
+ assert_select 'input + label'
- with_input_for @user, :active, :boolean, :components => [:label, :input]
- assert_select 'label + input'
+ with_input_for @user, :active, :boolean, :components => [:label, :input]
+ assert_select 'label + input'
- with_input_for @user, :description, :text, :components => [:input, :label]
- assert_select 'textarea + label'
+ with_input_for @user, :description, :text, :components => [:input, :label]
+ assert_select 'textarea + label'
- with_input_for @user, :password, :password, :components => [:input, :label]
- assert_select 'input + label'
+ with_input_for @user, :password, :password, :components => [:input, :label]
+ assert_select 'input + label'
- with_input_for @user, :name, :file, :components => [:input, :label]
- assert_select 'input + label'
+ with_input_for @user, :name, :file, :components => [:input, :label]
+ assert_select 'input + label'
- with_input_for @user, :country, :country, :components => [:input, :label]
- assert_select 'select + label'
+ with_input_for @user, :country, :country, :components => [:input, :label]
+ assert_select 'select + label'
- with_input_for @user, :time_zone, :time_zone, :components => [:input, :label]
- assert_select 'select + label'
+ with_input_for @user, :time_zone, :time_zone, :components => [:input, :label]
+ assert_select 'select + label'
+ end
end
# StringInput

0 comments on commit f1c42ea

Please sign in to comment.