administrate-field-enumerate 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -2
- data/administrate-field-enumerate.gemspec +2 -2
- data/lib/administrate/field/enumerate.rb +2 -1
- data/spec/lib/administrate/field/enumerate_spec.rb +43 -3
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b45a5c32197f0a184c6a8e6846f43b2e3ecd4bf7719278eb5e84f3b3686885b
|
4
|
+
data.tar.gz: 36fbd1cc353a8e65fe5c1190c8a760fdb454b7a51e13615d23fe7b0ee4c0a962
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bae1605dcaf2bc81f2646a9afe9a0e6533b89fca9ea12d58cd17ae3f493ad54fa43a9a3ee7818b523cb36fb0c35a4f9e32a11a3bedcc4206239a0065fc9acdd
|
7
|
+
data.tar.gz: b2f01952ba76d443ed48735434993f02ba26fa9468604a783d536d01f03dbcc6e90d77d4adc7fa01a016f109a2ec586a1249151dcc988b84fca107f84cac7f02
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
## administrate-enumerate
|
1
|
+
## administrate-field-enumerate
|
2
2
|
|
3
3
|
A plugin to show [enumerate_it](https://github.com/lucascaton/enumerate_it) attributes in [Administrate](https://github.com/thoughtbot/administrate).
|
4
4
|
|
@@ -16,7 +16,25 @@ In your terminal execute:
|
|
16
16
|
$ bundle install
|
17
17
|
```
|
18
18
|
|
19
|
-
## Usage
|
19
|
+
## Usage example
|
20
|
+
```
|
21
|
+
# app/enumerations/role_type.rb
|
22
|
+
class RoleType < EnumerateIt::Base
|
23
|
+
associate_values(
|
24
|
+
:contributor,
|
25
|
+
:editor,
|
26
|
+
:admin,
|
27
|
+
:super_admin
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
# app/dashboards/user_dashboard.rb
|
32
|
+
ATTRIBUTE_TYPES = {
|
33
|
+
...
|
34
|
+
role: Field::Enumerate
|
35
|
+
...
|
36
|
+
}
|
37
|
+
```
|
20
38
|
|
21
39
|
## Contributing
|
22
40
|
|
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'administrate-field-enumerate'
|
5
|
-
s.version = '0.0.
|
5
|
+
s.version = '0.0.2'
|
6
6
|
s.authors = ['Jônatas Rancan', 'Andrei Bondarev']
|
7
7
|
s.email = ['hello@sourcelabs.io']
|
8
8
|
s.homepage = 'https://github.com/SourceLabsLLC/administrate-field-enumerate'
|
@@ -16,5 +16,5 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.add_dependency 'administrate'
|
18
18
|
s.add_dependency 'enumerate_it'
|
19
|
-
s.add_dependency 'rails', '>= 4.2', '<
|
19
|
+
s.add_dependency 'rails', '>= 4.2', '< 7.0'
|
20
20
|
end
|
@@ -1,14 +1,54 @@
|
|
1
1
|
require 'administrate/field/enumerate'
|
2
2
|
|
3
3
|
describe Administrate::Field::Enumerate do
|
4
|
+
class CategoryType < EnumerateIt::Base
|
5
|
+
associate_values(
|
6
|
+
first_type: 0,
|
7
|
+
second_type: 1
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
class Dumb
|
12
|
+
extend EnumerateIt
|
13
|
+
attr_accessor :category_type
|
14
|
+
|
15
|
+
def initialize(category_type)
|
16
|
+
@category_type = category_type
|
17
|
+
end
|
18
|
+
|
19
|
+
has_enumeration_for :category_type, with: CategoryType
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:page) { :show }
|
23
|
+
let(:data) { double(:data) }
|
24
|
+
let(:resource) { Dumb.new(1) }
|
25
|
+
|
26
|
+
let(:field) do
|
27
|
+
described_class.new(
|
28
|
+
:category_type,
|
29
|
+
data,
|
30
|
+
page,
|
31
|
+
resource: resource
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
4
35
|
describe '#to_partial_path' do
|
5
36
|
it 'returns a partial based on the page being rendered' do
|
6
|
-
page = :show
|
7
|
-
field = described_class.new(:status, 'status', page)
|
8
|
-
|
9
37
|
path = field.to_partial_path
|
10
38
|
|
11
39
|
expect(path).to eq("/fields/enumerate/#{page}")
|
12
40
|
end
|
13
41
|
end
|
42
|
+
|
43
|
+
describe '#choices' do
|
44
|
+
it 'returns a list containing the humanized name and the value for the enum' do
|
45
|
+
expect(field.choices).to eq([["First Type", 0], ["Second Type", 1]])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#to_s' do
|
50
|
+
it 'returns a list containing the humanized name and the value for the enum' do
|
51
|
+
expect(field.to_s).to eq('Second Type')
|
52
|
+
end
|
53
|
+
end
|
14
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate-field-enumerate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jônatas Rancan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: administrate
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
version: '4.2'
|
49
49
|
- - "<"
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
51
|
+
version: '7.0'
|
52
52
|
type: :runtime
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
version: '4.2'
|
59
59
|
- - "<"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '7.0'
|
62
62
|
description: enumerate_it field plugin for Administrate
|
63
63
|
email:
|
64
64
|
- hello@sourcelabs.io
|
@@ -94,8 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
|
-
|
98
|
-
rubygems_version: 2.7.3
|
97
|
+
rubygems_version: 3.1.2
|
99
98
|
signing_key:
|
100
99
|
specification_version: 4
|
101
100
|
summary: enumerate_it field plugin for Administrate
|