Skip to content
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

Check post.categories instead of post.category #357

Merged
merged 2 commits into from
Dec 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jekyll-feed/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{% assign posts = site[page.collection] %}
{% endif %}
{% if page.category %}
{% assign posts = posts | where: "category", page.category %}
{% assign posts = posts | where: "categories", page.category %}
{% endif %}
{% unless site.show_drafts %}
{% assign posts = posts | where_exp: "post", "post.draft != true" %}
Expand Down
12 changes: 5 additions & 7 deletions spec/jekyll-feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ def to_s
context "with top-level post categories" do
let(:overrides) do
{
"feed" => { "categories" => ["news"] },
"feed" => { "categories" => ["jekyll"] },
}
end
let(:news_feed) { File.read(dest_dir("feed/news.xml")) }
let(:category_feed) { File.read(dest_dir("feed/jekyll.xml")) }

it "outputs the primary feed" do
expect(contents).to match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
Expand All @@ -411,11 +411,9 @@ def to_s
end

it "outputs the category feed" do
expect(news_feed).to match '<title type="html">My awesome site | News</title>'
expect(news_feed).to match "http://example.org/news/2014/03/02/march-the-second.html"
expect(news_feed).to match "http://example.org/news/2013/12/12/dec-the-second.html"
expect(news_feed).to_not match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
expect(category_feed).to match '<title type="html">My awesome site | News</title>'
expect(category_feed).to match "http://example.org/updates/jekyll/2014/03/04/march-the-fourth.html"
expect(category_feed).to match "March the fourth!"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we cover the category: jekyll case too? The fixtures don't seem to have a post with the singular key name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixtures don't seem to have a post with the singular key name

The existing test on master uses a fixture post with a singular key name..

end
end

Expand Down