Sha256: 733e72967866bd8f411f5686a5f79297f168599eaae9be3741c0a32a55462439

Contents?: true

Size: 961 Bytes

Versions: 1

Compression:

Stored size: 961 Bytes

Contents

# frozen_string_literal: true

RSpec.describe(OmniAuth::Identity::Models::Mongoid, db: true) do
  class MongoidTestIdentity
    include Mongoid::Document
    include OmniAuth::Identity::Models::Mongoid
    auth_key :ham_sandwich
    store_in database: 'db1', collection: 'mongoid_test_identities', client: 'secondary'
  end

  describe 'model', type: :model do
    subject { MongoidTestIdentity }

    it { is_expected.to be_mongoid_document }

    it 'does not munge collection name' do
      expect(subject).to be_stored_in(database: 'db1', collection: 'mongoid_test_identities', client: 'secondary')
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-identity-3.0.2 spec/omniauth/identity/models/mongoid_spec.rb