Commit 92e7810
Changed files (2)
lib
scim
kit
spec
scim
kit
lib/scim/kit/v2/attribute_type.rb
@@ -19,6 +19,7 @@ module Scim
attr_accessor :required
attr_accessor :case_exact
attr_accessor :description
+ attr_accessor :reference_types
attr_reader :mutability
attr_reader :returned
attr_reader :uniqueness
@@ -77,7 +78,8 @@ module Scim
returned: returned,
uniqueness: uniqueness
}
- x[:caseExact] = case_exact if string?
+ x[:caseExact] = case_exact if string? || reference?
+ x[:referenceTypes] = reference_types if reference?
x
end
end
@@ -91,6 +93,10 @@ module Scim
def string?
type.to_sym == :string
end
+
+ def reference?
+ type.to_sym == :reference
+ end
end
end
end
spec/scim/kit/v2/schema_spec.rb
@@ -84,4 +84,24 @@ RSpec.describe Scim::Kit::V2::Schema do
specify { expect(result[:attributes][0][:subAttributes][1][:returned]).to eql('default') }
specify { expect(result[:attributes][0][:subAttributes][1][:uniqueness]).to eql('none') }
end
+
+ context 'with a reference attribute' do
+ before do
+ subject.add_attribute(name: '$ref', type: 'reference') do |x|
+ x.reference_types = %w[User Group]
+ x.mutability = :read_only
+ end
+ end
+
+ specify { expect(result[:attributes][0][:name]).to eql('$ref') }
+ specify { expect(result[:attributes][0][:type]).to eql('reference') }
+ specify { expect(result[:attributes][0][:referenceTypes]).to match_array(%w[User Group]) }
+ specify { expect(result[:attributes][0][:multiValued]).to be(false) }
+ specify { expect(result[:attributes][0][:description]).to eql('') }
+ specify { expect(result[:attributes][0][:required]).to be(false) }
+ specify { expect(result[:attributes][0][:caseExact]).to be(false) }
+ specify { expect(result[:attributes][0][:mutability]).to eql('readOnly') }
+ specify { expect(result[:attributes][0][:returned]).to eql('default') }
+ specify { expect(result[:attributes][0][:uniqueness]).to eql('none') }
+ end
end