tests for bsky posts

This commit is contained in:
Dylan Knutson
2025-08-08 00:40:28 +00:00
parent 608044e8fb
commit e30e20b033
10 changed files with 43 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@@ -48,6 +48,11 @@ module Domain::PostsHelper
domain_icon_path: "domain-icons/sofurry.png",
domain_icon_title: "SoFurry",
),
Domain::DomainType::Bluesky =>
DomainData.new(
domain_icon_path: "domain-icons/bluesky.png",
domain_icon_title: "Bluesky",
),
},
T::Hash[Domain::DomainType, DomainData],
)

View File

@@ -102,6 +102,8 @@ module Domain::UsersHelper
asset_path("domain-icons/inkbunny.png")
when Domain::User::SofurryUser
asset_path("domain-icons/sofurry.png")
when Domain::User::BlueskyUser
asset_path("domain-icons/bluesky.png")
else
Kernel.raise "Unknown user type: #{user.class}"
end

View File

@@ -55,7 +55,7 @@ class Domain::User::BlueskyUser < Domain::User
sig { override.returns(T.nilable(String)) }
def external_url_for_view
"https://bsky.app/profile/#{handle}" if handle.present?
"https://bsky.app/profile/#{did}" if did.present?
end
sig { override.returns(T.nilable(String)) }

View File

@@ -0,0 +1,3 @@
# typed: strict
class Domain::Post::BlueskyPostPolicy < Domain::PostPolicy
end

View File

@@ -0,0 +1,3 @@
# typed: strict
class Domain::User::BlueskyUserPolicy < Domain::UserPolicy
end

View File

@@ -29,7 +29,7 @@
<%
description = []
description << "posted #{@post.posted_at.strftime("%B %d, %Y")}" if @post.respond_to?(:posted_at) && @post.posted_at.present?
description << "by #{@post.primary_creator_for_view&.name || "Unknown"}"
description << "by #{@post.primary_creator_for_view&.name_for_view || "Unknown"}"
description << "@ #{domain_name_for_model(@post)}"
%>
<meta name="og:description" content="<%= description.join(" ") %>">

View File

@@ -2,8 +2,6 @@
require "rails_helper"
RSpec.describe Domain::PostsController, type: :controller do
render_views
# Create a real user with admin role
let(:user) { create(:user, :admin) }
@@ -75,6 +73,11 @@ RSpec.describe Domain::PostsController, type: :controller do
it_behaves_like "a post"
end
context "with a bluesky post" do
let(:post) { create(:domain_post_bluesky_post) }
it_behaves_like "a post"
end
context "when post file is pending download" do
let(:post) do
create(

View File

@@ -0,0 +1,15 @@
# typed: false
FactoryBot.define do
factory :domain_post_bluesky_post, class: "Domain::Post::BlueskyPost" do
association :creator, factory: :domain_user_bluesky_user
sequence(:bluesky_rkey) { |n| "rkey#{n}" }
sequence(:at_uri) do |n|
"at://did:plc:#{n.to_s.rjust(10, "0")}/app.bsky.feed.post/rkey#{n}"
end
bluesky_created_at { Time.now }
state { "ok" }
text { "Hello from Bluesky" }
hashtags { %w[test bluesky] }
like_count { 0 }
end
end

View File

@@ -0,0 +1,8 @@
# typed: false
FactoryBot.define do
factory :domain_user_bluesky_user, class: "Domain::User::BlueskyUser" do
sequence(:handle) { |n| "user#{n}.bsky.social" }
sequence(:did) { |n| "did:plc:#{n.to_s.rjust(10, "0")}" }
state { "ok" }
end
end