granite-form 0.4.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -1
  3. data/.github/workflows/ruby.yml +3 -5
  4. data/.rubocop.yml +26 -48
  5. data/.rubocop_todo.yml +304 -27
  6. data/Appraisals +1 -1
  7. data/CHANGELOG.md +15 -2
  8. data/gemfiles/{rails.5.0.gemfile → rails.7.1.gemfile} +3 -3
  9. data/granite-form.gemspec +6 -5
  10. data/lib/granite/form/active_record/associations.rb +4 -3
  11. data/lib/granite/form/config.rb +1 -1
  12. data/lib/granite/form/errors.rb +34 -32
  13. data/lib/granite/form/extensions.rb +2 -1
  14. data/lib/granite/form/model/associations/base.rb +6 -2
  15. data/lib/granite/form/model/associations/collection/embedded.rb +1 -1
  16. data/lib/granite/form/model/associations/collection/proxy.rb +3 -3
  17. data/lib/granite/form/model/associations/embeds_any.rb +1 -1
  18. data/lib/granite/form/model/associations/embeds_many.rb +15 -11
  19. data/lib/granite/form/model/associations/embeds_one.rb +9 -8
  20. data/lib/granite/form/model/associations/nested_attributes.rb +60 -32
  21. data/lib/granite/form/model/associations/persistence_adapters/active_record/referenced_proxy.rb +2 -1
  22. data/lib/granite/form/model/associations/persistence_adapters/active_record.rb +7 -6
  23. data/lib/granite/form/model/associations/persistence_adapters/base.rb +8 -4
  24. data/lib/granite/form/model/associations/references_any.rb +1 -1
  25. data/lib/granite/form/model/associations/references_many.rb +3 -2
  26. data/lib/granite/form/model/associations/references_one.rb +1 -1
  27. data/lib/granite/form/model/associations/reflections/base.rb +3 -2
  28. data/lib/granite/form/model/associations/reflections/embeds_any.rb +4 -4
  29. data/lib/granite/form/model/associations/reflections/embeds_many.rb +4 -1
  30. data/lib/granite/form/model/associations/reflections/embeds_one.rb +4 -1
  31. data/lib/granite/form/model/associations/reflections/references_any.rb +6 -6
  32. data/lib/granite/form/model/associations/reflections/references_many.rb +1 -1
  33. data/lib/granite/form/model/associations/reflections/references_one.rb +1 -1
  34. data/lib/granite/form/model/associations/validations.rb +6 -6
  35. data/lib/granite/form/model/associations.rb +6 -4
  36. data/lib/granite/form/model/attributes/attribute.rb +1 -0
  37. data/lib/granite/form/model/attributes/base.rb +9 -7
  38. data/lib/granite/form/model/attributes/reference_one.rb +1 -1
  39. data/lib/granite/form/model/attributes/reflections/base/build_type_definition.rb +2 -1
  40. data/lib/granite/form/model/attributes/reflections/represents/build_type_definition.rb +2 -2
  41. data/lib/granite/form/model/attributes/represents.rb +1 -1
  42. data/lib/granite/form/model/attributes.rb +21 -13
  43. data/lib/granite/form/model/conventions.rb +1 -1
  44. data/lib/granite/form/model/persistence.rb +1 -1
  45. data/lib/granite/form/model/primary.rb +1 -1
  46. data/lib/granite/form/model/representation.rb +4 -4
  47. data/lib/granite/form/model/scopes.rb +5 -5
  48. data/lib/granite/form/model/validations.rb +4 -3
  49. data/lib/granite/form/types/active_support/time_zone.rb +1 -1
  50. data/lib/granite/form/types/array.rb +1 -1
  51. data/lib/granite/form/types/big_decimal.rb +1 -1
  52. data/lib/granite/form/types/boolean.rb +1 -1
  53. data/lib/granite/form/types/date.rb +1 -1
  54. data/lib/granite/form/types/date_time.rb +1 -1
  55. data/lib/granite/form/types/dictionary.rb +1 -1
  56. data/lib/granite/form/types/float.rb +1 -1
  57. data/lib/granite/form/types/has_subtype.rb +1 -0
  58. data/lib/granite/form/types/hash_with_action_controller_parameters.rb +2 -2
  59. data/lib/granite/form/types/integer.rb +1 -1
  60. data/lib/granite/form/types/object.rb +2 -1
  61. data/lib/granite/form/types/string.rb +1 -1
  62. data/lib/granite/form/types/time.rb +1 -1
  63. data/lib/granite/form/types/uuid.rb +1 -1
  64. data/lib/granite/form/util.rb +1 -1
  65. data/lib/granite/form/version.rb +1 -1
  66. data/spec/granite/form/active_record/associations_spec.rb +35 -13
  67. data/spec/granite/form/config_spec.rb +8 -4
  68. data/spec/granite/form/model/associations/embeds_many_spec.rb +99 -51
  69. data/spec/granite/form/model/associations/embeds_one_spec.rb +48 -25
  70. data/spec/granite/form/model/associations/persistence_adapters/active_record_spec.rb +12 -7
  71. data/spec/granite/form/model/associations/references_many_spec.rb +51 -10
  72. data/spec/granite/form/model/associations/references_one_spec.rb +17 -6
  73. data/spec/granite/form/model/associations/reflections/embeds_many_spec.rb +51 -16
  74. data/spec/granite/form/model/associations/reflections/embeds_one_spec.rb +19 -9
  75. data/spec/granite/form/model/associations/reflections/references_many_spec.rb +67 -15
  76. data/spec/granite/form/model/associations/reflections/references_one_spec.rb +34 -11
  77. data/spec/granite/form/model/associations/validations_spec.rb +16 -5
  78. data/spec/granite/form/model/associations_spec.rb +28 -9
  79. data/spec/granite/form/model/attributes/attribute_spec.rb +33 -11
  80. data/spec/granite/form/model/attributes/base_spec.rb +26 -2
  81. data/spec/granite/form/model/attributes/reflections/attribute_spec.rb +1 -0
  82. data/spec/granite/form/model/attributes/reflections/base_spec.rb +1 -0
  83. data/spec/granite/form/model/attributes/reflections/represents/build_type_definition_spec.rb +3 -1
  84. data/spec/granite/form/model/attributes/reflections/represents_spec.rb +2 -2
  85. data/spec/granite/form/model/attributes/represents_spec.rb +2 -2
  86. data/spec/granite/form/model/attributes_spec.rb +76 -36
  87. data/spec/granite/form/model/dirty_spec.rb +3 -0
  88. data/spec/granite/form/model/persistence_spec.rb +15 -5
  89. data/spec/granite/form/model/primary_spec.rb +17 -2
  90. data/spec/granite/form/model/representation_spec.rb +13 -3
  91. data/spec/granite/form/model/scopes_spec.rb +8 -3
  92. data/spec/granite/form/model/validations/associated_spec.rb +20 -6
  93. data/spec/granite/form/model/validations/nested_spec.rb +30 -14
  94. data/spec/granite/form/model/validations_spec.rb +1 -1
  95. data/spec/granite/form/model_spec.rb +1 -0
  96. data/spec/granite/form/types/collection_spec.rb +2 -1
  97. data/spec/granite/form/types/date_spec.rb +1 -1
  98. data/spec/granite/form/types/date_time_spec.rb +0 -2
  99. data/spec/granite/form/types/dictionary_spec.rb +1 -0
  100. data/spec/granite/form/types/has_subtype_spec.rb +6 -1
  101. data/spec/granite/form/types/hash_with_action_controller_parameters_spec.rb +1 -1
  102. data/spec/granite/form/types/object_spec.rb +2 -0
  103. data/spec/granite/form/types/time_spec.rb +0 -2
  104. data/spec/granite/form/util_spec.rb +6 -3
  105. data/spec/support/active_record.rb +13 -0
  106. data/spec/support/shared/nested_attribute_examples.rb +110 -54
  107. metadata +28 -16
  108. data/gemfiles/rails.5.1.gemfile +0 -14
  109. data/gemfiles/rails.5.2.gemfile +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 908865a58fa79739294c85bb506d878596a28782c02a9a2825ca1fb7fd128972
4
- data.tar.gz: ff9b6cbed34774e3dedb0b33c28b75694b1575051adb989248ca5695254e9586
3
+ metadata.gz: 7a1314ba3c2ba30bdc16261970529bae85d79d96c49f54fb445c350e6f828532
4
+ data.tar.gz: a868509fd29600d0c94ec7de9e20c584b1caf29d985f5e6a7334ffeb0df6a2ac
5
5
  SHA512:
6
- metadata.gz: 92d055b121d30a9644521227782908a0b84ef0847c16ce60fafec47cb17c5c2988e8a071e199ed5506dd0783bba335b6a399a519c095867658e310680dd96f10
7
- data.tar.gz: 4b4cf5f23530ad12408f498df6eed11e53438dd0a6f110ae04c10568934f041dbb64b946ee42352b7bfec83119a5827b652c8fddd62e745fa0f2835448674ce6
6
+ metadata.gz: 27ad9896a8c1e282a220051ff2eac56bbcaa97cf4c378bceb26779051b36a888623b33aad6be0b30c1810efdb032c182f575fb9caf4e0c9fcc2ce9591d72d957
7
+ data.tar.gz: c989dc6d3e3f96597780d9b84ea0137cc1345a70047f56c400c0e3ca79900fe0b92f057b8be977390cf1ef75aef05154431e9b974351fe343b1fc55c8fa5b784
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @toptal/portals-experience-be
1
+ * @toptal/devx
@@ -10,12 +10,10 @@ jobs:
10
10
  fail-fast: false
