Sha256: b630745f369012ae29e4fa94e0ca07aceceb0b51fbf8acbb0a9444ec19af0b22

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe ScimPatch do

  let(:params) {
    {
      'schemas' => ['urn:ietf:params:scim:api:messages:2.0:PatchOp'],
      'Operations' => [
        {
          'op' => 'Replace',
          'path' => 'userName',
          'value' => 'taro.suzuki'
        },
        {
          'op' =>  'Replace',
          'path' => 'emails[type eq "work"].value',
          'value' => 'taro.suzuki@example.com'
        },
        {
          'op' => 'Replace',
          'path' => 'name.familyName',
          'value' => 'Suzuki'
        }
      ]
    }
  }

  let(:mutable_attributes_schema) {
    {
      userName: :name,
      displayName: :display_name,
      emails: [
        {
          value: :email
        }
      ],
      name: {
        familyName: :family_name,
        givenName: :given_name
      }
    }
  }

  let(:patch) { described_class.new(params, mutable_attributes_schema) }

  describe '#initialize' do
    it {
      expect(patch.operations[0].op).to eq :replace
      expect(patch.operations[0].path_scim).to eq 'userName'
      expect(patch.operations[0].path_sp).to eq :name
      expect(patch.operations[0].value).to eq 'taro.suzuki'

      expect(patch.operations[1].op).to eq :replace
      expect(patch.operations[1].path_scim).to eq 'emails[type eq "work"].value'
      expect(patch.operations[1].path_sp).to eq :email
      expect(patch.operations[1].value).to eq 'taro.suzuki@example.com'

      expect(patch.operations[2].op).to eq :replace
      expect(patch.operations[2].path_scim).to eq 'name.familyName'
      expect(patch.operations[2].path_sp).to eq :family_name
      expect(patch.operations[2].value).to eq 'Suzuki'
    }
  end

  # describe '#update' do
    # create user by factory bot
    # patch.update(user)
  # end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scimaenaga-0.6.0 spec/libraries/scim_patch_spec.rb
scimaenaga-0.5.0 spec/libraries/scim_patch_spec.rb