Commit b598300
Changed files (2)
app
controllers
scim
spec
requests
scim
app/controllers/scim/v2/users_controller.rb
@@ -10,8 +10,9 @@ module Scim
def index
@page, @page_size = page_params
- @total = User.count
- @users = User.offset(@page - 1).limit(@page_size)
+ query = User.all
+ @total = query.count
+ @users = query.offset(@page - 1).limit(@page_size)
render formats: :scim, status: :ok
end
spec/requests/scim/v2/users_spec.rb
@@ -169,6 +169,16 @@ describe '/scim/v2/users' do
specify { expect(json[:Resources]).to be_present }
end
+ context "when requesting an invalid page" do
+ before { get "/scim/v2/users", params: { startIndex: 'x' }, headers: headers }
+
+ specify { expect(response).to have_http_status(:ok) }
+ specify { expect(json[:totalResults]).to be(users.count + 1) }
+ specify { expect(json[:startIndex]).to eql(1) }
+ specify { expect(json[:itemsPerPage]).to eql(25) }
+ specify { expect(json[:Resources]).to be_present }
+ end
+
context "when requesting a page size of 0 results" do
before { get "/scim/v2/users", params: { count: 0 }, headers: headers }