Skip to content

Commit aa1792a

Browse files
committed
Fix podcasts appearing in the "Writing" list
Before, podcast episodes appeared in both the "Writing" and "Podcasts" lists. There was no need for this duplication, and we wanted to highlight more of our content. We fixed the list only to include items where we've marked `auto_social_share` as false. [Trello](https://trello.com/c/2CIy3mOR)
1 parent ea58fa1 commit aa1792a

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

lib/combined_rss_feed.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
require "rss_feed"
22

3+
class Feedjira::Parser::ITunesRSSItem
4+
element "thoughtbot:auto_social_share", as: :auto_social_share
5+
end
6+
37
class CombinedRssFeed
48
include Enumerable
59

lib/rss_feed.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
require "feed_item"
66

7+
class Feedjira::Parser::AtomEntry
8+
element "thoughtbot:auto_social_share", as: :auto_social_share
9+
end
10+
711
class RssFeed
812
include Enumerable
913

@@ -12,7 +16,7 @@ def initialize(url:)
1216
end
1317

1418
def each
15-
feed.entries.each do |entry|
19+
feed.entries.reject { it.auto_social_share == "false" }.each do |entry|
1620
yield FeedItem.new(
1721
id: entry.id,
1822
title: entry.title,

spec/rss_feed_spec.rb

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,58 @@
2929
)
3030
end
3131

32+
it "ignores entries we don't automatically share to social media" do
33+
Excon.stub({}, {status: 200, body: <<~XML.chomp})
34+
<?xml version="1.0" encoding="UTF-8"?>
35+
<feed xmlns="http://www.w3.org/2005/Atom">
36+
<title>TEST_FEED_TITLE</title>
37+
<subtitle>TEST_SUBTITLE</subtitle>
38+
<id>https://example.com/</id>
39+
<link href="https://example.com/blog"/>
40+
<link href="https://example.com/blog/feed.xml" rel="self"/>
41+
<updated>2024-12-20T00:00:00+00:00</updated>
42+
<author>
43+
<name>TEST_NAME</name>
44+
</author>
45+
<entry>
46+
<title>TEST_ENTRY_1</title>
47+
<link rel="alternate" href="https://example.com/test-entry-1"/>
48+
<author>
49+
<name>TEST_AUTHOR</name>
50+
</author>
51+
<id>https://example.com/test-entry-1</id>
52+
<published>2025-05-22T00:00:00+00:00</published>
53+
<updated>2025-05-22T12:40:11Z</updated>
54+
<content type="html">
55+
<![CDATA[TEST_CONTENT]]>
56+
</content>
57+
<summary>TEST_SUMMARY</summary>
58+
<thoughtbot:auto_social_share>false</thoughtbot:auto_social_share>
59+
</entry>
60+
<entry>
61+
<title>TEST_ENTRY_2</title>
62+
<link rel="alternate" href="https://example.com/test-entry-2"/>
63+
<author>
64+
<name>TEST_AUTHOR</name>
65+
</author>
66+
<id>https://example.com/test-entry-2</id>
67+
<published>2025-05-29T00:00:00+00:00</published>
68+
<updated>2025-05-29T12:40:11Z</updated>
69+
<content type="html">
70+
<![CDATA[TEST_CONTENT]]>
71+
</content>
72+
<summary>TEST_SUMMARY</summary>
73+
<thoughtbot:auto_social_share>true</thoughtbot:auto_social_share>
74+
</entry>
75+
</feed>
76+
XML
77+
rss_feed = RssFeed.new url: "https://example.com/blog/feed.xml"
78+
79+
entries_titles = rss_feed.map(&:title)
80+
81+
expect(entries_titles).to contain_exactly "TEST_ENTRY_2"
82+
end
83+
3284
def atom_feed
3385
File.read("spec/fixtures/rss_feed.xml")
3486
end

0 commit comments

Comments
 (0)