formtastic 2.3.0.rc3 → 2.3.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDM3NTE4ZDViMzMxYTExYmY4MWIxNTYxODMxNzYzYjdmMDM3NDY4YQ==
5
+ data.tar.gz: !binary |-
6
+ OTAwNmUwZGUyY2Q0NjQzMTM3NWRkMjBjMjY2YzU4YzEyZTQ1NWRmYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OGJmYmEyZDU3NDZlOTI4ZmI1YzhlZTc0M2RiMjEwMTY0NmM1NmRhMWMzOGY2
10
+ ZjdmZGY1NzBlMzhmNjE2NTliOWFjMTRhMWZmOGM0YTQwNTdkMzU5MDI4NmMx
11
+ ODgxOWFhMTQ4ODhkODEyMTVmNzRhNmZkNzY2M2YxNTNmZTBlNGQ=
12
+ data.tar.gz: !binary |-
13
+ MDQxOGFiNGQxMTNiNWMzZmRjNDM3NzYzMGY5ZGFiOGIzZmY3Mjk4ODMwNjZi
14
+ MjJhMTZkNjRiNGRmYjY0ZjJhMzczM2UwZTU3MGZlNTNlNmQzNmM4MGNkZmU0
15
+ MTY2ZDRkOGY5MTA1ZjMzZDY5MzczMjg4YzJlNWY2NGY2NzQ1ODA=
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
+ language: ruby
1
2
  before_install:
2
3
  - gem update --system
3
4
  - gem update bundler
@@ -7,40 +8,37 @@ rvm:
7
8
  - 1.9.2
8
9
  - 1.9.3
9
10
  - 2.0.0
10
- - 2.1.0
11
+ - 2.1
11
12
  gemfile:
12
13
  - gemfiles/rails_3.0.gemfile
13
14
  - gemfiles/rails_3.1.gemfile
14
15
  - gemfiles/rails_3.2.gemfile
16
+ - gemfiles/rails_4.gemfile
17
+ - gemfiles/rails_4.0.4.gemfile
18
+ - gemfiles/rails_edge.gemfile
15
19
  env:
16
20
  - DEFER_GC=false RAILS_EDGE=true
17
- script: "rake spec"
21
+ script: "bundle exec rake spec"
18
22
  matrix:
19
- include:
20
- - rvm: 1.9.3
23
+ exclude:
24
+ - rvm: 1.8.7
21
25
  gemfile: gemfiles/rails_4.gemfile
22
- env: DEFER_GC=false RAILS_EDGE=true
23
- - rvm: 2.0.0
26
+ - rvm: ree
24
27
  gemfile: gemfiles/rails_4.gemfile
25
- env: DEFER_GC=false RAILS_EDGE=true
26
- - rvm: 2.1.0
28
+ - rvm: 1.9.2
27
29
  gemfile: gemfiles/rails_4.gemfile
28
- env: DEFER_GC=false RAILS_EDGE=true
29
- - rvm: 1.9.3
30
+ - rvm: 1.8.7
30
31
  gemfile: gemfiles/rails_4.0.4.gemfile
31
- env: DEFER_GC=false RAILS_EDGE=true
32
- - rvm: 2.0.0
32
+ - rvm: ree
33
33
  gemfile: gemfiles/rails_4.0.4.gemfile
34
- env: DEFER_GC=false RAILS_EDGE=true
35
- - rvm: 1.9.3
34
+ - rvm: 1.9.2
35
+ gemfile: gemfiles/rails_4.0.4.gemfile
36
+ - rvm: 1.8.7
36
37
  gemfile: gemfiles/rails_edge.gemfile
37
- env: DEFER_GC=false RAILS_EDGE=true
38
- - rvm: 2.0.0
38
+ - rvm: ree
39
39
  gemfile: gemfiles/rails_edge.gemfile
40
- env: DEFER_GC=false RAILS_EDGE=true
41
- - rvm: 2.1.0
40
+ - rvm: 1.9.2
42
41
  gemfile: gemfiles/rails_edge.gemfile
43
- env: DEFER_GC=false RAILS_EDGE=true
44
42
  allow_failures:
45
43
  - rvm: 1.9.3
46
44
  gemfile: gemfiles/rails_edge.gemfile
@@ -48,9 +46,6 @@ matrix:
48
46
  - rvm: 2.0.0
49
47
  gemfile: gemfiles/rails_edge.gemfile
50
48
  env: DEFER_GC=false RAILS_EDGE=true
