mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: take into account unlisted banners
This commit is contained in:
parent
41e427bd2e
commit
efb02ae561
@ -162,12 +162,12 @@ class TopicsController < ApplicationController
|
|||||||
params.require(:category_id)
|
params.require(:category_id)
|
||||||
category_id = params[:category_id].to_i
|
category_id = params[:category_id].to_i
|
||||||
|
|
||||||
topics = Topic.listable_topics.visible
|
visible_topics = Topic.listable_topics.visible
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
pinned_in_category_count: topics.where(category_id: category_id).where(pinned_globally: false).where.not(pinned_at: nil).count,
|
pinned_in_category_count: visible_topics.where(category_id: category_id).where(pinned_globally: false).where.not(pinned_at: nil).count,
|
||||||
pinned_globally_count: topics.where(pinned_globally: true).where.not(pinned_at: nil).count,
|
pinned_globally_count: visible_topics.where(pinned_globally: true).where.not(pinned_at: nil).count,
|
||||||
banner_count: topics.where(archetype: Archetype.banner).count,
|
banner_count: Topic.listable_topics.where(archetype: Archetype.banner).count,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -976,7 +976,6 @@ describe TopicsController do
|
|||||||
|
|
||||||
xhr :put, :remove_bookmarks, topic_id: post.topic_id
|
xhr :put, :remove_bookmarks, topic_id: post.topic_id
|
||||||
expect(PostAction.where(user_id: user.id, post_action_type: bookmark).count).to eq(0)
|
expect(PostAction.where(user_id: user.id, post_action_type: bookmark).count).to eq(0)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -996,8 +995,27 @@ describe TopicsController do
|
|||||||
xhr :put, :reset_new
|
xhr :put, :reset_new
|
||||||
user.reload
|
user.reload
|
||||||
expect(user.user_stat.new_since.to_date).not_to eq(old_date.to_date)
|
expect(user.user_stat.new_since.to_date).not_to eq(old_date.to_date)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "feature_stats" do
|
||||||
|
it "works" do
|
||||||
|
xhr :get, :feature_stats, category_id: 1
|
||||||
|
|
||||||
|
expect(response).to be_success
|
||||||
|
json = JSON.parse(response.body)
|
||||||
|
expect(json["pinned_in_category_count"]).to eq(0)
|
||||||
|
expect(json["pinned_globally_count"]).to eq(0)
|
||||||
|
expect(json["banner_count"]).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "allows unlisted banner topic" do
|
||||||
|
Fabricate(:topic, category_id: 1, archetype: Archetype.banner, visible: false)
|
||||||
|
|
||||||
|
xhr :get, :feature_stats, category_id: 1
|
||||||
|
json = JSON.parse(response.body)
|
||||||
|
expect(json["banner_count"]).to eq(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user