Commit 163bb482 authored by James Lopez's avatar James Lopez

Refactor users and spec

parent 09c4d8e0
...@@ -11,13 +11,14 @@ module EE ...@@ -11,13 +11,14 @@ module EE
identity.user.name identity.user.name
end end
present_collection true, :email
expose :email_user, as: :emails, using: '::EE::Gitlab::Scim::Emails' expose :email_user, as: :emails, using: '::EE::Gitlab::Scim::Emails'
private private
DEFAULT_SCHEMA = 'urn:ietf:params:scim:schemas:core:2.0:User'
def schemas def schemas
["urn:ietf:params:scim:schemas:core:2.0:User"] [DEFAULT_SCHEMA]
end end
def active def active
......
...@@ -9,8 +9,7 @@ module EE ...@@ -9,8 +9,7 @@ module EE
expose :items_per_page, as: :itemsPerPage expose :items_per_page, as: :itemsPerPage
expose :start_index, as: :startIndex expose :start_index, as: :startIndex
present_collection true, :Resources expose :resources, as: :Resources, using: ::EE::Gitlab::Scim::User #, if: ->(identity, _) { identity.present? }
expose :resources, as: :Resources, using: ::EE::Gitlab::Scim::User
private private
...@@ -23,7 +22,7 @@ module EE ...@@ -23,7 +22,7 @@ module EE
end end
def total_results def total_results
1 resources.count
end end
def items_per_page def items_per_page
...@@ -35,9 +34,8 @@ module EE ...@@ -35,9 +34,8 @@ module EE
end end
# We only support a single resource at the moment # We only support a single resource at the moment
# Please update `total_results` to `resources.count` once this changes
def resources def resources
[object] object.present? ? [object] : []
end end
end end
end end
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe ::EE::Gitlab::Scim::User do describe ::EE::Gitlab::Scim::User do
let(:user) { create(:user) } let(:user) { build(:user) }
let(:identity) { create(:group_saml_identity, user: user) } let(:identity) { build(:group_saml_identity, user: user) }
let(:entity) do let(:entity) do
described_class.new(identity) described_class.new(identity)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment