mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 14:32:44 +08:00
FIX: exclude topics from latest in /categories on refresh
When you hit refresh on categories page it would not supress correctly
This commit is contained in:
parent
fd14ee4797
commit
146a6c3592
|
@ -42,7 +42,8 @@ class CategoriesController < ApplicationController
|
|||
style = SiteSetting.desktop_category_page_style
|
||||
topic_options = {
|
||||
per_page: SiteSetting.categories_topics,
|
||||
no_definitions: true
|
||||
no_definitions: true,
|
||||
exclude_category_ids: Category.where(suppress_from_latest: true).pluck(:id)
|
||||
}
|
||||
|
||||
if style == "categories_and_latest_topics".freeze
|
||||
|
|
|
@ -1,24 +1,42 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe GroupsController do
|
||||
let(:admin) { Fabricate(:admin) }
|
||||
let(:category) { Fabricate(:category, user: admin) }
|
||||
describe CategoriesController do
|
||||
|
||||
before do
|
||||
category
|
||||
sign_in(admin)
|
||||
context 'index' do
|
||||
|
||||
it 'suppresses categories correctly' do
|
||||
post = create_post(title: 'super AMAZING AMAZING post')
|
||||
|
||||
get "/categories"
|
||||
expect(response.body).to include('AMAZING AMAZING')
|
||||
|
||||
post.topic.category.update_columns(suppress_from_latest: true)
|
||||
|
||||
get "/categories"
|
||||
expect(response.body).not_to include('AMAZING AMAZING')
|
||||
end
|
||||
end
|
||||
|
||||
it "triggers a extensibility event" do
|
||||
event = DiscourseEvent.track_events {
|
||||
put "/categories/#{category.id}.json", params: {
|
||||
name: 'hello',
|
||||
color: 'ff0',
|
||||
text_color: 'fff'
|
||||
}
|
||||
}.last
|
||||
context 'extensibility event' do
|
||||
let(:admin) { Fabricate(:admin) }
|
||||
let(:category) { Fabricate(:category, user: admin) }
|
||||
|
||||
expect(event[:event_name]).to eq(:category_updated)
|
||||
expect(event[:params].first).to eq(category)
|
||||
before do
|
||||
category
|
||||
sign_in(admin)
|
||||
end
|
||||
|
||||
it "triggers a extensibility event" do
|
||||
event = DiscourseEvent.track_events {
|
||||
put "/categories/#{category.id}.json", params: {
|
||||
name: 'hello',
|
||||
color: 'ff0',
|
||||
text_color: 'fff'
|
||||
}
|
||||
}.last
|
||||
|
||||
expect(event[:event_name]).to eq(:category_updated)
|
||||
expect(event[:params].first).to eq(category)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user