enumerize 0.8.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +27 -12
  5. data/CHANGELOG.md +135 -0
  6. data/Gemfile +5 -21
  7. data/Gemfile.global +20 -0
  8. data/Gemfile.mongo_mapper +7 -0
  9. data/Gemfile.rails42 +7 -0
  10. data/Gemfile.rails51 +7 -0
  11. data/README.md +185 -9
  12. data/Rakefile +2 -4
  13. data/enumerize.gemspec +1 -0
  14. data/lib/enumerize/activerecord.rb +55 -27
  15. data/lib/enumerize/attribute.rb +41 -9
  16. data/lib/enumerize/base.rb +28 -17
  17. data/lib/enumerize/hooks/formtastic.rb +3 -8
  18. data/lib/enumerize/hooks/sequel_dataset.rb +15 -0
  19. data/lib/enumerize/hooks/simple_form.rb +5 -11
  20. data/lib/enumerize/hooks/uniqueness.rb +3 -8
  21. data/lib/enumerize/integrations/rspec/matcher.rb +107 -26
  22. data/lib/enumerize/mongoid.rb +13 -0
  23. data/lib/enumerize/predicatable.rb +7 -16
  24. data/lib/enumerize/predicates.rb +3 -1
  25. data/lib/enumerize/scope/activerecord.rb +37 -0
  26. data/lib/enumerize/scope/mongoid.rb +35 -0
  27. data/lib/enumerize/scope/sequel.rb +40 -0
  28. data/lib/enumerize/sequel.rb +57 -0
  29. data/lib/enumerize/set.rb +18 -8
  30. data/lib/enumerize/value.rb +10 -9
  31. data/lib/enumerize/version.rb +3 -1
  32. data/lib/enumerize.rb +23 -1
  33. data/spec/enumerize/integrations/rspec/matcher_spec.rb +258 -0
  34. data/spec/spec_helper.rb +28 -0
  35. data/test/activerecord_test.rb +233 -10
  36. data/test/attribute_test.rb +22 -0
  37. data/test/base_test.rb +7 -7
  38. data/test/formtastic_test.rb +3 -12
  39. data/test/mongo_mapper_test.rb +7 -1
  40. data/test/mongoid_test.rb +63 -7
  41. data/test/multiple_test.rb +21 -0
  42. data/test/predicates_test.rb +6 -0
  43. data/test/sequel_test.rb +291 -0
  44. data/test/set_test.rb +14 -0
  45. data/test/simple_form_test.rb +0 -1
  46. data/test/support/mock_controller.rb +4 -0
  47. data/test/support/view_test_helper.rb +4 -0
  48. data/test/test_helper.rb +23 -2
  49. data/test/value_test.rb +51 -21
  50. metadata +40 -9
  51. data/Gemfile.rails4 +0 -23
  52. data/lib/enumerize/form_helper.rb +0 -23
  53. data/test/rspec_matcher_test.rb +0 -76
  54. data/test/rspec_spec.rb +0 -13
