mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 03:32:18 -05:00
62 lines
1.6 KiB
Ruby
62 lines
1.6 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe Creator do
|
|
it_behaves_like "Followable"
|
|
it_behaves_like "Commentable"
|
|
it_behaves_like "Caber::Object"
|
|
it_behaves_like "Sluggable"
|
|
it_behaves_like "Indexable"
|
|
it_behaves_like "Linkable"
|
|
|
|
it "is not valid if name is too long" do
|
|
expect(build(:creator, name: SecureRandom.alphanumeric(226))).not_to be_valid
|
|
end
|
|
|
|
it "is not valid if slug is too long" do
|
|
expect(build(:creator, slug: SecureRandom.alphanumeric(226))).not_to be_valid
|
|
end
|
|
|
|
context "when generating an ActivityStreams representation" do
|
|
subject(:creator) { create(:creator, :public) }
|
|
|
|
let(:ap) { creator.to_activitypub_object }
|
|
|
|
it "includes concrete type" do
|
|
expect(ap[:"f3di:concreteType"]).to eq "Creator"
|
|
end
|
|
|
|
it "includes attributionDomain" do
|
|
expect(ap[:attributionDomains]).to contain_exactly("localhost:3214")
|
|
end
|
|
|
|
it "includes caption in summary" do
|
|
expect(ap[:summary]).to include creator.caption
|
|
end
|
|
|
|
it "includes notes in content" do
|
|
expect(ap[:content]).to include creator.notes
|
|
end
|
|
|
|
it "includes links as attachments" do
|
|
expect(ap[:attachment]).to include({type: "Link", href: "http://example.com"})
|
|
end
|
|
end
|
|
|
|
context "when serializing JSON fields", :after_first_run do
|
|
let(:creator) { create(:creator, :with_avatar, :with_banner) }
|
|
|
|
before do
|
|
create(:library)
|
|
end
|
|
|
|
[
|
|
:avatar_data,
|
|
:banner_data
|
|
].each do |field|
|
|
it "deserializes #{field.to_s.humanize} correctly" do
|
|
expect(creator.reload.send(field)).to be_a Hash
|
|
end
|
|
end
|
|
end
|
|
end
|