Skip to content

Commit

Permalink
Merge pull request #6 from infinum/feature/add-groups-to-params
Browse files Browse the repository at this point in the history
Release 3.1.0
  • Loading branch information
cilim authored Aug 19, 2024
2 parents ccc4f54 + 53d2e55 commit 9d7fef0
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
# rspec failure tracking
.rspec_status
coverage
.idea
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion app/services/infinum_azure/resources/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class Params
employee: {
procedure: ->(value) { value&.include?('employees') },
target_name: :groups
}
},
groups: :propagate
}.freeze

def self.normalize(payload)
Expand Down
2 changes: 1 addition & 1 deletion lib/infinum_azure/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/infinum_azure/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module InfinumAzure
VERSION = '3.0.0'
VERSION = '3.1.0'
end
2 changes: 1 addition & 1 deletion spec/rails_app/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/rails_app/db/migrate/20181109120000_create_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/rails_app/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Binary file modified spec/rails_app/db/test.sqlite3
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
last_name: user_params[:last_name],
avatar_url: azure_params[:avatar_url],
deactivated_at: nil,
groups: 'employees',
employee: true
}

Expand Down
5 changes: 3 additions & 2 deletions spec/services/infinum_azure/resources/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
email: 'email',
first_name: 'first_name',
last_name: 'last_name',
avatar_url: 'avatar_url'
avatar_url: 'avatar_url',
groups: 'groups'
}
end

describe 'attributes to propagate' do
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

Expand Down
2 changes: 2 additions & 0 deletions spec/support/factory_bot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'pathname'

FactoryBot.definition_file_paths = [Pathname.new(File.expand_path('../factories', __dir__))]

0 comments on commit 9d7fef0

Please sign in to comment.