enumerize 2.0.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +73 -0
  3. data/CHANGELOG.md +80 -3
  4. data/Gemfile +3 -3
  5. data/Gemfile.global +2 -9
  6. data/Gemfile.mongo_mapper +2 -2
  7. data/Gemfile.rails60 +6 -0
  8. data/Gemfile.rails61 +6 -0
  9. data/Gemfile.rails70 +9 -0
  10. data/Gemfile.railsmaster +5 -0
  11. data/README.md +209 -92
  12. data/Rakefile +2 -0
  13. data/lib/enumerize/activemodel.rb +47 -0
  14. data/lib/enumerize/activerecord.rb +79 -0
  15. data/lib/enumerize/attribute.rb +19 -11
  16. data/lib/enumerize/attribute_map.rb +2 -0
  17. data/lib/enumerize/base.rb +6 -6
  18. data/lib/enumerize/hooks/formtastic.rb +4 -1
  19. data/lib/enumerize/hooks/sequel_dataset.rb +2 -0
  20. data/lib/enumerize/hooks/simple_form.rb +4 -1
  21. data/lib/enumerize/hooks/uniqueness.rb +5 -1
  22. data/lib/enumerize/integrations/rails_admin.rb +3 -1
  23. data/lib/enumerize/integrations/rspec/matcher.rb +7 -2
  24. data/lib/enumerize/integrations/rspec.rb +2 -0
  25. data/lib/enumerize/module.rb +2 -0
  26. data/lib/enumerize/module_attributes.rb +2 -0
  27. data/lib/enumerize/mongoid.rb +16 -0
  28. data/lib/enumerize/predicatable.rb +3 -1
  29. data/lib/enumerize/predicates.rb +2 -0
  30. data/lib/enumerize/scope/activerecord.rb +16 -0
  31. data/lib/enumerize/scope/mongoid.rb +15 -0
  32. data/lib/enumerize/scope/sequel.rb +16 -0
  33. data/lib/enumerize/sequel.rb +9 -4
  34. data/lib/enumerize/set.rb +2 -0
  35. data/lib/enumerize/utils.rb +12 -0
  36. data/lib/enumerize/value.rb +14 -15
  37. data/lib/enumerize/version.rb +3 -1
  38. data/lib/enumerize.rb +9 -0
  39. data/lib/sequel/plugins/enumerize.rb +18 -0
  40. data/spec/enumerize/integrations/rspec/matcher_spec.rb +13 -10
  41. data/spec/spec_helper.rb +2 -0
  42. data/test/activemodel_test.rb +114 -0
  43. data/test/activerecord_test.rb +277 -79
  44. data/test/attribute_map_test.rb +9 -7
  45. data/test/attribute_test.rb +37 -30
  46. data/test/base_test.rb +66 -64
  47. data/test/formtastic_test.rb +25 -0
  48. data/test/module_attributes_test.rb +10 -8
  49. data/test/mongo_mapper_test.rb +19 -10
  50. data/test/mongoid_test.rb +51 -22
  51. data/test/multiple_test.rb +26 -18
  52. data/test/predicates_test.rb +30 -28
  53. data/test/rails_admin_test.rb +8 -6
  54. data/test/sequel_test.rb +111 -58
  55. data/test/set_test.rb +28 -26
  56. data/test/simple_form_test.rb +25 -0
  57. data/test/support/mock_controller.rb +6 -0
  58. data/test/support/shared_enums.rb +43 -0
  59. data/test/support/view_test_helper.rb +14 -1
  60. data/test/test_helper.rb +2 -0
  61. data/test/value_test.rb +51 -30
  62. metadata +14 -27
  63. data/.travis.yml +0 -18
  64. data/Gemfile.rails42 +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1b707373f1cda45d2a21fd4f4b6fa2e512e94d0c
4
- data.tar.gz: 989f1bbf21977dd0ab191ed2a41d865193702b82
2
+ SHA256:
3
+ metadata.gz: c86135927c636fc672bb7371b83b78b6844716f70dd2b9fa19a255b35ce2a5ca
4
+ data.tar.gz: d1ac5ff95c2673d0743fab97725cf7abc939b157594545ad3e40dd9a1eefb841
5
5
  SHA512:
6
- metadata.gz: 55c9e20ec4db7a12db817177e8de84caa23659186312418bba4c8f96df5acde2cbea01f68485884e315dae24bbec36d4d4485dc8013591be9cae26e638f44abd
7
- data.tar.gz: 6c592bfc03f5187f9caa8a07138ea16107a37fe037c610dfe8e4cf9e71b42e88e2a89181014a1074d57b07d234bd70b80663c33b7bc43017caa2731b8403ab7c
6
+ metadata.gz: 811f624a3f6d92fa20bc988b80051103e441315eab1662f3f2b1b9b98a866984e247e1b823669a7f7645d13e5aa44aaf8e1e95e39294e8c27a28d96dfc87b572
7
+ data.tar.gz: 8c50e7946135c94719ac50149ab55ad1601d508b9cdf663e4542f220655b611899824af77a60873601d2193b01fc2611735f643c51d07d8d188213b478123149
@@ -0,0 +1,73 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-20.04
12
+ services:
13
+ mongodb:
14
+ image: mongo:latest
15
+ ports:
16
+ - 27017:27017
17
+ postgres:
18
+ image: postgres:12
19
+ env:
20
+ POSTGRES_USER: postgres
21
+ POSTGRES_PASSWORD: postgres
22
+ ports:
23
+ - 5432:5432
24
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
25
+ mysql:
26
+ image: mysql:5.6
27
+ env:
28
+ MYSQL_ROOT_PASSWORD: mysql
29
+ ports:
30
+ - 3306:3306
31
+ options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ ruby-version: ['2.6', '2.7', '3.0.2']
36
+ gemfile:
37
+ - Gemfile
38
+ - Gemfile.rails60
39
+ - Gemfile.rails61
40
+ - Gemfile.rails70
41
+ - Gemfile.railsmaster
42
+ - Gemfile.mongo_mapper
43
+ db:
44
+ - sqlite3
45
+ - postgresql
46
+ - mysql2
47
+ exclude:
48
+ - gemfile: Gemfile.mongo_mapper
49
+ db: postgresql
50
+ - ruby-version: '3.0.2'
51
+ gemfile: Gemfile
52
+ - ruby-version: '3.0.2'
53
+ gemfile: Gemfile.mongo_mapper
54
+ - ruby-version: '2.6'
55
+ gemfile: Gemfile.rails70
56
+ - ruby-version: '2.6'
57
+ gemfile: Gemfile.railsmaster
58
+ env:
59
+ BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
60
+ DB: "${{ matrix.db }}"
61
+ steps:
62
+ - uses: actions/checkout@v2
63
+ - name: Set up Ruby
64
+ uses: ruby/setup-ruby@v1
65
+ with:
66
+ ruby-version: ${{ matrix.ruby-version }}
67
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
68
+ - name: Run tests
69
+ run: bundle exec rake
70
+ env:
71
+ POSTGRES_USER: postgres
72
+ POSTGRES_PASSWORD: postgres
73
+ MYSQL_ROOT_PASSWORD: mysql
data/CHANGELOG.md CHANGED
@@ -1,9 +1,86 @@
1
- ## master
1
+ ## 2.5.0 (December 24, 2021)
2
2
 
3
3
  ### enhancements
4
4
 
