diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index 5d1eb39745b..3b56132a737 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -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 diff --git a/lib/topic_query.rb b/lib/topic_query.rb index f9608a104cf..2f77ac99841 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -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 diff --git a/spec/controllers/list_controller_spec.rb b/spec/controllers/list_controller_spec.rb index 5994e0db899..4408d3753f3 100644 --- a/spec/controllers/list_controller_spec.rb +++ b/spec/controllers/list_controller_spec.rb @@ -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 diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index bb8c61101aa..67675e71496 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -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