51
- - rvm: 2.1.0
52
- gemfile: gemfiles/rails_4.gemfile
53
- env: DEFER_GC=false RAILS_EDGE=true
54
- - rvm: 2.1.0
49
+ - rvm: 2.1
55
50
  gemfile: gemfiles/rails_edge.gemfile
56
51
  env: DEFER_GC=false RAILS_EDGE=true
data/CHANGELOG CHANGED
@@ -1,3 +1,28 @@
1
+ 2.3.0.rc4
2
+
3
+ * Removed deprecated date, time and datetime inputs
4
+ * Fixed comparison checking of boolean checked values
5
+ * Fixed errors raised when handling some validations
6
+ * Fixed that we weren't rendering a label on checkbox inputs when hidden_fields was set to true
7
+ * Fixed eager loading in test environments
8
+ * Fixed documentation to point to the new official country_select gem
9
+ * Fixed that we would previously render a default wrapper id if wrapper_html[:id] was deliberately set to nil
10
+ * Fixed bg with duplicate hidden fields in Rails >= 3.2.13
11
+ * Note: Re-built 2.3-stable branch from 2.3.0.rc3 onwards due to accidental merges of master inside PRs
12
+
13
+ 2.3.0.rc3
14
+
15
+ * Fixed invalid HTML attributes in BooleanInput with a whitelist
16
+ * Fixed compatibility with Rails 4.0.x, 4.1
17
+ * Fixed compatibility with newer I18n
18
+ * Fixed compatibility with Paperclip
19
+ * Fixed submit button in slim template
20
+ * Fixed class with Rails' field_error_proc
21
+ * Deprecated :error_class option
22
+ * Deprecated support for Rails < 3.2.13
23
+ * Added ability to change the model-derived class we add to the form (eg 'post')
24
+ * Added support for symbols & sets in collections
25
+
1
26
  2.3.0.rc2
2
27
 
3
28
  * deprecate support for Rails < 3.2
data/README.textile CHANGED
@@ -1,7 +1,7 @@
1
1
  h1. Formtastic
2
2
 
3
3
  !https://travis-ci.org/justinfrench/formtastic.png?branch=master!:https://travis-ci.org/justinfrench/formtastic
4
- !http://inch-pages.github.io/github/justinfrench/formtastic.png!:http://inch-pages.github.io/github/justinfrench/formtastic
4
+ !http://inch-ci.org/github/justinfrench/formtastic.png!:http://inch-ci.org/github/justinfrench/formtastic
5
5
  !https://codeclimate.com/github/justinfrench/formtastic.png!:https://codeclimate.com/github/justinfrench/formtastic
6
6
  !https://badge.fury.io/rb/formtastic.png!:http://badge.fury.io/rb/formtastic
7
7
  !https://gemnasium.com/justinfrench/formtastic.png!:https://gemnasium.com/justinfrench/formtastic
@@ -20,7 +20,7 @@ h2. Documentation & Support
20
20
 
21
21
  h2. Compatibility
22
22
 
23
- * Formtastic 4 (master on Github) will require Rails 3.2 minimum
23
+ * Formtastic 3 (master on Github) will require Rails 3.2 minimum
24
24
  * Formtastic 2.3 is Rails 3 and Rails 4 compatible (Rails < 3.2 is deprecated)
25
25
  * Formtastic 2.1 & 2.2 is Rails 3 and Rails 4 compatible
26
26
  * Formtastic, much like Rails, is very ActiveRecord-centric. Many are successfully using other ActiveModel-like ORMs and objects (DataMapper, MongoMapper, Mongoid, Authlogic, Devise...) but we're not guaranteeing full compatibility at this stage. Patches are welcome!
@@ -602,7 +602,7 @@ h2. Dependencies
602
602
 
603
603
  There are none other than Rails itself, but...
604
604
 
605
- * If you want to use the @:country@ input, you'll need to install the "country-select plugin":https://github.com/stefanpenner/country_select (or any other country_select plugin with the same API).
605
+ * If you want to use the @:country@ input, you'll need to install the "country-select plugin":https://github.com/stefanpenner/country_select (or any other country_select plugin with the same API). Both 1.x and 2.x are supported, but they behave differently when storing data, so please see their "upgrade notes":https://github.com/stefanpenner/country_select/blob/master/UPGRADING.md if switching from 1.x.
606
606
  * There are a bunch of development dependencies if you plan to contribute to Formtastic
607
607
 
608
608
 
data/lib/formtastic.rb CHANGED
@@ -15,9 +15,9 @@ module Formtastic
15
15
  autoload :Util
16
16
 
17
17
  # Deprecate support for Rails < 3.2
