Sha256: 20752c8b6dba79199ab6bc3821170a83d1c5153bc2bf21fb30c69781e7e1dfe7

Contents?: true

Size: 1.07 KB

Versions: 2

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

2 entries across 2 versions & 1 rubygems

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