rhino_project_core 0.22.0.alpha.2 → 0.22.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/rhino/error_handling.rb +1 -1
  3. data/app/overrides/active_record/nested_error_override.rb +21 -0
  4. data/app/policies/rhino/crud_policy.rb +1 -2
  5. data/app/policies/rhino/user_policy.rb +1 -1
  6. data/app/resources/rhino/open_api_info.rb +2 -2
  7. data/lib/commands/rhino/module/coverage_command.rb +1 -1
  8. data/lib/commands/rhino/module/dummy_command.rb +1 -1
  9. data/lib/commands/rhino/module/rails_command.rb +1 -1
  10. data/lib/commands/rhino/module/test_command.rb +1 -1
  11. data/lib/generators/rhino/dev/setup/setup_generator.rb +0 -1
  12. data/lib/generators/rhino/module/module_generator.rb +1 -1
  13. data/lib/rhino/resource/active_model_extension/backing_store/google_sheet.rb +1 -1
  14. data/lib/rhino/resource/active_model_extension/describe.rb +1 -1
  15. data/lib/rhino/resource/active_model_extension/params.rb +1 -1
  16. data/lib/rhino/resource/active_model_extension/properties.rb +5 -7
  17. data/lib/rhino/resource/active_record_extension/describe.rb +1 -1
  18. data/lib/rhino/resource/active_record_extension/params.rb +7 -8
  19. data/lib/rhino/resource/active_record_extension/properties.rb +1 -3
  20. data/lib/rhino/resource/active_record_extension/properties_describe.rb +6 -7
  21. data/lib/rhino/resource/owner.rb +1 -2
  22. data/lib/rhino/resource/properties.rb +2 -4
  23. data/lib/rhino/resource/reference.rb +1 -1
  24. data/lib/rhino/resource/routing.rb +2 -4
  25. data/lib/rhino/resource/sieves.rb +0 -2
  26. data/lib/rhino/sieve/filter.rb +2 -2
  27. data/lib/rhino/sieve/geospatial.rb +1 -1
  28. data/lib/rhino/test_case/controller.rb +1 -2
  29. data/lib/rhino/test_case/model.rb +3 -3
  30. data/lib/rhino/version.rb +1 -1
  31. data/lib/rhino_project_core.rb +2 -2
  32. metadata +14 -15
  33. data/app/overrides/active_record/autosave_association_override.rb +0 -18
  34. data/app/overrides/active_record/delegated_type_override.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a3abd1e7752359aab0f783bed6900e94f8de837ac9e571b72c6278bac888e55
4
- data.tar.gz: 9654f63fa463b08c070bee2e3cd2da93193830008ac8396cfee781e3e6d2f547
3
+ metadata.gz: cf37bf5ee31347fb2b245178fb38d4def3068dce29d6dbf22b4c70cc2ff75d55
4
+ data.tar.gz: b4acadca2f17693cb43675d467dc7e0af0197d407a10499e2813c641941259e3
5
5
  SHA512:
6
- metadata.gz: 105bbb3750d5a4fd2783e6f6b7b0569f9a2a7494e14768c9fdcec07fa853b9982277791af512dfcd27d58d73bf861e7487e06f68236cabadc5769ac356a1cac2
7
- data.tar.gz: 55b673aeaaa6c9e41815a1d56f6c533727d1e8223c6759f49c409c358d0a78ee47a6fa0c987bd586dbaa4f61d3e82fbe1cbaf9222b315aded657375a9f127bcb
6
+ metadata.gz: 3e7e9d1b573c598327c3e8bc00d178ffed27cf620784645ee9e7ac6f0f077534923c1883ca1ab1a6b17026c9b9287253f1f7b54406eb529bb47f2dc0a799d7e7
7
+ data.tar.gz: e0d237bc399bf3cbbb13af6f223d92876a4f59c66309bb8559cc72c7bc875bf6eaae5f2a84f8450104d1be160c9c5a8e42fc89f14adb5e08394fc6c198c41267
@@ -6,7 +6,7 @@ module Rhino
6
6
  module ErrorHandling
7
7
  extend ActiveSupport::Concern
8
8
 