18
- if Util.deprecated_version_of_rails?
18
+ if defined?(::Rails) && Util.deprecated_version_of_rails?
19
19
  ::ActiveSupport::Deprecation.warn(
20
- "Support for Rails 3.0 and 3.1 will be dropped from Formtastic 3.0",
20
+ "Support for Rails < 3.2.13 will be dropped from Formtastic 3.0",
21
21
  caller)
22
22
  end
23
23
 
@@ -321,7 +321,9 @@ module Formtastic
321
321
  def input_class(as)
322
322
  @input_classes_cache ||= {}
323
323
  @input_classes_cache[as] ||= begin
324
- Rails.application.config.cache_classes ? input_class_with_const_defined(as) : input_class_by_trying(as)
324
+ config = Rails.application.config
325
+ use_const_defined = config.respond_to?(:eager_load) ? config.eager_load : config.cache_classes
326
+ use_const_defined ? input_class_with_const_defined(as) : input_class_by_trying(as)
325
327
  end
326
328
  end
327
329
 
@@ -37,6 +37,8 @@ module Formtastic
37
37
 
38
38
  result = if conditional.respond_to?(:call) && conditional.arity > 0
39
39
  conditional.call(object)
40
+ elsif conditional.respond_to?(:call) && conditional.arity == 0
41
+ object.instance_exec(&conditional)
40
42
  elsif conditional.is_a?(::Symbol) && object.respond_to?(conditional)
41
43
  object.send(conditional)
42
44
  else
@@ -3,33 +3,33 @@ module Formtastic
3
3
  module Base
4
4
  # @todo relies on `dom_id`, `required?`, `optional`, `errors?`, `association_primary_key` & `sanitized_method_name` methods from another module
5
5
  module Wrapping
6
-
6
+
7
7
  # Override this method if you want to change the display order (for example, rendering the
8
8
  # errors before the body of the input).
9
9
  def input_wrapping(&block)
