Permalink
Browse files

Actually deprecate DateInput, DatetimeInput and TimeInput.

  • Loading branch information...
1 parent 8f08dbc commit 04c926b59fe61a4d1d39c44d367c19eb034796fe @mjbellantoni committed Sep 2, 2012
@@ -1,7 +1,10 @@
module FormtasticBootstrap
module Inputs
- class DateInput < Formtastic::Inputs::DateInput
- # This has been deprecated.
+ class DateInput < FormtasticBootstrap::Inputs::DateSelectInput
+ def to_html
+ ::ActiveSupport::Deprecation.warn("DateInput (:as => :date) has been renamed to DateSelectInput (:as => :date_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2))
+ super
+ end
end
end
end
@@ -1,7 +1,10 @@
module FormtasticBootstrap
module Inputs
- class DatetimeInput < Formtastic::Inputs::DatetimeInput
- # This has been deprecated.
+ class DatetimeInput < FormtasticBootstrap::Inputs::DatetimeSelectInput
+ def to_html
+ ::ActiveSupport::Deprecation.warn("DatetimeInput (:as => :datetime) has been renamed to DatetimeSelectInput (:as => :datetime_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2))
+ super
+ end
end
end
end
@@ -1,7 +1,10 @@
module FormtasticBootstrap
module Inputs
- class TimeInput < Formtastic::Inputs::TimeInput
- # This has been deprecated.
+ class TimeInput < FormtasticBootstrap::Inputs::TimeSelectInput
+ def to_html
+ ::ActiveSupport::Deprecation.warn("TimeInput (:as => :time) has been renamed to TimeSelectInput (:as => :time_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2))
+ super
+ end
end
end
end
@@ -0,0 +1,48 @@
+require 'spec_helper'
+
+describe 'deprecated time, datetime and date inputs' do
+ include FormtasticSpecHelper
+
+ before do
+ @output_buffer = ''
+ mock_everything
+ end
+
+ it 'should warn :time is deprecated' do
+ ::ActiveSupport::Deprecation.should_receive(:warn)
+ semantic_form_for(@new_post) do |f|
+ concat(f.input :created_at, :as => :time)
+ end
+ end
+
+ it 'should warn :datetime is deprecated' do
+ ::ActiveSupport::Deprecation.should_receive(:warn)
+ semantic_form_for(@new_post) do |f|
+ concat(f.input :created_at, :as => :datetime)
+ end
+ end
+
+ it 'should warn :date is deprecated' do
+ ::ActiveSupport::Deprecation.should_receive(:warn)
+ semantic_form_for(@new_post) do |f|
+ concat(f.input :created_at, :as => :date)
+ end
+ end
+
+ it 'should use wrapper css class based off :as, not off their parent class' do
+ with_deprecation_silenced do
+ concat(semantic_form_for(@new_post) do |f|
+ concat(f.input :created_at, :as => :time)
+ concat(f.input :created_at, :as => :datetime)
+ concat(f.input :created_at, :as => :date)
+ end)
+ end
+ output_buffer.should have_tag('div.control-group.time')
+ output_buffer.should have_tag('div.control-group.datetime')
+ output_buffer.should have_tag('div.control-group.date')
+ output_buffer.should_not have_tag('li.time_select')
+ output_buffer.should_not have_tag('li.datetime_select')
+ output_buffer.should_not have_tag('li.date_select')
+ end
+
+end

0 comments on commit 04c926b

Please sign in to comment.