Switch PercentLiteralDelimiters to new default
Let's change that to the new rubocop default, which is also the suggestion in the ruby style guide. See https://github.com/bbatsov/ruby-style-guide#percent-literal-braces This was changed in diaspora too, see diaspora/diaspora#7466 It also includes the changes in the code. This was done with `rubocop --auto-correct` and no we have zero offenses again.
This commit is contained in:
parent
5730b88296
commit
e26a86c173
50 changed files with 80 additions and 90 deletions
10
.rubocop.yml
10
.rubocop.yml
|
|
@ -189,16 +189,6 @@ Layout/EmptyLineBetweenDefs:
|
||||||
Style/NumericPredicate:
|
Style/NumericPredicate:
|
||||||
EnforcedStyle: comparison
|
EnforcedStyle: comparison
|
||||||
|
|
||||||
# Old defaults from rubocop < 0.48.1 (Maybe change this in the future?)
|
|
||||||
Style/PercentLiteralDelimiters:
|
|
||||||
PreferredDelimiters:
|
|
||||||
default: '()'
|
|
||||||
'%i': '()'
|
|
||||||
'%I': '()'
|
|
||||||
'%r': '{}'
|
|
||||||
'%w': '()'
|
|
||||||
'%W': '()'
|
|
||||||
|
|
||||||
### backward compatibility
|
### backward compatibility
|
||||||
|
|
||||||
# only with ruby >= 2.3
|
# only with ruby >= 2.3
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
# Don't log received xml data.
|
# Don't log received xml data.
|
||||||
Rails.application.config.filter_parameters += %i(xml aes_key encrypted_magic_envelope)
|
Rails.application.config.filter_parameters += %i[xml aes_key encrypted_magic_envelope]
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ require "diaspora_federation/federation"
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
extend Logging
|
extend Logging
|
||||||
|
|
||||||
@callbacks = Callbacks.new %i(
|
@callbacks = Callbacks.new %i[
|
||||||
fetch_person_for_webfinger
|
fetch_person_for_webfinger
|
||||||
fetch_person_for_hcard
|
fetch_person_for_hcard
|
||||||
save_person_after_webfinger
|
save_person_after_webfinger
|
||||||
|
|
@ -36,7 +36,7 @@ module DiasporaFederation
|
||||||
fetch_public_entity
|
fetch_public_entity
|
||||||
fetch_person_url_to
|
fetch_person_url_to
|
||||||
update_pod
|
update_pod
|
||||||
)
|
]
|
||||||
|
|
||||||
# defaults
|
# defaults
|
||||||
@http_concurrency = 20
|
@http_concurrency = 20
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ module DiasporaFederation
|
||||||
XMLNS = "http://docs.oasis-open.org/ns/xri/xrd-1.0".freeze
|
XMLNS = "http://docs.oasis-open.org/ns/xri/xrd-1.0".freeze
|
||||||
|
|
||||||
# +Link+ element attributes
|
# +Link+ element attributes
|
||||||
LINK_ATTRS = %i(rel type href template).freeze
|
LINK_ATTRS = %i[rel type href template].freeze
|
||||||
|
|
||||||
# format string for datetime (+Expires+ element)
|
# format string for datetime (+Expires+ element)
|
||||||
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ".freeze
|
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ".freeze
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ module DiasporaFederation
|
||||||
# The order for signing
|
# The order for signing
|
||||||
# @return [Array]
|
# @return [Array]
|
||||||
def signature_order
|
def signature_order
|
||||||
@signature_order || self.class.class_props.keys - %i(author_signature parent_author_signature parent)
|
@signature_order || self.class.class_props.keys - %i[author_signature parent_author_signature parent]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
@ -145,7 +145,7 @@ module DiasporaFederation
|
||||||
data = super.tap do |hash|
|
data = super.tap do |hash|
|
||||||
hash[:parent_author_signature] = parent_author_signature || sign_with_parent_author_if_available.to_s
|
hash[:parent_author_signature] = parent_author_signature || sign_with_parent_author_if_available.to_s
|
||||||
end
|
end
|
||||||
order = signature_order + %i(author_signature parent_author_signature)
|
order = signature_order + %i[author_signature parent_author_signature]
|
||||||
order.map {|element| [element, data[element] || ""] }.to_h
|
order.map {|element| [element, data[element] || ""] }.to_h
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
|
|
||||||
def setable_string?(type, val)
|
def setable_string?(type, val)
|
||||||
%i(string integer boolean).include?(type) && val.respond_to?(:to_s)
|
%i[string integer boolean].include?(type) && val.respond_to?(:to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def setable_nested?(type, val)
|
def setable_nested?(type, val)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
def parse_element_from_value(type, value)
|
def parse_element_from_value(type, value)
|
||||||
return if value.nil?
|
return if value.nil?
|
||||||
if %i(integer boolean timestamp).include?(type) && !value.is_a?(String)
|
if %i[integer boolean timestamp].include?(type) && !value.is_a?(String)
|
||||||
value
|
value
|
||||||
elsif type.instance_of?(Symbol)
|
elsif type.instance_of?(Symbol)
|
||||||
parse_string(type, value)
|
parse_string(type, value)
|
||||||
|
|
@ -45,7 +45,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
|
|
||||||
def from_json_sanity_validation(json_hash)
|
def from_json_sanity_validation(json_hash)
|
||||||
missing = %w(entity_type entity_data).map {|prop|
|
missing = %w[entity_type entity_data].map {|prop|
|
||||||
prop if json_hash[prop].nil?
|
prop if json_hash[prop].nil?
|
||||||
}.compact.join(", ")
|
}.compact.join(", ")
|
||||||
raise DeserializationError, "Required properties are missing in JSON object: #{missing}" unless missing.empty?
|
raise DeserializationError, "Required properties are missing in JSON object: #{missing}" unless missing.empty?
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
|
|
||||||
def property_type_valid?(type)
|
def property_type_valid?(type)
|
||||||
%i(string integer boolean timestamp).include?(type)
|
%i[string integer boolean timestamp].include?(type)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks if the type extends {Entity}
|
# Checks if the type extends {Entity}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
class AccountDeletionValidator < Validation::Validator
|
class AccountDeletionValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
class AccountMigrationValidator < Validation::Validator
|
class AccountMigrationValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
|
|
||||||
rule :profile, :not_nil
|
rule :profile, :not_nil
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ module DiasporaFederation
|
||||||
class ContactValidator < Validation::Validator
|
class ContactValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
rule :recipient, %i(not_empty diaspora_id)
|
rule :recipient, %i[not_empty diaspora_id]
|
||||||
rule :following, :boolean
|
rule :following, :boolean
|
||||||
rule :sharing, :boolean
|
rule :sharing, :boolean
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
class ConversationValidator < Validation::Validator
|
class ConversationValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
rule :guid, :guid
|
rule :guid, :guid
|
||||||
|
|
||||||
rule :subject, [:not_empty, length: {maximum: 255}]
|
rule :subject, [:not_empty, length: {maximum: 255}]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
class EventValidator < Validation::Validator
|
class EventValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
|
|
||||||
rule :guid, :guid
|
rule :guid, :guid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
class MessageValidator < Validation::Validator
|
class MessageValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
rule :guid, :guid
|
rule :guid, :guid
|
||||||
rule :conversation_guid, :guid
|
rule :conversation_guid, :guid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
class ParticipationValidator < Validation::Validator
|
class ParticipationValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
rule :guid, :guid
|
rule :guid, :guid
|
||||||
rule :parent_guid, :guid
|
rule :parent_guid, :guid
|
||||||
rule :parent_type, [:not_empty, regular_expression: {regex: /\APost\z/}]
|
rule :parent_type, [:not_empty, regular_expression: {regex: /\APost\z/}]
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ module DiasporaFederation
|
||||||
|
|
||||||
rule :guid, :guid
|
rule :guid, :guid
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
|
|
||||||
rule :url, %i(not_nil URI)
|
rule :url, %i[not_nil URI]
|
||||||
|
|
||||||
rule :profile, :not_nil
|
rule :profile, :not_nil
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
rule :guid, :guid
|
rule :guid, :guid
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
|
|
||||||
rule :public, :boolean
|
rule :public, :boolean
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
class RelatedEntityValidator < Validation::Validator
|
class RelatedEntityValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
rule :local, :boolean
|
rule :local, :boolean
|
||||||
rule :public, :boolean
|
rule :public, :boolean
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ module DiasporaFederation
|
||||||
# @param [Validation::Validator] validator the validator in which it is included
|
# @param [Validation::Validator] validator the validator in which it is included
|
||||||
def self.included(validator)
|
def self.included(validator)
|
||||||
validator.class_eval do
|
validator.class_eval do
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
rule :guid, :guid
|
rule :guid, :guid
|
||||||
rule :parent_guid, :guid
|
rule :parent_guid, :guid
|
||||||
rule :parent, :not_nil
|
rule :parent, :not_nil
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ module DiasporaFederation
|
||||||
class ReshareValidator < Validation::Validator
|
class ReshareValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :root_author, %i(not_empty diaspora_id)
|
rule :root_author, %i[not_empty diaspora_id]
|
||||||
|
|
||||||
rule :root_guid, :guid
|
rule :root_guid, :guid
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
|
|
||||||
rule :guid, :guid
|
rule :guid, :guid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
class RetractionValidator < Validation::Validator
|
class RetractionValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
|
|
||||||
rule :target_guid, :guid
|
rule :target_guid, :guid
|
||||||
rule :target_type, :not_empty
|
rule :target_type, :not_empty
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
class StatusMessageValidator < Validation::Validator
|
class StatusMessageValidator < Validation::Validator
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
|
|
||||||
rule :guid, :guid
|
rule :guid, :guid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ module DiasporaFederation
|
||||||
|
|
||||||
rule :acct_uri, :not_empty
|
rule :acct_uri, :not_empty
|
||||||
|
|
||||||
rule :hcard_url, [:not_nil, URI: %i(host path)]
|
rule :hcard_url, [:not_nil, URI: %i[host path]]
|
||||||
rule :seed_url, %i(not_nil URI)
|
rule :seed_url, %i[not_nil URI]
|
||||||
rule :profile_url, URI: %i(host path)
|
rule :profile_url, URI: %i[host path]
|
||||||
rule :atom_url, URI: %i(host path)
|
rule :atom_url, URI: %i[host path]
|
||||||
rule :salmon_url, URI: %i(host path)
|
rule :salmon_url, URI: %i[host path]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ module DiasporaFederation
|
||||||
include Validation
|
include Validation
|
||||||
|
|
||||||
rule :test, :boolean
|
rule :test, :boolean
|
||||||
rule :author, %i(not_empty diaspora_id)
|
rule :author, %i[not_empty diaspora_id]
|
||||||
rule :guid, :guid
|
rule :guid, :guid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe Callbacks do
|
describe Callbacks do
|
||||||
subject(:callbacks) { Callbacks.new %i(some_event another_event) }
|
subject(:callbacks) { Callbacks.new %i[some_event another_event] }
|
||||||
|
|
||||||
context "callbacks" do
|
context "callbacks" do
|
||||||
it "defines a callback and calls it" do
|
it "defines a callback and calls it" do
|
||||||
|
|
@ -56,12 +56,12 @@ module DiasporaFederation
|
||||||
|
|
||||||
describe "#missing_handlers" do
|
describe "#missing_handlers" do
|
||||||
it "contains all events if nothing isdefined" do
|
it "contains all events if nothing isdefined" do
|
||||||
expect(callbacks.missing_handlers).to eq(%i(some_event another_event))
|
expect(callbacks.missing_handlers).to eq(%i[some_event another_event])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "contains the missing events if not all events are defined" do
|
it "contains the missing events if not all events are defined" do
|
||||||
callbacks.on(:some_event) {}
|
callbacks.on(:some_event) {}
|
||||||
expect(callbacks.missing_handlers).to eq(%i(another_event))
|
expect(callbacks.missing_handlers).to eq(%i[another_event])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is empty if all events are defined" do
|
it "is empty if all events are defined" do
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ XML
|
||||||
{
|
{
|
||||||
subject: "http://blog.example.com/article/id/314",
|
subject: "http://blog.example.com/article/id/314",
|
||||||
expires: DateTime.parse("2010-01-30T09:30:00Z"),
|
expires: DateTime.parse("2010-01-30T09:30:00Z"),
|
||||||
aliases: %w(
|
aliases: %w[
|
||||||
http://blog.example.com/cool_new_thing
|
http://blog.example.com/cool_new_thing
|
||||||
http://blog.example.com/steve/article/7
|
http://blog.example.com/steve/article/7
|
||||||
),
|
],
|
||||||
properties: {
|
properties: {
|
||||||
"http://blgx.example.net/ns/version" => "1.3",
|
"http://blgx.example.net/ns/version" => "1.3",
|
||||||
"http://blgx.example.net/ns/ext" => nil
|
"http://blgx.example.net/ns/ext" => nil
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ XML
|
||||||
|
|
||||||
it_behaves_like "an Entity subclass"
|
it_behaves_like "an Entity subclass"
|
||||||
|
|
||||||
it_behaves_like "an XML Entity", %i(parent parent_guid)
|
it_behaves_like "an XML Entity", %i[parent parent_guid]
|
||||||
|
|
||||||
context "default values" do
|
context "default values" do
|
||||||
it "allows no nested messages" do
|
it "allows no nested messages" do
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ module DiasporaFederation
|
||||||
let(:hash) { {guid: guid, author: author, parent_guid: parent_guid, parent: local_parent, property: property} }
|
let(:hash) { {guid: guid, author: author, parent_guid: parent_guid, parent: local_parent, property: property} }
|
||||||
let(:hash_with_fake_signatures) { hash.merge!(author_signature: "aa", parent_author_signature: "bb") }
|
let(:hash_with_fake_signatures) { hash.merge!(author_signature: "aa", parent_author_signature: "bb") }
|
||||||
|
|
||||||
let(:signature_order) { %i(author guid parent_guid property) }
|
let(:signature_order) { %i[author guid parent_guid property] }
|
||||||
let(:signature_data) { "#{author};#{guid};#{parent_guid};#{property}" }
|
let(:signature_data) { "#{author};#{guid};#{parent_guid};#{property}" }
|
||||||
|
|
||||||
describe "#initialize" do
|
describe "#initialize" do
|
||||||
|
|
@ -132,7 +132,7 @@ XML
|
||||||
end
|
end
|
||||||
|
|
||||||
it "accepts string names of known properties in signature_order" do
|
it "accepts string names of known properties in signature_order" do
|
||||||
signature_order = %w(author guid parent_guid property new_property)
|
signature_order = %w[author guid parent_guid property new_property]
|
||||||
xml = Entities::SomeRelayable.new(
|
xml = Entities::SomeRelayable.new(
|
||||||
hash_with_fake_signatures, signature_order, "new_property" => new_property
|
hash_with_fake_signatures, signature_order, "new_property" => new_property
|
||||||
).to_xml
|
).to_xml
|
||||||
|
|
@ -294,7 +294,7 @@ XML
|
||||||
let(:entity_class) { Entities::SomeRelayable }
|
let(:entity_class) { Entities::SomeRelayable }
|
||||||
|
|
||||||
it "contains the property order within the property_order property" do
|
it "contains the property order within the property_order property" do
|
||||||
property_order = %i(author guid parent_guid property)
|
property_order = %i[author guid parent_guid property]
|
||||||
json = entity_class.new(hash_with_fake_signatures, property_order).to_json.to_json
|
json = entity_class.new(hash_with_fake_signatures, property_order).to_json.to_json
|
||||||
|
|
||||||
expect(json).to include_json(property_order: property_order.map(&:to_s))
|
expect(json).to include_json(property_order: property_order.map(&:to_s))
|
||||||
|
|
@ -304,7 +304,7 @@ XML
|
||||||
entity = entity_class.new(hash_with_fake_signatures)
|
entity = entity_class.new(hash_with_fake_signatures)
|
||||||
expect(
|
expect(
|
||||||
entity.to_json.to_json
|
entity.to_json.to_json
|
||||||
).to include_json(property_order: %w(author guid parent_guid property))
|
).to include_json(property_order: %w[author guid parent_guid property])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds new unknown elements to the json again" do
|
it "adds new unknown elements to the json again" do
|
||||||
|
|
@ -385,7 +385,7 @@ XML
|
||||||
:parent_author_signature => parent_author_signature
|
:parent_author_signature => parent_author_signature
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let(:property_order) { %w(author guid parent_guid new_property property) }
|
let(:property_order) { %w[author guid parent_guid new_property property] }
|
||||||
|
|
||||||
it "parses entity properties from the input data" do
|
it "parses entity properties from the input data" do
|
||||||
entity = Entities::SomeRelayable.from_hash(entity_data, property_order)
|
entity = Entities::SomeRelayable.from_hash(entity_data, property_order)
|
||||||
|
|
@ -419,7 +419,7 @@ XML
|
||||||
parent_author_signature: parent_author_signature,
|
parent_author_signature: parent_author_signature,
|
||||||
parent: remote_parent
|
parent: remote_parent
|
||||||
}.merge("new_property" => new_property),
|
}.merge("new_property" => new_property),
|
||||||
%w(author guid parent_guid new_property property),
|
%w[author guid parent_guid new_property property],
|
||||||
"new_property" => new_property
|
"new_property" => new_property
|
||||||
).and_call_original
|
).and_call_original
|
||||||
Entities::SomeRelayable.from_hash(entity_data, property_order)
|
Entities::SomeRelayable.from_hash(entity_data, property_order)
|
||||||
|
|
@ -427,7 +427,7 @@ XML
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates Entity with empty 'additional_data' if it has only known properties" do
|
it "creates Entity with empty 'additional_data' if it has only known properties" do
|
||||||
property_order = %w(author guid parent_guid property)
|
property_order = %w[author guid parent_guid property]
|
||||||
|
|
||||||
entity_data = {
|
entity_data = {
|
||||||
guid: guid,
|
guid: guid,
|
||||||
|
|
@ -447,7 +447,7 @@ XML
|
||||||
|
|
||||||
context "relayable signature verification feature support" do
|
context "relayable signature verification feature support" do
|
||||||
it "calls signatures verification on relayable unpack" do
|
it "calls signatures verification on relayable unpack" do
|
||||||
property_order = %w(guid author property parent_guid)
|
property_order = %w[guid author property parent_guid]
|
||||||
entity_data = {
|
entity_data = {
|
||||||
guid: guid,
|
guid: guid,
|
||||||
author: author,
|
author: author,
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ XML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%w(Comment Like PollParticipation).each do |target_type|
|
%w[Comment Like PollParticipation].each do |target_type|
|
||||||
context "#{target_type} target" do
|
context "#{target_type} target" do
|
||||||
let(:relayable_target) {
|
let(:relayable_target) {
|
||||||
Fabricate(
|
Fabricate(
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ module DiasporaFederation
|
||||||
xml_children = entity.to_xml.children
|
xml_children = entity.to_xml.children
|
||||||
expect(xml_children).to have_exactly(4).items
|
expect(xml_children).to have_exactly(4).items
|
||||||
xml_children.each do |node|
|
xml_children.each do |node|
|
||||||
expect(%w(test1 test2 test3 test4)).to include(node.name)
|
expect(%w[test1 test2 test3 test4]).to include(node.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -319,7 +319,7 @@ JSON
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(EntityWithFromHashMethod).to receive(:json_parser_class).and_call_original
|
expect(EntityWithFromHashMethod).to receive(:json_parser_class).and_call_original
|
||||||
expect_any_instance_of(Parsers::JsonParser).to receive(:parse).with("{}").and_return(%i(arg1 arg2 arg3))
|
expect_any_instance_of(Parsers::JsonParser).to receive(:parse).with("{}").and_return(%i[arg1 arg2 arg3])
|
||||||
expect(EntityWithFromHashMethod).to receive(:from_hash).with(:arg1, :arg2, :arg3)
|
expect(EntityWithFromHashMethod).to receive(:from_hash).with(:arg1, :arg2, :arg3)
|
||||||
EntityWithFromHashMethod.from_json("{}")
|
EntityWithFromHashMethod.from_json("{}")
|
||||||
end
|
end
|
||||||
|
|
@ -456,7 +456,7 @@ JSON
|
||||||
xml = entity.to_xml
|
xml = entity.to_xml
|
||||||
expect(xml.children).to have_exactly(4).items
|
expect(xml.children).to have_exactly(4).items
|
||||||
xml.children.each do |node|
|
xml.children.each do |node|
|
||||||
expect(%w(asdf test_entity other_entity)).to include(node.name)
|
expect(%w[asdf test_entity other_entity]).to include(node.name)
|
||||||
end
|
end
|
||||||
expect(xml.xpath("test_entity")).to have_exactly(1).items
|
expect(xml.xpath("test_entity")).to have_exactly(1).items
|
||||||
expect(xml.xpath("other_entity")).to have_exactly(2).items
|
expect(xml.xpath("other_entity")).to have_exactly(2).items
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ JSON
|
||||||
expect(parsed_data[0][:guid]).to eq("im a guid")
|
expect(parsed_data[0][:guid]).to eq("im a guid")
|
||||||
expect(parsed_data[0][:property]).to eq("value")
|
expect(parsed_data[0][:property]).to eq("value")
|
||||||
expect(parsed_data[0][:author]).to eq("id@example.tld")
|
expect(parsed_data[0][:author]).to eq("id@example.tld")
|
||||||
expect(parsed_data[1]).to eq(%w(property guid author))
|
expect(parsed_data[1]).to eq(%w[property guid author])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ XML
|
||||||
expect(parsed_data[0][:guid]).to eq("im a guid")
|
expect(parsed_data[0][:guid]).to eq("im a guid")
|
||||||
expect(parsed_data[0][:property]).to eq("value")
|
expect(parsed_data[0][:property]).to eq("value")
|
||||||
expect(parsed_data[0][:author]).to eq("id@example.tld")
|
expect(parsed_data[0][:author]).to eq("id@example.tld")
|
||||||
expect(parsed_data[1]).to eq(%i(guid property author))
|
expect(parsed_data[1]).to eq(%i[guid property author])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ XML
|
||||||
end
|
end
|
||||||
|
|
||||||
it "parses boolean fields with a randomly matching pattern as nil" do
|
it "parses boolean fields with a randomly matching pattern as nil" do
|
||||||
%w(ttFFFtt yesFFDSFSDy noDFDSFFDFn fXf LLyes).each do |weird_value|
|
%w[ttFFFtt yesFFDSFSDy noDFDSFFDFn fXf LLyes].each do |weird_value|
|
||||||
xml = <<-XML.strip
|
xml = <<-XML.strip
|
||||||
<test_entity_with_boolean>
|
<test_entity_with_boolean>
|
||||||
<test>#{weird_value}</test>
|
<test>#{weird_value}</test>
|
||||||
|
|
@ -102,7 +102,7 @@ XML
|
||||||
end
|
end
|
||||||
|
|
||||||
it "parses integer fields with a randomly matching pattern as nil" do
|
it "parses integer fields with a randomly matching pattern as nil" do
|
||||||
%w(1,2,3 foobar two).each do |weird_value|
|
%w[1,2,3 foobar two].each do |weird_value|
|
||||||
xml = <<-XML.strip
|
xml = <<-XML.strip
|
||||||
<test_entity_with_integer>
|
<test_entity_with_integer>
|
||||||
<test>#{weird_value}</test>
|
<test>#{weird_value}</test>
|
||||||
|
|
@ -117,7 +117,7 @@ XML
|
||||||
end
|
end
|
||||||
|
|
||||||
it "parses timestamp fields with a randomly matching pattern as nil" do
|
it "parses timestamp fields with a randomly matching pattern as nil" do
|
||||||
%w(foobar yesterday now 1.2.foo).each do |weird_value|
|
%w[foobar yesterday now 1.2.foo].each do |weird_value|
|
||||||
xml = <<-XML.strip
|
xml = <<-XML.strip
|
||||||
<test_entity_with_timestamp>
|
<test_entity_with_timestamp>
|
||||||
<test>#{weird_value}</test>
|
<test>#{weird_value}</test>
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
|
|
||||||
it "accepts only supported types" do
|
it "accepts only supported types" do
|
||||||
%i(text number foobar).each do |val|
|
%i[text number foobar].each do |val|
|
||||||
expect {
|
expect {
|
||||||
dsl.property :fail, val
|
dsl.property :fail, val
|
||||||
}.to raise_error PropertiesDSL::InvalidType
|
}.to raise_error PropertiesDSL::InvalidType
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ module DiasporaFederation
|
||||||
env_xml = envelope.envelop(privkey).root
|
env_xml = envelope.envelop(privkey).root
|
||||||
expect(env_xml.name).to eq("env")
|
expect(env_xml.name).to eq("env")
|
||||||
|
|
||||||
control = %w(data encoding alg sig)
|
control = %w[data encoding alg sig]
|
||||||
env_xml.children.each do |node|
|
env_xml.children.each do |node|
|
||||||
expect(control).to include(node.name)
|
expect(control).to include(node.name)
|
||||||
control.reject! {|i| i == node.name }
|
control.reject! {|i| i == node.name }
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ module DiasporaFederation
|
||||||
|
|
||||||
it_behaves_like "a common validator"
|
it_behaves_like "a common validator"
|
||||||
|
|
||||||
%i(author recipient).each do |prop|
|
%i[author recipient].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a diaspora* ID validator" do
|
it_behaves_like "a diaspora* ID validator" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
@ -13,7 +13,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(following sharing).each do |prop|
|
%i[following sharing].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a boolean validator" do
|
it_behaves_like "a boolean validator" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ module DiasporaFederation
|
||||||
it_behaves_like "a property with a value validation/restriction" do
|
it_behaves_like "a property with a value validation/restriction" do
|
||||||
let(:property) { :status }
|
let(:property) { :status }
|
||||||
let(:wrong_values) { ["", "yes", "foobar"] }
|
let(:wrong_values) { ["", "yes", "foobar"] }
|
||||||
let(:correct_values) { %w(accepted declined tentative) }
|
let(:correct_values) { %w[accepted declined tentative] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(first_name last_name).each do |prop|
|
%i[first_name last_name].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a name validator" do
|
it_behaves_like "a name validator" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
@ -20,7 +20,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(photo_large_url photo_medium_url photo_small_url).each do |prop|
|
%i[photo_large_url photo_medium_url photo_small_url].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a property that mustn't be empty" do
|
it_behaves_like "a property that mustn't be empty" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ module DiasporaFederation
|
||||||
it_behaves_like "a property with a value validation/restriction" do
|
it_behaves_like "a property with a value validation/restriction" do
|
||||||
let(:property) { :parent_type }
|
let(:property) { :parent_type }
|
||||||
let(:wrong_values) { [nil, "", "any", "Postxxx", "post"] }
|
let(:wrong_values) { [nil, "", "any", "Postxxx", "post"] }
|
||||||
let(:correct_values) { %w(Post Comment) }
|
let(:correct_values) { %w[Post Comment] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ module DiasporaFederation
|
||||||
let(:entity) { :location_entity }
|
let(:entity) { :location_entity }
|
||||||
it_behaves_like "a common validator"
|
it_behaves_like "a common validator"
|
||||||
|
|
||||||
%i(lat lng).each do |prop|
|
%i[lat lng].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a property that mustn't be empty" do
|
it_behaves_like "a property that mustn't be empty" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ module DiasporaFederation
|
||||||
let(:property) { :public }
|
let(:property) { :public }
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(remote_photo_name remote_photo_path).each do |prop|
|
%i[remote_photo_name remote_photo_path].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a property that mustn't be empty" do
|
it_behaves_like "a property that mustn't be empty" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
@ -35,7 +35,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(height width).each do |prop|
|
%i[height width].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a property with a value validation/restriction" do
|
it_behaves_like "a property with a value validation/restriction" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ module DiasporaFederation
|
||||||
let(:mandatory) { false }
|
let(:mandatory) { false }
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(first_name last_name).each do |prop|
|
%i[first_name last_name].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a name validator" do
|
it_behaves_like "a name validator" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
@ -18,7 +18,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(image_url image_url_medium image_url_small).each do |prop|
|
%i[image_url image_url_medium image_url_small].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a property with a value validation/restriction" do
|
it_behaves_like "a property with a value validation/restriction" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
@ -61,7 +61,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(searchable public nsfw).each do |prop|
|
%i[searchable public nsfw].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a boolean validator" do
|
it_behaves_like "a boolean validator" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ module DiasporaFederation
|
||||||
let(:mandatory) { true }
|
let(:mandatory) { true }
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(local public).each do |prop|
|
%i[local public].each do |prop|
|
||||||
it_behaves_like "a boolean validator" do
|
it_behaves_like "a boolean validator" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ module DiasporaFederation
|
||||||
let(:entity) { :reshare_entity }
|
let(:entity) { :reshare_entity }
|
||||||
it_behaves_like "a common validator"
|
it_behaves_like "a common validator"
|
||||||
|
|
||||||
%i(root_author author).each do |prop|
|
%i[root_author author].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a diaspora* ID validator" do
|
it_behaves_like "a diaspora* ID validator" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
@ -12,7 +12,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(root_guid guid).each do |prop|
|
%i[root_guid guid].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a guid validator" do
|
it_behaves_like "a guid validator" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ describe Validation::Rule::Boolean do
|
||||||
context "validation" do
|
context "validation" do
|
||||||
context "strings" do
|
context "strings" do
|
||||||
it "validates boolean-esque strings" do
|
it "validates boolean-esque strings" do
|
||||||
%w(true false yes no t f y n 1 0).each do |str|
|
%w[true false yes no t f y n 1 0].each do |str|
|
||||||
validator = Validation::Validator.new(OpenStruct.new(boolean: str))
|
validator = Validation::Validator.new(OpenStruct.new(boolean: str))
|
||||||
validator.rule(:boolean, :boolean)
|
validator.rule(:boolean, :boolean)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(hcard_url).each do |prop|
|
%i[hcard_url].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a url validator without path" do
|
it_behaves_like "a url validator without path" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
@ -23,7 +23,7 @@ module DiasporaFederation
|
||||||
end
|
end
|
||||||
|
|
||||||
# optional urls
|
# optional urls
|
||||||
%i(salmon_url profile_url atom_url).each do |prop|
|
%i[salmon_url profile_url atom_url].each do |prop|
|
||||||
describe "##{prop}" do
|
describe "##{prop}" do
|
||||||
it_behaves_like "a property with a value validation/restriction" do
|
it_behaves_like "a property with a value validation/restriction" do
|
||||||
let(:property) { prop }
|
let(:property) { prop }
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ shared_examples "a relayable Entity" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "computes correct signatures for the entity" do
|
it "computes correct signatures for the entity" do
|
||||||
order = described_class.class_props.keys - %i(author_signature parent_author_signature parent)
|
order = described_class.class_props.keys - %i[author_signature parent_author_signature parent]
|
||||||
signed_string = order.map {|name| data[name].is_a?(Time) ? data[name].iso8601 : data[name] }.join(";")
|
signed_string = order.map {|name| data[name].is_a?(Time) ? data[name].iso8601 : data[name] }.join(";")
|
||||||
|
|
||||||
xml = instance.to_xml
|
xml = instance.to_xml
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,6 @@ module Dummy
|
||||||
# config.assets.version = "1.0"
|
# config.assets.version = "1.0"
|
||||||
|
|
||||||
# autoload files from test/dummy/lib
|
# autoload files from test/dummy/lib
|
||||||
config.autoload_once_paths += %W(#{config.root}/lib)
|
config.autoload_once_paths += %W[#{config.root}/lib]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ Rails.application.configure do
|
||||||
# config.action_view.raise_on_missing_translations = true
|
# config.action_view.raise_on_missing_translations = true
|
||||||
|
|
||||||
# Set the logging destination(s)
|
# Set the logging destination(s)
|
||||||
config.log_to = %w(stdout file)
|
config.log_to = %w[stdout file]
|
||||||
|
|
||||||
# Show the logging configuration on STDOUT
|
# Show the logging configuration on STDOUT
|
||||||
config.show_log_configuration = true
|
config.show_log_configuration = true
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ Rails.application.configure do
|
||||||
config.log_level = :debug
|
config.log_level = :debug
|
||||||
|
|
||||||
# Set the logging destination(s)
|
# Set the logging destination(s)
|
||||||
config.log_to = %w(file)
|
config.log_to = %w[file]
|
||||||
|
|
||||||
# Show the logging configuration on STDOUT
|
# Show the logging configuration on STDOUT
|
||||||
config.show_log_configuration = false
|
config.show_log_configuration = false
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue