granite-form 0.5.0 → 0.6.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 +4 -4
- data/.rubocop.yml +26 -48
- data/.rubocop_todo.yml +304 -27
- data/CHANGELOG.md +7 -2
- data/granite-form.gemspec +2 -1
- data/lib/granite/form/active_record/associations.rb +4 -3
- data/lib/granite/form/config.rb +1 -1
- data/lib/granite/form/errors.rb +34 -32
- data/lib/granite/form/extensions.rb +2 -1
- data/lib/granite/form/model/associations/base.rb +6 -2
- data/lib/granite/form/model/associations/collection/embedded.rb +1 -1
- data/lib/granite/form/model/associations/collection/proxy.rb +3 -3
- data/lib/granite/form/model/associations/embeds_any.rb +1 -1
- data/lib/granite/form/model/associations/embeds_many.rb +15 -11
- data/lib/granite/form/model/associations/embeds_one.rb +9 -8
- data/lib/granite/form/model/associations/nested_attributes.rb +60 -32
- data/lib/granite/form/model/associations/persistence_adapters/active_record/referenced_proxy.rb +2 -1
- data/lib/granite/form/model/associations/persistence_adapters/active_record.rb +7 -6
- data/lib/granite/form/model/associations/persistence_adapters/base.rb +8 -4
- data/lib/granite/form/model/associations/references_any.rb +1 -1
- data/lib/granite/form/model/associations/references_many.rb +3 -2
- data/lib/granite/form/model/associations/references_one.rb +1 -1
- data/lib/granite/form/model/associations/reflections/base.rb +3 -2
- data/lib/granite/form/model/associations/reflections/embeds_any.rb +4 -4
- data/lib/granite/form/model/associations/reflections/embeds_many.rb +4 -1
- data/lib/granite/form/model/associations/reflections/embeds_one.rb +4 -1
- data/lib/granite/form/model/associations/reflections/references_any.rb +6 -6
- data/lib/granite/form/model/associations/reflections/references_many.rb +1 -1
- data/lib/granite/form/model/associations/reflections/references_one.rb +1 -1
- data/lib/granite/form/model/associations/validations.rb +6 -6
- data/lib/granite/form/model/associations.rb +6 -4
- data/lib/granite/form/model/attributes/attribute.rb +1 -0
- data/lib/granite/form/model/attributes/base.rb +9 -7
- data/lib/granite/form/model/attributes/reference_one.rb +1 -1
- data/lib/granite/form/model/attributes/reflections/base/build_type_definition.rb +2 -1
- data/lib/granite/form/model/attributes/reflections/represents/build_type_definition.rb +2 -2
- data/lib/granite/form/model/attributes/represents.rb +1 -1
- data/lib/granite/form/model/attributes.rb +21 -13
- data/lib/granite/form/model/conventions.rb +1 -1
- data/lib/granite/form/model/persistence.rb +1 -1
- data/lib/granite/form/model/primary.rb +1 -1
- data/lib/granite/form/model/representation.rb +4 -4
- data/lib/granite/form/model/scopes.rb +5 -5
- data/lib/granite/form/model/validations.rb +4 -3
- data/lib/granite/form/types/active_support/time_zone.rb +1 -1
- data/lib/granite/form/types/array.rb +1 -1
- data/lib/granite/form/types/big_decimal.rb +1 -1
- data/lib/granite/form/types/boolean.rb +1 -1
- data/lib/granite/form/types/date.rb +1 -1
- data/lib/granite/form/types/date_time.rb +1 -1
- data/lib/granite/form/types/dictionary.rb +1 -1
- data/lib/granite/form/types/float.rb +1 -1
- data/lib/granite/form/types/has_subtype.rb +1 -0
- data/lib/granite/form/types/hash_with_action_controller_parameters.rb +2 -2
- data/lib/granite/form/types/integer.rb +1 -1
- data/lib/granite/form/types/object.rb +2 -1
- data/lib/granite/form/types/string.rb +1 -1
- data/lib/granite/form/types/time.rb +1 -1
- data/lib/granite/form/types/uuid.rb +1 -1
- data/lib/granite/form/util.rb +1 -1
- data/lib/granite/form/version.rb +1 -1
- data/spec/granite/form/active_record/associations_spec.rb +35 -13
- data/spec/granite/form/config_spec.rb +8 -4
- data/spec/granite/form/model/associations/embeds_many_spec.rb +99 -51
- data/spec/granite/form/model/associations/embeds_one_spec.rb +48 -25
- data/spec/granite/form/model/associations/persistence_adapters/active_record_spec.rb +12 -7
- data/spec/granite/form/model/associations/references_many_spec.rb +51 -10
- data/spec/granite/form/model/associations/references_one_spec.rb +17 -6
- data/spec/granite/form/model/associations/reflections/embeds_many_spec.rb +51 -16
- data/spec/granite/form/model/associations/reflections/embeds_one_spec.rb +19 -9
- data/spec/granite/form/model/associations/reflections/references_many_spec.rb +67 -15
- data/spec/granite/form/model/associations/reflections/references_one_spec.rb +34 -11
- data/spec/granite/form/model/associations/validations_spec.rb +16 -5
- data/spec/granite/form/model/associations_spec.rb +28 -9
- data/spec/granite/form/model/attributes/attribute_spec.rb +33 -11
- data/spec/granite/form/model/attributes/base_spec.rb +9 -3
- data/spec/granite/form/model/attributes/reflections/attribute_spec.rb +1 -0
- data/spec/granite/form/model/attributes/reflections/base_spec.rb +1 -0
- data/spec/granite/form/model/attributes/reflections/represents/build_type_definition_spec.rb +3 -1
- data/spec/granite/form/model/attributes/reflections/represents_spec.rb +2 -2
- data/spec/granite/form/model/attributes/represents_spec.rb +2 -2
- data/spec/granite/form/model/attributes_spec.rb +76 -36
- data/spec/granite/form/model/dirty_spec.rb +3 -0
- data/spec/granite/form/model/persistence_spec.rb +15 -5
- data/spec/granite/form/model/primary_spec.rb +17 -2
- data/spec/granite/form/model/representation_spec.rb +13 -3
- data/spec/granite/form/model/scopes_spec.rb +8 -3
- data/spec/granite/form/model/validations/associated_spec.rb +20 -6
- data/spec/granite/form/model/validations/nested_spec.rb +30 -14
- data/spec/granite/form/model/validations_spec.rb +1 -1
- data/spec/granite/form/model_spec.rb +1 -0
- data/spec/granite/form/types/collection_spec.rb +2 -1
- data/spec/granite/form/types/date_spec.rb +1 -1
- data/spec/granite/form/types/date_time_spec.rb +0 -2
- data/spec/granite/form/types/dictionary_spec.rb +1 -0
- data/spec/granite/form/types/has_subtype_spec.rb +6 -1
- data/spec/granite/form/types/hash_with_action_controller_parameters_spec.rb +1 -1
- data/spec/granite/form/types/object_spec.rb +2 -0
- data/spec/granite/form/types/time_spec.rb +0 -2
- data/spec/granite/form/util_spec.rb +6 -3
- data/spec/support/active_record.rb +13 -0
- data/spec/support/shared/nested_attribute_examples.rb +110 -54
- metadata +23 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7a1314ba3c2ba30bdc16261970529bae85d79d96c49f54fb445c350e6f828532
|
|
4
|
+
data.tar.gz: a868509fd29600d0c94ec7de9e20c584b1caf29d985f5e6a7334ffeb0df6a2ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 27ad9896a8c1e282a220051ff2eac56bbcaa97cf4c378bceb26779051b36a888623b33aad6be0b30c1810efdb032c182f575fb9caf4e0c9fcc2ce9591d72d957
|
|
7
|
+
data.tar.gz: c989dc6d3e3f96597780d9b84ea0137cc1345a70047f56c400c0e3ca79900fe0b92f057b8be977390cf1ef75aef05154431e9b974351fe343b1fc55c8fa5b784
|
data/.rubocop.yml
CHANGED
|
@@ -1,64 +1,42 @@
|
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
|
2
2
|
|
|
3
|
+
require:
|
|
4
|
+
- rubocop-rspec
|
|
5
|
+
|
|
3
6
|
AllCops:
|
|
7
|
+
Include:
|
|
8
|
+
- '**/*.rb'
|
|
9
|
+
- '**/Gemfile'
|
|
10
|
+
- '**/Rakefile'
|
|
11
|
+
Exclude:
|
|
12
|
+
- 'vendor/bundle/**/*'
|
|
13
|
+
- 'log/**/*'
|
|
14
|
+
- 'spec/fixtures/**/*'
|
|
15
|
+
- 'lib/granite/form/model/dirty.rb'
|
|
4
16
|
DisplayCopNames: true
|
|
5
|
-
TargetRubyVersion: 2.
|
|
17
|
+
TargetRubyVersion: 2.6
|
|
18
|
+
NewCops: enable
|
|
6
19
|
|
|
7
|
-
|
|
20
|
+
RSpec/MultipleExpectations:
|
|
8
21
|
Enabled: false
|
|
9
22
|
|
|
10
|
-
|
|
11
|
-
EnforcedStyleAlignWith: variable
|
|
12
|
-
|
|
13
|
-
Layout/AccessModifierIndentation:
|
|
14
|
-
EnforcedStyle: outdent
|
|
15
|
-
|
|
16
|
-
Layout/AlignHash:
|
|
17
|
-
EnforcedLastArgumentHashStyle: always_ignore
|
|
18
|
-
|
|
19
|
-
Layout/AlignParameters:
|
|
20
|
-
EnforcedStyle: with_fixed_indentation
|
|
21
|
-
|
|
22
|
-
Layout/CaseIndentation:
|
|
23
|
-
EnforcedStyle: end
|
|
24
|
-
|
|
25
|
-
Layout/IndentArray:
|
|
26
|
-
EnforcedStyle: consistent
|
|
27
|
-
|
|
28
|
-
Layout/IndentHash:
|
|
29
|
-
EnforcedStyle: consistent
|
|
30
|
-
|
|
31
|
-
Layout/IndentHeredoc:
|
|
23
|
+
RSpec/NestedGroups:
|
|
32
24
|
Enabled: false
|
|
33
25
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Layout/MultilineOperationIndentation:
|
|
38
|
-
EnforcedStyle: indented
|
|
39
|
-
|
|
40
|
-
Layout/SpaceInsideHashLiteralBraces:
|
|
41
|
-
EnforcedStyle: no_space
|
|
42
|
-
|
|
43
|
-
Metrics/BlockLength:
|
|
44
|
-
Exclude:
|
|
45
|
-
- '**/*_spec.rb'
|
|
46
|
-
- '**/*_examples.rb'
|
|
47
|
-
- '**/*.rake'
|
|
26
|
+
RSpec/MessageSpies:
|
|
27
|
+
Enabled: false
|
|
48
28
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- '**/*_spec.rb'
|
|
52
|
-
- 'lib/granite/form.rb'
|
|
29
|
+
Gemspec/DevelopmentDependencies:
|
|
30
|
+
Enabled: false
|
|
53
31
|
|
|
54
|
-
Style/
|
|
55
|
-
|
|
32
|
+
Style/FrozenStringLiteralComment:
|
|
33
|
+
Enabled: false
|
|
56
34
|
|
|
57
|
-
|
|
58
|
-
|
|
35
|
+
RSpec/DescribedClass:
|
|
36
|
+
Enabled: false
|
|
59
37
|
|
|
60
|
-
Style/
|
|
38
|
+
Style/OptionalBooleanParameter:
|
|
61
39
|
Enabled: false
|
|
62
40
|
|
|
63
|
-
Style/
|
|
41
|
+
Style/MissingRespondToMissing:
|
|
64
42
|
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,48 +1,325 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2024-05-13 08:55:48 UTC using RuboCop version 1.63.5.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
-
# Offense count:
|
|
9
|
+
# Offense count: 10
|
|
10
|
+
# Configuration parameters: AllowComments, AllowEmptyLambdas.
|
|
11
|
+
Lint/EmptyBlock:
|
|
12
|
+
Exclude:
|
|
13
|
+
- 'spec/granite/form/config_spec.rb'
|
|
14
|
+
- 'spec/granite/form/model/associations/reflections/embeds_any_spec.rb'
|
|
15
|
+
- 'spec/granite/form/model/attributes/reflections/attribute_spec.rb'
|
|
16
|
+
- 'spec/granite/form/model/attributes_spec.rb'
|
|
17
|
+
- 'spec/granite/form/model/dirty_spec.rb'
|
|
18
|
+
- 'spec/granite/form/model/validations_spec.rb'
|
|
19
|
+
|
|
20
|
+
# Offense count: 1
|
|
21
|
+
# Configuration parameters: AllowComments.
|
|
22
|
+
Lint/EmptyClass:
|
|
23
|
+
Exclude:
|
|
24
|
+
- 'lib/granite/form/extensions.rb'
|
|
25
|
+
|
|
26
|
+
# Offense count: 1
|
|
27
|
+
# Configuration parameters: AllowedParentClasses.
|
|
28
|
+
Lint/MissingSuper:
|
|
29
|
+
Exclude:
|
|
30
|
+
- 'lib/granite/form/model/associations/reflections/references_any.rb'
|
|
31
|
+
|
|
32
|
+
# Offense count: 1
|
|
33
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
34
|
+
Lint/NonDeterministicRequireOrder:
|
|
35
|
+
Exclude:
|
|
36
|
+
- 'lib/granite/form/model/validations.rb'
|
|
37
|
+
|
|
38
|
+
# Offense count: 8
|
|
39
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
10
40
|
Metrics/AbcSize:
|
|
11
|
-
Max:
|
|
41
|
+
Max: 60
|
|
42
|
+
|
|
43
|
+
# Offense count: 5
|
|
44
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
45
|
+
Metrics/CyclomaticComplexity:
|
|
46
|
+
Max: 17
|
|
47
|
+
|
|
48
|
+
# Offense count: 14
|
|
49
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
50
|
+
Metrics/MethodLength:
|
|
51
|
+
Max: 46
|
|
52
|
+
|
|
53
|
+
# Offense count: 5
|
|
54
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
55
|
+
Metrics/PerceivedComplexity:
|
|
56
|
+
Max: 20
|
|
12
57
|
|
|
13
58
|
# Offense count: 2
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
|
|
59
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
60
|
+
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
|
|
61
|
+
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
|
|
62
|
+
Naming/MemoizedInstanceVariableName:
|
|
63
|
+
Exclude:
|
|
64
|
+
- 'lib/granite/form/model/associations/embeds_many.rb'
|
|
65
|
+
- 'lib/granite/form/model/associations/references_many.rb'
|
|
17
66
|
|
|
18
|
-
# Offense count:
|
|
19
|
-
|
|
20
|
-
|
|
67
|
+
# Offense count: 2
|
|
68
|
+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
|
69
|
+
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
|
|
70
|
+
Naming/MethodParameterName:
|
|
71
|
+
Exclude:
|
|
72
|
+
- 'spec/granite/form/model/attributes_spec.rb'
|
|
21
73
|
|
|
22
|
-
# Offense count:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Max: 187
|
|
74
|
+
# Offense count: 2
|
|
75
|
+
RSpec/AnyInstance:
|
|
76
|
+
Exclude:
|
|
77
|
+
- 'spec/granite/form/model/attributes/attribute_spec.rb'
|
|
27
78
|
|
|
28
|
-
# Offense count:
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
|
|
79
|
+
# Offense count: 77
|
|
80
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
81
|
+
RSpec/BeEq:
|
|
82
|
+
Exclude:
|
|
83
|
+
- 'spec/granite/form/active_record/associations_spec.rb'
|
|
84
|
+
- 'spec/granite/form/config_spec.rb'
|
|
85
|
+
- 'spec/granite/form/model/associations/embeds_many_spec.rb'
|
|
86
|
+
- 'spec/granite/form/model/associations/embeds_one_spec.rb'
|
|
87
|
+
- 'spec/granite/form/model/associations/references_many_spec.rb'
|
|
88
|
+
- 'spec/granite/form/model/associations/references_one_spec.rb'
|
|
89
|
+
- 'spec/granite/form/model/associations/validations_spec.rb'
|
|
90
|
+
- 'spec/granite/form/model/attributes/attribute_spec.rb'
|
|
91
|
+
- 'spec/granite/form/model/attributes/base_spec.rb'
|
|
92
|
+
- 'spec/granite/form/model/attributes_spec.rb'
|
|
93
|
+
- 'spec/granite/form/model/primary_spec.rb'
|
|
94
|
+
- 'spec/granite/form/model/representation_spec.rb'
|
|
95
|
+
- 'spec/granite/form/model/validations_spec.rb'
|
|
96
|
+
- 'spec/granite/form/types/boolean_spec.rb'
|
|
97
|
+
- 'spec/granite/form/types/object_spec.rb'
|
|
98
|
+
|
|
99
|
+
# Offense count: 1
|
|
100
|
+
RSpec/BeforeAfterAll:
|
|
101
|
+
Exclude:
|
|
102
|
+
- '**/spec/spec_helper.rb'
|
|
103
|
+
- '**/spec/rails_helper.rb'
|
|
104
|
+
- '**/spec/support/**/*.rb'
|
|
105
|
+
- 'spec/granite/form/types/hash_with_action_controller_parameters_spec.rb'
|
|
106
|
+
|
|
107
|
+
# Offense count: 74
|
|
108
|
+
# Configuration parameters: Prefixes, AllowedPatterns.
|
|
109
|
+
# Prefixes: when, with, without
|
|
110
|
+
RSpec/ContextWording:
|
|
111
|
+
Enabled: false
|
|
112
|
+
|
|
113
|
+
# Offense count: 42
|
|
114
|
+
# Configuration parameters: CountAsOne.
|
|
115
|
+
RSpec/ExampleLength:
|
|
116
|
+
Max: 10
|
|
117
|
+
|
|
118
|
+
# Offense count: 220
|
|
119
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
120
|
+
# Configuration parameters: EnforcedStyle.
|
|
121
|
+
# SupportedStyles: method_call, block
|
|
122
|
+
RSpec/ExpectChange:
|
|
123
|
+
Exclude:
|
|
124
|
+
- 'spec/granite/form/active_record/associations_spec.rb'
|
|
125
|
+
- 'spec/granite/form/config_spec.rb'
|
|
126
|
+
- 'spec/granite/form/model/associations/embeds_many_spec.rb'
|
|
127
|
+
- 'spec/granite/form/model/associations/embeds_one_spec.rb'
|
|
128
|
+
- 'spec/granite/form/model/associations/references_many_spec.rb'
|
|
129
|
+
- 'spec/granite/form/model/associations/references_one_spec.rb'
|
|
130
|
+
- 'spec/granite/form/model/associations/reflections/embeds_many_spec.rb'
|
|
131
|
+
- 'spec/granite/form/model/associations/reflections/embeds_one_spec.rb'
|
|
132
|
+
- 'spec/granite/form/model/associations/reflections/references_many_spec.rb'
|
|
133
|
+
- 'spec/granite/form/model/associations/reflections/references_one_spec.rb'
|
|
134
|
+
- 'spec/granite/form/model/attributes_spec.rb'
|
|
135
|
+
- 'spec/granite/form/model/representation_spec.rb'
|
|
136
|
+
- 'spec/support/shared/nested_attribute_examples.rb'
|
|
137
|
+
|
|
138
|
+
# Offense count: 3
|
|
139
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
|
140
|
+
# Include: **/*_spec*rb*, **/spec/**/*
|
|
141
|
+
RSpec/FilePath:
|
|
142
|
+
Exclude:
|
|
143
|
+
- 'spec/granite/form/extensions_spec.rb'
|
|
144
|
+
- 'spec/granite/form/model/validations/associated_spec.rb'
|
|
145
|
+
- 'spec/granite/form/model/validations/nested_spec.rb'
|
|
146
|
+
|
|
147
|
+
# Offense count: 6
|
|
148
|
+
RSpec/IdenticalEqualityAssertion:
|
|
149
|
+
Exclude:
|
|
150
|
+
- 'spec/granite/form/model/associations_spec.rb'
|
|
151
|
+
- 'spec/granite/form/model/primary_spec.rb'
|
|
152
|
+
|
|
153
|
+
# Offense count: 23
|
|
154
|
+
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
|
|
155
|
+
RSpec/IndexedLet:
|
|
156
|
+
Exclude:
|
|
157
|
+
- 'spec/granite/form/model/associations/embeds_many_spec.rb'
|
|
158
|
+
- 'spec/granite/form/model/associations/embeds_one_spec.rb'
|
|
159
|
+
- 'spec/granite/form/model/associations/references_many_spec.rb'
|
|
160
|
+
- 'spec/granite/form/model/associations/reflections/embeds_many_spec.rb'
|
|
161
|
+
- 'spec/granite/form/model/associations/reflections/references_many_spec.rb'
|
|
162
|
+
- 'spec/granite/form/model/associations/reflections/references_one_spec.rb'
|
|
163
|
+
- 'spec/granite/form/model/attributes_spec.rb'
|
|
164
|
+
- 'spec/granite/form/model/scopes_spec.rb'
|
|
165
|
+
|
|
166
|
+
# Offense count: 8
|
|
167
|
+
# Configuration parameters: AssignmentOnly.
|
|
168
|
+
RSpec/InstanceVariable:
|
|
169
|
+
Exclude:
|
|
170
|
+
- 'spec/granite/form/model/attributes/reflections/base/build_type_definition_spec.rb'
|
|
171
|
+
- 'spec/granite/form/model/attributes/reflections/collection/build_type_definition_spec.rb'
|
|
172
|
+
- 'spec/granite/form/model/attributes/reflections/dictionary/build_type_definition_spec.rb'
|
|
173
|
+
- 'spec/granite/form/model/attributes/reflections/represents/build_type_definition_spec.rb'
|
|
174
|
+
|
|
175
|
+
# Offense count: 81
|
|
176
|
+
RSpec/MissingExampleGroupArgument:
|
|
177
|
+
Enabled: false
|
|
178
|
+
|
|
179
|
+
# Offense count: 39
|
|
180
|
+
# Configuration parameters: AllowSubject.
|
|
181
|
+
RSpec/MultipleMemoizedHelpers:
|
|
182
|
+
Max: 9
|
|
183
|
+
|
|
184
|
+
# Offense count: 95
|
|
185
|
+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
|
186
|
+
# SupportedStyles: always, named_only
|
|
187
|
+
RSpec/NamedSubject:
|
|
188
|
+
Exclude:
|
|
189
|
+
- 'spec/granite/form/config_spec.rb'
|
|
190
|
+
- 'spec/granite/form/model/attributes/base_spec.rb'
|
|
191
|
+
- 'spec/granite/form/model/attributes_spec.rb'
|
|
192
|
+
- 'spec/granite/form/model/persistence_spec.rb'
|
|
193
|
+
- 'spec/granite/form/model/validations/nested_spec.rb'
|
|
194
|
+
- 'spec/granite/form/types/collection_spec.rb'
|
|
195
|
+
- 'spec/granite/form/types/dictionary_spec.rb'
|
|
196
|
+
- 'spec/granite/form/types/has_subtype_spec.rb'
|
|
197
|
+
- 'spec/granite/form/util_spec.rb'
|
|
198
|
+
- 'spec/granite/form_spec.rb'
|
|
199
|
+
|
|
200
|
+
# Offense count: 14
|
|
201
|
+
# Configuration parameters: AllowedPatterns.
|
|
202
|
+
# AllowedPatterns: ^expect_, ^assert_
|
|
203
|
+
RSpec/NoExpectationExample:
|
|
204
|
+
Exclude:
|
|
205
|
+
- 'spec/granite/form/model/attributes_spec.rb'
|
|
206
|
+
|
|
207
|
+
# Offense count: 1
|
|
208
|
+
RSpec/PendingWithoutReason:
|
|
209
|
+
Exclude:
|
|
210
|
+
- 'spec/granite/form/model/associations/reflections/references_many_spec.rb'
|
|
211
|
+
|
|
212
|
+
# Offense count: 10
|
|
213
|
+
RSpec/RepeatedExample:
|
|
214
|
+
Exclude:
|
|
215
|
+
- 'spec/support/shared/nested_attribute_examples.rb'
|
|
216
|
+
|
|
217
|
+
# Offense count: 2
|
|
218
|
+
RSpec/RepeatedExampleGroupDescription:
|
|
219
|
+
Exclude:
|
|
220
|
+
- 'spec/granite/form/model/primary_spec.rb'
|
|
221
|
+
|
|
222
|
+
# Offense count: 3
|
|
223
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
|
|
224
|
+
# Include: **/*_spec.rb
|
|
225
|
+
RSpec/SpecFilePathFormat:
|
|
226
|
+
Exclude:
|
|
227
|
+
- '**/spec/routing/**/*'
|
|
228
|
+
- 'spec/granite/form/extensions_spec.rb'
|
|
229
|
+
- 'spec/granite/form/model/validations/associated_spec.rb'
|
|
230
|
+
- 'spec/granite/form/model/validations/nested_spec.rb'
|
|
231
|
+
|
|
232
|
+
# Offense count: 1
|
|
233
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
234
|
+
# Configuration parameters: EnforcedStyle.
|
|
235
|
+
# SupportedStyles: constant, string
|
|
236
|
+
RSpec/VerifiedDoubleReference:
|
|
237
|
+
Exclude:
|
|
238
|
+
- 'spec/granite/form/model/representation_spec.rb'
|
|
239
|
+
|
|
240
|
+
# Offense count: 3
|
|
241
|
+
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
|
242
|
+
RSpec/VerifiedDoubles:
|
|
243
|
+
Exclude:
|
|
244
|
+
- 'spec/granite/form/types/has_subtype_spec.rb'
|
|
245
|
+
- 'spec/granite/form/types/object_spec.rb'
|
|
32
246
|
|
|
33
247
|
# Offense count: 2
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
248
|
+
RSpec/VoidExpect:
|
|
249
|
+
Exclude:
|
|
250
|
+
- 'spec/granite/form/model/attributes_spec.rb'
|
|
251
|
+
|
|
252
|
+
# Offense count: 1
|
|
253
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
254
|
+
# Configuration parameters: EnforcedStyle.
|
|
255
|
+
# SupportedStyles: not_to, be_invalid
|
|
256
|
+
RSpecRails/NegationBeValid:
|
|
257
|
+
Exclude:
|
|
258
|
+
- 'spec/granite/form/model/validations_spec.rb'
|
|
259
|
+
|
|
260
|
+
# Offense count: 1
|
|
261
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
262
|
+
# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols.
|
|
263
|
+
# SupportedStyles: inline, group
|
|
264
|
+
Style/AccessModifierDeclarations:
|
|
265
|
+
Exclude:
|
|
266
|
+
- 'lib/granite/form/model/associations/reflections/embeds_any.rb'
|
|
37
267
|
|
|
38
268
|
# Offense count: 2
|
|
39
|
-
|
|
40
|
-
|
|
269
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
270
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
271
|
+
# AllowedMethods: ==, equal?, eql?
|
|
272
|
+
Style/ClassEqualityComparison:
|
|
273
|
+
Exclude:
|
|
274
|
+
- 'lib/granite/form/model/attributes.rb'
|
|
41
275
|
|
|
42
|
-
# Offense count:
|
|
43
|
-
|
|
44
|
-
|
|
276
|
+
# Offense count: 7
|
|
277
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
278
|
+
Style/ConcatArrayLiterals:
|
|
279
|
+
Exclude:
|
|
280
|
+
- 'spec/granite/form/model/associations/embeds_many_spec.rb'
|
|
281
|
+
- 'spec/granite/form/model/associations/references_many_spec.rb'
|
|
282
|
+
|
|
283
|
+
# Offense count: 8
|
|
284
|
+
Style/DocumentDynamicEvalDefinition:
|
|
285
|
+
Exclude:
|
|
286
|
+
- 'lib/granite/form/active_record/associations.rb'
|
|
287
|
+
- 'lib/granite/form/model/associations/nested_attributes.rb'
|
|
288
|
+
- 'lib/granite/form/model/associations/reflections/base.rb'
|
|
289
|
+
- 'lib/granite/form/model/associations/reflections/embeds_one.rb'
|
|
290
|
+
- 'lib/granite/form/model/attributes/reflections/attribute.rb'
|
|
291
|
+
- 'lib/granite/form/model/attributes/reflections/reference_one.rb'
|
|
292
|
+
- 'lib/granite/form/model/dirty.rb'
|
|
45
293
|
|
|
46
|
-
# Offense count:
|
|
294
|
+
# Offense count: 96
|
|
295
|
+
# Configuration parameters: AllowedConstants.
|
|
47
296
|
Style/Documentation:
|
|
48
297
|
Enabled: false
|
|
298
|
+
|
|
299
|
+
# Offense count: 1
|
|
300
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
301
|
+
Style/GlobalStdStream:
|
|
302
|
+
Exclude:
|
|
303
|
+
- 'lib/granite/form/config.rb'
|
|
304
|
+
|
|
305
|
+
# Offense count: 1
|
|
306
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
307
|
+
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
|
|
308
|
+
Style/GuardClause:
|
|
309
|
+
Exclude:
|
|
310
|
+
- 'lib/granite/form/config.rb'
|
|
311
|
+
|
|
312
|
+
# Offense count: 3
|
|
313
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
314
|
+
# Configuration parameters: AllowSplatArgument.
|
|
315
|
+
Style/HashConversion:
|
|
316
|
+
Exclude:
|
|
317
|
+
- 'lib/granite/form/model/attributes.rb'
|
|
318
|
+
- 'lib/granite/form/types/dictionary.rb'
|
|
319
|
+
|
|
320
|
+
# Offense count: 2
|
|
321
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
322
|
+
Style/IfUnlessModifier:
|
|
323
|
+
Exclude:
|
|
324
|
+
- 'lib/granite/form/model/associations/nested_attributes.rb'
|
|
325
|
+
- 'spec/granite/form/model/representation_spec.rb'
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## Next
|
|
4
4
|
|
|
5
|
+
## v0.6.0
|
|
6
|
+
|
|
7
|
+
* Fix crash when mapping PostgreSQL enum to ruby variable in https://github.com/toptal/granite-form/pull/28
|
|
8
|
+
* Lower severity of the log message during mass assignment https://github.com/toptal/granite-form/pull/26
|
|
9
|
+
|
|
5
10
|
## v0.5.0
|
|
6
11
|
|
|
7
12
|
* Support for ruby 3.2 by @konalegi in https://github.com/toptal/granite-form/pull/22
|
|
@@ -15,7 +20,7 @@
|
|
|
15
20
|
* Add support for evaluating `Symbol` for readonly/enum/normalize. If symbol is passed in one of those options, method with that name will be called when evaluating the value.
|
|
16
21
|
* [BREAKING] Remove `localized` attribute type.
|
|
17
22
|
* [BREAKING] Change the behavior of `default` and `normalize` for `collection` & `dictionary`. Instead of acting per element they will now act on the attribute as a whole.
|
|
18
|
-
* E.g. `collection :numbers, default: [1, 2, 3]` will not set the default for the whole collection of `numbers` rather than each element in `numbers`.
|
|
23
|
+
* E.g. `collection :numbers, default: [1, 2, 3]` will not set the default for the whole collection of `numbers` rather than each element in `numbers`.
|
|
19
24
|
|
|
20
25
|
## v0.3.0
|
|
21
26
|
|
|
@@ -32,7 +37,7 @@
|
|
|
32
37
|
|
|
33
38
|
## v0.1.1
|
|
34
39
|
|
|
35
|
-
- Fixed represented error message copying when represented model uses symbols for `message`.
|
|
40
|
+
- Fixed represented error message copying when represented model uses symbols for `message`.
|
|
36
41
|
|
|
37
42
|
## v0.1.0
|
|
38
43
|
|
data/granite-form.gemspec
CHANGED
|
@@ -23,7 +23,8 @@ Gem::Specification.new do |gem|
|
|
|
23
23
|
gem.add_development_dependency 'rake'
|
|
24
24
|
gem.add_development_dependency 'rspec', '~> 3.7.0'
|
|
25
25
|
gem.add_development_dependency 'rspec-its'
|
|
26
|
-
gem.add_development_dependency 'rubocop', '
|
|
26
|
+
gem.add_development_dependency 'rubocop', '1.63.5'
|
|
27
|
+
gem.add_development_dependency 'rubocop-rspec', '2.29.2'
|
|
27
28
|
gem.add_development_dependency 'uuidtools'
|
|
28
29
|
|
|
29
30
|
gem.add_runtime_dependency 'activemodel', '>= 6.0'
|
|
@@ -30,11 +30,12 @@ module Granite
|
|
|
30
30
|
extend ActiveSupport::Concern
|
|
31
31
|
|
|
32
32
|
included do
|
|
33
|
-
{embeds_many: Reflections::EmbedsMany,
|
|
33
|
+
{ embeds_many: Reflections::EmbedsMany,
|
|
34
|
+
embeds_one: Reflections::EmbedsOne }.each do |(method, reflection_class)|
|
|
34
35
|
define_singleton_method method do |name, options = {}, &block|
|
|
35
36
|
reflection = reflection_class.build(self, self, name,
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
options.reverse_merge(read: READER, write: WRITER),
|
|
38
|
+
&block)
|
|
38
39
|
if ::ActiveRecord::Reflection.respond_to? :add_reflection
|
|
39
40
|
::ActiveRecord::Reflection.add_reflection self, reflection.name, reflection
|
|
40
41
|
else
|
data/lib/granite/form/config.rb
CHANGED
|
@@ -4,7 +4,7 @@ module Granite
|
|
|
4
4
|
include Singleton
|
|
5
5
|
|
|
6
6
|
attr_accessor :include_root_in_json, :i18n_scope, :logger, :primary_attribute, :base_class, :base_concern,
|
|
7
|
-
|
|
7
|
+
:_normalizers, :types
|
|
8
8
|
|
|
9
9
|
def self.delegated
|
|
10
10
|
public_instance_methods - superclass.public_instance_methods - Singleton.public_instance_methods
|
data/lib/granite/form/errors.rb
CHANGED
|
@@ -13,53 +13,55 @@ module Granite
|
|
|
13
13
|
def initialize(model)
|
|
14
14
|
@model = model
|
|
15
15
|
errors = @model.errors.full_messages.join(', ')
|
|
16
|
-
super(I18n.t(:"#{@model.class.i18n_scope}.errors.messages.model_invalid",
|
|
16
|
+
super(I18n.t(:"#{@model.class.i18n_scope}.errors.messages.model_invalid",
|
|
17
|
+
errors: errors, default: :'errors.messages.model_invalid'))
|
|
17
18
|
end
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
class AssociationTypeMismatch < Error
|
|
21
22
|
def initialize(expected, got)
|
|
22
|
-
super
|
|
23
|
+
super("Expected `#{expected}` (##{expected.object_id}), but got `#{got}` (##{got.object_id})")
|
|
23
24
|
end
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
class ObjectNotFound < Error
|
|
27
28
|
def initialize(object, association_name, record_id)
|
|
29
|
+
primary_name = object.respond_to?(:_primary_name) ? object._primary_name : 'id'
|
|
28
30
|
message = "Couldn't find #{object.class.reflect_on_association(association_name).klass.name}" \
|
|
29
|
-
|
|
30
|
-
super
|
|
31
|
+
"with #{primary_name} = #{record_id} for #{object.inspect}"
|
|
32
|
+
super(message)
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
class TooManyObjects < Error
|
|
35
37
|
def initialize(limit, actual_size)
|
|
36
|
-
super
|
|
38
|
+
super("Maximum #{limit} objects are allowed. Got #{actual_size} objects instead.")
|
|
37
39
|
end
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
class UndefinedPrimaryAttribute < Error
|
|
41
43
|
def initialize(klass, association_name)
|
|
42
|
-
super
|
|
43
|
-
Undefined primary attribute for `#{association_name}` in #{klass}.
|
|
44
|
-
It is required for embeds_many nested attributes proper operation.
|
|
45
|
-
You can define this association as:
|
|
44
|
+
super(<<~MESSAGE)
|
|
45
|
+
Undefined primary attribute for `#{association_name}` in #{klass}.
|
|
46
|
+
It is required for embeds_many nested attributes proper operation.
|
|
47
|
+
You can define this association as:
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
embeds_many :#{association_name} do
|
|
50
|
+
primary :attribute_name
|
|
51
|
+
end
|
|
50
52
|
MESSAGE
|
|
51
53
|
end
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
class NormalizerMissing < NoMethodError
|
|
55
57
|
def initialize(name)
|
|
56
|
-
super
|
|
57
|
-
Could not find normalizer `:#{name}`
|
|
58
|
-
You can define it with:
|
|
58
|
+
super(<<~MESSAGE)
|
|
59
|
+
Could not find normalizer `:#{name}`
|
|
60
|
+
You can define it with:
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
Granite::Form.normalizer(:#{name}) do |value, options|
|
|
63
|
+
# do some staff with value and options
|
|
64
|
+
end
|
|
63
65
|
MESSAGE
|
|
64
66
|
end
|
|
65
67
|
end
|
|
@@ -67,28 +69,28 @@ You can define it with:
|
|
|
67
69
|
class TypecasterMissing < NoMethodError
|
|
68
70
|
def initialize(*classes)
|
|
69
71
|
classes = classes.flatten
|
|
70
|
-
super
|
|
71
|
-
Could not find typecaster for #{classes}
|
|
72
|
-
You can define it with:
|
|
72
|
+
super(<<~MESSAGE)
|
|
73
|
+
Could not find typecaster for #{classes}
|
|
74
|
+
You can define it with:
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
Granite::Form.typecaster('#{classes.first}') do |value|
|
|
77
|
+
# do some staff with value and options
|
|
78
|
+
end
|
|
77
79
|
MESSAGE
|
|
78
80
|
end
|
|
79
81
|
end
|
|
80
82
|
|
|
81
83
|
class PersistenceAdapterMissing < NoMethodError
|
|
82
84
|
def initialize(data_source)
|
|
83
|
-
super
|
|
84
|
-
Could not find persistence adapter for #{data_source}
|
|
85
|
-
You can define it with:
|
|
85
|
+
super(<<~MESSAGE)
|
|
86
|
+
Could not find persistence adapter for #{data_source}
|
|
87
|
+
You can define it with:
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
class #{data_source}
|
|
90
|
+
def self.granite_persistence_adapter
|
|
91
|
+
#{data_source}GraniteFormPersistenceAdapter
|
|
92
|
+
end
|
|
93
|
+
end
|
|
92
94
|
MESSAGE
|
|
93
95
|
end
|
|
94
96
|
end
|