Commit 9626543

mokha <mokha@cisco.com>
2018-01-24 19:11:56
remove coupling to controller.
1 parent 1136453
Changed files (3)
app
controllers
models
config
environments
app/controllers/scim/v2/users_controller.rb
@@ -12,13 +12,13 @@ module Scim
       def show
         user = repository.find!(params[:id])
         response.headers['Location'] = scim_v2_users_url(user)
-        render json: user.to_scim(self).to_json, status: :ok
+        render json: user.to_scim.to_json, status: :ok
       end
 
       def create
         user = repository.create!(user_params)
         response.headers['Location'] = scim_v2_users_url(user)
-        render json: user.to_scim(self).to_json, status: :created
+        render json: user.to_scim.to_json, status: :created
       end
 
       def update
@@ -26,7 +26,7 @@ module Scim
         user.update!(email: user_params[:userName])
 
         response.headers['Location'] = scim_v2_users_url(user)
-        render json: user.to_scim(self).to_json, status: :ok
+        render json: user.to_scim.to_json, status: :ok
       end
 
       def destroy
app/models/user.rb
@@ -23,7 +23,8 @@ class User < ApplicationRecord
     nil
   end
 
-  def to_scim(url_helpers)
+  def to_scim
+    url_helpers = Rails.application.routes.url_helpers
     Scim::Shady::User.build do |x|
       x.id = uuid
       x.username = email
config/environments/test.rb
@@ -40,3 +40,4 @@ Rails.application.configure do
   # Raises error for missing translations
   # config.action_view.raise_on_missing_translations = true
 end
+Rails.application.default_url_options = { host: 'www.example.com' }