Commit d6b50fb

mokha <mokha@cisco.com>
2018-01-24 19:13:58
extract repository#destroy.
1 parent 9626543
Changed files (2)
app
controllers
models
app/controllers/scim/v2/users_controller.rb
@@ -30,8 +30,7 @@ module Scim
       end
 
       def destroy
-        user = repository.find!(params[:id])
-        user.destroy!
+        repository.destroy!(params[:id])
       end
 
       private
@@ -54,6 +53,10 @@ module Scim
         password = SecureRandom.hex(32)
         User.create!(email: params[:userName], password: password)
       end
+
+      def destroy!(id)
+        find!(id).destroy!
+      end
     end
   end
 end
app/models/user.rb
@@ -23,8 +23,7 @@ class User < ApplicationRecord
     nil
   end
 
-  def to_scim
-    url_helpers = Rails.application.routes.url_helpers
+  def to_scim(url_helpers = Rails.application.routes.url_helpers)
     Scim::Shady::User.build do |x|
       x.id = uuid
       x.username = email