@@ -0,0 +1,291 @@
1
+ require 'test_helper'
2
+ require 'sequel'
3
+ require 'logger'
4
+ require 'jdbc/sqlite3' if RUBY_PLATFORM == 'java'
5
+
6
+ module SequelTest
7
+ silence_warnings do
8
+ DB = if RUBY_PLATFORM == 'java'
9
+ Sequel.connect('jdbc:sqlite::memory:')
10
+ else
11
+ Sequel.sqlite
12
+ end
13
+ DB.loggers << Logger.new(nil)
14
+ end
15
+
16
+ DB.create_table :users do
17
+ primary_key :id
18
+ String :sex
19
+ String :role
20
+ String :lambda_role
21
+ String :name
22
+ String :interests
23
+ String :status
24
+ String :account_type, default: "basic"
25
+ end
26
+
27
+ DB.create_table :documents do
28
+ primary_key :id
29
+ String :visibility
30
+ Time :created_at
31
+ Time :updated_at
32
+ end
33
+
34
+ class Document < Sequel::Model
35
+ extend Enumerize
36
+ enumerize :visibility, :in => [:public, :private, :protected], :scope => true, :default => :public
37
+ end
38
+
39
+ module RoleEnum
40
+ extend Enumerize
41
+ enumerize :role, :in => [:user, :admin], :default => :user, scope: :having_role
42
+ enumerize :lambda_role, :in => [:user, :admin], :default => lambda { :admin }
43
+ end
44
+
45
+ class User < Sequel::Model
46
+ plugin :serialization, :json, :interests
47
+ plugin :dirty
48
+ plugin :defaults_setter
49
+ plugin :validation_helpers
50
+ extend Enumerize
51
+ include RoleEnum
52
+
53
+ enumerize :sex, :in => [:male, :female]
54
+
55
+ enumerize :interests, :in => [:music, :sports, :dancing, :programming], :multiple => true
56
+
57
+ enumerize :status, :in => { active: 1, blocked: 2 }, scope: true
58
+
59
+ enumerize :account_type, :in => [:basic, :premium]
60
+ end
61
+
62
+ class UniqStatusUser < User
63
+ def validate
64
+ super
65
+ validates_unique :status
66
+ validates_presence :sex
67
+ end
68
+ end
69
+
70
+ describe Enumerize::SequelSupport do
71
+ it 'sets nil if invalid value is passed' do
72
+ user = User.new
73
+ user.sex = :invalid
74
+ user.sex.must_be_nil
75
+ end
76
+
77
+ it 'saves value' do
78
+ User.filter.delete
79
+ user = User.new
80
+ user.sex = :female
81
+ user.save
82
+ user.sex.must_equal 'female'
83
+ end
84
+
85
+ it 'loads value' do
86
+ User.filter.delete
87
+ User.create(:sex => :male)
88
+ store_translations(:en, :enumerize => {:sex => {:male => 'Male'}}) do
89
+ user = User.first
90
+ user.sex.must_equal 'male'
91
+ user.sex_text.must_equal 'Male'
92
+ end
93
+ end
94
+
95
+ it 'has default value' do
96
+ User.new.role.must_equal 'user'
97
+ User.new.values[:role].must_equal 'user'
98
+ end
99
+
100
+ it 'does not set default value for not selected attributes' do
101
+ User.filter.delete
102
+ User.create(:sex => :male)
103
+
104
+ assert_equal [:id], User.select(:id).first.values.keys
105
+ end
106
+
107
+ it 'has default value with lambda' do
108
+ User.new.lambda_role.must_equal 'admin'
109
+ User.new.values[:lambda_role].must_equal 'admin'
110
+ end
111
+ it 'uses after_initialize callback to set default value' do
112
+ User.filter.delete
113
+ User.create(sex: 'male', lambda_role: nil)
114
+
115
+ user = User.where(:sex => 'male').first
116
+ user.lambda_role.must_equal 'admin'
117
+ end
118
+
119
+ it 'uses default value from db column' do
120
+ User.new.account_type.must_equal 'basic'
121
+ end
122
+
123
+ it 'validates inclusion' do
124
+ user = User.new
125
+ user.role = 'wrong'
126
+ user.wont_be :valid?
127
+ user.errors[:role].must_include 'is not included in the list'
128
+ end
129
+
130
+ it 'validates inclusion on mass assignment' do
131
+ assert_raises Sequel::ValidationFailed do
132
+ User.create(role: 'wrong')
133
+ end
134
+ end
135
+
136
+ it "uses persisted value for validation if it hasn't been set" do
137
+ user = User.create :sex => :male
138
+ User[user.id].read_attribute_for_validation(:sex).must_equal 'male'
139
+ end
140
+
141
+ it 'is valid with empty string assigned' do
142
+ user = User.new
143
+ user.role = ''
144
+ user.must_be :valid?
145
+ end
146
+
147
+ it 'stores nil when empty string assigned' do
148
+ user = User.new
149
+ user.role = ''
150
+ user.values[:role].must_be_nil
151
+ end
152
+
153
+ it 'supports multiple attributes' do
154
+ user = User.new
155
+ user.interests ||= []
156
+ user.interests.must_be_empty
157
+ user.interests << "music"
158
+ user.interests.must_equal %w(music)
159
+ user.save
160
+
161
+ user = User[user.id]
162
+ user.interests.must_be_instance_of Enumerize::Set
163
+ user.interests.must_equal %w(music)
164
+ user.interests << "sports"
165
+ user.interests.must_equal %w(music sports)
166
+
167
+ user.interests = []
168
+ interests = user.interests
169
+ interests << "music"
170
+ interests.must_equal %w(music)
171
+ interests << "dancing"
172
+ interests.must_equal %w(music dancing)
173
+ end
174
+
175
+ it 'returns invalid multiple value for validation' do
176
+ user = User.new
177
+ user.interests << :music
178
+ user.interests << :invalid
179
+ values = user.read_attribute_for_validation(:interests)
180
+ values.must_equal %w(music invalid)
181
+ end
182
+
183
+ it 'validates multiple attributes' do
184
+ user = User.new
185
+ user.interests << :invalid
186
+ user.wont_be :valid?
187
+
188
+ user.interests = Object.new
189
+ user.wont_be :valid?
190
+
191
+ user.interests = ['music', '']
192
+ user.must_be :valid?
193
+ end
194
+
195
+ it 'stores custom values for multiple attributes' do
196
+ User.filter.delete
197
+
198
+ klass = Class.new(User)
199
+ klass.enumerize :interests, in: { music: 0, sports: 1, dancing: 2, programming: 3}, multiple: true
200
+
201
+ user = klass.new
202
+ user.interests << :music
203
+ user.interests.must_equal %w(music)
204
+ user.save
205
+
206
+ user = klass[user.id]
207
+ user.interests.must_equal %w(music)
208
+ end
209
+
210
+ it 'adds scope' do
211
+ User.filter.delete
212
+
213
+ user_1 = User.create(status: :active, role: :admin)
214
+ user_2 = User.create(status: :blocked)
215
+
216
+ User.with_status(:active).to_a.must_equal [user_1]
217
+ User.with_status(:blocked).to_a.must_equal [user_2]
218
+ User.with_status(:active, :blocked).to_set.must_equal [user_1, user_2].to_set
219
+
220
+ User.without_status(:active).to_a.must_equal [user_2]
221
+ User.without_status(:active, :blocked).to_a.must_equal []
222
+
223
+ User.having_role(:admin).to_a.must_equal [user_1]
224
+ end
225
+
226
+ it 'allows either key or value as valid' do
227
+ user_1 = User.new(status: :active)
228
+ user_2 = User.new(status: 1)
229
+ user_3 = User.new(status: '1')
230
+
231
+ user_1.status.must_equal 'active'
232
+ user_2.status.must_equal 'active'
233
+ user_3.status.must_equal 'active'
234
+
235
+ user_1.must_be :valid?
236
+ user_2.must_be :valid?
237
+ user_3.must_be :valid?
238
+ end
239
+
240
+ it 'supports defining enumerized attributes on abstract class' do
241
+ Document.filter.delete
242
+
243
+ document = Document.new
244
+ document.visibility = :protected
245
+ document.visibility.must_equal 'protected'
246
+ end
247
+
248
+ it 'supports defining enumerized scopes on abstract class' do
249
+ Document.filter.delete
250
+
251
+ document_1 = Document.create(visibility: :public)
252
+ document_2 = Document.create(visibility: :private)
253
+
254
+ Document.with_visibility(:public).to_a.must_equal [document_1]
255
+ end
256
+
257
+ it 'validates uniqueness' do
258
+ user = User.create(status: :active, sex: "male")
259
+
260
+ user = UniqStatusUser.new
261
+ user.sex = "male"
262
+ user.status = :active
263
+ user.valid?.must_equal false
264
+
265
+ user.errors[:status].wont_be :empty?
266
+ end
267
+
268
+ it "doesn't update record" do
269
+ Document.filter.delete
270
+
271
+ expected = Time.new(2010, 10, 10)
272
+
273
+ document = Document.new
274
+ document.updated_at = expected
275
+ document.save
276
+
277
+ document = Document.last
278
+ document.save
279
+
280
+ assert_equal expected, document.updated_at
281
+ end
282
+
283
+ it 'changes from dirty should be serialized as scalar values' do
284
+ user = User.create(:status => :active)
285
+ user.status = :blocked
286
+
287
+ expected = { status: [1, 2] }.to_yaml
288
+ assert_equal expected, user.column_changes.to_yaml
289
+ end
290
+ end
291
+ end
data/test/set_test.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'yaml'
2
3
 
