Sha256: a3cd432a3637205e3ce1c88d3337784a5f4adb0df4e7226c45a366b4d661645b

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require 'sqlite3'
require 'active_record'
require 'anonymous_active_record'

class TestIdentity < OmniAuth::Identity::Models::ActiveRecord; end

RSpec.describe(OmniAuth::Identity::Models::ActiveRecord, sqlite3: 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
        auth_key :email
        def flower
          '🌸'
        end
      end
    end

    include_context 'persistable model'

    describe '::table_name' do
      it 'does not use STI rules for its table name' do
        expect(TestIdentity.table_name).to eq('test_identities')
      end
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-identity-3.0.9 spec/omniauth/identity/models/active_record_spec.rb