9
- included do # rubocop:disable Metrics/BlockLength
9
+ included do
10
10
  rescue_from Exception, with: :handle_uncaught_error
11
11
 
12
12
  # ActiveRecord::DeleteRestrictionError is for dependent: :restrict_with_exception
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_record/associations/nested_error"
4
+
5
+ module ActiveRecord
6
+ module Associations
7
+ class NestedError < ::ActiveModel::NestedError
8
+ private
9
+ def compute_attribute(inner_error)
10
+ association_name = association.reflection.name
11
+
12
+ # Dot notation is used to represent nested attributes in the error message.
13
+ if index_errors_setting && index
14
+ "#{association_name}.#{index}.#{inner_error.attribute}".to_sym
15
+ else
16
+ "#{association_name}.#{inner_error.attribute}".to_sym
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -70,8 +70,7 @@ module Rhino
70
70
  end
71
71
 
72
72
  class Scope < ::Rhino::BasePolicy::Scope
73
- # rubocop:todo Metrics/MethodLength
74
- def resolve # rubocop:disable Metrics/AbcSize,
73
+ def resolve
75
74
  role_scopes = []
76
75
 
77
76
  # Get every role for the auth owner
@@ -4,7 +4,7 @@ module Rhino
4
4
  class UserPolicy < ::Rhino::ViewerPolicy
5
5
  class Scope < ::Rhino::ViewerPolicy::Scope
6
6
  # We allow other users in the org to view the user
7
- def resolve # rubocop:disable Metrics/AbcSize
7
+ def resolve
8
8
  return scope.none unless auth_owner
9
9
 
10
10
  base_owner_pk = "#{Rhino.base_owner.table_name}.#{Rhino.base_owner.primary_key}"
@@ -56,7 +56,7 @@ module Rhino
56
56
  end
57
57
  end
58
58
 
59
- def self.describe_path(path) # rubocop:todo Metrics/AbcSize
59
+ def self.describe_path(path)
60
60
  new_path = path.index_by { |p| p[:verb].downcase.to_sym }
61
61
  new_path.transform_values! do |verb_values|
62
62
  klass = verb_values[:rhino_resource].constantize
@@ -75,7 +75,7 @@ module Rhino
75
75
  end
76
76
 
77
77
  PATH_IGNORES = ["Rhino::OpenApiInfo", "Rhino::InfoGraph"].freeze
78
- def self.describe_paths # rubocop:todo Metrics/AbcSize
78
+ def self.describe_paths
79
79
  routes = Rails.application.routes.routes
80
80
 
81
81
  # Extract the path information we need
@@ -16,7 +16,7 @@ module Rails
16
16
  end
17
17
 
18
18
  protected
19
- def rhino_command(extra_path, base_command, *args) # rubocop:todo Metrics/MethodLength
19
+ def rhino_command(extra_path, base_command, *args)
20
20
  module_name = if Dir.exist?(args[0])
21
21
  args.shift
22
22
  else
@@ -15,7 +15,7 @@ module Rails
15
15
  end
16
16
 
17
17
  protected
18
- def rhino_command(extra_path, base_command, *args) # rubocop:todo Metrics/MethodLength
18
+ def rhino_command(extra_path, base_command, *args)
19
19
  module_name = if Dir.exist?(args[0])
20
20
  args.shift
21
21
  else
@@ -15,7 +15,7 @@ module Rails
15
15
  end
16
16
 
17
17
  protected
18
- def rhino_command(extra_path, base_command, *args) # rubocop:todo Metrics/MethodLength
18
+ def rhino_command(extra_path, base_command, *args)
19
19
  module_name = if Dir.exist?(args[0])
20
20
  args.shift
21
21
  else
@@ -15,7 +15,7 @@ module Rails
15
15
  end
16
16
 
17
17
  protected
18
- def rhino_command(extra_path, base_command, *args) # rubocop:todo Metrics/MethodLength
18
+ def rhino_command(extra_path, base_command, *args)
19
19
  module_name = if Dir.exist?(args[0])
20
20
  args.shift
21
21
  else
@@ -3,7 +3,6 @@
3
3
  module Rhino
4
4
  module Generators
5
5
  module Dev