3
4
  describe Enumerize::Set do
4
5
  let(:klass) do
@@ -103,6 +104,12 @@ describe Enumerize::Set do
103
104
  end
104
105
  end
105
106
 
107
+ describe '#texts' do
108
+ it 'returns array of text values' do
109
+ set.texts.must_equal ['A']
110
+ end
111
+ end
112
+
106
113
  describe '#join' do
107
114
  it 'joins values' do
108
115
  set << :b
@@ -147,4 +154,11 @@ describe Enumerize::Set do
147
154
  set.wont_respond_to :some_method?
148
155
  end
149
156
  end
157
+
158
+ describe 'serialization' do
159
+ it 'is serialized to yaml as array' do
160
+ set << :a
161
+ assert_equal YAML.dump(%w(a)), YAML.dump(set)
162
+ end
163
+ end
150
164
  end
@@ -1,6 +1,5 @@
1
1
  require 'test_helper'
2
2
  require 'simple_form/version'
3
- require 'rails'
4
3
 
5
4
  class SimpleFormSpec < MiniTest::Spec
6
5
  include ViewTestHelper
@@ -22,4 +22,8 @@ class MockController
22
22
  end
23
23
 
24
24
  def hash_for_users_path(*); end
25
+
26
+ def polymorphic_mappings
27
+ {}
28
+ end
25
29
  end
@@ -1,6 +1,10 @@
1
1
  require 'active_support/concern'
2
2
  require 'active_support/testing/setup_and_teardown'
3
3
 
4
+ if defined?(ActionView::RoutingUrlFor)
5
+ ActionView::RoutingUrlFor.send(:include, ActionDispatch::Routing::UrlFor)
6
+ end
7
+
4
8
  module ViewTestHelper
5
9
  extend ActiveSupport::Concern
6
10
 
data/test/test_helper.rb CHANGED
@@ -2,12 +2,33 @@ require 'minitest/autorun'
2
2
  require 'minitest/spec'
3
3
  require 'active_support/core_ext/kernel/reporting'
4
4
  require 'active_model'
5
-
6
- $VERBOSE=true
5
+ require 'rails'
6
+ begin
7
+ require 'mongoid'
8
+ rescue LoadError
9
+ end
7
10
 
8
11
  module RailsAdmin
9
12
  end
10
13
 
14
+ require 'simple_form'
15
+ SimpleForm.setup {}
16
+
17
+ require 'formtastic'
18
+
19
+ module EnumerizeTest
20
+ class Application < Rails::Application
21
+ config.active_support.deprecation = :stderr
22
+ config.active_support.test_order = :random
23
+ config.eager_load = false
24
+ config.secret_key_base = 'secret'
25
+ end
26
+ end
27
+
28
+ EnumerizeTest::Application.initialize!
29
+
30
+ $VERBOSE=true
31
+
11
32
  require 'enumerize'
12
33
 
13
34
  Dir["#{File.dirname(__FILE__)}/support/*.rb"].each do |file|
data/test/value_test.rb CHANGED
@@ -1,15 +1,32 @@
1
1
  require 'test_helper'
2
+ require 'yaml'
2
3
 
3
4
  describe Enumerize::Value do
