File tree Expand file tree Collapse file tree 4 files changed +26
-6
lines changed
Expand file tree Collapse file tree 4 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -256,9 +256,9 @@ def pull_pinned_links_and_hot_questions
256256 . joins ( :category ) . where ( categories : { use_for_hot_posts : true } )
257257 . where ( 'score >= ?' , SiteSetting [ 'HotPostsScoreThreshold' ] )
258258 . where . not ( id : pinned_post_ids )
259- . order ( 'score DESC' ) . limit ( SiteSetting [ 'HotQuestionsCount' ] ) . all
259+ . limit ( SiteSetting [ 'HotQuestionsCount' ] )
260260 end
261- end
261+ end . order ( 'score DESC' )
262262
263263 # eager loading revived collections' used relation to prevent N+1 queries
264264 @pinned_links = @pinned_links . list_includes
@@ -267,8 +267,8 @@ def pull_pinned_links_and_hot_questions
267267
268268 def pull_categories
269269 @header_categories = Rails . cache . fetch_collection ( 'header_categories' ) do
270- Category . all . order ( sequence : :asc , id : :asc )
271- end
270+ Category . all
271+ end . order ( sequence : :asc , id : :asc )
272272 end
273273
274274 def check_if_warning_or_suspension_pending
Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ def reactions
1515 ReactionType . active . where ( post_type : self )
1616 else
1717 ReactionType . active . where ( post_type : self ) . or ( ReactionType . active . where ( post_type : nil ) )
18- end . order ( position : :asc ) . all
19- end
18+ end
19+ end . order ( position : :asc )
2020 end
2121
2222 # @return [Boolean] whether the post type is a system type
Original file line number Diff line number Diff line change @@ -9,6 +9,22 @@ class CategoriesControllerTest < ActionController::TestCase
99 assert_not_nil assigns ( :categories )
1010 end
1111
12+ test 'homepage should show categories in the correct order' do
13+ get :homepage
14+ assert_not_nil assigns ( :header_categories )
15+ seq = 0
16+ id = 0
17+ assigns ( :header_categories ) . each do |category |
18+ if category . sequence . nil?
19+ assert category . id > id , "Category #{ category . id } not after #{ id } "
20+ else
21+ assert category . sequence >= seq , "Category #{ category . id } sequence #{ category . sequence } not greater than #{ seq } "
22+ end
23+ seq = category . sequence || seq
24+ id = category . id
25+ end
26+ end
27+
1228 test ':homepage should correctly show the homepage category' do
1329 get :homepage
1430 assert_response ( :success )
Original file line number Diff line number Diff line change 77 - <%= Article.post_type_id %>
88 tag_set : main
99 license : cc_by_sa
10+ sequence : 1
1011
1112meta :
1213 community : sample
1617 - <%= Question.post_type_id %>
1718 tag_set : meta
1819 license : cc_by_sa
20+ sequence : 2
1921
2022high_trust :
2123 community : sample
@@ -26,6 +28,7 @@ high_trust:
2628 tag_set : main
2729 min_trust_level : 3
2830 license : cc_by_sa
31+ sequence : 3
2932
3033admin_only :
3134 community : sample
@@ -37,6 +40,7 @@ admin_only:
3740 min_trust_level : 5
3841 min_view_trust_level : 5
3942 license : cc_by_sa
43+ sequence : 99
4044
4145articles_only :
4246 community : sample
You can’t perform that action at this time.
0 commit comments