Sha256: 48677e6711e9f132a9f0a8a9d3caf6ea9f138a0c7d2b420f9c0881059b745fd5

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

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

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

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

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

      worker = GlobalRegistry::Bindings::Workers::PushRelationshipWorker.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_relationship_worker_spec.rb
global-registry-bindings-0.0.3 spec/workers/push_relationship_worker_spec.rb
global-registry-bindings-0.0.2 spec/workers/push_relationship_worker_spec.rb
global-registry-bindings-0.0.1 spec/workers/push_relationship_worker_spec.rb