Commit cf1898d

mo <mo.khan@gmail.com>
2019-01-04 23:51:44
add filter support
1 parent 0a97f32
lib/scim/kit/v2/templates/service_provider_configuration.json.jbuilder
@@ -10,7 +10,7 @@ json.bulk do
   render bulk, json: json
 end
 json.filter do
-  json.supported false
+  render filter, json: json
 end
 json.change_password do
   render change_password, json: json
lib/scim/kit/v2/templates/supportable.json.jbuilder
@@ -5,4 +5,3 @@ json.supported supported
 @custom_attributes.each do |key, value|
   json.set! key, value
 end
-
lib/scim/kit/v2/service_provider_configuration.rb
@@ -11,7 +11,7 @@ module Scim
         attr_accessor :created, :last_modified, :version
         attr_reader :authentication_schemes
         attr_reader :etag, :sort, :change_password, :patch
-        attr_reader :bulk
+        attr_reader :bulk, :filter
 
         def initialize(location:)
           @location = location
@@ -22,6 +22,7 @@ module Scim
           @change_password = Supportable.new
           @patch = Supportable.new
           @bulk = Supportable.new(:max_operations, :max_payload_size)
+          @filter = Supportable.new(:max_results)
         end
 
         def add_authentication(type)
lib/scim/kit/v2/supportable.rb
@@ -14,7 +14,7 @@ module Scim
         end
 
         def method_missing(method, *args)
-          target = method.to_s.gsub(/=/, '').to_sym
+          target = method.to_s.delete('=').to_sym
           if @custom_attributes.key?(target)
             @custom_attributes[target] = args[0]
           else
spec/scim/kit/v2/service_provider_configuration_spec.rb
@@ -69,40 +69,50 @@ RSpec.describe Scim::Kit::V2::ServiceProviderConfiguration do
       specify { expect(result[:authenticationSchemes][0][:type]).to eql('custom') }
     end
 
-    context "with etag support" do
+    context 'with etag support' do
       before { subject.etag.supported = true }
 
       specify { expect(result[:etag][:supported]).to be(true) }
     end
 
-    context "with sort support" do
+    context 'with sort support' do
       before { subject.sort.supported = true }
 
       specify { expect(result[:sort][:supported]).to be(true) }
     end
 
-    context "with change_password support" do
+    context 'with change_password support' do
       before { subject.change_password.supported = true }
 
       specify { expect(result[:changePassword][:supported]).to be(true) }
     end
 
-    context "with patch support" do
+    context 'with patch support' do
       before { subject.patch.supported = true }
 
       specify { expect(result[:patch][:supported]).to be(true) }
     end
 
-    context "with bulk support" do
+    context 'with bulk support' do
       before do
         subject.bulk.supported = true
         subject.bulk.max_operations = 1000
-        subject.bulk.max_payload_size = 1048576
+        subject.bulk.max_payload_size = 1_048_576
       end
 
       specify { expect(result[:bulk][:supported]).to be(true) }
-      specify { expect(result[:bulk][:maxOperations]).to eql(1000) }
-      specify { expect(result[:bulk][:maxPayloadSize]).to eql(1048576) }
+      specify { expect(result[:bulk][:maxOperations]).to be(1000) }
+      specify { expect(result[:bulk][:maxPayloadSize]).to be(1_048_576) }
+    end
+
+    context 'with filter support' do
+      before do
+        subject.filter.supported = true
+        subject.filter.max_results = 200
+      end
+
+      specify { expect(result[:filter][:supported]).to be(true) }
+      specify { expect(result[:filter][:maxResults]).to be(200) }
     end
   end
 end