FIX: Load more on groups page does not account for params.
https://meta.discourse.org/t/cant-scroll-through-list-of-users-groups-if-more-than-one-page/92259
This commit is contained in:
parent
de2243319e
commit
b4f92a05b3
|
@ -98,7 +98,13 @@ class GroupsController < ApplicationController
|
|||
type_filters: type_filters
|
||||
},
|
||||
total_rows_groups: count,
|
||||
load_more_groups: groups_path(page: page + 1, type: type),
|
||||
load_more_groups: groups_path(
|
||||
page: page + 1,
|
||||
type: type,
|
||||
order: order,
|
||||
asc: params[:asc],
|
||||
filter: filter
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -48,7 +48,14 @@ describe GroupsController do
|
|||
get "/groups.json", params: { filter: 'test' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["groups"].first["id"]).to eq(other_group.id)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
|
||||
expect(response_body["groups"].first["id"]).to eq(other_group.id)
|
||||
|
||||
expect(response_body["load_more_groups"]).to eq(
|
||||
"/groups?filter=test&page=1"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -72,8 +79,14 @@ describe GroupsController do
|
|||
group_ids = [moderator_group_id, group.id, other_group.id]
|
||||
group_ids.reverse! if !is_asc
|
||||
|
||||
expect(JSON.parse(response.body)["groups"].map { |group| group["id"] })
|
||||
response_body = JSON.parse(response.body)
|
||||
|
||||
expect(response_body["groups"].map { |group| group["id"] })
|
||||
.to eq(group_ids)
|
||||
|
||||
expect(response_body["load_more_groups"]).to eq(
|
||||
"/groups?#{is_asc ? 'asc=true&' : '' }order=name&page=1"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -85,8 +98,14 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["groups"].map { |group| group["id"] })
|
||||
response_body = JSON.parse(response.body)
|
||||
|
||||
expect(response_body["groups"].map { |group| group["id"] })
|
||||
.to eq([other_group.id, group.id, moderator_group_id])
|
||||
|
||||
expect(response_body["load_more_groups"]).to eq(
|
||||
"/groups?order=name&page=1"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue