mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06: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
|
||||
|
||||
def category
|
||||
query = TopicQuery.new(current_user, page: params[:page])
|
||||
|
||||
if !@category
|
||||
raise Discourse::NotFound
|
||||
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
|
||||
|
||||
list_opts = build_topic_list_options
|
||||
query = TopicQuery.new(current_user, list_opts)
|
||||
list = query.list_latest
|
||||
list.more_topics_url = construct_url_with(:latest, list_opts)
|
||||
respond(list)
|
||||
end
|
||||
|
||||
|
@ -161,9 +161,10 @@ class TopicQuery
|
||||
# If we're logged in, we have to pay attention to our pinned settings
|
||||
if @user
|
||||
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
|
||||
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
|
||||
result
|
||||
end
|
||||
@ -176,11 +177,9 @@ class TopicQuery
|
||||
# topics. Otherwise, just use bumped_at.
|
||||
if sort_column == 'default'
|
||||
if sort_dir == 'DESC'
|
||||
|
||||
# If something requires a custom order, for example "unread" which sorts the least read
|
||||
# to the top, do nothing
|
||||
return result if options[:unordered]
|
||||
|
||||
# Otherwise apply our default ordering
|
||||
return default_ordering(result, options)
|
||||
end
|
||||
|
@ -56,12 +56,6 @@ describe ListController do
|
||||
context 'in a category' do
|
||||
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
|
||||
before do
|
||||
xhr :get, :category, category: category.slug
|
||||
@ -112,14 +106,6 @@ describe ListController do
|
||||
it { should_not respond_with(:success) }
|
||||
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
|
||||
|
||||
describe 'feed' do
|
||||
|
@ -135,6 +135,8 @@ describe Group do
|
||||
end
|
||||
|
||||
it "correctly destroys groups" do
|
||||
|
||||
original_count = GroupUser.count
|
||||
g = Fabricate(:group)
|
||||
u1 = Fabricate(:user)
|
||||
g.add(u1)
|
||||
@ -143,7 +145,7 @@ describe Group do
|
||||
g.destroy
|
||||
|
||||
User.where(id: u1.id).count.should == 1
|
||||
GroupUser.count.should == 0
|
||||
GroupUser.count.should == original_count
|
||||
end
|
||||
|
||||
it "allows you to lookup a new group by name" do
|
||||
|
Loading…
Reference in New Issue
Block a user