formtastic 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmQ3ZGJkMDc3NDc1ZDQyMjkzMzkwZTVhMjY5NGQwZDAyNWMwZGUzNw==
4
+ ZTFjYzY2MDMyNWE2NGI2YzNkMzJkNTVkNTQ0ZTg2N2QxYjg0OTgwMQ==
5
5
  data.tar.gz: !binary |-
6
- NDAwNDk5MGRiZGY2YTdmODM3ZTU2ZjhiOTkwNjU1MjI5MjU0MmU3NA==
6
+ ZmE5MzZiNWU2YTUxNTEzYTgxYjhiZjhiOTkyYzY1MGRmZWE3NDZiMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDQ4NDU3MGFiMDAwMWMzMTk4MDE4ZDQ3MTQ2MzkwMmExZTIwOTk0MjA0ZThm
10
- YTIxZmIzN2ViM2RmYzg5NTAwMDQ5OGI2YTQ5YTY4MjZmNjViNTc5Njk4MjFm
11
- Zjg2NzQyYzVkNGJhNjc4YzFjNjJhYzkyM2JhZmFlZTlmZWIyYmU=
9
+ ZTlhMTIxZTcxNWJhMTU5NmRkMzk2OGE2ZDBlYzQzOGZmNTQxZjE0ZTA4YTE2
10
+ OTFlMWMyYTNiYTBjZmZhMTFhMjRiOTI4ZWFkYzI1MzFhMzRhOGI5ZWIwYzhk
11
+ NzFlZmMwYTE3MDE2NmFmNjY1NTg2MDM4YmNhMDc1YTE4M2NlMTg=
12
12
  data.tar.gz: !binary |-
13
- OTlhMjI0OTk2MWEzYTVjNzA0ZGIzMjNlNzgyZjJhZjhlYjM5NzQ4NjdkZWIz
14
- NGJkMWY4NzJiMjljMWIzZGZlMmJmNGNhZjkzMzQyOTY0OWRjNTBmNDIxODFm
15
- ZDYwN2RlYWNjM2ExNzUyZjVmZDg2N2M2ODcyNjkxYmUyZjgxYzI=
13
+ OTYxODJlYjUxYWFmNDQyZDIyMjU2YjI2MWM3MzRhODEyOGY4MTE3YzliM2Q5
14
+ NmVlNGQ5ZTM4MDg2ZmQyMzc1MmVkZTYzMTVhMjFkNDEwNjE3YjEzYmUzYjY3
15
+ NDU1ZGZhYmRlNWZlYTcyNGE2N2RlZDMxOTY5YzMyN2QzM2VjZjE=
@@ -102,7 +102,9 @@ module Formtastic
102
102
  value
103
103
  when NilClass
104
104
  false
105
- when Integer, String
105
+ when Integer
106
+ value == checked_value.to_i
107
+ when String
106
108
  value == checked_value
107
109
  when Array
108
110
  value.include?(checked_value)
@@ -1,3 +1,3 @@
1
1
  module Formtastic
2
- VERSION = "2.3.0"
2
+ VERSION = "2.3.1"
3
3
  end
@@ -8,18 +8,21 @@ describe 'boolean input' do
8
8
  before do
9
9
  @output_buffer = ''
10
10
  mock_everything
11
-
12
- concat(semantic_form_for(@new_post) do |builder|
13
- concat(builder.input(:allow_comments, :as => :boolean))
14
- end)
15
11
  end
16
12
 
17
- it_should_have_input_wrapper_with_class("boolean")
18
- it_should_have_input_wrapper_with_class(:input)
19
- it_should_have_input_wrapper_with_id("post_allow_comments_input")
20
- it_should_apply_error_logic_for_input_type(:boolean)
21
-
22
- it 'should generate a label containing the input' do
13
+ describe 'generic' do
14
+ before do
15
+ concat(semantic_form_for(@new_post) do |builder|
16
+ concat(builder.input(:allow_comments, :as => :boolean))
17
+ end)
18
+ end
19
+
20
+ it_should_have_input_wrapper_with_class("boolean")
21
+ it_should_have_input_wrapper_with_class(:input)
22
+ it_should_have_input_wrapper_with_id("post_allow_comments_input")
23
+ it_should_apply_error_logic_for_input_type(:boolean)
24
+
25
+ it 'should generate a label containing the input' do
23
26
  output_buffer.should_not have_tag('label.label')
