Sha256: 61eaff6ded4087e750e6432ed1d2a7f2702aca5786ae248e8e7cf66cb19160ad

Contents?: true

Size: 1.04 KB

Versions: 2

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

2 entries across 2 versions & 1 rubygems

Version Path
global-registry-bindings-0.0.6 spec/workers/push_gr_entity_worker_spec.rb
global-registry-bindings-0.0.5 spec/workers/push_gr_entity_worker_spec.rb