-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac44084
commit 9f54d8d
Showing
8 changed files
with
86 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryBot.define do | ||
factory :outboxer_exception, class: 'Outboxer::Models::Exception' do | ||
class_name { 'NoMethodError' } | ||
message_text { 'undefined method `method_name' } | ||
created_at { DateTime.parse("2024-03-16T12:00:00") } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FactoryBot.define do | ||
factory :outboxer_frame, class: 'Outboxer::Models::Frame' do | ||
index { 1 } | ||
text { 'app/controllers/my_controller.rb:23:in `index`' } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
module Outboxer | ||
RSpec.describe Message do | ||
describe '.find_by_id!' do | ||
context 'when a failed message exists' do | ||
let!(:message) { create(:outboxer_message, :failed) } | ||
let!(:exception) { create(:outboxer_exception, message: message) } | ||
let!(:frame) { create(:outboxer_frame, exception: exception) } | ||
|
||
it 'returns the message, exceptions and frames' do | ||
result = Message.find_by_id!(id: message.id) | ||
|
||
expect(result['id']).to eq(message.id) | ||
expect(result['status']).to eq('failed') | ||
expect(result['created_at']).to eq(message.created_at.utc.to_s) | ||
expect(result['updated_at']).to eq(message.updated_at.utc.to_s) | ||
expect(result['exceptions'].first['id']).to eq(exception.id) | ||
expect(result['exceptions'].first['class_name']).to eq(exception.class_name) | ||
expect(result['exceptions'].first['message_text']).to eq(exception.message_text) | ||
expect(result['exceptions'].first['frames'].first['id']).to eq(frame.id) | ||
expect(result['exceptions'].first['frames'].first['index']).to eq(frame.index) | ||
expect(result['exceptions'].first['frames'].first['text']).to eq(frame.text) | ||
end | ||
end | ||
|
||
context 'when the message does not exist' do | ||
it 'raises a NotFound error' do | ||
expect { Message.find_by_id!(id: -1) }.to raise_error(Message::NotFound) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters