Skip to content

Commit

Permalink
Fix hidden threads showing in news
Browse files Browse the repository at this point in the history
Fixes #509
  • Loading branch information
BenjaminSchaaf committed Jun 20, 2024
1 parent 2a1bf63 commit c253684
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def read_news_topic_config(config)
limit = config['display'] || 3

@topic = Forums::Topic.find(config['id'])
@threads = @topic.threads.ordered.limit(limit)
@threads = @topic.threads.visible.ordered.limit(limit)
@news_posts = @threads.map { |thread| [thread, thread.original_post] }.to_h
@more_threads = @topic.threads.limit(limit + 1).size > limit
@more_threads = @topic.threads.visible.limit(limit + 1).size > limit
end
end
14 changes: 14 additions & 0 deletions spec/controllers/pages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@

expect(response).to have_http_status(:success)
end

it 'hides hidden threads' do
topic = create(:forums_topic)
thread = create(:forums_thread, topic: topic)
hidden_thread = create(:forums_thread, topic: topic, hidden: true)

Rails.configuration.news['type'] = 'topic'
Rails.configuration.news['id'] = topic.id

get :home

expect(response).to have_http_status(:success)
expect(controller.view_assigns['threads']).to eq([thread])
end
end

context 'invalid news config' do
Expand Down

0 comments on commit c253684

Please sign in to comment.