Files
growstuff/spec/views/members/show.rss.haml_spec.rb
T
Daniel O'Connorandgoogle-labs-jules[bot] 2b366213e8 Cap RSS feeds iterate unbounded associations to 50 records (#4809)
- Cap @member.posts in app/views/members/show.rss.haml with .limit(50)
- Cap @post.comments in app/views/posts/show.rss.haml with .limit(50) and eager load authors
- Remove eager loading of all comments+authors on Post in PostsController#show
- Add view specs to verify RSS feed limits

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-09-20 16:41:28 +09:30

45 lines
1.3 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe 'members/show.rss.haml', type: "view" do
subject { rendered }
context 'with a few posts' do
before do
@member = assign(:member, create(:member, login_name: 'callum'))
@post1 = create(:post, id: 1, author: @member, body: "This is some text.")
@post2 = create(:markdown_post, id: 2, author: @member)
assign(:posts, [@post1, @post2])
render
end
it 'shows RSS feed title' do
expect(subject).to have_text("callum's recent posts")
end
it 'shows content of posts' do
expect(subject).to have_content "This is some text."
end
it 'renders post bodies to HTML and XML-escapes them' do
# The variable "rendered" has been entity-replaced and tag-stripped
# The literal string output contains "&lt;strong&gt;" etc.
expect(subject).to have_content "<strong>strong</strong>"
end
it 'gives the author in the item title' do
expect(subject).to have_content "#{@post1.subject} by #{@post1.author}"
end
end
context 'with more than 50 posts' do
it 'limits posts in the RSS feed to 50' do
member = assign(:member, create(:member))
create_list(:post, 55, author: member)
render
expect(rendered.scan(/<item>/).size).to eq(50)
end
end
end