Save syndication sources to posts

This commit is contained in:
2023-01-29 16:54:34 +11:00
parent 37932ea4ad
commit 2d371812f5
17 changed files with 231 additions and 10 deletions

View File

@@ -0,0 +1,37 @@
require "spec_helper"
RSpec.describe Adamantium::Commands::Posts::AddSyndicationSource, :db do
subject { described_class.new }
describe "setting a syndication source" do
let(:post) { Test::Factory[:post] }
let(:repo) { Adamantium::Container["repos.post_repo"] }
context "when no sources exist" do
it "sets a new source" do
subject.call(post.id, "mastodon", "some_url")
updated_post = repo.find!(post.id)
expect(updated_post.syndication_sources).to eq({
"mastodon" => "some_url"
})
end
end
context "when a source exists" do
let(:post) { Test::Factory[:post, syndication_sources: {"twitter" => "twitter_url"}, slug: "existing-post"] }
it "adds another source" do
subject.call(post.id, "mastodon", "some_url")
updated_post = repo.find!(post.id)
expect(updated_post.syndication_sources).to eq({
"mastodon" => "some_url",
"twitter" => "twitter_url"
})
end
end
end
end