Sha256: 972fc859566f3df80c95c7725494d71d06505801d4949403aec86ef279b3f30f

Contents?: true

Size: 968 Bytes

Versions: 4

Compression:

Stored size: 968 Bytes

Contents

# frozen_string_literal: true

require 'mongoid'

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

RSpec.describe(OmniAuth::Identity::Models::Mongoid, db: true) do
  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

4 entries across 4 versions & 1 rubygems

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