Commit 92514e1

mokha <mokha@cisco.com>
2018-06-11 17:57:24
return all users.
1 parent f426f8b
Changed files (2)
app
controllers
spec
requests
app/controllers/scim/v2/groups_controller.rb
@@ -8,9 +8,17 @@ module Scim
         render json: {
           schemas: [Scim::Shady::Messages::LIST_RESPONSE],
           totalResults: 0,
-          Resources: [],
+          Resources: resources,
         }.to_json, status: :ok
       end
+
+      private
+
+      def resources
+        User.pluck(:uuid, :email).map do |x|
+          { id: x[0], userName: x[1] }
+        end
+      end
     end
   end
 end
spec/requests/scim/v2/groups_spec.rb
@@ -12,6 +12,7 @@ describe "/scim/v2/groups" do
 
   describe "GET /scim/v2/groups" do
     context "when retrieving all groups" do
+      let!(:user) { create(:user) }
       before { get '/scim/v2/groups', headers: headers }
 
       specify { expect(response).to have_http_status(:ok) }
@@ -19,8 +20,8 @@ describe "/scim/v2/groups" do
       specify { expect(response.body).to be_present }
       let(:json) { JSON.parse(response.body, symbolize_names: true) }
       specify { expect(json[:schemas]).to match_array([Scim::Shady::Messages::LIST_RESPONSE]) }
-      specify { expect(json[:totalResults]).to be_zero }
-      specify { expect(json[:Resources]).to be_empty }
+      specify { expect(json[:totalResults]).to eql(1) }
+      specify { expect(json[:Resources]).to match_array([id: user.uuid, userName: user.email]) }
     end
   end
 end