10
- template.content_tag(:li,
11
- [template.capture(&block), error_html, hint_html].join("\n").html_safe,
10
+ template.content_tag(:li,
11
+ [template.capture(&block), error_html, hint_html].join("\n").html_safe,
12
12
  wrapper_html_options
13
13
  )
14
14
  end
15
-
15
+
16
16
  def wrapper_html_options
17
17
  opts = wrapper_html_options_raw
18
18
  opts[:class] = wrapper_classes
19
- opts[:id] ||= wrapper_dom_id
19
+ opts[:id] = wrapper_dom_id unless opts.has_key? :id
20
20
  opts
21
21
  end
22
-
22
+
23
23
  def wrapper_html_options_raw
24
24
  (options[:wrapper_html] || {}).dup
25
25
  end
26
-
26
+
27
27
  def wrapper_classes_raw
28
28
  classes = wrapper_html_options_raw[:class] || []
29
29
  return classes.dup if classes.is_a?(Array)
30
30
  return [classes]
31
31
  end
32
-
32
+
33
33
  def wrapper_classes
34
34
  classes = wrapper_classes_raw
35
35
  classes << as
@@ -41,11 +41,11 @@ module Formtastic
41
41
 
42
42
  classes.join(' ')
43
43
  end
44
-
44
+
45
45
  def wrapper_dom_id
46
46
  @wrapper_dom_id ||= "#{dom_id.to_s.gsub((association_primary_key || method).to_s, sanitized_method_name.to_s)}_input"
47
47
  end
48
-
48
+
49
49
  end
50
50
  end
51
51
  end
@@ -102,9 +102,7 @@ module Formtastic
102
102
  value
103
103
  when NilClass
104
104
  false
105
- when Integer
106
- value != 0
107
- when String
105
+ when Integer, String
108
106
  value == checked_value
109
107
  when Array
110
108
  value.include?(checked_value)
@@ -103,18 +103,16 @@ module Formtastic
103
103
  end
104
104
 
105
105
  def choice_html(choice)
106
- template.content_tag(:label,
107
- hidden_fields? ?
108
- check_box_with_hidden_input(choice) :
109
- check_box_without_hidden_input(choice) <<
110
- choice_label(choice),
106
+ template.content_tag(
107
+ :label,
108
+ checkbox_input(choice) + choice_label(choice),
111
109
  label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)
112
110
  )
113
111
  end
114
112
 
115
113
  def hidden_field_for_all
116
114
  if hidden_fields?
117
- ""
115
+ ''
118
116
  else
119
117
  options = {}
120
118
  options[:class] = [method.to_s.singularize, 'default'].join('_') if value_as_class?
@@ -183,6 +181,14 @@ module Formtastic
183
181
 
184
182
  protected
185
183
 
184
+ def checkbox_input(choice)
185
+ if hidden_fields?
186
+ check_box_with_hidden_input(choice)
187
+ else
188
+ check_box_without_hidden_input(choice)
189
+ end
190
+ end
191
+
186
192
  def make_selected_values
187
193
  if object.respond_to?(method)
188
194
  selected_items = object.send(method)
@@ -4,13 +4,15 @@ module Formtastic
4
4
  # Rails doesn't come with a `country_select` helper by default any more, so you'll need to do
5
5
  # one of the following:
6
6
  #
7
- # * install the [country-select](https://github.com/jamesds/country-select) gem
8
- # * install the no longer maintained [official Rails plugin](http://github.com/rails/iso-3166-country-select)
7
+ # * install the [country_select](https://github.com/stefanpenner/country_select) gem
9
8
  # * install any other country_select plugin that behaves in a similar way
10
9
  # * roll your own `country_select` helper with the same args and options as the Rails one
11
10
  #
11
+ # Formtastic supports both 1.x and 2.x of stefanpenner/country_select, but if you're upgrading
12
+ # from 1.x, they behave quite differently, so please see their [upgrade instructions](https://github.com/stefanpenner/country_select/blob/master/UPGRADING.md).
13
+ #
12
14
  # By default, Formtastic includes a handful of English-speaking countries as "priority
13
- # counties", which can be set in the `priority_countries` configuration array in the
15
+ # countries", which can be set in the `priority_countries` configuration array in the
14
16
  # formtastic.rb initializer to suit your market and user base (see README for more info on
15
17
  # configuration). Additionally, it is possible to set the :priority_countries on a per-input
16
18
  # basis through the `:priority_countries` option. These priority countries will be passed down
@@ -31,7 +33,7 @@ module Formtastic
31
33
  # # ...
32
34
  # </li>
33
35
  #
34
- # @example `:priority_countries` set on a specific input
36
+ # @example `:priority_countries` set on a specific input (country_select 1.x)
35
37
  #
36
38
  # <%= semantic_form_for @user do |f| %>
37
39
  # <%= f.inputs do %>
@@ -46,12 +48,27 @@ module Formtastic
46
48
  # # ...
47
49
  # </li>
48
50
  #
51
+ # @example `:priority_countries` set on a specific input (country_select 2.x)
52
+ #
53
+ # <%= semantic_form_for @user do |f| %>
54
+ # <%= f.inputs do %>
55
+ # <%= f.input :nationality, :as => :country, :priority_countries => ["AU", "NZ"] %>
56
+ # <% end %>
57
+ # <% end %>
58
+ #
59
+ # <li class='country'>
60
+ # <label for="user_nationality">Country</label>
61
+ # <select id="user_nationality" name="user[nationality]">
62
+ # <option value="...">...</option>
63
+ # # ...
64
+ # </li>
65
+ #
49
66
  # @see Formtastic::Helpers::InputsHelper#input InputsHelper#input for full documentation of all possible options.
50
67
  class CountryInput
51
68
  include Base
52
69
 
53
70
  def to_html
54
- raise "To use the :country input, please install a country_select plugin, like this one: https://github.com/jamesds/country-select" unless builder.respond_to?(:country_select)
71
+ raise "To use the :country input, please install a country_select plugin, like this one: https://github.com/stefanpenner/country_select" unless builder.respond_to?(:country_select)
55
72
  input_wrapping do
56
73
  label_html <<
57
74
  builder.country_select(method, priority_countries, input_options, input_html_options)
@@ -144,12 +144,21 @@ module Formtastic
144
144
 
145
145
  def to_html
146
146
  input_wrapping do
147
- hidden_input <<
147
+ deprecated_hidden_input <<
148
148
  label_html <<
149
149
  (options[:group_by] ? grouped_select_html : select_html)
150
150
  end
151
151
  end
152
152
 
153
+ # TODO: remove from Formtastic 3.0
154
+ def deprecated_hidden_input
155
+ if multiple? && Util.rails3? && Util.deprecated_version_of_rails?
156
+ template.hidden_field_tag(input_html_options_name_multiple, '', :id => nil)
157
+ else
158
+ "".html_safe
159
+ end
160
+ end
161
+
153
162
  def select_html
154
163
  builder.select(input_name, collection, input_options, input_html_options)
155
164
  end
@@ -171,14 +180,6 @@ module Formtastic
171
180
  options.key?(:include_blank) ? options[:include_blank] : (single? && builder.include_blank_for_select_by_default)
172
181
  end
173
182
 
174
- def hidden_input
175
- if multiple?
176
- template.hidden_field_tag(input_html_options_name_multiple, '', :id => nil)
177
- else
178
- "".html_safe
179
- end
180
- end
181
-
182
183
  def prompt?
183
184
  !!options[:prompt]
184
185
  end
@@ -15,8 +15,12 @@ module Formtastic
15
15
  time_fragments
16
16
  end
17
17
 
18
+ def value_or_default_value
19
+ value ? value : Time.current
20
+ end
21
+
18
22
  def fragment_value(fragment)
19
- value ? value.send(fragment) : ""
23
+ value_or_default_value.send(fragment)
20
24
  end
21
25
 
22
26
  def hidden_fragments
@@ -22,23 +22,31 @@ module Formtastic
22
22
  end
23
23
 
24
24
  def rails3?
25
- ::Rails::VERSION::MAJOR == 3
25
+ rails_version >= Gem::Version.new("3.0.0") &&
26
+ rails_version < Gem::Version.new("4.0.0")
26
27
  end
27
28
 
28
29
  def rails4?
29
- ::Rails::VERSION::MAJOR == 4
30
+ rails_version >= Gem::Version.new("4.0.0") &&
31
+ rails_version < Gem::Version.new("5.0.0")
30
32
  end
31
33
 
32
34
  def rails4_0?
33
- ::Rails::VERSION::MAJOR == 4 && ::Rails::VERSION::MINOR == 0
35
+ rails_version >= Gem::Version.new("4.0.0") &&
36
+ rails_version < Gem::Version.new("4.1.0")
34
37
  end
35
38
 
36
39
  def rails4_1?
37
- ::Rails::VERSION::MAJOR == 4 && ::Rails::VERSION::MINOR == 1
40
+ rails_version >= Gem::Version.new("4.1.0") &&
41
+ rails_version < Gem::Version.new("4.2.0")
38
42
  end
39
43
 
40
44
  def deprecated_version_of_rails?
41
- const_defined?(:Rails) && ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR < 2 && ::Rails::VERSION::PATCH < 13
45
+ rails_version < Gem::Version.new("3.2.13")
46
+ end
47
+
48
+ def rails_version
49
+ Gem::Version.new(::Rails::VERSION::STRING)
42
50
  end
43
51
 
44
52
  end
@@ -1,3 +1,3 @@
1
1
  module Formtastic
2
- VERSION = "2.3.0.rc3"
2
+ VERSION = "2.3.0.rc4"
3
3
  end
@@ -821,6 +821,15 @@ describe 'Formtastic::FormBuilder#input' do
821
821
  output_buffer.should have_tag("form li.my_class")
822
822
  output_buffer.should have_tag("form li.another_class")
823
823
  end
824
+
825
+ describe 'when nil' do
826
+ it 'should not put an id attribute on the div tag' do
827
+ concat(semantic_form_for(@new_post) do |builder|
828
+ concat(builder.input(:title, :wrapper_html => {:id => nil}))
829
+ end)
830
+ output_buffer.should have_tag('form li:not([id])')
831
+ end
832
+ end
824
833
  end
825
834
 
826
835
  describe 'when not provided' do
@@ -127,6 +127,16 @@ describe 'boolean input' do
127
127
  output_buffer.should have_tag('form li label input[@type="checkbox"][@value="yes"][@checked="checked"]')
128
128
  end
129
129
 
130
+ it 'should generate a checked input if object.method returns checked value when inverted' do
131
+ @new_post.stub(:allow_comments).and_return(0)
132
+
133
+ concat(semantic_form_for(@new_post) do |builder|
134
+ concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 0, :unchecked_value => 1))
135
+ end)
136
+
137
+ output_buffer.should have_tag('form li label input[@type="checkbox"][@value="0"][@checked="checked"]')
138
+ end
139
+
130
140
  it 'should not generate a checked input if object.method returns unchecked value' do
