fix some complexity issues codeclimate
This commit is contained in:
parent
f413a4a963
commit
c27dbbefb5
3 changed files with 19 additions and 19 deletions
|
|
@ -17,7 +17,7 @@ module DiasporaFederation
|
||||||
# @example Creating a hCard document from account data
|
# @example Creating a hCard document from account data
|
||||||
# hc = HCard.from_profile({
|
# hc = HCard.from_profile({
|
||||||
# guid: "0123456789abcdef",
|
# guid: "0123456789abcdef",
|
||||||
# diaspora_handle: "user@server.example",
|
# nickname: "user",
|
||||||
# full_name: "User Name",
|
# full_name: "User Name",
|
||||||
# url: "https://server.example/",
|
# url: "https://server.example/",
|
||||||
# photo_full_url: "https://server.example/uploads/f.jpg",
|
# photo_full_url: "https://server.example/uploads/f.jpg",
|
||||||
|
|
@ -108,7 +108,7 @@ module DiasporaFederation
|
||||||
hc = allocate
|
hc = allocate
|
||||||
hc.instance_eval {
|
hc.instance_eval {
|
||||||
@guid = data[:guid]
|
@guid = data[:guid]
|
||||||
@nickname = data[:diaspora_handle].split("@").first
|
@nickname = data[:nickname]
|
||||||
@full_name = data[:full_name]
|
@full_name = data[:full_name]
|
||||||
@url = data[:url]
|
@url = data[:url]
|
||||||
@photo_full_url = data[:photo_full_url]
|
@photo_full_url = data[:photo_full_url]
|
||||||
|
|
@ -228,12 +228,12 @@ module DiasporaFederation
|
||||||
# @param [Hash] data account data
|
# @param [Hash] data account data
|
||||||
# @return [Boolean] validation result
|
# @return [Boolean] validation result
|
||||||
def self.account_data_complete?(data)
|
def self.account_data_complete?(data)
|
||||||
data.instance_of?(Hash) && data.key?(:guid) &&
|
data.instance_of?(Hash) &&
|
||||||
data.key?(:diaspora_handle) && data.key?(:full_name) &&
|
%i(
|
||||||
data.key?(:url) && data.key?(:photo_full_url) &&
|
guid nickname full_name url
|
||||||
data.key?(:photo_medium_url) && data.key?(:photo_small_url) &&
|
photo_full_url photo_medium_url photo_small_url
|
||||||
data.key?(:pubkey) && data.key?(:searchable) &&
|
pubkey searchable first_name last_name
|
||||||
data.key?(:first_name) && data.key?(:last_name)
|
).all? {|k| data.key? k }
|
||||||
end
|
end
|
||||||
private_class_method :account_data_complete?
|
private_class_method :account_data_complete?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,11 +181,11 @@ module DiasporaFederation
|
||||||
# @param [Hash] data account data
|
# @param [Hash] data account data
|
||||||
# @return [Boolean] validation result
|
# @return [Boolean] validation result
|
||||||
def self.account_data_complete?(data)
|
def self.account_data_complete?(data)
|
||||||
data.instance_of?(Hash) && data.key?(:acct_uri) &&
|
data.instance_of?(Hash) &&
|
||||||
data.key?(:alias_url) && data.key?(:hcard_url) &&
|
%i(
|
||||||
data.key?(:seed_url) && data.key?(:guid) &&
|
acct_uri alias_url hcard_url seed_url
|
||||||
data.key?(:profile_url) && data.key?(:atom_url) &&
|
guid profile_url atom_url salmon_url pubkey
|
||||||
data.key?(:salmon_url) && data.key?(:pubkey)
|
).all? {|k| data.key? k }
|
||||||
end
|
end
|
||||||
private_class_method :account_data_complete?
|
private_class_method :account_data_complete?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module DiasporaFederation
|
module DiasporaFederation
|
||||||
describe WebFinger::HCard do
|
describe WebFinger::HCard do
|
||||||
let(:guid) { "abcdef0123456789" }
|
let(:guid) { "abcdef0123456789" }
|
||||||
let(:handle) { "user@pod.example.tld" }
|
let(:nickname) { "user" }
|
||||||
let(:first_name) { "Test" }
|
let(:first_name) { "Test" }
|
||||||
let(:last_name) { "Testington" }
|
let(:last_name) { "Testington" }
|
||||||
let(:name) { "#{first_name} #{last_name}" }
|
let(:name) { "#{first_name} #{last_name}" }
|
||||||
|
|
@ -35,7 +35,7 @@ module DiasporaFederation
|
||||||
<dl class="entity_nickname">
|
<dl class="entity_nickname">
|
||||||
<dt>Nickname</dt>
|
<dt>Nickname</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<span class="nickname">#{handle.split('@').first}</span>
|
<span class="nickname">#{nickname}</span>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl class="entity_full_name">
|
<dl class="entity_full_name">
|
||||||
|
|
@ -107,7 +107,7 @@ HTML
|
||||||
it "creates an instance from a data hash" do
|
it "creates an instance from a data hash" do
|
||||||
hc = WebFinger::HCard.from_profile(
|
hc = WebFinger::HCard.from_profile(
|
||||||
guid: guid,
|
guid: guid,
|
||||||
diaspora_handle: handle,
|
nickname: nickname,
|
||||||
full_name: name,
|
full_name: name,
|
||||||
url: url,
|
url: url,
|
||||||
photo_full_url: photo_url,
|
photo_full_url: photo_url,
|
||||||
|
|
@ -124,8 +124,8 @@ HTML
|
||||||
it "fails if some params are missing" do
|
it "fails if some params are missing" do
|
||||||
expect {
|
expect {
|
||||||
WebFinger::HCard.from_profile(
|
WebFinger::HCard.from_profile(
|
||||||
guid: guid,
|
guid: guid,
|
||||||
diaspora_handle: handle
|
nickname: nickname
|
||||||
)
|
)
|
||||||
}.to raise_error WebFinger::InvalidData
|
}.to raise_error WebFinger::InvalidData
|
||||||
end
|
end
|
||||||
|
|
@ -143,7 +143,7 @@ HTML
|
||||||
it "reads its own output" do
|
it "reads its own output" do
|
||||||
hc = WebFinger::HCard.from_html(html)
|
hc = WebFinger::HCard.from_html(html)
|
||||||
expect(hc.guid).to eq(guid)
|
expect(hc.guid).to eq(guid)
|
||||||
expect(hc.nickname).to eq(handle.split("@").first)
|
expect(hc.nickname).to eq(nickname)
|
||||||
expect(hc.full_name).to eq(name)
|
expect(hc.full_name).to eq(name)
|
||||||
expect(hc.url).to eq(url)
|
expect(hc.url).to eq(url)
|
||||||
expect(hc.photo_full_url).to eq(photo_url)
|
expect(hc.photo_full_url).to eq(photo_url)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue