tests for bsky posts
This commit is contained in:
BIN
app/assets/images/domain-icons/bluesky.png
Normal file
BIN
app/assets/images/domain-icons/bluesky.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
@@ -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],
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)) }
|
||||
|
||||
3
app/policies/domain/post/bluesky_post_policy.rb
Normal file
3
app/policies/domain/post/bluesky_post_policy.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
# typed: strict
|
||||
class Domain::Post::BlueskyPostPolicy < Domain::PostPolicy
|
||||
end
|
||||
3
app/policies/domain/user/bluesky_user_policy.rb
Normal file
3
app/policies/domain/user/bluesky_user_policy.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
# typed: strict
|
||||
class Domain::User::BlueskyUserPolicy < Domain::UserPolicy
|
||||
end
|
||||
@@ -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(" ") %>">
|
||||
|
||||
@@ -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(
|
||||
|
||||
15
spec/factories/domain/post/bluesky_post.rb
Normal file
15
spec/factories/domain/post/bluesky_post.rb
Normal 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
|
||||
8
spec/factories/domain/user/bluesky_user.rb
Normal file
8
spec/factories/domain/user/bluesky_user.rb
Normal 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
|
||||
Reference in New Issue
Block a user