diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index e19ba856282..88f2bd67745 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -392,4 +392,30 @@ expect(response).to redirect_to('/tree_display/drill') end end + + context '#paginate_list' do + before do + # Seed the database with a number of users for pagination tests + create_list(:user, 120) + + it 'displays 25 users per page when per_page is 25' do + get :paginate_list, params: { per_page: '1' } + expect(assigns(:users).length).to eq(25) + end + + it 'displays 50 users per page when per_page is 50' do + get :paginate_list, params: { per_page: '2' } + expect(assigns(:users).length).to eq(50) + end + + it 'displays 100 users per page when per_page is 100' do + get :paginate_list, params: { per_page: '3' } + expect(assigns(:users).length).to eq(100) + end + + it 'displays all users on a single page when per_page is "all"' do + get :paginate_list, params: { per_page: '4' } + expect(assigns(:users).length).to eq(User.count) + end + end end