4
- let(:attr) { Struct.new(:values).new([]) }
5
- let(:value) { Enumerize::Value.new(attr, 'test_value') }
5
+ class Attr < Struct.new(:values)
6
+ end
7
+
8
+ let(:attr) { Attr.new([]) }
9
+ let(:val) { Enumerize::Value.new(attr, 'test_value', 1) }
6
10
 
7
11
  it 'is a string' do
8
- value.must_be_kind_of String
12
+ val.must_be_kind_of String
9
13
  end
10
14
 
11
- it 'is compared to string' do
12
- value.must_be :==, 'test_value'
15
+ describe 'equality' do
16
+ it 'is compared to string' do
17
+ val.must_be :==, 'test_value'
18
+ val.wont_be :==, 'not_value'
19
+ end
20
+
21
+ it 'is compared to symbol' do
22
+ val.must_be :==, :test_value
23
+ val.wont_be :==, :not_value
24
+ end
25
+
26
+ it 'is compared to integer' do
27
+ val.must_be :==, 1
28
+ val.wont_be :==, 2
29
+ end
13
30
  end
14
31
 
15
32
  describe 'translation' do
@@ -17,7 +34,13 @@ describe Enumerize::Value do
17
34
 
18
35
  it 'uses common translation' do
19
36
  store_translations(:en, :enumerize => {:attribute_name => {:test_value => "Common translation"}}) do
20
- value.text.must_be :==, "Common translation"
37
+ val.text.must_be :==, "Common translation"
38
+ end
39
+ end
40
+
41
+ it 'uses default translation from the "default" section if its present' do
42
+ store_translations(:en, :enumerize => {:defaults => {:attribute_name => {:test_value => "Common translation"}}}) do
43
+ val.text.must_be :==, "Common translation"
21
44
  end
22
45
  end
23
46
 
@@ -25,7 +48,7 @@ describe Enumerize::Value do
25
48
  attr.i18n_scopes = ["enumerize.model_name.attribute_name"]
26
49
 
27
50
  store_translations(:en, :enumerize => {:model_name => {:attribute_name => {:test_value => "Model Specific translation"}}}) do
28
- value.text.must_be :==, "Model Specific translation"
51
+ val.text.must_be :==, "Model Specific translation"
29
52
  end
30
53
  end
31
54
 
@@ -33,13 +56,13 @@ describe Enumerize::Value do
33
56
  attr.i18n_scopes = ["enumerize.model_name.attribute_name"]
34
57
 
35
58
  store_translations(:en, :enumerize => {:attribute_name => {:test_value => "Common translation"}, :model_name => {:attribute_name => {:test_value => "Model Specific translation"}}}) do
36
- value.text.must_be :==, "Model Specific translation"
59
+ val.text.must_be :==, "Model Specific translation"
37
60
  end
38
61
  end
39
62
 
40
63
  it 'uses simply humanized value when translation is undefined' do
41
64
  store_translations(:en, :enumerize => {}) do
42
- value.text.must_be :==, "Test value"
65
+ val.text.must_be :==, "Test value"
43
66
  end
44
67
  end
45
68
 
@@ -47,7 +70,7 @@ describe Enumerize::Value do
47
70
  attr.i18n_scopes = ["other.scope"]
48
71
 
49
72
  store_translations(:en, :other => {:scope => {:test_value => "Scope specific translation"}}) do
50
- value.text.must_be :==, "Scope specific translation"
73
+ val.text.must_be :==, "Scope specific translation"
51
74
  end
52
75
  end
53
76
 
@@ -55,53 +78,60 @@ describe Enumerize::Value do
55
78
  attr.i18n_scopes = ["nonexistent.scope", "other.scope"]
56
79
 
57
80
  store_translations(:en, :other => {:scope => {:test_value => "Scope specific translation"}}) do
58
- value.text.must_be :==, "Scope specific translation"
81
+ val.text.must_be :==, "Scope specific translation"
59
82
  end
60
83
  end
61
84
  end
62
85
 
63
86
  describe 'boolean methods comparison' do
64
87
  before do
