Sha256: 5cb5bb58dc078b1c600c44479f0dc14a20717d6fdd4fe4a045708963c2b0b47e

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'GlobalRegistry::Bindings::Workers' do
  describe 'PushGrEntityWorker' do
    let(:user) { create(:person) }

    it 'sends :push_entity_to_global_registry to the model instance' do
      allow(Namespaced::Person).to receive(:push_entity_to_global_registry_async)
      expect(Namespaced::Person).to receive(:find).with(user.id).and_return(user)
      expect(user).to receive(:push_entity_to_global_registry)

      worker = GlobalRegistry::Bindings::Workers::PushGrEntityWorker.new
      worker.perform(Namespaced::Person, user.id)
    end

    it 'fails silently on ActiveRecord::RecordNotFound' do
      allow(Namespaced::Person).to receive(:push_entity_to_global_registry_async)
      expect(Namespaced::Person).to receive(:find).with(user.id).and_raise(ActiveRecord::RecordNotFound)
      expect(user).not_to receive(:push_entity_to_global_registry)

      worker = GlobalRegistry::Bindings::Workers::PushGrEntityWorker.new
      worker.perform(Namespaced::Person, user.id)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
global-registry-bindings-0.0.4 spec/workers/push_gr_entity_worker_spec.rb
global-registry-bindings-0.0.3 spec/workers/push_gr_entity_worker_spec.rb
global-registry-bindings-0.0.2 spec/workers/push_gr_entity_worker_spec.rb
global-registry-bindings-0.0.1 spec/workers/push_gr_entity_worker_spec.rb