Skip to content

Commit

Permalink
fix: remove result raises error on result not success (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdenquin authored Aug 8, 2022
1 parent 8e272e3 commit fdcc67f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
4 changes: 1 addition & 3 deletions app/jobs/events/create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ class CreateJob < ApplicationJob
queue_as :default

def perform(organization, params, timestamp, metadata)
result = Events::CreateService.new.call(
Events::CreateService.new.call(
organization: organization,
params: params,
timestamp: Time.zone.at(timestamp),
metadata: metadata,
)

result.throw_error unless result.success?
end
end
end
20 changes: 0 additions & 20 deletions spec/jobs/events/create_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,4 @@
expect(Events::CreateService).to have_received(:new)
expect(create_service).to have_received(:call)
end

context 'when result is a failure' do
let(:result) do
BaseService::Result.new.fail!(code: 'Invalid customer id')
end

it 'raises an error' do
allow(Events::CreateService).to receive(:new).and_return(create_service)
allow(create_service).to receive(:call)
.with(organization: organization, params: params, timestamp: Time.zone.at(timestamp), metadata: metadata)
.and_return(result)

expect do
described_class.perform_now(organization, params, timestamp, metadata)
end.to raise_error(BaseService::FailedResult)

expect(Events::CreateService).to have_received(:new)
expect(create_service).to have_received(:call)
end
end
end

0 comments on commit fdcc67f

Please sign in to comment.