6
- # rubocop:disable Metrics/ClassLength
7
6
  class SetupGenerator < ::Rails::Generators::Base
8
7
  DEFAULT_SERVER_PORT = 3000
9
8
 
@@ -49,7 +49,7 @@ module Rhino
49
49
  end
50
50
 
51
51
  # Has to be named this way as it overrides the default
52
- def get_builder_class # rubocop:disable Naming/AccessorMethodName
52
+ def get_builder_class
53
53
  ModuleBuilder
54
54
  end
55
55
 
@@ -35,7 +35,7 @@ module Rhino
35
35
  delegate :sheet, to: :class
36
36
  end
37
37
 
38
- class_methods do # rubocop:todo Metrics/BlockLength
38
+ class_methods do
39
39
  def backing_store_index
40
40
  sheet.reload
41
41
 
@@ -7,7 +7,7 @@ module Rhino
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  class_methods do
10
- def describe # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
10
+ def describe
11
11
  properties = all_properties.index_with { |p| describe_property(p) }
12
12
 
13
13
  required = properties.reject { |_p, d| d[:nullable] || d[:readOnly] }.keys
@@ -6,7 +6,7 @@ module Rhino
6
6
  module Params
7
7
  extend ActiveSupport::Concern
8
8
 
9
- class_methods do # rubocop:todo Metrics/BlockLength
9
+ class_methods do
10
10
  def create_params
11
11
  writeable_params("create")
12
12
  end
@@ -5,10 +5,10 @@ require "js_regex"
5
5
  module Rhino
6
6
  module Resource
7
7
  module ActiveModelExtension
8
- module Properties # rubocop:disable Metrics/ModuleLength
8
+ module Properties
9
9
  extend ActiveSupport::Concern
10
10
 
11
- class_methods do # rubocop:disable Metrics/BlockLength
11
+ class_methods do
12
12
  def identifier_property
13
13
  "id"
14
14
  end
@@ -29,7 +29,7 @@ module Rhino
29
29
  writeable_properties
30
30
  end
31
31
 
32
- def describe_property(property) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
32
+ def describe_property(property)
33
33
  name = property_name(property).to_s
