Skip to content

Commit

Permalink
Autocorrect rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JDutil committed Jun 18, 2024
1 parent d9def4b commit 2619c8f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/contentful_lite/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def initialize(response, body)
super(body['sys'] && body['sys']['type'] == 'Error' ? "#{body['sys']['id']}: #{body['message']}" : "Invalid Contentful Response: #{body}")
end
end

class NotFoundError < RequestError; end

attr_reader :space_id, :environment, :preview
Expand Down
2 changes: 1 addition & 1 deletion lib/contentful_lite/entries_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def build_entry(id)

klass = ContentfulLite::Entry.get_class(hash['sys']['contentType']['sys']['id'])
@entries[id] = klass.new(hash)
@entries[id].localized_fields.values.each do |fields|
@entries[id].localized_fields.each_value do |fields|
fields.transform_values! { |field| solve_link(field) }
end
@entries[id]
Expand Down
2 changes: 1 addition & 1 deletion lib/contentful_lite/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Entry
def initialize(raw)
super(raw)
@content_type_id = raw['sys']['contentType']['sys']['id']
@localized_fields.values.each do |fields|
@localized_fields.each_value do |fields|
fields.transform_values! { |value| build_link(value) }
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class IncludedAssetValidator < ActiveModel::EachValidator

def validate_child(record, attr_name, value, idx = nil)
record_error(record, attr_name, "value#{idx} is not a published asset") && return unless value.is_a?(ContentfulLite::Asset)

record_error(record, attr_name, "value#{idx} has an invalid asset type. Expecting #{options[:type]}") if options[:type] && !value&.content_type&.include?(options[:type].to_s)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def record_error(record, attr_name, message)

def validate_array(record, attr_name, value)
record_error(record, attr_name, "value is not an array") && return unless value.is_a?(Array)

value.each_with_index { |asset, idx| validate_child(record, attr_name, asset, "[#{idx}]") }
end

Expand Down
1 change: 1 addition & 0 deletions spec/validations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def create_validable_model(validation_method, options)
include ContentfulLite::Validations::Entry
attr_reader :fake_field
attr_accessor :locale

send(validation_method, :fake_field, options)

def initialize(value)
Expand Down

0 comments on commit 2619c8f

Please sign in to comment.