5
+ * Add support for Rails 7.0.0.alpha. (by [@f-mer](https://github.com/f-mer))
6
+ * Add support for negative shallow scopes. (by [@nashby](https://github.com/nashby))
7
+
8
+ ## 2.4.0 (December 12, 2020)
9
+
10
+ ### enhancements
11
+
12
+ * Show warning when enumerized value name conflicts with existing object's methods. (by [@aki77](https://github.com/aki77))
13
+ * Add RSpec support for shallow scopes. (by [@nashby](https://github.com/nashby))
14
+ * Drop support for Ruby older than 2.5. Support only Ruby 2.5+. (by [@nashby](https://github.com/nashby))
15
+ * Drop support for Rails 4. Support only Rails 5.2+. (by [@nashby](https://github.com/nashby))
16
+ * Add support for Rails 6.1 (by [@y-yagi](https://github.com/y-yagi))
17
+
18
+ ### bug fix
19
+
20
+ * Fix exception when using predicate methods on enumerized value transformed into invalid value. (by [@guigs](https://github.com/guigs))
21
+ * Fix issue with RSpec#with_predicates matcher when custom values are used as attribute. (by [@nashby](https://github.com/nashby))
22
+
23
+ ## 2.3.1 (May 2, 2019)
24
+
25
+ ### enhancements
26
+
27
+ * Add ability to skip validations by passing `:skip_validations` option. (by [@chumakoff](https://github.com/chumakoff))
28
+ * Add option `scope: shallow` to extend scopes based on enumerized attribute values (by [@moofkit](https://github.com/moofkit/))
29
+
5
30
  ### bug fix
6
31
 
32
+ * Fix issue with ActiveRecord and Mongoid `reload` method when enumberized attributes weren't synced from DB. (by [@nashby](https://github.com/nashby) and [@FunkyloverOne](https://github.com/FunkyloverOne))
33
+ * Fix issue with ActiveRecord `reload` method not working for ActiveRecord::Store attributes due to `1b776c`. (by [@rickcsong](https://github.com/rickcsong))
34
+
35
+ ## 2.2.2 (March 6, 2018)
36
+
37
+ ### bug fix
38
+
39
+ * Support non-ActiveModel objects in SimpleForm/Formtastic integration. (by [@nashby](https://github.com/nashby))
40
+
41
+ ## 2.2.1 (February 15, 2018)
42
+
43
+ ### bug fix
44
+
45
+ * Fix issue with SimpleForm/Formtastic forms without object. (by [@nashby](https://github.com/nashby))
46
+
47
+ ## 2.2.0 (February 13, 2018)
48
+
49
+ ### enhancements
50
+
51
+ * Add integration with active_interaction. (by [@runephilosof](https://github.com/runephilosof))
52
+ * Allow using `plugin :enumerize` with Sequel. (by [@jnylen](https://github.com/jnylen))
53
+ * Support ActiveModel::Attributes from Rails 5.2. (by [@troter](https://github.com/troter))
54
+ * Support Sequel 5.2.0. (by [@troter](https://github.com/troter))
55
+
56
+ ### bug fix
57
+
58
+ * Fix RailsAdmin integration when enumerated field used on edit form and enumerated value wasn't set. (by [@nashby](https://github.com/nashby))
59
+ * Fallback to a raw passed value instead of nil if AR type can't find value in the attribute. (by [@nashby](https://github.com/nashby))
60
+
61
+ ## 2.1.2 (May 18, 2017)
62
+
63
+ ### bug fix
64
+
65
+ * Support YAML serialization for the custom AR type. (by [@lest](https://github.com/lest))
66
+
67
+ ## 2.1.1 (May 1, 2017)
68
+
69
+ ### enhancements
70
+
71
+ * Run tests with multiple DBs (SQLite and PostgreSQL). (by [tkawa](https://github.com/tkawa))
72
+
73
+ ### bug fix
74
+
75
+ * Support deserialize and Rails 4.2 methods in the custom AR::Type class. (by [@lest](https://github.com/lest))
76
+ * Support dumping custom AR type to JSON. (by [@lest](https://github.com/lest))
77
+
78
+ ## 2.1.0 (March 31, 2017)
79
+
80
+ ### enhancements
81
+
82
+ * Support Active Record types serialization. (by [@lest](https://github.com/lest))
83
+
7
84
  ## 2.0.1 (October 18, 2016)
8
85
 
9
86
  ### bug fix
@@ -18,11 +95,11 @@
18
95
  * Drop support for Rails 4.0 and 4.1. Support only Rails 4.2 and newer. (by [@lest](https://github.com/lest))
19
96
  * Support Rails 5.0. (by [@nashby](https://github.com/nashby) and [@lest](https://github.com/lest))
20
97
  * Allow to pass enumerize values to `ActiveRecord#update_all` (by [@DmitryTsepelev](https://github.com/DmitryTsepelev) and [@ianwhite](https://github.com/ianwhite))
21
-
98
+
22
99
  ```ruby
23
100
  User.update_all(status: :blocked)
24
101
  ```
25
-
102
+
26
103
  ### bug fix
27
104
 
28
105
  * Rescue MissingAttributeError on attribute writing. (by [@embs](https://github.com/embs))
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  eval_gemfile('Gemfile.global')
2
2
 
3
3
  gem 'minitest', '~> 5.8'
4
- gem 'rails', '5.0.0', require: false
5
- gem 'activerecord-jdbcsqlite3-adapter', github: 'jruby/activerecord-jdbc-adapter', branch: 'rails-5', platform: :jruby
6
- gem 'mongoid', github: 'mongodb/mongoid'
4
+ gem 'rails', '~> 5.2.4', require: false
5
+ gem 'mongoid'
6
+ gem 'sqlite3', '~> 1.3.6', :platform => [:ruby, :mswin, :mingw]
data/Gemfile.global CHANGED
@@ -5,15 +5,8 @@ gemspec
5
5
  gem 'rake'
6
6
  gem 'rspec', :require => false
7
7
 
8
- gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
8
+ gem 'pg', '~> 1.2.3', :platform => [:ruby, :mswin, :mingw]
9
9
  gem 'sequel'
10
-
11
- platforms :rbx do
12
- gem 'rubysl', '~> 2.0'
13
- gem 'psych'
14
- gem 'rubinius-developer_tools'
15
- gem 'rubysl-test-unit'
16
- end
17
-
18
10
  gem 'simple_form'
19
11
  gem 'formtastic'
12
+ gem 'mysql2'
data/Gemfile.mongo_mapper CHANGED
@@ -1,6 +1,6 @@
1
1
  eval_gemfile('Gemfile.global')
2
2
 
3
3
  gem 'minitest', '~> 5.8'
4
- gem 'rails', '4.2.7', :require => false
5
- gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
4
+ gem 'rails', '~> 5.2.4', :require => false
6
5
  gem 'mongo_mapper'
6
+ gem 'sqlite3', '~> 1.3.6', :platform => [:ruby, :mswin, :mingw]
data/Gemfile.rails60 ADDED
@@ -0,0 +1,6 @@
1
+ eval_gemfile('Gemfile.global')
2
+
3
+ gem 'minitest', '~> 5.8'
4
+ gem 'rails', '~> 6.0.0', require: false
5
+ gem 'mongoid', github: 'mongodb/mongoid'
6
+ gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
data/Gemfile.rails61 ADDED
@@ -0,0 +1,6 @@
1
+ eval_gemfile('Gemfile.global')
2
+
3
+ gem 'minitest', '~> 5.8'
4
+ gem 'rails', github: 'rails/rails', branch: '6-1-stable', require: false
5
+ gem 'mongoid', github: 'mongodb/mongoid'
6
+ gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
data/Gemfile.rails70 ADDED
@@ -0,0 +1,9 @@
1
+ eval_gemfile('Gemfile.global')
2
+
3
+ gem 'minitest', '~> 5.8'
4
+ gem 'rails', github: 'rails/rails', branch: '7-0-stable', require: false
5
+
6
+ # TODO: Mongoid doesn't support Rails 7 yet. Uncomment when it's fixed https://jira.mongodb.org/browse/MONGOID-5193
7
+ # gem 'mongoid', github: 'mongodb/mongoid'
8
+
9
+ gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
@@ -0,0 +1,5 @@
1
+ eval_gemfile('Gemfile.global')
2
+
3
+ gem 'minitest', '~> 5.8'
4
+ gem 'rails', github: 'rails/rails', branch: 'main', require: false
5
+ gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]