131
141
  @new_post.stub(:allow_comments).and_return('no')
132
142
 
@@ -227,5 +237,4 @@ describe 'boolean input' do
227
237
  end
228
238
 
229
239
  end
230
-
231
240
  end
@@ -107,6 +107,7 @@ describe 'check_boxes input' do
107
107
  ::Post.all.each do |post|
108
108
  output_buffer.should have_tag("form li fieldset ol li label input#author_post_ids_#{post.id}")
109
109
  output_buffer.should have_tag("form li fieldset ol li label input[@name='author[post_ids][]']", :count => 2)
110
+ output_buffer.should have_tag('form li fieldset ol li label', /#{post.to_label}/)
110
111
  end
111
112
 
112
113
  end
@@ -383,7 +383,7 @@ describe 'select input' do
383
383
  end
384
384
 
385
385
  it 'should have a hidden field' do
386
- output_buffer.should have_tag('form li input[@type="hidden"][@name="author[post_ids][]"]')
386
+ output_buffer.should have_tag('form li input[@type="hidden"][@name="author[post_ids][]"]', :count => 1)
387
387
  end
388
388
 
389
389
  it 'should have a select option for each Post' do
@@ -108,6 +108,46 @@ describe 'string input' do
108
108
  should_have_maxlength(42, :options => { :maximum => 42, :unless => :specify_maxlength })
109
109
  end
110
110
  end
111
+
112
+ describe 'any conditional validation' do
113
+ describe 'proc with arity that calls an instance method' do
114
+ it 'calls the method on the object' do
115
+ @new_post.should_receive(:something?)
116
+ @new_post.class.should_receive(:validators_on).with(:title).at_least(1).and_return([
117
+ active_model_presence_validator([:title], { :unless => Proc.new { |user| user.something? } })
118
+ ])
119
+ concat(semantic_form_for(@new_post) do |builder|
120
+ concat(builder.input(:title))
121
+ end)
122
+ end
123
+ end
124
+
125
+ describe 'symbol method name' do
126
+ it 'calls the method on the object if the method exists' do
127
+ @new_post.should_receive(:something?)
128
+ @new_post.class.should_receive(:validators_on).with(:title).at_least(1).and_return([
129
+ active_model_presence_validator([:title], { :unless => :something? })
130
+ ])
131
+ concat(semantic_form_for(@new_post) do |builder|
132
+ concat(builder.input(:title))
133
+ end)
134
+ end
135
+ end
136
+
137
+ describe 'any other conditional' do
138
+ it 'does not raise an error' do
139
+ @conditional = double()
140
+ @new_post.class.should_receive(:validators_on).with(:title).at_least(1).and_return([
141
+ active_model_presence_validator([:title], { :unless => @conditional })
142
+ ])
143
+ concat(semantic_form_for(@new_post) do |builder|
144
+ concat(builder.input(:title))
145
+ end)
146
+ end
147
+ end
148
+
149
+ end
150
+
111
151
  end
112
152
  end
113
153
 
@@ -64,33 +64,6 @@ describe 'time select input' do
64
64
 
65
65
  end
66
66
 
67
- describe "with :ignore_date => false and no initial Time" do
68
- before do
69
- @new_post.stub(:publish_at)
70
- concat(semantic_form_for(@new_post) do |builder|
71
- concat(builder.input(:publish_at, :as => :time_select, :ignore_date => false))
72
- end)
73
- end
74
-
75
- it 'should have a hidden input for day, month and year' do
76
- output_buffer.should have_tag('input#post_publish_at_1i')
77
- output_buffer.should have_tag('input#post_publish_at_2i')
78
- output_buffer.should have_tag('input#post_publish_at_3i')
79
- end
80
-
81
- it 'should not have values in hidden inputs for day, month and year' do
82
- output_buffer.should have_tag('input#post_publish_at_1i[@value=""]')
83
- output_buffer.should have_tag('input#post_publish_at_2i[@value=""]')
84
- output_buffer.should have_tag('input#post_publish_at_3i[@value=""]')
85
- end
86
-
87
- it 'should have an select for hour and minute' do
88
- output_buffer.should have_tag('select#post_publish_at_4i')
89
- output_buffer.should have_tag('select#post_publish_at_5i')
90
- end
91
-
92
- end
93
-
94
67
  describe "without seconds" do
95
68
  before do
96
69
  concat(semantic_form_for(@new_post) do |builder|
data/spec/util_spec.rb ADDED
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe 'Formtastic::Util' do
5
+
6
+ describe '.deprecated_version_of_rails?' do
7
+
8
+ subject { Formtastic::Util.deprecated_version_of_rails? }
9
+
10
+ context '3.0.0' do
11
+ before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("3.0.0") } }
12
+ it 'should be true' do
13
+ expect(subject).to be_true
14
+ end
15
+ end
16
+
17
+ context '3.1.0' do
18
+ before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("3.1.0") } }
19
+ it 'should be true' do
20
+ expect(subject).to be_true
21
+ end
22
+ end
23
+
24
+ context '3.2.12' do
25
+ before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("3.2.12") } }
26
+ it 'should be true' do
27
+ expect(subject).to be_true
28
+ end
29
+ end
30
+
31
+ context '3.2.13' do
32
+ before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("3.2.13") } }
33
+ it 'should be true' do
34
+ expect(subject).to be_false
35
+ end
36
+ end
37
+
38
+ context '3.2.14' do
39
+ before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("3.2.14") } }
40
+ it 'should be true' do
41
+ expect(subject).to be_false
42
+ end
43
+ end
44
+
45
+ context '3.3.0' do
46
+ before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("3.3.0") } }
47
+ it 'should be true' do
48
+ expect(subject).to be_false
49
+ end
50
+ end
51
+
52
+ context '4.0.0' do
53
+ before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("4.0.0") } }
54
+ it 'should be true' do
55
+ expect(subject).to be_false
56
+ end
57
+ end
58
+ end
59
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0.rc3
5
- prerelease: 6
4
+ version: 2.3.0.rc4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Justin French
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-12 00:00:00.000000000 Z
11
+ date: 2014-08-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: actionpack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: nokogiri
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - <
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - <
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec-rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec_tag_matchers
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: hpricot
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: BlueCloth
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ! '>='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ! '>='
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: yard
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: colored
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ! '>='
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ! '>='
140
123
  - !ruby/object:Gem::Version
