Sha256: 800052551adca7e3699be6e2c17296b02b9beff4d239418c6692aa08293c78b7

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

RSpec.describe(OmniAuth::Identity::Models::ActiveRecord, db: true) do
  describe 'model', type: :model do
    subject(:model_klass) do
      AnonymousActiveRecord.generate(
        parent_klass: 'OmniAuth::Identity::Models::ActiveRecord',
        columns: OmniAuth::Identity::Model::SCHEMA_ATTRIBUTES | %w[provider password_digest],
        connection_params: { adapter: 'sqlite3', encoding: 'utf8', database: ':memory:' }
      ) do
        def flower
          '🌸'
        end
      end
    end

    it 'delegates locate to the where query method' do
      allow(model_klass).to receive(:where).with('ham_sandwich' => 'open faced', 'category' => 'sandwiches',
                                                 'provider' => 'identity').and_return(['wakka'])
      expect(model_klass.locate('ham_sandwich' => 'open faced', 'category' => 'sandwiches')).to eq('wakka')
    end
  end

  describe '#table_name' do
    class TestIdentity < OmniAuth::Identity::Models::ActiveRecord; end
    it 'does not use STI rules for its table name' do
      expect(TestIdentity.table_name).to eq('test_identities')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
omniauth-identity-3.0.6 spec/omniauth/identity/models/active_record_spec.rb
omniauth-identity-3.0.5 spec/omniauth/identity/models/active_record_spec.rb
omniauth-identity-3.0.4 spec/omniauth/identity/models/active_record_spec.rb
omniauth-identity-3.0.3 spec/omniauth/identity/models/active_record_spec.rb