65
- attr.values = [value, Enumerize::Value.new(attr, 'other_value')]
88
+ attr.values = [val, Enumerize::Value.new(attr, 'other_value')]
66
89
  end
67
90
 
68
91
  it 'returns true if value equals method' do
69
- value.test_value?.must_equal true
92
+ val.test_value?.must_equal true
70
93
  end
71
94
 
72
95
  it 'returns false if value does not equal method' do
73
- value.other_value?.must_equal false
96
+ val.other_value?.must_equal false
74
97
  end
75
98
 
76
99
  it 'raises NoMethodError if there are no values like boolean method' do
77
100
  proc {
78
- value.some_method?
101
+ val.some_method?
79
102
  }.must_raise NoMethodError
80
103
  end
81
104
 
82
105
  it 'raises ArgumentError if arguments are passed' do
83
106
  proc {
84
- value.other_value?('<3')
107
+ val.other_value?('<3')
85
108
  }.must_raise ArgumentError
86
109
  end
87
110
 
88
111
  it 'responds to methods for existing values' do
89
- value.must_respond_to :test_value?
90
- value.must_respond_to :other_value?
112
+ val.must_respond_to :test_value?
113
+ val.must_respond_to :other_value?
91
114
  end
92
115
 
93
116
  it 'returns a method object' do
94
- value.method(:test_value?).must_be_instance_of Method
117
+ val.method(:test_value?).must_be_instance_of Method
95
118
  end
96
119
 
97
120
  it "doesn't respond to a method for not existing value" do
98
- value.wont_respond_to :some_method?
121
+ val.wont_respond_to :some_method?
99
122
  end
100
123
  end
101
124
 
102
125
  describe 'serialization' do
126
+ let(:val) { Enumerize::Value.new(attr, 'test_value') }
127
+
103
128
  it 'should be serialized to yaml as string value' do
104
- assert_equal YAML.dump('test_value'), YAML.dump(value)
129
+ assert_equal YAML.dump('test_value'), YAML.dump(val)
130
+ end
131
+
132
+ it 'serializes with Marshal' do
133
+ dump_value = Marshal.dump(val)
134
+ Marshal.load(dump_value).must_equal 'test_value'
105
135
  end
106
136
  end
107
137
  end
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: 0.8.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Nartimov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-04 00:00:00.000000000 Z
11
+ date: 2017-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -32,10 +32,14 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - ".gitignore"
35
+ - ".rspec"
35
36
  - ".travis.yml"
36
37
  - CHANGELOG.md
37
38
  - Gemfile
38
- - Gemfile.rails4
39
+ - Gemfile.global
40
+ - Gemfile.mongo_mapper
41
+ - Gemfile.rails42
42
+ - Gemfile.rails51
39
43
  - MIT-LICENSE
40
44
  - README.md
41
45
  - Rakefile
@@ -45,8 +49,8 @@ files:
45
49
  - lib/enumerize/attribute.rb
46
50
  - lib/enumerize/attribute_map.rb
47
51
  - lib/enumerize/base.rb
48
- - lib/enumerize/form_helper.rb
49
52
  - lib/enumerize/hooks/formtastic.rb
53
+ - lib/enumerize/hooks/sequel_dataset.rb
50
54
  - lib/enumerize/hooks/simple_form.rb
51
55
  - lib/enumerize/hooks/uniqueness.rb
52
56
  - lib/enumerize/integrations/rails_admin.rb
@@ -54,11 +58,18 @@ files:
54
58
  - lib/enumerize/integrations/rspec/matcher.rb
55
59
  - lib/enumerize/module.rb
56
60
  - lib/enumerize/module_attributes.rb
61
+ - lib/enumerize/mongoid.rb
57
62
  - lib/enumerize/predicatable.rb
58
63
  - lib/enumerize/predicates.rb
64
+ - lib/enumerize/scope/activerecord.rb
65
+ - lib/enumerize/scope/mongoid.rb
66
+ - lib/enumerize/scope/sequel.rb
67
+ - lib/enumerize/sequel.rb
59
68
  - lib/enumerize/set.rb