@@ -142,7 +125,6 @@ dependencies:
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: tzinfo
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - ! '>='
148
130
  - !ruby/object:Gem::Version
@@ -150,7 +132,6 @@ dependencies:
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - ! '>='
156
137
  - !ruby/object:Gem::Version
@@ -158,7 +139,6 @@ dependencies:
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: ammeter
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
143
  - - '='
164
144
  - !ruby/object:Gem::Version
@@ -166,7 +146,6 @@ dependencies:
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
150
  - - '='
172
151
  - !ruby/object:Gem::Version
@@ -174,7 +153,6 @@ dependencies:
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: appraisal
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
157
  - - '='
180
158
  - !ruby/object:Gem::Version
@@ -182,7 +160,6 @@ dependencies:
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
164
  - - '='
188
165
  - !ruby/object:Gem::Version
@@ -190,7 +167,6 @@ dependencies:
190
167
  - !ruby/object:Gem::Dependency
191
168
  name: rake
192
169
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
170
  requirements:
195
171
  - - <=
196
172
  - !ruby/object:Gem::Version
@@ -198,7 +174,6 @@ dependencies:
198
174
  type: :development
199
175
  prerelease: false
200
176
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
177
  requirements:
203
178
  - - <=
204
179
  - !ruby/object:Gem::Version