11
11
  matrix:
12
12
  include:
13
- - { ruby: '2.4', rails: '5.0' }
14
- - { ruby: '2.5', rails: '5.1' }
15
- - { ruby: '2.6', rails: '5.2' }
16
13
  - { ruby: '2.7', rails: '6.0' }
17
14
  - { ruby: '3.0', rails: '6.1' }
18
15
  - { ruby: '3.1', rails: '7.0' }
16
+ - { ruby: '3.2', rails: '7.1' }
19
17
  runs-on: ubuntu-latest
20
18
  env:
21
19
  BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails.${{ matrix.rails }}.gemfile
@@ -35,7 +33,7 @@ jobs:
35
33
  # Maps tcp port 5432 on service container to the host
36
34
  - 5432:5432
37
35
  steps:
38
- - uses: actions/checkout@v2
36
+ - uses: actions/checkout@v3
39
37
  - uses: ruby/setup-ruby@v1
40
38
  with:
41
39
  ruby-version: ${{ matrix.ruby }}
@@ -45,7 +43,7 @@ jobs:
45
43
  rubocop:
46
44
  runs-on: ubuntu-latest
47
45
  steps:
48
- - uses: actions/checkout@v2
46
+ - uses: actions/checkout@v3
49
47
  - uses: ruby/setup-ruby@v1
50
48
  with:
51
49
  ruby-version: '3.0'
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.4.0
17
+ TargetRubyVersion: 2.6
18
+ NewCops: enable
6
19
 
7
- Lint/AmbiguousBlockAssociation:
20
+ RSpec/MultipleExpectations:
8
21
  Enabled: false
9
22
 
10
- Lint/EndAlignment:
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
- Layout/MultilineMethodCallIndentation:
35
- EnforcedStyle: indented
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
- Metrics/ModuleLength:
50
- Exclude:
51
- - '**/*_spec.rb'
52
- - 'lib/granite/form.rb'
29
+ Gemspec/DevelopmentDependencies:
30
+ Enabled: false
53
31
 
54
- Style/Alias:
55
- EnforcedStyle: prefer_alias_method
32
+ Style/FrozenStringLiteralComment:
33
+ Enabled: false
56
34
 
57
- Style/AndOr:
58
- EnforcedStyle: conditionals
35
+ RSpec/DescribedClass:
36
+ Enabled: false
59
37
 
60
- Style/DoubleNegation:
38
+ Style/OptionalBooleanParameter:
61
39
  Enabled: false
62
40
 
