Skip to content

Commit

Permalink
Fixed Pagination issue (#9330)
Browse files Browse the repository at this point in the history
* Added translations in users/settings.html.erb

* Fixed pagination issue

* fixed pagination issue

* Fixed pagination in wiki/stale too

* Delete identifier.sqlite

* fixed a minor issue

* Fixed minor issue

* Delete identifier.sqlite

* Added functional test to check pagination

* reduced no of new wikis for test

* reduced 31 to 12

Co-authored-by: Cess <cessmbuguar@gmail.com>
  • Loading branch information
gaurav2699 and cesswairimu authored Mar 23, 2021
1 parent 1b54747 commit d70efef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/controllers/wiki_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def index
.references(:node_revisions)
.group('node_revisions.nid, node_revisions.vid')
.order(order_string)
.where("node_revisions.status = 1 AND node.status = 1 AND type = 'page'"))
.where("node_revisions.status = 1 AND node.status = 1 AND type = 'page'"), items: 10)

@paginated = true
end
Expand All @@ -353,7 +353,7 @@ def stale
.references(:node_revisions)
.group('node_revisions.nid, node_revisions.vid')
.order('node_revisions.timestamp ASC')
.where("node_revisions.status = 1 AND node.status = 1 AND type = 'page'"))
.where("node_revisions.status = 1 AND node.status = 1 AND type = 'page'"), items: 10)

@paginated = true
render template: 'wiki/index'
Expand Down
21 changes: 19 additions & 2 deletions test/functional/wiki_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,28 @@ def teardown
assert assigns(:wikis).each_cons(2).all?{|i,j| "j.node_revisions.title" >= "i.node_revisions.title" }
end

test 'should paginate the wikis' do
12.times{
post :create,
params: {
uid: users(:bob).id,
title: 'Test',
body: 'This is fascinating documentation about balloon mapping.',
tags: 'balloon-mapping'
}
}
get :index
wikis = assigns(:wikis)
assert wikis.size==10
end

test 'should sort by last edited' do
get :index, params: { sort: "last_edited" }
wikis = assigns(:wikis)
assert_equal(wikis.first.title,"Important work")
assert_equal(wikis.last.title,"Method page")
wiki1 = wikis.order(changed: :desc).first
wiki2 = wikis.order(changed: :desc).reverse.first
assert_equal(wikis.first.title, wiki1.title)
assert_equal(wikis.last.title, wiki2.title)
end

test 'should get wiki stale pages' do
Expand Down

0 comments on commit d70efef

Please sign in to comment.