@@ -206,7 +181,6 @@ dependencies:
206
181
  - !ruby/object:Gem::Dependency
207
182
  name: activemodel
208
183
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
184
  requirements:
211
185
  - - ! '>='
212
186
  - !ruby/object:Gem::Version
@@ -214,7 +188,6 @@ dependencies:
214
188
  type: :development
215
189
  prerelease: false
216
190
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
191
  requirements:
219
192
  - - ! '>='
220
193
  - !ruby/object:Gem::Version
@@ -294,10 +267,8 @@ files:
294
267
  - lib/formtastic/inputs/boolean_input.rb
295
268
  - lib/formtastic/inputs/check_boxes_input.rb
296
269
  - lib/formtastic/inputs/country_input.rb
297
- - lib/formtastic/inputs/date_input.rb
298
270
  - lib/formtastic/inputs/date_picker_input.rb
299
271
  - lib/formtastic/inputs/date_select_input.rb
300
- - lib/formtastic/inputs/datetime_input.rb
301
272
  - lib/formtastic/inputs/datetime_picker_input.rb
302
273
  - lib/formtastic/inputs/datetime_select_input.rb
303
274
  - lib/formtastic/inputs/email_input.rb
@@ -312,7 +283,6 @@ files:
312
283
  - lib/formtastic/inputs/select_input.rb
313
284
  - lib/formtastic/inputs/string_input.rb
314
285
  - lib/formtastic/inputs/text_input.rb
315
- - lib/formtastic/inputs/time_input.rb
316
286
  - lib/formtastic/inputs/time_picker_input.rb
317
287
  - lib/formtastic/inputs/time_select_input.rb
318
288
  - lib/formtastic/inputs/time_zone_input.rb
@@ -356,7 +326,6 @@ files:
356
326
  - spec/inputs/date_select_input_spec.rb
357
327
  - spec/inputs/datetime_picker_input_spec.rb
358
328
  - spec/inputs/datetime_select_input_spec.rb
359
- - spec/inputs/deprecated_time_date_datetime_inputs_spec.rb
360
329
  - spec/inputs/email_input_spec.rb
361
330
  - spec/inputs/file_input_spec.rb
