-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support RSS feeds for specific topics (essentially combining current /feed
and /topic
functionality)
#430
base: master
Are you sure you want to change the base?
Conversation
defp setup_topic_feed_tests(context) do | ||
# Add some topics | ||
t1 = insert(:topic, slug: "rust", name: "Rust", description: "Rust is a systems programming language created by Mozilla.") | ||
# Create some news items | ||
ni1 = insert(:published_news_item, headline: "Rust is pretty cool", story: "Use it or lose it") | ||
# Associate those news items with topics | ||
nit1 = insert(:news_item_topic, topic: t1, news_item: ni1) | ||
|
||
# Add a post | ||
post1 = insert(:published_post, body: "Can you believe this Rust thing?!") | ||
pt1 = insert(:post_topic, post: post1, topic: t1) | ||
|
||
# Add a podcast | ||
pod1 = insert(:podcast, name: "Rust Crust", slug: "rustcrust", description: "Rust is neat") | ||
# Add a podcast episode | ||
e1 = insert(:published_episode, podcast: pod1) | ||
# Associate that episode with a topic | ||
et1 = insert(:episode_topic, episode: e1, topic: t1) | ||
|
||
%{ | ||
topics: %{ | ||
"rust" => t1 | ||
}, | ||
news_items_with_topics: [nit1], | ||
posts_with_topics: [pt1], | ||
podcast_episodes_with_topics: [et1] | ||
} | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1) test Topic feed the topic's podcasts feed (ChangelogWeb.FeedControllerTest)
test/changelog_web/controllers/feed_controller_test.exs:175
Assertion with =~ failed
code: assert conn.resp_body =~ post_with_topic.post.title
left: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:itunes=\"http://www.itunes.com/dtds/podcast-1.0.dtd\">\n <channel>\n <title>Changelog: Rust</title>\n <copyright>All rights reserved</copyright>\n <link>http://localhost:4001/</link>\n <atom:link href=\"http://localhost:4001/feed\" rel=\"self\" type=\"application/rss+xml\" />\n <atom:link href=\"http://localhost:4001/\" rel=\"alternate\" type=\"text/html\" />\n <language>en-us</language>\n <description>Rust is a systems programming language created by Mozilla.</description>\n \n </channel>\n</rss>\n"
right: "Post 4"
stacktrace:
test/changelog_web/controllers/feed_controller_test.exs:193: anonymous fn/2 in ChangelogWeb.FeedControllerTest."test Topic feed the topic's podcasts feed"/1
(elixir 1.13.4) lib/enum.ex:937: Enum."-each/2-lists^foreach/1-0-"/2
test/changelog_web/controllers/feed_controller_test.exs:192: (test)
Currently trying to figure out why this test is failing. I think my test setup with the various ExMachina
insert
statements isn't set up correctly. 🤔 I'll hack at it some more soon!
|> filter_items_by_topic(:all) | ||
|> fetch_items_by_topic() | ||
|
||
render_topic(conn, slug, items) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
render_topic(conn, topic, items)
🐛
In router
First one should be |
<description><%= @topic_description %></description> | ||
<%= for item <- @items do %> | ||
<item> | ||
<%= render_item(item, assigns) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern matches to def render_item(item = %{object: nil}, assigns) do ...
because a NewsItem
struct is returned. Maybe the query should be changed so that it returns only the preloaded posts of the specific topic. wdyt? 🤔
Closes #384
Original PR I branched off of: #390