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.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +73 -0
- data/CHANGELOG.md +80 -3
- data/Gemfile +3 -3
- data/Gemfile.global +2 -9
- data/Gemfile.mongo_mapper +2 -2
- data/Gemfile.rails60 +6 -0
- data/Gemfile.rails61 +6 -0
- data/Gemfile.rails70 +9 -0
- data/Gemfile.railsmaster +5 -0
- data/README.md +209 -92
- data/Rakefile +2 -0
- data/lib/enumerize/activemodel.rb +47 -0
- data/lib/enumerize/activerecord.rb +79 -0
- data/lib/enumerize/attribute.rb +19 -11
- data/lib/enumerize/attribute_map.rb +2 -0
- data/lib/enumerize/base.rb +6 -6
- data/lib/enumerize/hooks/formtastic.rb +4 -1
- data/lib/enumerize/hooks/sequel_dataset.rb +2 -0
- data/lib/enumerize/hooks/simple_form.rb +4 -1
- data/lib/enumerize/hooks/uniqueness.rb +5 -1
- data/lib/enumerize/integrations/rails_admin.rb +3 -1
- data/lib/enumerize/integrations/rspec/matcher.rb +7 -2
- data/lib/enumerize/integrations/rspec.rb +2 -0
- data/lib/enumerize/module.rb +2 -0
- data/lib/enumerize/module_attributes.rb +2 -0
- data/lib/enumerize/mongoid.rb +16 -0
- data/lib/enumerize/predicatable.rb +3 -1
- data/lib/enumerize/predicates.rb +2 -0
- data/lib/enumerize/scope/activerecord.rb +16 -0
- data/lib/enumerize/scope/mongoid.rb +15 -0
- data/lib/enumerize/scope/sequel.rb +16 -0
- data/lib/enumerize/sequel.rb +9 -4
- data/lib/enumerize/set.rb +2 -0
- data/lib/enumerize/utils.rb +12 -0
- data/lib/enumerize/value.rb +14 -15
- data/lib/enumerize/version.rb +3 -1
- data/lib/enumerize.rb +9 -0
- data/lib/sequel/plugins/enumerize.rb +18 -0
- data/spec/enumerize/integrations/rspec/matcher_spec.rb +13 -10
- data/spec/spec_helper.rb +2 -0
- data/test/activemodel_test.rb +114 -0
- data/test/activerecord_test.rb +277 -79
- data/test/attribute_map_test.rb +9 -7
- data/test/attribute_test.rb +37 -30
- data/test/base_test.rb +66 -64
- data/test/formtastic_test.rb +25 -0
- data/test/module_attributes_test.rb +10 -8
- data/test/mongo_mapper_test.rb +19 -10
- data/test/mongoid_test.rb +51 -22
- data/test/multiple_test.rb +26 -18
- data/test/predicates_test.rb +30 -28
- data/test/rails_admin_test.rb +8 -6
- data/test/sequel_test.rb +111 -58
- data/test/set_test.rb +28 -26
- data/test/simple_form_test.rb +25 -0
- data/test/support/mock_controller.rb +6 -0
- data/test/support/shared_enums.rb +43 -0
- data/test/support/view_test_helper.rb +14 -1
- data/test/test_helper.rb +2 -0
- data/test/value_test.rb +51 -30
- metadata +14 -27
- data/.travis.yml +0 -18
- data/Gemfile.rails42 +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c86135927c636fc672bb7371b83b78b6844716f70dd2b9fa19a255b35ce2a5ca
|
4
|
+
data.tar.gz: d1ac5ff95c2673d0743fab97725cf7abc939b157594545ad3e40dd9a1eefb841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
##
|
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.
|
5
|
-
gem '
|
6
|
-
gem '
|
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 '
|
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', '
|
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
data/Gemfile.rails61
ADDED
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]
|