Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract user retrieval into its own method for easy overriding #62

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ gemfile:
- gemfiles/rails_5.gemfile
- gemfiles/rails_6.gemfile
- gemfiles/rails_6.1.gemfile
- gemfiles/rails_7.gemfile

before_script:
- bin/rails db:migrate RAILS_ENV=test
before_install:
Expand Down
4 changes: 4 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ end
appraise "rails-6.1" do
gem "rails", "~> 6.1"
end

appraise "rails-7" do
gem "rails", "~> 7.0"
end
10 changes: 7 additions & 3 deletions app/controllers/scim_rails/scim_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def create
end

def show
user = @company.public_send(ScimRails.config.scim_users_scope).find(params[:id])
user = find_user
json_scim_response(object: user)
end

def put_update
user = @company.public_send(ScimRails.config.scim_users_scope).find(params[:id])
user = find_user
update_status(user) unless put_active_param.nil?
user.update!(permitted_user_params)
json_scim_response(object: user)
Expand All @@ -57,13 +57,17 @@ def put_update
# TODO: PATCH will only deprovision or reprovision users.
# This will work just fine for Okta but is not SCIM compliant.
def patch_update
user = @company.public_send(ScimRails.config.scim_users_scope).find(params[:id])
user = find_user
update_status(user)
json_scim_response(object: user)
end

private

def find_user
@company.public_send(ScimRails.config.scim_users_scope).find(params[:id])
end

def permitted_user_params
ScimRails.config.mutable_user_attributes.each.with_object({}) do |attribute, hash|
hash[attribute] = find_value_for(attribute)
Expand Down
8 changes: 8 additions & 0 deletions gemfiles/rails_7.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 7.0"
gem "pry", group: [:development, :test]

gemspec path: "../"
2 changes: 1 addition & 1 deletion lib/scim_rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ScimRails
VERSION = "0.4.0"
VERSION = "0.4.1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end
2 changes: 1 addition & 1 deletion scim_rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]

s.required_ruby_version = "~> 2.4"
s.add_dependency "rails", ">= 5.0", "< 6.2"
s.add_dependency "rails", ">= 5.0", "< 7.1"
s.add_runtime_dependency "jwt", ">= 1.5"
s.test_files = Dir["spec/**/*"]

Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
#Rails.application.config.assets.version = '1.0'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/LeadingCommentSpace: Missing space after #.


# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
Expand Down