diff --git a/.gitignore b/.gitignore index a2f36b5..278ca04 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ # rspec failure tracking .rspec_status coverage +.idea diff --git a/CHANGELOG.md b/CHANGELOG.md index 8933b9b..405d485 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## [Unreleased] +## [3.1.0] - 2024-08-16 + +### Changed +- Change provider_groups to groups and add groups attribute to Params + ## [3.0.0] - 2024-06-12 ### Changed diff --git a/Gemfile.lock b/Gemfile.lock index aa0be57..e640f86 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - infinum_azure (3.0.0) + infinum_azure (3.1.0) bundler devise omniauth-infinum_azure (>= 0.3.0, < 2.0) diff --git a/README.md b/README.md index 05a6475..a28aa93 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Or install it yourself as: InfinumAzure.configure do |config| config.resource_name = 'User' config.resource_attributes = [:uid, :email, :first_name, :last_name, :avatar_url, - :deactivated_at, :provider_groups, :employee] + :deactivated_at, :groups, :employee] config.user_migration_scope = -> { resource_class.where(provider: 'infinum_id') } config.user_migration_operation = -> (record, resource) { @@ -89,7 +89,7 @@ Configuration options: * *last_name* _string_ * *avatar_url* _string_ * *deactivated_at* _datetime_ -* *provider_groups* _jsonb array_ +* *groups* _jsonb array_ * *employee* _boolean_ 2. Add following rows to resource model: diff --git a/app/services/infinum_azure/resources/params.rb b/app/services/infinum_azure/resources/params.rb index 7ccc6e7..4edf29f 100644 --- a/app/services/infinum_azure/resources/params.rb +++ b/app/services/infinum_azure/resources/params.rb @@ -16,7 +16,8 @@ class Params employee: { procedure: ->(value) { value&.include?('employees') }, target_name: :groups - } + }, + groups: :propagate }.freeze def self.normalize(payload) diff --git a/lib/infinum_azure/config.rb b/lib/infinum_azure/config.rb index 606126b..3ceba64 100644 --- a/lib/infinum_azure/config.rb +++ b/lib/infinum_azure/config.rb @@ -6,7 +6,7 @@ class Config PROVIDER_INFINUM_AZURE = 'infinum_azure' UID = 'uid' DEFAULT_RESOURCE_ATTRIBUTES = [ - :uid, :email, :first_name, :last_name, :avatar_url, :deactivated_at, :provider_groups, :employee + :uid, :email, :first_name, :last_name, :avatar_url, :deactivated_at, :groups, :employee ].freeze attr_accessor :resource_name diff --git a/lib/infinum_azure/version.rb b/lib/infinum_azure/version.rb index db10860..083b77b 100644 --- a/lib/infinum_azure/version.rb +++ b/lib/infinum_azure/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module InfinumAzure - VERSION = '3.0.0' + VERSION = '3.1.0' end diff --git a/spec/rails_app/config/application.rb b/spec/rails_app/config/application.rb index 3e3109d..76a5a8d 100644 --- a/spec/rails_app/config/application.rb +++ b/spec/rails_app/config/application.rb @@ -14,7 +14,7 @@ class Application < Rails::Application InfinumAzure.config.resource_name = 'User' InfinumAzure.config.resource_attributes = [ - :uid, :email, :first_name, :last_name, :avatar_url, :deactivated_at, :provider_groups, :employee + :uid, :email, :first_name, :last_name, :avatar_url, :deactivated_at, :groups, :employee ] end end diff --git a/spec/rails_app/db/migrate/20181109120000_create_users.rb b/spec/rails_app/db/migrate/20181109120000_create_users.rb index 26166e6..59feab2 100644 --- a/spec/rails_app/db/migrate/20181109120000_create_users.rb +++ b/spec/rails_app/db/migrate/20181109120000_create_users.rb @@ -15,7 +15,7 @@ def change # rubocop:disable Metrics/MethodLength t.string :uid t.datetime :deactivated_at - t.string :provider_groups + t.string :groups t.boolean :employee t.datetime :remember_created_at diff --git a/spec/rails_app/db/schema.rb b/spec/rails_app/db/schema.rb index f7bf752..6b1ce4b 100644 --- a/spec/rails_app/db/schema.rb +++ b/spec/rails_app/db/schema.rb @@ -21,7 +21,7 @@ t.string 'provider' t.string 'uid' t.datetime 'deactivated_at', precision: nil - t.string 'provider_groups' + t.string 'groups' t.boolean 'employee' t.datetime 'remember_created_at', precision: nil t.string 'remember_token' diff --git a/spec/rails_app/db/test.sqlite3 b/spec/rails_app/db/test.sqlite3 index abb3f4b..3768252 100644 Binary files a/spec/rails_app/db/test.sqlite3 and b/spec/rails_app/db/test.sqlite3 differ diff --git a/spec/requests/infinum_azure/api/webhooks_controller_spec.rb b/spec/requests/infinum_azure/api/webhooks_controller_spec.rb index b87ac23..1aa4cf8 100644 --- a/spec/requests/infinum_azure/api/webhooks_controller_spec.rb +++ b/spec/requests/infinum_azure/api/webhooks_controller_spec.rb @@ -46,6 +46,7 @@ last_name: user_params[:last_name], avatar_url: azure_params[:avatar_url], deactivated_at: nil, + groups: 'employees', employee: true } diff --git a/spec/services/infinum_azure/resources/params_spec.rb b/spec/services/infinum_azure/resources/params_spec.rb index 36000b0..af47f50 100644 --- a/spec/services/infinum_azure/resources/params_spec.rb +++ b/spec/services/infinum_azure/resources/params_spec.rb @@ -10,7 +10,8 @@ email: 'email', first_name: 'first_name', last_name: 'last_name', - avatar_url: 'avatar_url' + avatar_url: 'avatar_url', + groups: 'groups' } end @@ -18,7 +19,7 @@ let(:params) { propagating_params } it 'just propagates the attributes marked as :propagate' do - expect(normalized_hash).to eq(params.merge(deactivated_at: nil, employee: nil)) + expect(normalized_hash).to eq(params.merge(deactivated_at: nil, employee: false)) end end diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb index 63fd4b0..1ba9fff 100644 --- a/spec/support/factory_bot.rb +++ b/spec/support/factory_bot.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'pathname' FactoryBot.definition_file_paths = [Pathname.new(File.expand_path('../factories', __dir__))]