24
27
  output_buffer.should have_tag('form li label', :count => 1)
25
28
  output_buffer.should have_tag('form li label[@for="post_allow_comments"]')
@@ -27,24 +30,25 @@ describe 'boolean input' do
27
30
  output_buffer.should have_tag('form li label input[@type="checkbox"]', :count => 1)
28
31
  output_buffer.should have_tag('form li input[@type="hidden"]', :count => 1)
29
32
  output_buffer.should_not have_tag('form li label input[@type="hidden"]', :count => 1) # invalid HTML5
30
- end
31
-
32
- it 'should not add a "name" attribute to the label' do
33
- output_buffer.should_not have_tag('form li label[@name]')
34
- end
35
-
36
- it 'should generate a checkbox input' do
37
- output_buffer.should have_tag('form li label input')
38
- output_buffer.should have_tag('form li label input#post_allow_comments')
39
- output_buffer.should have_tag('form li label input[@type="checkbox"]')
40
- output_buffer.should have_tag('form li label input[@name="post[allow_comments]"]')
41
- output_buffer.should have_tag('form li label input[@type="checkbox"][@value="1"]')
42
- end
43
-
44
- it 'should generate a checked input if object.method returns true' do
45
- output_buffer.should have_tag('form li label input[@checked="checked"]')
46
- output_buffer.should have_tag('form li input[@name="post[allow_comments]"]', :count => 2)
47
- output_buffer.should have_tag('form li input#post_allow_comments', :count => 1)
33
+ end
34
+
35
+ it 'should not add a "name" attribute to the label' do
36
+ output_buffer.should_not have_tag('form li label[@name]')
37
+ end
38
+
39
+ it 'should generate a checkbox input' do
40
+ output_buffer.should have_tag('form li label input')
41
+ output_buffer.should have_tag('form li label input#post_allow_comments')
42
+ output_buffer.should have_tag('form li label input[@type="checkbox"]')
43
+ output_buffer.should have_tag('form li label input[@name="post[allow_comments]"]')
44
+ output_buffer.should have_tag('form li label input[@type="checkbox"][@value="1"]')
45
+ end
46
+
47
+ it 'should generate a checked input if object.method returns true' do
48
+ output_buffer.should have_tag('form li label input[@checked="checked"]')
49
+ output_buffer.should have_tag('form li input[@name="post[allow_comments]"]', :count => 2)
50
+ output_buffer.should have_tag('form li input#post_allow_comments', :count => 1)
51
+ end
48
52
  end
49
53
 
50
54
  it 'should generate a checked input if :input_html is passed :checked => checked' do
@@ -127,6 +131,16 @@ describe 'boolean input' do
127
131
  output_buffer.should have_tag('form li label input[@type="checkbox"][@value="yes"][@checked="checked"]')
128
132
  end
129
133
 
134
+ it 'should generate a checked input for boolean database values compared to string checked values' do
135
+ @new_post.stub(:foo).and_return(1)
136
+
137
+ concat(semantic_form_for(@new_post) do |builder|
138
+ concat(builder.input(:foo, :as => :boolean))
139
+ end)
140
+
141
+ output_buffer.should have_tag('form li label input[@type="checkbox"][@value="1"][@checked="checked"]')
142
+ end
143
+
130
144
  it 'should generate a checked input if object.method returns checked value when inverted' do
131
145
  @new_post.stub(:allow_comments).and_return(0)
132
146
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin French
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-22 00:00:00.000000000 Z
11
+ date: 2014-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack