enumerize 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/enumerize/hooks/formtastic.rb +2 -1
- data/lib/enumerize/hooks/simple_form.rb +2 -1
- data/lib/enumerize/version.rb +1 -1
- data/test/formtastic_test.rb +15 -0
- data/test/simple_form_test.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09a21a038b965b870133316f6ff3343c673999dc49fc619045695e2b56acd5be'
|
4
|
+
data.tar.gz: 031bb09cc643bff2ab3fbc1b9d3786ece309d684841a6199d11082aa14169c56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53ebadba90aaf20fd45007f386d2de7a702b3ee1973992675136a41be99fe92889e1c852c409fa0ae8eea1d948b5cfec08163a1b3b0f13fb58de7984992e9a01
|
7
|
+
data.tar.gz: f8f90dd597f8ae953f8c162682ee96e24e49b0b4685b21d9003991c9779fb9abe9764b7cf4d5f6afeafce2a0a2f5ed073b3a00251210268cab76db6a45ba9b65
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,8 @@ module Enumerize
|
|
5
5
|
module FormtasticFormBuilderExtension
|
6
6
|
|
7
7
|
def input(method, options={})
|
8
|
-
|
8
|
+
enumerized_object = convert_to_model(object)
|
9
|
+
klass = enumerized_object.class
|
9
10
|
|
10
11
|
if klass.respond_to?(:enumerized_attributes) && (attr = klass.enumerized_attributes[method])
|
11
12
|
options[:collection] ||= attr.options
|
@@ -17,7 +17,8 @@ module Enumerize
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def add_input_options_for_enumerized_attribute(attribute_name, options)
|
20
|
-
|
20
|
+
enumerized_object = convert_to_model(object)
|
21
|
+
klass = enumerized_object.class
|
21
22
|
|
22
23
|
if klass.respond_to?(:enumerized_attributes) && (attr = klass.enumerized_attributes[attribute_name])
|
23
24
|
options[:collection] ||= attr.options
|
data/lib/enumerize/version.rb
CHANGED
data/test/formtastic_test.rb
CHANGED
@@ -42,6 +42,12 @@ class FormtasticSpec < MiniTest::Spec
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
class Registration < Struct.new(:sex)
|
46
|
+
extend Enumerize
|
47
|
+
|
48
|
+
enumerize :sex, in: [:male, :female]
|
49
|
+
end
|
50
|
+
|
45
51
|
before { $VERBOSE = nil }
|
46
52
|
after { $VERBOSE = true }
|
47
53
|
|
@@ -125,6 +131,15 @@ class FormtasticSpec < MiniTest::Spec
|
|
125
131
|
assert_select 'input[type=text]'
|
126
132
|
end
|
127
133
|
|
134
|
+
it 'renders select with enumerized values for non-ActiveModel object' do
|
135
|
+
concat(semantic_form_for(Registration.new, as: 'registration', url: '/') do |f|
|
136
|
+
f.input(:sex)
|
137
|
+
end)
|
138
|
+
|
139
|
+
assert_select 'select option[value=male]'
|
140
|
+
assert_select 'select option[value=female]'
|
141
|
+
end
|
142
|
+
|
128
143
|
it 'does not affect forms without object' do
|
129
144
|
concat(semantic_form_for('') do |f|
|
130
145
|
f.input(:name)
|
data/test/simple_form_test.rb
CHANGED
@@ -40,6 +40,12 @@ class SimpleFormSpec < MiniTest::Spec
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
class Registration < Struct.new(:sex)
|
44
|
+
extend Enumerize
|
45
|
+
|
46
|
+
enumerize :sex, in: [:male, :female]
|
47
|
+
end
|
48
|
+
|
43
49
|
let(:user) { User.new }
|
44
50
|
let(:post) { Post.new }
|
45
51
|
|
@@ -129,6 +135,15 @@ class SimpleFormSpec < MiniTest::Spec
|
|
129
135
|
assert_select 'input.string'
|
130
136
|
end
|
131
137
|
|
138
|
+
it 'renders select with enumerized values for non-ActiveModel object' do
|
139
|
+
concat(simple_form_for(Registration.new, as: 'registration', url: '/') do |f|
|
140
|
+
f.input(:sex)
|
141
|
+
end)
|
142
|
+
|
143
|
+
assert_select 'select option[value=male]'
|
144
|
+
assert_select 'select option[value=female]'
|
145
|
+
end
|
146
|
+
|
132
147
|
it 'does not affect forms without object' do
|
133
148
|
concat(simple_form_for('') do |f|
|
134
149
|
f.input(:name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumerize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Nartimov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|