mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-12 15:33:14 +00:00
Compare commits
2 Commits
87289d06db
...
a95ac9ebb7
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a95ac9ebb7 | ||
![]() |
a08a79fe96 |
|
@ -6,10 +6,6 @@
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
# versions of RuboCop, may require this file to be generated again.
|
# versions of RuboCop, may require this file to be generated again.
|
||||||
|
|
||||||
Lint/NonLocalExitFromIterator:
|
|
||||||
Exclude:
|
|
||||||
- 'app/helpers/json_ld_helper.rb'
|
|
||||||
|
|
||||||
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 82
|
Max: 82
|
||||||
|
|
|
@ -134,7 +134,7 @@ module JsonLdHelper
|
||||||
patch_for_forwarding!(value, compacted_value)
|
patch_for_forwarding!(value, compacted_value)
|
||||||
elsif value.is_a?(Array)
|
elsif value.is_a?(Array)
|
||||||
compacted_value = [compacted_value] unless compacted_value.is_a?(Array)
|
compacted_value = [compacted_value] unless compacted_value.is_a?(Array)
|
||||||
return if value.size != compacted_value.size
|
return(nil) if value.size != compacted_value.size
|
||||||
|
|
||||||
compacted[key] = value.zip(compacted_value).map do |v, vc|
|
compacted[key] = value.zip(compacted_value).map do |v, vc|
|
||||||
if v.is_a?(Hash) && vc.is_a?(Hash)
|
if v.is_a?(Hash) && vc.is_a?(Hash)
|
||||||
|
|
|
@ -180,6 +180,14 @@ RSpec.describe JsonLdHelper do
|
||||||
expect(compacted.dig('object', 'tag', 0, 'href')).to eq ['foo']
|
expect(compacted.dig('object', 'tag', 0, 'href')).to eq ['foo']
|
||||||
expect(safe_for_forwarding?(json, compacted)).to be true
|
expect(safe_for_forwarding?(json, compacted)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when array size mismatch exists' do
|
||||||
|
subject { helper.patch_for_forwarding!(json, alternate) }
|
||||||
|
|
||||||
|
let(:alternate) { json.merge('to' => %w(one two three)) }
|
||||||
|
|
||||||
|
it { is_expected.to be_nil }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'safe_for_forwarding?' do
|
describe 'safe_for_forwarding?' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user