34
34
  {
35
35
  "x-rhino-attribute": {
@@ -64,7 +64,7 @@ module Rhino
64
64
  []
65
65
  end
66
66
 
67
- def reference_properties(read = true) # rubocop:todo Style/OptionalBooleanParameter
67
+ def reference_properties(read = true)
68
68
  references.filter_map do |r|
69
69
  sym = reference_to_sym(r)
70
70
 
@@ -73,7 +73,6 @@ module Rhino
73
73
 
74
74
  # Writeable if a one type or accepting nested
75
75
  association = reflect_on_association(sym)
76
- # rubocop:todo Performance/CollectionLiteralInLoop
77
76
  sym if %i[has_one belongs_to].include?(association.macro) || nested_attributes_options.key?(sym)
78
77
  # rubocop:enable Performance/CollectionLiteralInLoop
79
78
  end
@@ -143,8 +142,7 @@ module Rhino
143
142
  { type: property_type_raw(property) }
144
143
  end
145
144
 
146
- # rubocop:todo Metrics/PerceivedComplexity
147
- def property_validations(property) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
145
+ def property_validations(property)
148
146
  constraint_hash = {}
149
147
 
150
148
  # https://swagger.io/specification/
@@ -7,7 +7,7 @@ module Rhino
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  class_methods do
10
- def describe # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
10
+ def describe
11
11
  properties = all_properties.index_with { |p| describe_property(p) }
12
12
 
13
13
  required = properties.reject { |_p, d| d[:nullable] || d[:readOnly] }.keys
@@ -3,10 +3,10 @@
3
3
  module Rhino
4
4
  module Resource
5
5
  module ActiveRecordExtension
6
- module Params # rubocop:todo Metrics/ModuleLength
6
+ module Params
7
7
  extend ActiveSupport::Concern
8
8
 
9
- class_methods do # rubocop:todo Metrics/BlockLength
9
+ class_methods do
10
10
  def create_params
11
11
  writeable_params("create")
12
12
  end
@@ -43,7 +43,7 @@ module Rhino
43
43
  send("#{type}_properties").dup
44
44
  end
45
45
 
46
- def readable_params(type, refs = references) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
46
+ def readable_params(type, refs = references) # rubocop:disable Metrics/CyclomaticComplexity
47
47
  params = []
48
48
 
49
49
  refs_index = refs.index_by { |r| reference_to_sym(r) }
@@ -79,10 +79,10 @@ module Rhino
79
79
  params << "display_name"
80
80
  end
81
81
 
82
- def writeable_params(type, _refs = references) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
82
+ def writeable_params(type, _refs = references) # rubocop:disable Metrics/CyclomaticComplexity
83
83
  params = []
84
84
 
85
- props_by_type(type).each do |prop| # rubocop:disable Metrics/BlockLength
85
+ props_by_type(type).each do |prop|
86
86
  desc = describe_property(prop)
87
87
  prop_sym = prop.to_sym
88
88
 
@@ -151,10 +151,9 @@ module Rhino
151
151
  end
152
152
 
153
153
  # Rebuild the params
154
- # rubocop:todo Metrics/CyclomaticComplexity
155
- def transform_params_recursive(params, parent = self) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity
154
+ def transform_params_recursive(params, parent = self)
156
155
  hash = {}
157
- params.each do |param_key, param_value| # rubocop:todo Metrics/BlockLength
156
+ params.each do |param_key, param_value|
158
157
  association = parent.reflect_on_association(param_key)
159
158
 
160
159
  # Its a regular attribute
@@ -10,7 +10,7 @@ module Rhino
10
10
 
11
11
  include Rhino::Resource::ActiveRecordExtension::PropertiesDescribe
12
12
 
13
- class_methods do # rubocop:disable Metrics/BlockLength
13
+ class_methods do
14
14
  def identifier_property
15
15
  primary_key
16
16
  end
@@ -51,7 +51,6 @@ module Rhino
51
51
  reflect_on_all_associations(:belongs_to).map(&:foreign_key).map(&:to_s)
52
52
  end
53
53
 
54
- # rubocop:todo Style/OptionalBooleanParameter
55
54
  def reference_properties(read = true)
56
55
  references.filter_map do |r|
57
56
  sym = reference_to_sym(r)
@@ -61,7 +60,6 @@ module Rhino
61
60
 
62
61
  # Writeable if a one type or accepting nested
63
62
  association = reflect_on_association(sym)
64
- # rubocop:todo Performance/CollectionLiteralInLoop, Layout/LineLength
65
63
  if %i[has_one belongs_to].include?(association.macro) || nested_attributes_options.key?(sym) || association.class_name == "ActiveStorage::Attachment"
66
64
  sym
67
65
  end
@@ -5,7 +5,7 @@ require "js_regex"
5
5
  module Rhino
6
6
  module Resource
7
7
  module ActiveRecordExtension
8
- module PropertiesDescribe # rubocop:disable Metrics/ModuleLength
8
+ module PropertiesDescribe
9
9
  extend ActiveSupport::Concern
10
10
 
11
11
  class PolymorphicModelName
@@ -22,8 +22,8 @@ module Rhino
22
22
  end
23
23
  end
24
24
 
25
- class_methods do # rubocop:disable Metrics/BlockLength
26
- def describe_property(property) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
25
+ class_methods do
26
+ def describe_property(property) # rubocop:disable Metrics/AbcSize
27
27
  name = property_name(property).to_s
28
28
  raise StandardError, "#{name} is not a valid property" unless property?(name)
29
29
 
@@ -61,7 +61,7 @@ module Rhino
61
61
  }
62
62
  end
63
63
 
64
- def property_type_and_format_attr(name) # rubocop:todo Metrics/MethodLength
64
+ def property_type_and_format_attr(name)
65
65
  atype = attribute_types[name.to_s].type
66
66
 
67
67
  # The PG array delegates type to "subtype" which is the actual type of the array elements
@@ -98,7 +98,6 @@ module Rhino
98
98
  { "x-rhino-attribute-array": array_options.merge(_properties_array[ref_sym] || {}) }
99
99
  end
100
100
 
101
- # rubocop:todo Metrics/PerceivedComplexity
102
101
  # rubocop:todo Metrics/AbcSize
103
102
  def property_type_and_format_ref(name) # rubocop:todo Metrics/AbcSize
104
103
  assoc = reflections[name]
@@ -125,7 +124,7 @@ module Rhino
125
124
  # rubocop:enable Metrics/AbcSize
126
125
  # rubocop:enable Metrics/PerceivedComplexity
127
126
 
128
- def property_type_and_format(name) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
127
+ def property_type_and_format(name) # rubocop:disable Metrics/AbcSize
129
128
  # Special cases
130
129
  return { type: :identifier } if name == identifier_property
131
130
  return { type: :string } if defined_enums.key?(name)
@@ -156,7 +155,7 @@ module Rhino
156
155
  _properties_overrides[property].deep_symbolize_keys
157
156
  end
158
157
 
159
- def property_validations(property) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
158
+ def property_validations(property) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
160
159
  constraint_hash = {}
161
160
 
162
161
  # https://swagger.io/specification/
@@ -21,8 +21,7 @@ module Rhino
21
21
  end
22
22
 
23
23
  # The self is actually required to work with class_attribute properly
24
- # rubocop:disable Style/RedundantSelf
25
- class_methods do # rubocop:disable Metrics/BlockLength
24
+ class_methods do
26
25
  # Test if rhino_owner[rdoc-ref:rhino_owner] is the auth owner
27
26
  # Also available on the instance
28
27
  def auth_owner?
@@ -26,7 +26,7 @@ module Rhino
26
26
  # readable_properties
27
27
  # creatable_properties
28
28
  # updatable_properties
29
- module Properties # rubocop:todo Metrics/ModuleLength
29
+ module Properties
30
30
  extend ActiveSupport::Concern
31
31
 
32
32
  included do
@@ -54,8 +54,7 @@ module Rhino
54
54
  delegate :describe_property, to: :class
55
55
  end
56
56
 
57
- # rubocop:disable Style/RedundantSelf
58
- class_methods do # rubocop:disable Metrics/BlockLength
57
+ class_methods do
59
58
  def rhino_properties_read(**options)
60
59
  self._read_properties_only = Array.wrap(options[:only]).map(&:to_s) if options.key?(:only)
61
60
  self._read_properties_except = Array.wrap(options[:except]).map(&:to_s) if options.key?(:except)
@@ -186,7 +185,6 @@ module Rhino
186
185
  raise NotImplementedError, "#describe_property is not implemented for #{property}"
187
186
  end
188
187
  end
189
- # rubocop:enable Style/RedundantSelf
190
188
  end
191
189
  end
192
190
  end
@@ -21,7 +21,7 @@ module Rhino
21
21
  end
22
22
 
23
23
  def references
24
- self._references # rubocop:disable Style/RedundantSelf
24
+ self._references
25
25
  end
26
26
  end
27
27
  end
@@ -18,7 +18,6 @@ module Rhino
18
18
  delegate :routes, to: :class
19
19
  end
20
20
 
21
- # rubocop:disable Style/RedundantSelf, Metrics/BlockLength
22
21
  class_methods do
23
22
  def route_key
24
23
  self._route_key ||= if route_singular?
@@ -50,7 +49,7 @@ module Rhino
50
49
 
51
50
  def routes
52
51
  unless self._rhino_routes
53
- if global_owner? # rubocop:disable Style/ConditionalAssignment
52
+ if global_owner?
54
53
  self._rhino_routes = %i[index show]
55
54
  else
56
55
  self._rhino_routes = %i[index create show update destroy]
@@ -72,10 +71,9 @@ module Rhino
72
71
  self.controller_name = "rhino/#{controller}"
73
72
  end
74
73
  end
75
- # rubocop:enable Style/RedundantSelf, Metrics/BlockLength
76
74
  end
77
75
 
78
- def route_frontend # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
76
+ def route_frontend
79
77
  base_owner_pk = "#{Rhino.base_owner.table_name}.#{Rhino.base_owner.primary_key}"
80
78
 
81
79
  joins = joins_for_base_owner
@@ -13,7 +13,6 @@ module Rhino
13
13
  delegate :sieves, to: :class
14
14
  end
15
15
 
16
- # rubocop:disable Style/RedundantSelf
17
16
  class_methods do
18
17
  def rhino_sieves
19
18
  self._sieves = Rhino.sieves.dup unless self._sieves
@@ -30,7 +29,6 @@ module Rhino
30
29
  scope
31
30
  end
32
31
  end
33
- # rubocop:enable Style/RedundantSelf
34
32
  end
35
33
  end
36
34
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Rhino
4
4
  module Sieve
5
- class Filter # rubocop:disable Metrics/ClassLength
5
+ class Filter
6
6
  def initialize(app)
7
7
  @app = app
8
8
  end
@@ -107,7 +107,7 @@ module Rhino
107
107
 
108
108
  BASIC_AREL_OPS = %w[eq gt lt gteq lteq].freeze
109
109
  BASIC_AREL_COALESCE_OPS = BASIC_AREL_OPS.map { |op| "#{op}_coalesce" }.freeze
110
- def merge_where_clause(base, scope, column_name, value, operation = nil) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
110
+ def merge_where_clause(base, scope, column_name, value, operation = nil)
111
111
  arel_node = base.arel_table[column_name]
112
112
  where_clause = case operation
113
113
  when *BASIC_AREL_OPS then arel_node.send(operation, value)
@@ -22,7 +22,7 @@ module Rhino
22
22
  end
23
23
 
24
24
  private
25
- def valid?(params) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
25
+ def valid?(params)
26
26
  @geospatial_params = params[:geospatial]
27
27
  return false unless @geospatial_params.is_a?(ActionController::Parameters)
28
28
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Rhino
4
4
  module TestCase
5
- # rubocop:disable Metrics/ClassLength
6
5
  class ControllerTest < ActionDispatch::IntegrationTest
7
6
  setup :set_cookie_attributes
8
7
 
@@ -81,7 +80,7 @@ module Rhino
81
80
  def assert_not_deleted_cookie(cookie_name)
82
81
  has_cookie = response.cookies.key?(cookie_name)
83
82
  cookie_not_blank = response.cookies[cookie_name].present?
84
- assert !has_cookie || cookie_not_blank, "Response should either not have the auth cookie present or it should be set to something. Current value is #{response.cookies[cookie_name]}" # rubocop:disable Layout/LineLength
83
+ assert !has_cookie || cookie_not_blank, "Response should either not have the auth cookie present or it should be set to something. Current value is #{response.cookies[cookie_name]}"
85
84
  end
86
85
 
87
86
  def sign_in(user = nil)
@@ -33,7 +33,7 @@ module Rhino
33
33
  end
34
34
 
35
35
  # association_model is a symbol
36
- def assert_accepts_nested_attributes_for(association_model, association_factory: association_model) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
36
+ def assert_accepts_nested_attributes_for(association_model, association_factory: association_model)
37
37
  association = @model.reflect_on_association(association_model)
38
38
 
39
39
  assert association.present?, "association :#{association_model} not found"
@@ -51,7 +51,7 @@ module Rhino
51
51
  end
52
52
 
53
53
  assert @model.new.respond_to?("#{key}="),
54
- "#{@model} doesn't have a #{key} setter method. Probably there's no `accepts_nested_attributes_for :#{association_model}` in #{@model}" # rubocop:disable Layout/LineLength
54
+ "#{@model} doesn't have a #{key} setter method. Probably there's no `accepts_nested_attributes_for :#{association_model}` in #{@model}"
55
55
  object = if association_factory.is_a?(Proc)
56
56
  model_instance = build factory
57
57
  association_instance = association_factory.call model_instance
@@ -65,7 +65,7 @@ module Rhino
65
65
  assert success_checker.call(object), "Should have a #{association_model} after assigning nested model attributes"
66
66
  end
67
67
 
68
- def assert_destroy_association_cascade(association_model, association_factory: association_model) # rubocop:disable Metrics/AbcSize
68
+ def assert_destroy_association_cascade(association_model, association_factory: association_model)
69
69
  instance = create factory
70
70
  association_instance = if association_factory.is_a?(Proc)
71
71
  association_factory.call(instance)
data/lib/rhino/version.rb CHANGED
@@ -10,7 +10,7 @@ module Rhino
10
10
  MAJOR = 0
11
11
  MINOR = 22
12
12
  TINY = 0
13
- PRE = "alpha.2"
13
+ PRE = "alpha.3"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -82,7 +82,7 @@ module Rhino
82
82
 
83
83
  # Set the auth owner reference object to access the mailer.
84
84
  def self.auth_owner=(class_name)
85
- @@auth_owner_ref = ref(class_name) # rubocop:disable Style/ClassVars
85
+ @@auth_owner_ref = ref(class_name)
86
86
  end
87
87
  self.auth_owner = 'User'
88
88
 
@@ -96,7 +96,7 @@ module Rhino
96
96
 
97
97
  # Set the mailer reference object to access the mailer.
98
98
  def self.base_owner=(class_name)
99
- @@base_owner_ref = ref(class_name) # rubocop:disable Style/ClassVars
99
+ @@base_owner_ref = ref(class_name)
100
100
  end
101
101
  self.base_owner = 'User'
102
102
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhino_project_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0.alpha.2
4
+ version: 0.22.0.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Rosevear
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-16 00:00:00.000000000 Z
11
+ date: 2024-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 7.1.0
19
+ version: 7.2.0
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 7.1.0
22
+ version: 7.2.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 7.1.0
29
+ version: 7.2.0
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 7.1.0
32
+ version: 7.2.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activeadmin
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - '='
52
52
  - !ruby/object:Gem::Version
53
- version: 10.0.0
53
+ version: 11.0.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - '='
59
59
  - !ruby/object:Gem::Version
60
- version: 10.0.0
60
+ version: 11.0.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: analytics-ruby
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 2.14.0
95
+ version: 2.15.0
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 2.14.0
102
+ version: 2.15.0
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: countries
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -134,14 +134,14 @@ dependencies:
134
134
  requirements:
135
135
  - - '='
136
136
  - !ruby/object:Gem::Version
137
- version: 1.2.3
137
+ version: 1.2.4
138
138
  type: :runtime
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - '='
143
143
  - !ruby/object:Gem::Version
144
- version: 1.2.3
144
+ version: 1.2.4
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: friendly_id
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -394,8 +394,7 @@ files:
394
394
  - app/models/rhino/account.rb
395
395
  - app/models/rhino/current.rb
396
396
  - app/models/rhino/user.rb
397
- - app/overrides/active_record/autosave_association_override.rb
398
- - app/overrides/active_record/delegated_type_override.rb
397
+ - app/overrides/active_record/nested_error_override.rb
399
398
  - app/overrides/activestorage/direct_uploads_controller_override.rb
400
399
  - app/overrides/activestorage/redirect_controller_override.rb
401
400
  - app/overrides/activestorage/redirect_representation_controller_override.rb
@@ -524,7 +523,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
524
523
  - !ruby/object:Gem::Version
525
524
  version: '0'
526
525
  requirements: []
527
- rubygems_version: 3.5.16
526
+ rubygems_version: 3.5.22
528
527
  signing_key:
529
528
  specification_version: 4
530
529
  summary: ''
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # correction for nested forms errors indexation
4
- # this correction is still necessary in rails 7.0
5
- module ActiveRecord::AutosaveAssociation
6
- private
7
- def validate_collection_association(reflection)
8
- return unless (association = association_instance_get(reflection.name))
9
-
10
- return unless (records = associated_records_to_validate_or_save(association, new_record?, reflection.options[:autosave]))
11
-
12
- all_records = association.target.find_all
13
- records.each do |record|
14
- index = all_records.find_index(record)
15
- association_valid?(reflection, record, index)
16
- end
17
- end
18
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # correction for nested forms errors indexation
4
- # this correction is still necessary in rails 7.0
5
- module ActiveRecord::DelegatedType
6
- def delegated_type(role, types:, **options)
7
- belongs_to role, options.delete(:scope), **options.merge(polymorphic: true)
8
- define_delegated_type_methods(role, types:, options:)
9
-
10
- define_singleton_method "#{role}_types" do
11
- types.map(&:to_s)
12
- end
13
- end
14
- end