362
331
  - spec/inputs/hidden_input_spec.rb
@@ -384,31 +353,31 @@ files:
384
353
  - spec/support/deferred_garbage_collection.rb
385
354
  - spec/support/deprecation.rb
386
355
  - spec/support/test_environment.rb
356
+ - spec/util_spec.rb
387
357
  homepage: http://github.com/justinfrench/formtastic
388
358
  licenses:
389
359
  - MIT
360
+ metadata: {}
390
361
  post_install_message:
391
362
  rdoc_options:
392
363
  - --charset=UTF-8
393
364
  require_paths:
394
365
  - lib
395
366
  required_ruby_version: !ruby/object:Gem::Requirement
396
- none: false
397
367
  requirements:
398
368
  - - ! '>='
399
369
  - !ruby/object:Gem::Version
400
370
  version: '0'
401
371
  required_rubygems_version: !ruby/object:Gem::Requirement
402
- none: false
403
372
  requirements:
404
373
  - - ! '>='
405
374
  - !ruby/object:Gem::Version
406
375
  version: '0'
407
376
  requirements: []
408
377
  rubyforge_project:
409
- rubygems_version: 1.8.23
378
+ rubygems_version: 2.4.1
410
379
  signing_key:
411
- specification_version: 3
380
+ specification_version: 4
412
381
  summary: A Rails form builder plugin/gem with semantically rich and accessible markup
413
382
  test_files:
414
383
  - spec/actions/button_action_spec.rb
@@ -436,7 +405,6 @@ test_files:
436
405
  - spec/inputs/date_select_input_spec.rb
437
406
  - spec/inputs/datetime_picker_input_spec.rb
438
407
  - spec/inputs/datetime_select_input_spec.rb
439
- - spec/inputs/deprecated_time_date_datetime_inputs_spec.rb
440
408
  - spec/inputs/email_input_spec.rb
441
409
  - spec/inputs/file_input_spec.rb
442
410
  - spec/inputs/hidden_input_spec.rb
@@ -464,4 +432,5 @@ test_files:
464
432
  - spec/support/deferred_garbage_collection.rb
465
433
  - spec/support/deprecation.rb
466
434
  - spec/support/test_environment.rb
435
+ - spec/util_spec.rb
467
436
  has_rdoc:
@@ -1,10 +0,0 @@
1
- module Formtastic
2
- module Inputs
3
- class DateInput < DateSelectInput
4
- def to_html
5
- ::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))
6
- super
7
- end
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- module Formtastic
2
- module Inputs
3
- class DatetimeInput < DatetimeSelectInput
4
- def to_html
5
- ::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))
6
- super
7
- end
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- module Formtastic
2
- module Inputs
3
- class TimeInput < TimeSelectInput
4
- def to_html
5
- ::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))
6
- super
7
- end
8
- end
9
- end
10
- end
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'deprecated time, datetime and date inputs' do
4
- include FormtasticSpecHelper
5
-
6
- before do
7
- @output_buffer = ''
8
- mock_everything
9
- end
10
-
11
- it 'should warn :time is deprecated' do
12
- ::ActiveSupport::Deprecation.should_receive(:warn)
13
- semantic_form_for(@new_post) do |f|
14
- concat(f.input :created_at, :as => :time)
15
- end
16
- end
17
-
18
- it 'should warn :datetime is deprecated' do
19
- ::ActiveSupport::Deprecation.should_receive(:warn)
20
- semantic_form_for(@new_post) do |f|
21
- concat(f.input :created_at, :as => :datetime)
22
- end
23
- end
24
-
25
- it 'should warn :date is deprecated' do
26
- ::ActiveSupport::Deprecation.should_receive(:warn)
27
- semantic_form_for(@new_post) do |f|
28
- concat(f.input :created_at, :as => :date)
29
- end
30
- end
31
-
32
- it 'should use wrapper css class based off :as, not off their parent class' do
33
- with_deprecation_silenced do
34
- concat(semantic_form_for(@new_post) do |f|
35
- concat(f.input :created_at, :as => :time)
36
- concat(f.input :created_at, :as => :datetime)
37
- concat(f.input :created_at, :as => :date)
38
- end)
39
- end
40
- output_buffer.should have_tag('li.time')
41
- output_buffer.should have_tag('li.datetime')
42
- output_buffer.should have_tag('li.date')
43
- output_buffer.should_not have_tag('li.time_select')
44
- output_buffer.should_not have_tag('li.datetime_select')
45
- output_buffer.should_not have_tag('li.date_select')
46
- end
47
-
48
- end