60
69
  - lib/enumerize/value.rb
61
70
  - lib/enumerize/version.rb
71
+ - spec/enumerize/integrations/rspec/matcher_spec.rb
72
+ - spec/spec_helper.rb
62
73
  - test/activerecord_test.rb
63
74
  - test/attribute_map_test.rb
64
75
  - test/attribute_test.rb
@@ -70,8 +81,7 @@ files:
70
81
  - test/multiple_test.rb
71
82
  - test/predicates_test.rb
72
83
  - test/rails_admin_test.rb
73
- - test/rspec_matcher_test.rb
74
- - test/rspec_spec.rb
84
+ - test/sequel_test.rb
75
85
  - test/set_test.rb
76
86
  - test/simple_form_test.rb
77
87
  - test/support/mock_controller.rb
@@ -79,7 +89,8 @@ files:
79
89
  - test/test_helper.rb
80
90
  - test/value_test.rb
81
91
  homepage: https://github.com/brainspec/enumerize
82
- licenses: []
92
+ licenses:
93
+ - MIT
83
94
  metadata: {}
84
95
  post_install_message:
85
96
  rdoc_options: []
@@ -97,8 +108,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
108
  version: '0'
98
109
  requirements: []
99
110
  rubyforge_project:
100
- rubygems_version: 2.2.0
111
+ rubygems_version: 2.6.11
101
112
  signing_key:
102
113
  specification_version: 4
103
114
  summary: Enumerated attributes with I18n and ActiveRecord/Mongoid/MongoMapper support
104
- test_files: []
115
+ test_files:
116
+ - spec/enumerize/integrations/rspec/matcher_spec.rb
117
+ - spec/spec_helper.rb
118
+ - test/activerecord_test.rb
119
+ - test/attribute_map_test.rb
120
+ - test/attribute_test.rb
121
+ - test/base_test.rb
122
+ - test/formtastic_test.rb
123
+ - test/module_attributes_test.rb
124
+ - test/mongo_mapper_test.rb
125
+ - test/mongoid_test.rb
126
+ - test/multiple_test.rb
127
+ - test/predicates_test.rb
128
+ - test/rails_admin_test.rb
129
+ - test/sequel_test.rb
130
+ - test/set_test.rb
131
+ - test/simple_form_test.rb
132
+ - test/support/mock_controller.rb
133
+ - test/support/view_test_helper.rb
134
+ - test/test_helper.rb
135
+ - test/value_test.rb
data/Gemfile.rails4 DELETED
@@ -1,23 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- gem 'rake'
6
- gem 'minitest', '~> 4.1'
7
- gem 'rspec', :require => false
8
-
9
- gem 'rails', '4.0.1', :require => false
10
- gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
11
- gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
12
-
13
- platforms :rbx do
14
- gem 'rubysl', '~> 2.0'
15
- gem 'psych'
16
- gem 'rubinius-developer_tools'
17
- gem 'rubysl-test-unit'
18
- end
19
-
20
- gem 'mongoid', github: 'mongoid/mongoid', ref: 'f91feef0a0c6b83a1b878e154f1014536aa1c298'
21
- gem 'mongo_mapper', github: 'jnunemaker/mongomapper'
22
- gem 'simple_form'
23
- gem 'formtastic', github: 'justinfrench/formtastic'
@@ -1,23 +0,0 @@
1
- # backport of https://github.com/rails/rails/commit/3be9e8a0c2187744b6c9879ca2836cef5ebed693
2
- if defined?(ActionView::Helpers::InstanceTag)
3
- ActionView::Helpers::InstanceTag.class_eval do
4
- def self.check_box_checked?(value, checked_value)
5
- case value
6
- when TrueClass, FalseClass
7
- value
8
- when NilClass
9
- false
10
- when Integer
11
- value != 0
12
- when String
13
- value == checked_value
14
- else
15
- if value.respond_to?(:include?)
16
- value.include?(checked_value)
17
- else
18
- value.to_i != 0
19
- end
20
- end
21
- end
22
- end
23
- end