Sha256: 2755699474c295a6402a37f6606d5b36c9553f1cf0404a2f78b78626857bc9fc

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

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: %w[name provider],
        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

2 entries across 2 versions & 1 rubygems

Version Path
omniauth-identity-3.0.1 spec/omniauth/identity/models/active_record_spec.rb
omniauth-identity-3.0.0 spec/omniauth/identity/models/active_record_spec.rb