63
- Style/FrozenStringLiteralComment:
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 2016-10-14 10:15:31 +0700 using RuboCop version 0.44.1.
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: 19
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: 59
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
- # Configuration parameters: CountComments.
15
- Metrics/ClassLength:
16
- Max: 128
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: 4
19
- Metrics/CyclomaticComplexity:
20
- Max: 15
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: 904
23
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
24
- # URISchemes: http, https
25
- Metrics/LineLength:
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: 21
29
- # Configuration parameters: CountComments.
30
- Metrics/MethodLength:
31
- Max: 43
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
- # Configuration parameters: CountComments.
35
- Metrics/ModuleLength:
36
- Max: 114
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
- Metrics/BlockLength:
40
- Max: 27
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: 4
43
- Metrics/PerceivedComplexity:
44
- Max: 18
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: 75
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/Appraisals CHANGED
@@ -1,4 +1,4 @@
1
- %w[5.0 5.1 5.2 6.0 6.1 7.0].each do |version|
1
+ %w[6.0 6.1 7.0 7.1].each do |version|
2
2
  appraise "rails.#{version}" do
3
3
  gem 'activesupport', "~> #{version}.0"
4
4
  gem 'activemodel', "~> #{version}.0"
data/CHANGELOG.md CHANGED
@@ -1,13 +1,26 @@
1
1
  # master
2
2
 
3
3
  ## Next
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
+
10
+ ## v0.5.0
11
+
12
+ * Support for ruby 3.2 by @konalegi in https://github.com/toptal/granite-form/pull/22
13
+ * Fix deprecated #to_s method by @mpiask in https://github.com/toptal/granite-form/pull/24
14
+ * Support for Rails 7.1 by @ojab in https://github.com/toptal/granite-form/pull/25
15
+ * [BREAKING] Drop support for Rails < 6.0 by @ojab in https://github.com/toptal/granite-form/pull/25
16
+
4
17
  ## v0.4.0
5
18
 
6
19
  * [BREAKING] Drop support for taking `model` as first argument in default/readonly/enum/normalize. This means that `default: -> (model) { model.other_field}` is no longer supported and should be replaced with `default: -> { other_field }`.
7
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.
8
21
  * [BREAKING] Remove `localized` attribute type.
9
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.
10
- * 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`.
11
24
 
12
25
  ## v0.3.0
13
26
 
@@ -24,7 +37,7 @@
24
37
 
25
38
  ## v0.1.1
26
39
 
27
- - 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`.
28
41
 
29
42
  ## v0.1.0
30
43
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "~> 5.0.0"
6
- gem "activemodel", "~> 5.0.0"
7
- gem "activerecord", "~> 5.0.0"
5
+ gem "activesupport", "~> 7.1.0"
6
+ gem "activemodel", "~> 7.1.0"
7
+ gem "activerecord", "~> 7.1.0"
8
8
 
9
9
  group :test do
10
10
  gem "guard"
data/granite-form.gemspec CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |gem|
14
14
  gem.required_ruby_version = '>= 2.4.0'
15
15
  gem.version = Granite::Form::VERSION
16
16
 
17
- gem.add_development_dependency 'actionpack', '>= 5.0'
18
- gem.add_development_dependency 'activerecord', '>= 5.0'
17
+ gem.add_development_dependency 'actionpack', '>= 6.0'
18
+ gem.add_development_dependency 'activerecord', '>= 6.0'
19
19
  gem.add_development_dependency 'appraisal'
20
20
  gem.add_development_dependency 'bump'
21
21
  gem.add_development_dependency 'database_cleaner'
@@ -23,10 +23,11 @@ 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', '0.52.1'
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
- gem.add_runtime_dependency 'activemodel', '>= 5.0'
30
- gem.add_runtime_dependency 'activesupport', '>= 5.0'
30
+ gem.add_runtime_dependency 'activemodel', '>= 6.0'
31
+ gem.add_runtime_dependency 'activesupport', '>= 6.0'
31
32
  gem.add_runtime_dependency 'tzinfo'
32
33
  end
@@ -30,11 +30,12 @@ module Granite
30
30
  extend ActiveSupport::Concern
31
31
 
32
32
  included do
33
- {embeds_many: Reflections::EmbedsMany, embeds_one: Reflections::EmbedsOne}.each do |(method, reflection_class)|
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
- options.reverse_merge(read: READER, write: WRITER),
37
- &block)
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
@@ -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
- :_normalizers, :types
7
+ :_normalizers, :types
8
8
 
9
9
  def self.delegated
10
10
  public_instance_methods - superclass.public_instance_methods - Singleton.public_instance_methods