Skip to content

Commit ddb860f

Browse files
committed
Merge branch 'master' into base_spec_single_ops
# Conflicts: # lib/jsonapi/request_parser.rb
2 parents ff8b0c9 + 0534288 commit ddb860f

File tree

3 files changed

+3
-43
lines changed

3 files changed

+3
-43
lines changed

lib/jsonapi/request_parser.rb

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def parse_modify_relationship_action(params, modification_type)
122122
if data_required
123123
data = params.fetch(:data)
124124
object_params = { relationships: { format_key(relationship.name) => { data: data } } }
125-
verified_params = parse_params(object_params, updatable_fields)
125+
verified_params = parse_params(object_params, @resource_klass.updatable_fields(@context))
126126

127127
parse_arguments = [verified_params, relationship, parent_key]
128128
else
@@ -362,7 +362,7 @@ def parse_add_operation(params)
362362

363363
verify_type(params[:type])
364364

365-
data = parse_params(params, creatable_fields)
365+
data = parse_params(params, @resource_klass.creatable_fields(@context))
366366
@operations.push JSONAPI::Operation.new(:create_resource,
367367
@resource_klass,
368368
context: @context,
@@ -567,17 +567,6 @@ def verify_permitted_params(params, allowed_fields)
567567
end
568568
end
569569

570-
# TODO: Please remove after `updateable_fields` is removed
571-
# :nocov:
572-
def updatable_fields
573-
if @resource_klass.respond_to?(:updateable_fields)
574-
@resource_klass.updateable_fields(@context)
575-
else
576-
@resource_klass.updatable_fields(@context)
577-
end
578-
end
579-
# :nocov:
580-
581570
def parse_add_relationship_operation(verified_params, relationship, parent_key)
582571
if relationship.is_a?(JSONAPI::Relationship::ToMany)
583572
@operations.push JSONAPI::Operation.new(:create_to_many_relationship,
@@ -636,7 +625,7 @@ def parse_single_replace_operation(data, keys, id_key_presence_check_required: t
636625
@resource_klass,
637626
context: @context,
638627
resource_id: key,
639-
data: parse_params(data, updatable_fields),
628+
data: parse_params(data, @resource_klass.updatable_fields(@context)),
640629
fields: @fields,
641630
include_directives: @include_directives
642631
)

lib/jsonapi/resource.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -572,21 +572,6 @@ def cache_field(field)
572572
@_cache_field = field.to_sym
573573
end
574574

575-
# TODO: remove this after the createable_fields and updateable_fields are phased out
576-
# :nocov:
577-
def method_missing(method, *args)
578-
if method.to_s.match(/createable_fields/)
579-
ActiveSupport::Deprecation.warn('`createable_fields` is deprecated, please use `creatable_fields` instead')
580-
creatable_fields(*args)
581-
elsif method.to_s.match(/updateable_fields/)
582-
ActiveSupport::Deprecation.warn('`updateable_fields` is deprecated, please use `updatable_fields` instead')
583-
updatable_fields(*args)
584-
else
585-
super
586-
end
587-
end
588-
# :nocov:
589-
590575
# Override in your resource to filter the updatable keys
591576
def updatable_fields(_context = nil)
592577
_updatable_relationships | _attributes.keys - [:id]

test/unit/resource/resource_test.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -289,20 +289,6 @@ def test_updatable_fields_does_not_include_id
289289
assert(!CatResource.updatable_fields.include?(:id))
290290
end
291291

292-
# TODO: Please remove after `updateable_fields` is removed
293-
def test_updateable_fields_delegates_to_updatable_fields_with_deprecation
294-
ActiveSupport::Deprecation.silence do
295-
assert_empty(CatResource.updateable_fields(nil) - [:mother, :father, :name, :breed, :kind])
296-
end
297-
end
298-
299-
# TODO: Please remove after `createable_fields` is removed
300-
def test_createable_fields_delegates_to_creatable_fields_with_deprecation
301-
ActiveSupport::Deprecation.silence do
302-
assert_empty(CatResource.createable_fields(nil) - [:mother, :father, :name, :breed, :id, :kind])
303-
end
304-
end
305-
306292
def test_filter_on_to_many_relationship_id
307293
posts = PostResource.find(:comments => 3)
308294
assert_equal([2], posts.map(&:id))

0 commit comments

Comments
 (0)