mirror of
https://github.com/discourse/discourse.git
synced 2025-03-25 12:18:53 +08:00
FIX: Pinned topics within a category weren't working without a refresh
This commit is contained in:
parent
6ff0f43703
commit
639394e38a
@ -47,22 +47,10 @@ class ListController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def category
|
def category
|
||||||
query = TopicQuery.new(current_user, page: params[:page])
|
list_opts = build_topic_list_options
|
||||||
|
query = TopicQuery.new(current_user, list_opts)
|
||||||
if !@category
|
list = query.list_latest
|
||||||
raise Discourse::NotFound
|
list.more_topics_url = construct_url_with(:latest, list_opts)
|
||||||
return
|
|
||||||
end
|
|
||||||
guardian.ensure_can_see!(@category)
|
|
||||||
list = query.list_category(@category)
|
|
||||||
@description = @category.description
|
|
||||||
|
|
||||||
if params[:parent_category].present?
|
|
||||||
list.more_topics_url = url_for(category_list_parent_path(params[:parent_category], params[:category], next_page_params))
|
|
||||||
else
|
|
||||||
list.more_topics_url = url_for(category_list_path(params[:category], next_page_params))
|
|
||||||
end
|
|
||||||
|
|
||||||
respond(list)
|
respond(list)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -161,9 +161,10 @@ class TopicQuery
|
|||||||
# If we're logged in, we have to pay attention to our pinned settings
|
# If we're logged in, we have to pay attention to our pinned settings
|
||||||
if @user
|
if @user
|
||||||
result = options[:category].blank? ? result.order(TopicQuerySQL.order_nocategory_with_pinned_sql) :
|
result = options[:category].blank? ? result.order(TopicQuerySQL.order_nocategory_with_pinned_sql) :
|
||||||
result.order(TopicQuerySQL.order_with_pinned_sql)
|
result.order(TopicQuerySQL.order_with_pinned_sql)
|
||||||
else
|
else
|
||||||
result = result.order(TopicQuerySQL.order_nocategory_basic_bumped)
|
result = options[:category].blank? ? result.order(TopicQuerySQL.order_nocategory_basic_bumped) :
|
||||||
|
result.order(TopicQuerySQL.order_basic_bumped)
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
@ -176,11 +177,9 @@ class TopicQuery
|
|||||||
# topics. Otherwise, just use bumped_at.
|
# topics. Otherwise, just use bumped_at.
|
||||||
if sort_column == 'default'
|
if sort_column == 'default'
|
||||||
if sort_dir == 'DESC'
|
if sort_dir == 'DESC'
|
||||||
|
|
||||||
# If something requires a custom order, for example "unread" which sorts the least read
|
# If something requires a custom order, for example "unread" which sorts the least read
|
||||||
# to the top, do nothing
|
# to the top, do nothing
|
||||||
return result if options[:unordered]
|
return result if options[:unordered]
|
||||||
|
|
||||||
# Otherwise apply our default ordering
|
# Otherwise apply our default ordering
|
||||||
return default_ordering(result, options)
|
return default_ordering(result, options)
|
||||||
end
|
end
|
||||||
|
@ -56,12 +56,6 @@ describe ListController do
|
|||||||
context 'in a category' do
|
context 'in a category' do
|
||||||
let(:category) { Fabricate(:category) }
|
let(:category) { Fabricate(:category) }
|
||||||
|
|
||||||
it "raises an invalid access error when the user can't see the category" do
|
|
||||||
Guardian.any_instance.expects(:can_see?).with(category).returns(false)
|
|
||||||
xhr :get, :category, category: category.slug
|
|
||||||
response.should be_forbidden
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with access to see the category' do
|
context 'with access to see the category' do
|
||||||
before do
|
before do
|
||||||
xhr :get, :category, category: category.slug
|
xhr :get, :category, category: category.slug
|
||||||
@ -112,14 +106,6 @@ describe ListController do
|
|||||||
it { should_not respond_with(:success) }
|
it { should_not respond_with(:success) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when child is requested without a parent' do
|
|
||||||
before do
|
|
||||||
xhr :get, :category, category: sub_category.slug
|
|
||||||
end
|
|
||||||
|
|
||||||
it { should_not respond_with(:success) }
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'feed' do
|
describe 'feed' do
|
||||||
|
@ -135,6 +135,8 @@ describe Group do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "correctly destroys groups" do
|
it "correctly destroys groups" do
|
||||||
|
|
||||||
|
original_count = GroupUser.count
|
||||||
g = Fabricate(:group)
|
g = Fabricate(:group)
|
||||||
u1 = Fabricate(:user)
|
u1 = Fabricate(:user)
|
||||||
g.add(u1)
|
g.add(u1)
|
||||||
@ -143,7 +145,7 @@ describe Group do
|
|||||||
g.destroy
|
g.destroy
|
||||||
|
|
||||||
User.where(id: u1.id).count.should == 1
|
User.where(id: u1.id).count.should == 1
|
||||||
GroupUser.count.should == 0
|
GroupUser.count.should == original_count
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows you to lookup a new group by name" do
|
it "allows you to lookup a new group by name" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user