Add avatar URL to Webfinger when available
This commit is contained in:
@@ -18,6 +18,46 @@ RSpec.describe "WebFinger", type: :request do
|
||||
})
|
||||
end
|
||||
|
||||
describe "Avatar" do
|
||||
context "not available" do
|
||||
it "does not include an avatar link" do
|
||||
get "/.well-known/webfinger?resource=acct%3Atony%40kosmos.org"
|
||||
expect(response).to have_http_status(:ok)
|
||||
res = JSON.parse(response.body)
|
||||
|
||||
link = res["links"].find{|l| l["rel"] == "http://webfinger.net/rel/avatar"}
|
||||
expect(link).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "available" do
|
||||
let(:fixture_path) { Rails.root.join("spec/fixtures/files/taipei.jpg") }
|
||||
let(:img_data) { File.read(fixture_path) }
|
||||
let(:img_hash) { Digest::SHA256.hexdigest(img_data) }
|
||||
|
||||
before do
|
||||
ActiveStorage::Blob.create_and_upload!(
|
||||
io: File.open(fixture_path),
|
||||
filename: "#{img_hash}.jpg",
|
||||
content_type: "image/jpeg"
|
||||
).tap do |blob|
|
||||
user.avatar.attach(blob)
|
||||
end
|
||||
end
|
||||
|
||||
it "includes a public avatar link" do
|
||||
get "/.well-known/webfinger?resource=acct%3Atony%40kosmos.org"
|
||||
expect(response).to have_http_status(:ok)
|
||||
res = JSON.parse(response.body)
|
||||
|
||||
link = res["links"].find { |l| l["rel"] == "http://webfinger.net/rel/avatar" }
|
||||
expect(link).to be_present
|
||||
expect(link["type"]).to eq("image/jpeg")
|
||||
expect(link["href"]).to match(%r{users/tony/avatars/#{img_hash}.jpg})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Mastodon entries" do
|
||||
context "Mastodon available" do
|
||||
it "includes the Mastodon aliases and links for the user" do
|
||||
|
||||
Reference in New Issue
Block a user