Sha256: c8bdf7141dff23b5a673dcd5a269eaa8111a81a8b0a23286fc13a5b58f8d0868

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

shared_examples 'Unidom::Authorization::Concerns::AsPermission' do |model_attributes, authorized, authorizer|

  context do

    authorizing_1_attribtues = {
        authorized_id:   SecureRandom.uuid,
        authorized_type: 'Unidom::Authorization::Authorized::Mock',
        authorizer_id:   SecureRandom.uuid,
        authorizer_type: 'Unidom::Authorization::Authorizer::Mock'
      }

    authorizing_2_attribtues = {
        authorized_id:   SecureRandom.uuid,
        authorized_type: 'Unidom::Authorization::Authorized::Mock',
        authorizer_id:   SecureRandom.uuid,
        authorizer_type: 'Unidom::Authorization::Authorizer::Mock'
      }

    it_behaves_like 'has_many', model_attributes, :authorizings, Unidom::Authorization::Authorizing, [ authorizing_1_attribtues, authorizing_2_attribtues ]

    permission = described_class.create! model_attributes
    it_behaves_like 'assert_present!', permission, :authorize!, [ authorized, { by: authorizer, at: Time.now } ], [ { 0 => :authorized }, :by, :at ]
    it_behaves_like 'assert_present!', permission, :authorize?, [ authorized, {                 at: Time.now } ], [ { 0 => :authorized },      :at ]
    it_behaves_like 'assert_present!', permission, :prohibit!,  [ authorized, {                 at: Time.now } ], [ { 0 => :authorized },      :at ]

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unidom-authorization-1.6.6 lib/rspec/models/unidom/authorization/concerns/as_permission_shared_examples.rb